Skip to content

Commit

Permalink
d/aws_ce_cost_category: Cosmetics.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Mar 10, 2023
1 parent 27c525b commit b7e7b96
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 191 deletions.
373 changes: 185 additions & 188 deletions internal/service/ce/cost_category_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions internal/service/ce/cost_category_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit b7e7b96

Please sign in to comment.