diff --git a/aws/resource_aws_waf_rate_based_rule.go b/aws/resource_aws_waf_rate_based_rule.go index 29826b76e350..ea1d7c510b5e 100644 --- a/aws/resource_aws_waf_rate_based_rule.go +++ b/aws/resource_aws_waf_rate_based_rule.go @@ -66,18 +66,22 @@ func resourceAwsWafRateBasedRule() *schema.Resource { Required: true, ValidateFunc: validation.IntAtLeast(100), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "arn": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWafRateBasedRuleCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().WafTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) wr := newWafRetryer(conn) out, err := wr.RetryWithToken(func(token *string) (interface{}, error) { @@ -90,7 +94,7 @@ func resourceAwsWafRateBasedRuleCreate(d *schema.ResourceData, meta interface{}) } if len(tags) > 0 { - params.Tags = tags + params.Tags = tags.IgnoreAws().WafTags() } return conn.CreateRateBasedRule(params) @@ -115,6 +119,7 @@ func resourceAwsWafRateBasedRuleCreate(d *schema.ResourceData, meta interface{}) func resourceAwsWafRateBasedRuleRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &waf.GetRateBasedRuleInput{ @@ -155,8 +160,16 @@ func resourceAwsWafRateBasedRuleRead(d *schema.ResourceData, meta interface{}) e if err != nil { return fmt.Errorf("Failed to get WAF Rated Based Rule parameter tags for %s: %s", d.Get("name"), err) } - if err := d.Set("tags", tagList.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + + tags := tagList.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } d.Set("predicates", predicates) @@ -182,8 +195,8 @@ func resourceAwsWafRateBasedRuleUpdate(d *schema.ResourceData, meta interface{}) } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.WafUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating tags: %s", err) diff --git a/aws/resource_aws_waf_rule.go b/aws/resource_aws_waf_rule.go index 964cbb945c25..ab180eca1d6c 100644 --- a/aws/resource_aws_waf_rule.go +++ b/aws/resource_aws_waf_rule.go @@ -65,18 +65,22 @@ func resourceAwsWafRule() *schema.Resource { }, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "arn": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWafRuleCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().WafTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) wr := newWafRetryer(conn) out, err := wr.RetryWithToken(func(token *string) (interface{}, error) { @@ -87,7 +91,7 @@ func resourceAwsWafRuleCreate(d *schema.ResourceData, meta interface{}) error { } if len(tags) > 0 { - params.Tags = tags + params.Tags = tags.IgnoreAws().WafTags() } return conn.CreateRule(params) @@ -114,6 +118,7 @@ func resourceAwsWafRuleCreate(d *schema.ResourceData, meta interface{}) error { func resourceAwsWafRuleRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &waf.GetRuleInput{ @@ -166,10 +171,17 @@ func resourceAwsWafRuleRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error listing tags for WAF Rule (%s): %w", arn, err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { return fmt.Errorf("error setting tags: %w", err) } + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) + } + d.Set("predicates", predicates) d.Set("name", resp.Rule.Name) d.Set("metric_name", resp.Rule.MetricName) @@ -190,8 +202,8 @@ func resourceAwsWafRuleUpdate(d *schema.ResourceData, meta interface{}) error { } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.WafUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating WAF Rule (%s) tags: %w", d.Id(), err) diff --git a/aws/resource_aws_waf_rule_group.go b/aws/resource_aws_waf_rule_group.go index b07e7f549a3c..df92ed7ff20c 100644 --- a/aws/resource_aws_waf_rule_group.go +++ b/aws/resource_aws_waf_rule_group.go @@ -67,18 +67,22 @@ func resourceAwsWafRuleGroup() *schema.Resource { }, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "arn": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWafRuleGroupCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().WafTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) wr := newWafRetryer(conn) out, err := wr.RetryWithToken(func(token *string) (interface{}, error) { @@ -89,7 +93,7 @@ func resourceAwsWafRuleGroupCreate(d *schema.ResourceData, meta interface{}) err } if len(tags) > 0 { - params.Tags = tags + params.Tags = tags.IgnoreAws().WafTags() } return conn.CreateRuleGroup(params) @@ -115,6 +119,7 @@ func resourceAwsWafRuleGroupCreate(d *schema.ResourceData, meta interface{}) err func resourceAwsWafRuleGroupRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &waf.GetRuleGroupInput{ @@ -151,8 +156,16 @@ func resourceAwsWafRuleGroupRead(d *schema.ResourceData, meta interface{}) error if err != nil { return fmt.Errorf("error listing tags for WAF Rule Group (%s): %s", arn, err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } d.Set("activated_rule", flattenWafActivatedRules(rResp.ActivatedRules)) @@ -175,8 +188,8 @@ func resourceAwsWafRuleGroupUpdate(d *schema.ResourceData, meta interface{}) err } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.WafUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating tags: %s", err) diff --git a/aws/resource_aws_waf_web_acl.go b/aws/resource_aws_waf_web_acl.go index 7295cfb26f8f..ae596360c32a 100644 --- a/aws/resource_aws_waf_web_acl.go +++ b/aws/resource_aws_waf_web_acl.go @@ -139,14 +139,18 @@ func resourceAwsWafWebAcl() *schema.Resource { }, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWafWebAclCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().WafTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) wr := newWafRetryer(conn) out, err := wr.RetryWithToken(func(token *string) (interface{}, error) { @@ -158,7 +162,7 @@ func resourceAwsWafWebAclCreate(d *schema.ResourceData, meta interface{}) error } if len(tags) > 0 { - params.Tags = tags + params.Tags = tags.IgnoreAws().WafTags() } return conn.CreateWebACL(params) @@ -212,6 +216,7 @@ func resourceAwsWafWebAclCreate(d *schema.ResourceData, meta interface{}) error func resourceAwsWafWebAclRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &waf.GetWebACLInput{ @@ -252,10 +257,18 @@ func resourceAwsWafWebAclRead(d *schema.ResourceData, meta interface{}) error { if err != nil { return fmt.Errorf("error listing tags for WAF Web ACL (%s): %w", arn, err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { return fmt.Errorf("error setting tags: %w", err) } + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) + } + if err := d.Set("rules", flattenWafWebAclRules(resp.WebACL.Rules)); err != nil { return fmt.Errorf("error setting rules: %w", err) } @@ -327,8 +340,8 @@ func resourceAwsWafWebAclUpdate(d *schema.ResourceData, meta interface{}) error } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.WafUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating WAF Web ACL (%s) tags: %w", d.Id(), err) diff --git a/aws/resource_aws_wafregional_rate_based_rule.go b/aws/resource_aws_wafregional_rate_based_rule.go index 81e5c9429457..c903718cd9c2 100644 --- a/aws/resource_aws_wafregional_rate_based_rule.go +++ b/aws/resource_aws_wafregional_rate_based_rule.go @@ -66,19 +66,23 @@ func resourceAwsWafRegionalRateBasedRule() *schema.Resource { Required: true, ValidateFunc: validation.IntAtLeast(100), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "arn": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWafRegionalRateBasedRuleCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafregionalconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) region := meta.(*AWSClient).region - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().WafregionalTags() wr := newWafRegionalRetryer(conn, region) out, err := wr.RetryWithToken(func(token *string) (interface{}, error) { @@ -91,7 +95,7 @@ func resourceAwsWafRegionalRateBasedRuleCreate(d *schema.ResourceData, meta inte } if len(tags) > 0 { - params.Tags = tags + params.Tags = tags.IgnoreAws().WafregionalTags() } return conn.CreateRateBasedRule(params) @@ -116,6 +120,7 @@ func resourceAwsWafRegionalRateBasedRuleCreate(d *schema.ResourceData, meta inte func resourceAwsWafRegionalRateBasedRuleRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafregionalconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &waf.GetRateBasedRuleInput{ @@ -155,8 +160,16 @@ func resourceAwsWafRegionalRateBasedRuleRead(d *schema.ResourceData, meta interf if err != nil { return fmt.Errorf("Failed to get WAF Regional Rated Based Rule parameter tags for %s: %s", d.Get("name"), err) } - if err := d.Set("tags", tagList.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + + tags := tagList.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } d.Set("predicate", predicates) @@ -188,8 +201,8 @@ func resourceAwsWafRegionalRateBasedRuleUpdate(d *schema.ResourceData, meta inte } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.WafregionalUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating tags: %s", err) diff --git a/aws/resource_aws_wafregional_rule.go b/aws/resource_aws_wafregional_rule.go index 30786c36ff03..0bef031eda8e 100644 --- a/aws/resource_aws_wafregional_rule.go +++ b/aws/resource_aws_wafregional_rule.go @@ -56,19 +56,23 @@ func resourceAwsWafRegionalRule() *schema.Resource { }, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "arn": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWafRegionalRuleCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafregionalconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) region := meta.(*AWSClient).region - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().WafregionalTags() wr := newWafRegionalRetryer(conn, region) out, err := wr.RetryWithToken(func(token *string) (interface{}, error) { @@ -79,7 +83,7 @@ func resourceAwsWafRegionalRuleCreate(d *schema.ResourceData, meta interface{}) } if len(tags) > 0 { - params.Tags = tags + params.Tags = tags.IgnoreAws().WafregionalTags() } return conn.CreateRule(params) @@ -103,6 +107,7 @@ func resourceAwsWafRegionalRuleCreate(d *schema.ResourceData, meta interface{}) func resourceAwsWafRegionalRuleRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafregionalconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &waf.GetRuleInput{ @@ -135,8 +140,15 @@ func resourceAwsWafRegionalRuleRead(d *schema.ResourceData, meta interface{}) er return fmt.Errorf("error listing tags for WAF Regional Rule (%s): %s", arn, err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } d.Set("predicate", flattenWafPredicates(resp.Rule.Predicates)) @@ -159,8 +171,8 @@ func resourceAwsWafRegionalRuleUpdate(d *schema.ResourceData, meta interface{}) } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.WafregionalUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating tags: %s", err) diff --git a/aws/resource_aws_wafregional_rule_group.go b/aws/resource_aws_wafregional_rule_group.go index 2e6c063bab26..b6a56468efb0 100644 --- a/aws/resource_aws_wafregional_rule_group.go +++ b/aws/resource_aws_wafregional_rule_group.go @@ -68,19 +68,23 @@ func resourceAwsWafRegionalRuleGroup() *schema.Resource { }, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "arn": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWafRegionalRuleGroupCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafregionalconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) region := meta.(*AWSClient).region - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().WafregionalTags() wr := newWafRegionalRetryer(conn, region) out, err := wr.RetryWithToken(func(token *string) (interface{}, error) { @@ -91,7 +95,7 @@ func resourceAwsWafRegionalRuleGroupCreate(d *schema.ResourceData, meta interfac } if len(tags) > 0 { - params.Tags = tags + params.Tags = tags.IgnoreAws().WafregionalTags() } return conn.CreateRuleGroup(params) @@ -117,6 +121,7 @@ func resourceAwsWafRegionalRuleGroupCreate(d *schema.ResourceData, meta interfac func resourceAwsWafRegionalRuleGroupRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafregionalconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &waf.GetRuleGroupInput{ @@ -154,8 +159,15 @@ func resourceAwsWafRegionalRuleGroupRead(d *schema.ResourceData, meta interface{ if err != nil { return fmt.Errorf("error listing tags for WAF Regional Rule Group (%s): %s", arn, err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } d.Set("activated_rule", flattenWafActivatedRules(rResp.ActivatedRules)) @@ -179,8 +191,8 @@ func resourceAwsWafRegionalRuleGroupUpdate(d *schema.ResourceData, meta interfac } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.WafregionalUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating tags: %s", err) diff --git a/aws/resource_aws_wafregional_web_acl.go b/aws/resource_aws_wafregional_web_acl.go index 406741efa192..91dd3ba55233 100644 --- a/aws/resource_aws_wafregional_web_acl.go +++ b/aws/resource_aws_wafregional_web_acl.go @@ -165,15 +165,19 @@ func resourceAwsWafRegionalWebAcl() *schema.Resource { }, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWafRegionalWebAclCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafregionalconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) region := meta.(*AWSClient).region - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().WafregionalTags() wr := newWafRegionalRetryer(conn, region) out, err := wr.RetryWithToken(func(token *string) (interface{}, error) { @@ -185,7 +189,7 @@ func resourceAwsWafRegionalWebAclCreate(d *schema.ResourceData, meta interface{} } if len(tags) > 0 { - params.Tags = tags + params.Tags = tags.IgnoreAws().WafregionalTags() } return conn.CreateWebACL(params) @@ -243,6 +247,7 @@ func resourceAwsWafRegionalWebAclCreate(d *schema.ResourceData, meta interface{} func resourceAwsWafRegionalWebAclRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafregionalconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &waf.GetWebACLInput{ @@ -292,8 +297,16 @@ func resourceAwsWafRegionalWebAclRead(d *schema.ResourceData, meta interface{}) if err != nil { return fmt.Errorf("error listing tags for WAF Regional ACL (%s): %s", webACLARN, err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } getLoggingConfigurationInput := &waf.GetLoggingConfigurationInput{ @@ -366,8 +379,8 @@ func resourceAwsWafRegionalWebAclUpdate(d *schema.ResourceData, meta interface{} } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.WafregionalUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating tags: %s", err) diff --git a/aws/resource_aws_wafv2_ip_set.go b/aws/resource_aws_wafv2_ip_set.go index f89ce0a06f10..77d653cb6b96 100644 --- a/aws/resource_aws_wafv2_ip_set.go +++ b/aws/resource_aws_wafv2_ip_set.go @@ -101,13 +101,18 @@ func resourceAwsWafv2IPSet() *schema.Resource { wafv2.ScopeRegional, }, false), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWafv2IPSetCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafv2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) params := &wafv2.CreateIPSetInput{ Addresses: aws.StringSlice([]string{}), IPAddressVersion: aws.String(d.Get("ip_address_version").(string)), @@ -123,8 +128,8 @@ func resourceAwsWafv2IPSetCreate(d *schema.ResourceData, meta interface{}) error params.Description = aws.String(v.(string)) } - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - params.Tags = keyvaluetags.New(v).IgnoreAws().Wafv2Tags() + if len(tags) > 0 { + params.Tags = tags.IgnoreAws().Wafv2Tags() } resp, err := conn.CreateIPSet(params) @@ -144,6 +149,7 @@ func resourceAwsWafv2IPSetCreate(d *schema.ResourceData, meta interface{}) error func resourceAwsWafv2IPSetRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafv2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &wafv2.GetIPSetInput{ @@ -182,8 +188,15 @@ func resourceAwsWafv2IPSetRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error listing tags for WAFv2 IpSet (%s): %s", arn, err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("Error setting tags: %s", err) + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } return nil @@ -216,8 +229,8 @@ func resourceAwsWafv2IPSetUpdate(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error updating WAFv2 IPSet: %s", err) } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.Wafv2UpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("Error updating tags: %s", err) } diff --git a/aws/resource_aws_wafv2_regex_pattern_set.go b/aws/resource_aws_wafv2_regex_pattern_set.go index abb8fb7fb639..7c11d3cd78ec 100644 --- a/aws/resource_aws_wafv2_regex_pattern_set.go +++ b/aws/resource_aws_wafv2_regex_pattern_set.go @@ -79,13 +79,18 @@ func resourceAwsWafv2RegexPatternSet() *schema.Resource { wafv2.ScopeRegional, }, false), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWafv2RegexPatternSetCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafv2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) params := &wafv2.CreateRegexPatternSetInput{ Name: aws.String(d.Get("name").(string)), Scope: aws.String(d.Get("scope").(string)), @@ -100,8 +105,8 @@ func resourceAwsWafv2RegexPatternSetCreate(d *schema.ResourceData, meta interfac params.RegularExpressionList = expandWafv2RegexPatternSet(v.(*schema.Set).List()) } - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - params.Tags = keyvaluetags.New(v).IgnoreAws().Wafv2Tags() + if len(tags) > 0 { + params.Tags = tags.IgnoreAws().Wafv2Tags() } resp, err := conn.CreateRegexPatternSet(params) @@ -121,6 +126,7 @@ func resourceAwsWafv2RegexPatternSetCreate(d *schema.ResourceData, meta interfac func resourceAwsWafv2RegexPatternSetRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafv2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &wafv2.GetRegexPatternSetInput{ Id: aws.String(d.Id()), @@ -156,8 +162,15 @@ func resourceAwsWafv2RegexPatternSetRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("Error listing tags for WAFv2 RegexPatternSet (%s): %s", aws.StringValue(resp.RegexPatternSet.ARN), err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("Error setting tags: %s", err) + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } return nil @@ -190,8 +203,8 @@ func resourceAwsWafv2RegexPatternSetUpdate(d *schema.ResourceData, meta interfac return fmt.Errorf("Error updating WAFv2 RegexPatternSet: %s", err) } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.Wafv2UpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("Error updating tags: %s", err) } diff --git a/aws/resource_aws_wafv2_rule_group.go b/aws/resource_aws_wafv2_rule_group.go index 95ca54abcf3b..e809c195209c 100644 --- a/aws/resource_aws_wafv2_rule_group.go +++ b/aws/resource_aws_wafv2_rule_group.go @@ -107,13 +107,18 @@ func resourceAwsWafv2RuleGroup() *schema.Resource { }, }, "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "visibility_config": wafv2VisibilityConfigSchema(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWafv2RuleGroupCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafv2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) var resp *wafv2.CreateRuleGroupOutput params := &wafv2.CreateRuleGroupInput{ @@ -128,8 +133,8 @@ func resourceAwsWafv2RuleGroupCreate(d *schema.ResourceData, meta interface{}) e params.Description = aws.String(v.(string)) } - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - params.Tags = keyvaluetags.New(v).IgnoreAws().Wafv2Tags() + if len(tags) > 0 { + params.Tags = tags.IgnoreAws().Wafv2Tags() } err := resource.Retry(5*time.Minute, func() *resource.RetryError { @@ -163,6 +168,7 @@ func resourceAwsWafv2RuleGroupCreate(d *schema.ResourceData, meta interface{}) e func resourceAwsWafv2RuleGroupRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafv2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &wafv2.GetRuleGroupInput{ @@ -205,8 +211,15 @@ func resourceAwsWafv2RuleGroupRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error listing tags for WAFv2 RuleGroup (%s): %s", arn, err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("Error setting tags: %s", err) + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } return nil @@ -249,8 +262,8 @@ func resourceAwsWafv2RuleGroupUpdate(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("Error updating WAFv2 RuleGroup: %s", err) } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.Wafv2UpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("Error updating tags: %s", err) } diff --git a/aws/resource_aws_wafv2_web_acl.go b/aws/resource_aws_wafv2_web_acl.go index 7c41381663d9..50a46a5f0b40 100644 --- a/aws/resource_aws_wafv2_web_acl.go +++ b/aws/resource_aws_wafv2_web_acl.go @@ -134,13 +134,18 @@ func resourceAwsWafv2WebACL() *schema.Resource { }, }, "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "visibility_config": wafv2VisibilityConfigSchema(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWafv2WebACLCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafv2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) var resp *wafv2.CreateWebACLOutput params := &wafv2.CreateWebACLInput{ @@ -155,8 +160,8 @@ func resourceAwsWafv2WebACLCreate(d *schema.ResourceData, meta interface{}) erro params.Description = aws.String(v.(string)) } - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - params.Tags = keyvaluetags.New(v).IgnoreAws().Wafv2Tags() + if len(tags) > 0 { + params.Tags = tags.IgnoreAws().Wafv2Tags() } err := resource.Retry(Wafv2WebACLCreateTimeout, func() *resource.RetryError { @@ -190,6 +195,7 @@ func resourceAwsWafv2WebACLCreate(d *schema.ResourceData, meta interface{}) erro func resourceAwsWafv2WebACLRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).wafv2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &wafv2.GetWebACLInput{ @@ -236,8 +242,15 @@ func resourceAwsWafv2WebACLRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error listing tags for WAFv2 WebACL (%s): %w", arn, err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("Error setting tags: %w", err) + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } return nil @@ -284,8 +297,8 @@ func resourceAwsWafv2WebACLUpdate(d *schema.ResourceData, meta interface{}) erro } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.Wafv2UpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating tags: %w", err) } diff --git a/aws/resource_aws_workspaces_directory.go b/aws/resource_aws_workspaces_directory.go index ee369ad22a5a..a611c9a63bf6 100644 --- a/aws/resource_aws_workspaces_directory.go +++ b/aws/resource_aws_workspaces_directory.go @@ -104,7 +104,8 @@ func resourceAwsWorkspacesDirectory() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "workspace_access_properties": { Type: schema.TypeList, Computed: true, @@ -188,21 +189,23 @@ func resourceAwsWorkspacesDirectory() *schema.Resource { Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWorkspacesDirectoryCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).workspacesconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) directoryID := d.Get("directory_id").(string) - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().WorkspacesTags() - input := &workspaces.RegisterWorkspaceDirectoryInput{ DirectoryId: aws.String(directoryID), EnableSelfService: aws.Bool(false), // this is handled separately below EnableWorkDocs: aws.Bool(false), Tenancy: aws.String(workspaces.TenancyShared), - Tags: tags, + Tags: tags.IgnoreAws().WorkspacesTags(), } if v, ok := d.GetOk("subnet_ids"); ok { @@ -277,6 +280,7 @@ func resourceAwsWorkspacesDirectoryCreate(d *schema.ResourceData, meta interface func resourceAwsWorkspacesDirectoryRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).workspacesconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig rawOutput, state, err := waiter.DirectoryState(conn, d.Id())() @@ -326,10 +330,17 @@ func resourceAwsWorkspacesDirectoryRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("error listing tags: %w", err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { return fmt.Errorf("error setting tags: %w", err) } + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) + } + return nil } @@ -406,8 +417,8 @@ func resourceAwsWorkspacesDirectoryUpdate(d *schema.ResourceData, meta interface log.Printf("[INFO] Updated WorkSpaces Directory (%s) IP Groups", d.Id()) } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.WorkspacesUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating tags: %w", err) } diff --git a/aws/resource_aws_workspaces_ip_group.go b/aws/resource_aws_workspaces_ip_group.go index 01752026d87e..7d9471819206 100644 --- a/aws/resource_aws_workspaces_ip_group.go +++ b/aws/resource_aws_workspaces_ip_group.go @@ -50,23 +50,26 @@ func resourceAwsWorkspacesIpGroup() *schema.Resource { }, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWorkspacesIpGroupCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).workspacesconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) rules := d.Get("rules").(*schema.Set).List() - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().WorkspacesTags() - resp, err := conn.CreateIpGroup(&workspaces.CreateIpGroupInput{ GroupName: aws.String(d.Get("name").(string)), GroupDesc: aws.String(d.Get("description").(string)), UserRules: expandIpGroupRules(rules), - Tags: tags, + Tags: tags.IgnoreAws().WorkspacesTags(), }) if err != nil { return err @@ -79,6 +82,7 @@ func resourceAwsWorkspacesIpGroupCreate(d *schema.ResourceData, meta interface{} func resourceAwsWorkspacesIpGroupRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).workspacesconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig resp, err := conn.DescribeIpGroups(&workspaces.DescribeIpGroupsInput{ @@ -113,10 +117,17 @@ func resourceAwsWorkspacesIpGroupRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error listing tags for WorkSpaces IP Group (%s): %w", d.Id(), err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { return fmt.Errorf("error setting tags: %w", err) } + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) + } + return nil } @@ -136,8 +147,8 @@ func resourceAwsWorkspacesIpGroupUpdate(d *schema.ResourceData, meta interface{} } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.WorkspacesUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating tags: %w", err) } diff --git a/aws/resource_aws_workspaces_workspace.go b/aws/resource_aws_workspaces_workspace.go index 8a8f71d374b4..b9c1d6581395 100644 --- a/aws/resource_aws_workspaces_workspace.go +++ b/aws/resource_aws_workspaces_workspace.go @@ -131,20 +131,23 @@ func resourceAwsWorkspacesWorkspace() *schema.Resource { }, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(waiter.WorkspaceAvailableTimeout), Update: schema.DefaultTimeout(waiter.WorkspaceUpdatingTimeout), Delete: schema.DefaultTimeout(waiter.WorkspaceTerminatedTimeout), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsWorkspacesWorkspaceCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).workspacesconn - - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().WorkspacesTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) input := &workspaces.WorkspaceRequest{ BundleId: aws.String(d.Get("bundle_id").(string)), @@ -152,7 +155,7 @@ func resourceAwsWorkspacesWorkspaceCreate(d *schema.ResourceData, meta interface UserName: aws.String(d.Get("user_name").(string)), RootVolumeEncryptionEnabled: aws.Bool(d.Get("root_volume_encryption_enabled").(bool)), UserVolumeEncryptionEnabled: aws.Bool(d.Get("user_volume_encryption_enabled").(bool)), - Tags: tags, + Tags: tags.IgnoreAws().WorkspacesTags(), } if v, ok := d.GetOk("volume_encryption_key"); ok { @@ -190,6 +193,7 @@ func resourceAwsWorkspacesWorkspaceCreate(d *schema.ResourceData, meta interface func resourceAwsWorkspacesWorkspaceRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).workspacesconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig rawOutput, state, err := waiter.WorkspaceState(conn, d.Id())() @@ -221,8 +225,15 @@ func resourceAwsWorkspacesWorkspaceRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("error listing tags: %s", err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } return nil @@ -265,8 +276,8 @@ func resourceAwsWorkspacesWorkspaceUpdate(d *schema.ResourceData, meta interface } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.WorkspacesUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating tags: %s", err) } diff --git a/website/docs/r/waf_rate_based_rule.html.markdown b/website/docs/r/waf_rate_based_rule.html.markdown index ffe086df5fdc..2aa15397acf6 100644 --- a/website/docs/r/waf_rate_based_rule.html.markdown +++ b/website/docs/r/waf_rate_based_rule.html.markdown @@ -47,7 +47,7 @@ The following arguments are supported: * `rate_key` - (Required) Valid value is IP. * `rate_limit` - (Required) The maximum number of requests, which have an identical value in the field specified by the RateKey, allowed in a five-minute period. Minimum value is 100. * `predicates` - (Optional) The objects to include in a rule (documented below). -* `tags` - (Optional) Key-value map of resource tags +* `tags` - (Optional) Key-value map of resource tags. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ## Nested Blocks @@ -72,6 +72,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the WAF rule. * `arn` - Amazon Resource Name (ARN) +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/waf_rule.html.markdown b/website/docs/r/waf_rule.html.markdown index 08b22cc49b92..bcb2acaa084e 100644 --- a/website/docs/r/waf_rule.html.markdown +++ b/website/docs/r/waf_rule.html.markdown @@ -42,7 +42,7 @@ The following arguments are supported: * `metric_name` - (Required) The name or description for the Amazon CloudWatch metric of this rule. The name can contain only alphanumeric characters (A-Z, a-z, 0-9); the name can't contain whitespace. * `name` - (Required) The name or description of the rule. * `predicates` - (Optional) The objects to include in a rule (documented below). -* `tags` - (Optional) Key-value map of resource tags +* `tags` - (Optional) Key-value map of resource tags. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ## Nested Blocks @@ -65,6 +65,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the WAF rule. * `arn` - The ARN of the WAF rule. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/waf_rule_group.html.markdown b/website/docs/r/waf_rule_group.html.markdown index b31b3d70e8ae..600beabccfff 100644 --- a/website/docs/r/waf_rule_group.html.markdown +++ b/website/docs/r/waf_rule_group.html.markdown @@ -40,7 +40,7 @@ The following arguments are supported: * `name` - (Required) A friendly name of the rule group * `metric_name` - (Required) A friendly name for the metrics from the rule group * `activated_rule` - (Optional) A list of activated rules, see below -* `tags` - (Optional) Key-value map of resource tags +* `tags` - (Optional) Key-value map of resource tags. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ## Nested Blocks @@ -60,6 +60,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the WAF rule group. * `arn` - The ARN of the WAF rule group. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/waf_web_acl.html.markdown b/website/docs/r/waf_web_acl.html.markdown index 0baf09d5e3e2..8dc5a0e881ba 100644 --- a/website/docs/r/waf_web_acl.html.markdown +++ b/website/docs/r/waf_web_acl.html.markdown @@ -91,7 +91,7 @@ The following arguments are supported: * `name` - (Required) The name or description of the web ACL. * `rules` - (Optional) Configuration blocks containing rules to associate with the web ACL and the settings for each rule. Detailed below. * `logging_configuration` - (Optional) Configuration block to enable WAF logging. Detailed below. -* `tags` - (Optional) Key-value map of resource tags +* `tags` - (Optional) Key-value map of resource tags. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ### `default_action` Configuration Block @@ -133,6 +133,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the WAF WebACL. * `arn` - The ARN of the WAF WebACL. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/wafregional_rate_based_rule.html.markdown b/website/docs/r/wafregional_rate_based_rule.html.markdown index b50f80c30eae..8883e44d8d27 100644 --- a/website/docs/r/wafregional_rate_based_rule.html.markdown +++ b/website/docs/r/wafregional_rate_based_rule.html.markdown @@ -47,7 +47,7 @@ The following arguments are supported: * `rate_key` - (Required) Valid value is IP. * `rate_limit` - (Required) The maximum number of requests, which have an identical value in the field specified by the RateKey, allowed in a five-minute period. Minimum value is 100. * `predicate` - (Optional) The objects to include in a rule (documented below). -* `tags` - (Optional) Key-value map of resource tags +* `tags` - (Optional) Key-value map of resource tags. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ## Nested Blocks @@ -70,6 +70,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the WAF Regional Rate Based Rule. * `arn` - The ARN of the WAF Regional Rate Based Rule. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/wafregional_rule.html.markdown b/website/docs/r/wafregional_rule.html.markdown index 41e712f4c2f4..62f56e797297 100644 --- a/website/docs/r/wafregional_rule.html.markdown +++ b/website/docs/r/wafregional_rule.html.markdown @@ -41,7 +41,7 @@ The following arguments are supported: * `name` - (Required) The name or description of the rule. * `metric_name` - (Required) The name or description for the Amazon CloudWatch metric of this rule. * `predicate` - (Optional) The objects to include in a rule (documented below). -* `tags` - (Optional) Key-value map of resource tags +* `tags` - (Optional) Key-value map of resource tags. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ## Nested Fields @@ -63,6 +63,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the WAF Regional Rule. * `arn` - The ARN of the WAF Regional Rule. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/wafregional_rule_group.html.markdown b/website/docs/r/wafregional_rule_group.html.markdown index 181665b1b08f..f67f2eb6694a 100644 --- a/website/docs/r/wafregional_rule_group.html.markdown +++ b/website/docs/r/wafregional_rule_group.html.markdown @@ -40,7 +40,7 @@ The following arguments are supported: * `name` - (Required) A friendly name of the rule group * `metric_name` - (Required) A friendly name for the metrics from the rule group * `activated_rule` - (Optional) A list of activated rules, see below -* `tags` - (Optional) Key-value map of resource tags +* `tags` - (Optional) Key-value map of resource tags. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ## Nested Blocks @@ -60,6 +60,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the WAF Regional Rule Group. * `arn` - The ARN of the WAF Regional Rule Group. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/wafregional_web_acl.html.markdown b/website/docs/r/wafregional_web_acl.html.markdown index 6d33d16ae35a..134f6868706c 100644 --- a/website/docs/r/wafregional_web_acl.html.markdown +++ b/website/docs/r/wafregional_web_acl.html.markdown @@ -112,7 +112,7 @@ The following arguments are supported: * `name` - (Required) The name or description of the web ACL. * `logging_configuration` - (Optional) Configuration block to enable WAF logging. Detailed below. * `rule` - (Optional) Set of configuration blocks containing rules for the web ACL. Detailed below. -* `tags` - (Optional) Key-value map of resource tags +* `tags` - (Optional) Key-value map of resource tags. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ### `default_action` Configuration Block @@ -155,6 +155,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - Amazon Resource Name (ARN) of the WAF Regional WebACL. * `id` - The ID of the WAF Regional WebACL. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/wafv2_ip_set.html.markdown b/website/docs/r/wafv2_ip_set.html.markdown index f0d46a50d835..c47a59510581 100644 --- a/website/docs/r/wafv2_ip_set.html.markdown +++ b/website/docs/r/wafv2_ip_set.html.markdown @@ -36,7 +36,7 @@ The following arguments are supported: * `scope` - (Required) Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are `CLOUDFRONT` or `REGIONAL`. To work with CloudFront, you must also specify the Region US East (N. Virginia). * `ip_address_version` - (Required) Specify IPV4 or IPV6. Valid values are `IPV4` or `IPV6`. * `addresses` - (Required) Contains an array of strings that specify one or more IP addresses or blocks of IP addresses in Classless Inter-Domain Routing (CIDR) notation. AWS WAF supports all address ranges for IP versions IPv4 and IPv6. -* `tags` - (Optional) An array of key:value pairs to associate with the resource. +* `tags` - (Optional) An array of key:value pairs to associate with the resource. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ## Attributes Reference @@ -44,6 +44,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - A unique identifier for the set. * `arn` - The Amazon Resource Name (ARN) that identifies the cluster. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/wafv2_regex_pattern_set.html.markdown b/website/docs/r/wafv2_regex_pattern_set.html.markdown index 71d7aff53ca1..56f55019391d 100644 --- a/website/docs/r/wafv2_regex_pattern_set.html.markdown +++ b/website/docs/r/wafv2_regex_pattern_set.html.markdown @@ -41,7 +41,7 @@ The following arguments are supported: * `description` - (Optional) A friendly description of the regular expression pattern set. * `scope` - (Required) Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are `CLOUDFRONT` or `REGIONAL`. To work with CloudFront, you must also specify the region `us-east-1` (N. Virginia) on the AWS provider. * `regular_expression` - (Optional) One or more blocks of regular expression patterns that you want AWS WAF to search for, such as `B[a@]dB[o0]t`. See [Regular Expression](#regular-expression) below for details. -* `tags` - (Optional) An array of key:value pairs to associate with the resource. +* `tags` - (Optional) An array of key:value pairs to associate with the resource. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ### Regular Expression @@ -53,6 +53,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - A unique identifier for the set. * `arn` - The Amazon Resource Name (ARN) that identifies the cluster. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/wafv2_rule_group.html.markdown b/website/docs/r/wafv2_rule_group.html.markdown index b10a5f7b0022..ebc521a80219 100644 --- a/website/docs/r/wafv2_rule_group.html.markdown +++ b/website/docs/r/wafv2_rule_group.html.markdown @@ -290,7 +290,7 @@ The following arguments are supported: * `name` - (Required, Forces new resource) A friendly name of the rule group. * `rule` - (Optional) The rule blocks used to identify the web requests that you want to `allow`, `block`, or `count`. See [Rules](#rules) below for details. * `scope` - (Required, Forces new resource) Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are `CLOUDFRONT` or `REGIONAL`. To work with CloudFront, you must also specify the region `us-east-1` (N. Virginia) on the AWS provider. -* `tags` - (Optional) An array of key:value pairs to associate with the resource. +* `tags` - (Optional) An array of key:value pairs to associate with the resource. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. * `visibility_config` - (Required) Defines and enables Amazon CloudWatch metrics and web request sample collection. See [Visibility Configuration](#visibility-configuration) below for details. ### Rules @@ -498,6 +498,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the WAF rule group. * `arn` - The ARN of the WAF rule group. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/wafv2_web_acl.html.markdown b/website/docs/r/wafv2_web_acl.html.markdown index 2ce8e49de23f..de0f98a1745f 100644 --- a/website/docs/r/wafv2_web_acl.html.markdown +++ b/website/docs/r/wafv2_web_acl.html.markdown @@ -260,7 +260,7 @@ The following arguments are supported: * `name` - (Required) A friendly name of the WebACL. * `rule` - (Optional) The rule blocks used to identify the web requests that you want to `allow`, `block`, or `count`. See [Rules](#rules) below for details. * `scope` - (Required) Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are `CLOUDFRONT` or `REGIONAL`. To work with CloudFront, you must also specify the region `us-east-1` (N. Virginia) on the AWS provider. -* `tags` - (Optional) An array of key:value pairs to associate with the resource. +* `tags` - (Optional) An map of key:value pairs to associate with the resource. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. * `visibility_config` - (Required) Defines and enables Amazon CloudWatch metrics and web request sample collection. See [Visibility Configuration](#visibility-configuration) below for details. ### Default Action @@ -536,6 +536,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the WAF WebACL. * `capacity` - The web ACL capacity units (WCUs) currently being used by this web ACL. * `id` - The ID of the WAF WebACL. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/workspaces_directory.html.markdown b/website/docs/r/workspaces_directory.html.markdown index 9e5c913c9329..e954a909172e 100644 --- a/website/docs/r/workspaces_directory.html.markdown +++ b/website/docs/r/workspaces_directory.html.markdown @@ -149,7 +149,7 @@ The following arguments are supported: * `directory_id` - (Required) The directory identifier for registration in WorkSpaces service. * `subnet_ids` - (Optional) The identifiers of the subnets where the directory resides. * `ip_group_ids` - The identifiers of the IP access control groups associated with the directory. -* `tags` – (Optional) A map of tags assigned to the WorkSpaces directory. +* `tags` – (Optional) A map of tags assigned to the WorkSpaces directory. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. * `self_service_permissions` – (Optional) Permissions to enable or disable self-service capabilities. Defined below. * `workspace_access_properties` – (Optional) Specifies which devices and operating systems users can use to access their WorkSpaces. Defined below. * `workspace_creation_properties` – (Optional) Default properties that are used for creating WorkSpaces. Defined below. @@ -195,6 +195,7 @@ In addition to all arguments above, the following attributes are exported: * `iam_role_id` - The identifier of the IAM role. This is the role that allows Amazon WorkSpaces to make calls to other services, such as Amazon EC2, on your behalf. * `ip_group_ids` - The identifiers of the IP access control groups associated with the directory. * `registration_code` - The registration code for the directory. This is the code that users enter in their Amazon WorkSpaces client application to connect to the directory. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). * `workspace_security_group_id` - The identifier of the security group that is assigned to new WorkSpaces. ## Import diff --git a/website/docs/r/workspaces_ip_group.html.markdown b/website/docs/r/workspaces_ip_group.html.markdown index 3923da0c1bd0..294c272dc7b3 100644 --- a/website/docs/r/workspaces_ip_group.html.markdown +++ b/website/docs/r/workspaces_ip_group.html.markdown @@ -26,6 +26,7 @@ The following arguments are supported: * `name` - (Required) The name of the IP group. * `description` - (Optional) The description of the IP group. * `rules` - (Optional) One or more pairs specifying the IP group rule (in CIDR format) from which web requests originate. +* `tags` – (Optional) A map of tags assigned to the WorkSpaces directory. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ## Nested Blocks @@ -41,6 +42,7 @@ The following arguments are supported: In addition to all arguments above, the following attributes are exported: * `id` - The IP group identifier. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/workspaces_workspace.html.markdown b/website/docs/r/workspaces_workspace.html.markdown index d39f28cd4cc8..2198b4f584a2 100644 --- a/website/docs/r/workspaces_workspace.html.markdown +++ b/website/docs/r/workspaces_workspace.html.markdown @@ -52,7 +52,7 @@ The following arguments are supported: * `root_volume_encryption_enabled` - (Optional) Indicates whether the data stored on the root volume is encrypted. * `user_volume_encryption_enabled` – (Optional) Indicates whether the data stored on the user volume is encrypted. * `volume_encryption_key` – (Optional) The symmetric AWS KMS customer master key (CMK) used to encrypt data stored on your WorkSpace. Amazon WorkSpaces does not support asymmetric CMKs. -* `tags` - (Optional) The tags for the WorkSpace. +* `tags` - (Optional) The tags for the WorkSpace. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. * `workspace_properties` – (Optional) The WorkSpace properties. `workspace_properties` supports the following: @@ -80,6 +80,7 @@ In addition to all arguments above, the following attributes are exported: * `ip_address` - The IP address of the WorkSpace. * `computer_name` - The name of the WorkSpace, as seen by the operating system. * `state` - The operational state of the WorkSpace. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import