From 60ec559e5339cbc6a67200ec3f1e50364245b55a Mon Sep 17 00:00:00 2001 From: Jim Razmus II Date: Tue, 7 Feb 2023 15:24:33 -0600 Subject: [PATCH 1/3] Add default_value to the cost category data source. --- internal/service/ce/cost_category_data_source.go | 5 +++++ internal/service/ce/cost_category_data_source_test.go | 1 + website/docs/d/ce_cost_category.html.markdown | 1 + 3 files changed, 7 insertions(+) diff --git a/internal/service/ce/cost_category_data_source.go b/internal/service/ce/cost_category_data_source.go index 9b98b06e8304..4fe0c01c1bf7 100644 --- a/internal/service/ce/cost_category_data_source.go +++ b/internal/service/ce/cost_category_data_source.go @@ -24,6 +24,10 @@ func DataSourceCostCategory() *schema.Resource { Type: schema.TypeString, Required: true, }, + "default_value": { + Type: schema.TypeString, + Computed: true, + }, "effective_end": { Type: schema.TypeString, Computed: true, @@ -321,6 +325,7 @@ func dataSourceCostCategoryRead(ctx context.Context, d *schema.ResourceData, met return create.DiagError(names.CE, create.ErrActionReading, ResNameCostCategory, d.Id(), err) } + d.Set("default_value", costCategory.DefaultValue) d.Set("effective_end", costCategory.EffectiveEnd) d.Set("effective_start", costCategory.EffectiveStart) d.Set("name", costCategory.Name) diff --git a/internal/service/ce/cost_category_data_source_test.go b/internal/service/ce/cost_category_data_source_test.go index 095952c5fb2c..6eae05efa22e 100644 --- a/internal/service/ce/cost_category_data_source_test.go +++ b/internal/service/ce/cost_category_data_source_test.go @@ -26,6 +26,7 @@ func TestAccCECostCategoryDataSource_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCostCategoryExists(ctx, resourceName, &output), resource.TestCheckResourceAttrPair(dataSourceName, "cost_category_arn", resourceName, "arn"), + resource.TestCheckResourceAttrPair(dataSourceName, "default_value", resourceName, "default_value"), resource.TestCheckResourceAttrPair(dataSourceName, "name", resourceName, "name"), resource.TestCheckResourceAttrPair(dataSourceName, "rule_version", resourceName, "rule_version"), resource.TestCheckResourceAttrPair(dataSourceName, "rule.%", resourceName, "rule.%"), diff --git a/website/docs/d/ce_cost_category.html.markdown b/website/docs/d/ce_cost_category.html.markdown index fcbf026e5e5d..4bdcca5c309c 100644 --- a/website/docs/d/ce_cost_category.html.markdown +++ b/website/docs/d/ce_cost_category.html.markdown @@ -29,6 +29,7 @@ The following arguments are required: In addition to all arguments above, the following attributes are exported: * `arn` - ARN of the cost category. +* `default_value` - Default value for the cost category. * `effective_end` - Effective end data of your Cost Category. * `effective_start` - Effective state data of your Cost Category. * `id` - Unique ID of the cost category. From 27c525bd4379b62ec9208e77745b2d0462bc59bd Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 10 Mar 2023 10:56:41 -0500 Subject: [PATCH 2/3] Add CHANGELOG entry. --- .changelog/29291.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/29291.txt diff --git a/.changelog/29291.txt b/.changelog/29291.txt new file mode 100644 index 000000000000..ea78ef419630 --- /dev/null +++ b/.changelog/29291.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +data-source/aws_ce_cost_category: Add `default_value` attribute +``` \ No newline at end of file From b7e7b96711c58ad94282872a9fa42603812f8b2e Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 10 Mar 2023 11:03:35 -0500 Subject: [PATCH 3/3] d/aws_ce_cost_category: Cosmetics. --- .../service/ce/cost_category_data_source.go | 373 +++++++++--------- .../ce/cost_category_data_source_test.go | 4 +- 2 files changed, 186 insertions(+), 191 deletions(-) diff --git a/internal/service/ce/cost_category_data_source.go b/internal/service/ce/cost_category_data_source.go index 3185e9ba23cb..06c4ece6f807 100644 --- a/internal/service/ce/cost_category_data_source.go +++ b/internal/service/ce/cost_category_data_source.go @@ -15,11 +15,193 @@ import ( // @SDKDataSource("aws_ce_cost_category") func DataSourceCostCategory() *schema.Resource { + schemaCostCategoryRuleExpressionComputed := func() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cost_category": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Computed: true, + }, + "match_options": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "values": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "dimension": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Computed: true, + }, + "match_options": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "values": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "tags": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Computed: true, + }, + "match_options": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "values": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + } + } + schemaCostCategoryRuleComputed := func() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "and": { + Type: schema.TypeSet, + Computed: true, + Elem: schemaCostCategoryRuleExpressionComputed(), + }, + "cost_category": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Computed: true, + }, + "match_options": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "values": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "dimension": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Computed: true, + }, + "match_options": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "values": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "not": { + Type: schema.TypeList, + Computed: true, + Elem: schemaCostCategoryRuleExpressionComputed(), + }, + "or": { + Type: schema.TypeSet, + Computed: true, + Elem: schemaCostCategoryRuleExpressionComputed(), + }, + "tags": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Computed: true, + }, + "match_options": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "values": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + } + } + return &schema.Resource{ ReadWithoutTimeout: dataSourceCostCategoryRead, - Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, - }, + Schema: map[string]*schema.Schema{ "cost_category_arn": { Type: schema.TypeString, @@ -131,191 +313,6 @@ func DataSourceCostCategory() *schema.Resource { } } -func schemaCostCategoryRuleComputed() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - "and": { - Type: schema.TypeSet, - Computed: true, - Elem: schemaCostCategoryRuleExpressionComputed(), - }, - "cost_category": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "key": { - Type: schema.TypeString, - Computed: true, - }, - "match_options": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "values": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - "dimension": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "key": { - Type: schema.TypeString, - Computed: true, - }, - "match_options": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "values": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - "not": { - Type: schema.TypeList, - Computed: true, - Elem: schemaCostCategoryRuleExpressionComputed(), - }, - "or": { - Type: schema.TypeSet, - Computed: true, - Elem: schemaCostCategoryRuleExpressionComputed(), - }, - "tags": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "key": { - Type: schema.TypeString, - Computed: true, - }, - "match_options": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "values": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - } -} - -func schemaCostCategoryRuleExpressionComputed() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cost_category": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "key": { - Type: schema.TypeString, - Computed: true, - }, - "match_options": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "values": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - "dimension": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "key": { - Type: schema.TypeString, - Computed: true, - }, - "match_options": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "values": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - "tags": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "key": { - Type: schema.TypeString, - Computed: true, - }, - "match_options": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "values": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - } -} - func dataSourceCostCategoryRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.AWSClient).CEConn() ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig diff --git a/internal/service/ce/cost_category_data_source_test.go b/internal/service/ce/cost_category_data_source_test.go index 6eae05efa22e..8af6285cc6dc 100644 --- a/internal/service/ce/cost_category_data_source_test.go +++ b/internal/service/ce/cost_category_data_source_test.go @@ -38,9 +38,7 @@ func TestAccCECostCategoryDataSource_basic(t *testing.T) { } func testAccCostCategoryDataSourceConfig_basic(rName string) string { - return acctest.ConfigCompose( - testAccCostCategoryConfig_basic(rName), - ` + return acctest.ConfigCompose(testAccCostCategoryConfig_basic(rName), ` data "aws_ce_cost_category" "test" { cost_category_arn = aws_ce_cost_category.test.arn }