From f553b32c2aed6c812d9dc0e49a835be8b4683b09 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Fri, 9 Apr 2021 17:05:27 -0400 Subject: [PATCH 1/5] provider: Support default tags (resources aws_c*) Reference: https://github.com/hashicorp/terraform-provider-aws/issues/7926 --- aws/resource_aws_cloud9_environment_ec2.go | 25 ++++++++++++---- aws/resource_aws_cloudformation_stack.go | 29 ++++++++++++++----- aws/resource_aws_cloudformation_stack_set.go | 29 ++++++++++++++----- aws/resource_aws_cloudfront_distribution.go | 25 ++++++++++++---- aws/resource_aws_cloudhsm_v2_cluster.go | 25 ++++++++++++---- aws/resource_aws_cloudtrail.go | 26 ++++++++++++----- ...resource_aws_cloudwatch_composite_alarm.go | 29 ++++++++++++++----- aws/resource_aws_cloudwatch_event_bus.go | 25 ++++++++++++---- aws/resource_aws_cloudwatch_event_rule.go | 25 ++++++++++++---- aws/resource_aws_cloudwatch_log_group.go | 26 ++++++++++++----- aws/resource_aws_cloudwatch_metric_alarm.go | 21 ++++++++++---- aws/resource_aws_codeartifact_domain.go | 23 +++++++++++---- aws/resource_aws_codeartifact_repository.go | 23 +++++++++++---- aws/resource_aws_codebuild_project.go | 24 +++++++++++---- aws/resource_aws_codebuild_report_group.go | 25 ++++++++++++---- aws/resource_aws_codecommit_repository.go | 25 ++++++++++++---- aws/resource_aws_codepipeline.go | 25 ++++++++++++---- aws/resource_aws_codepipeline_webhook.go | 25 ++++++++++++---- ...urce_aws_codestarconnections_connection.go | 27 ++++++++++++----- ...codestarnotifications_notification_rule.go | 27 +++++++++++++---- aws/resource_aws_cognito_identity_pool.go | 27 ++++++++++++----- aws/resource_aws_cognito_user_pool.go | 21 +++++++++++--- ...urce_aws_config_aggregate_authorization.go | 21 ++++++++++---- aws/resource_aws_config_config_rule.go | 25 ++++++++++++---- ...rce_aws_config_configuration_aggregator.go | 22 ++++++++++---- aws/resource_aws_customer_gateway.go | 25 ++++++++++++---- 26 files changed, 496 insertions(+), 154 deletions(-) diff --git a/aws/resource_aws_cloud9_environment_ec2.go b/aws/resource_aws_cloud9_environment_ec2.go index f6c0be29615..f2530ece447 100644 --- a/aws/resource_aws_cloud9_environment_ec2.go +++ b/aws/resource_aws_cloud9_environment_ec2.go @@ -63,19 +63,24 @@ func resourceAwsCloud9EnvironmentEc2() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCloud9EnvironmentEc2Create(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloud9conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) params := &cloud9.CreateEnvironmentEC2Input{ InstanceType: aws.String(d.Get("instance_type").(string)), Name: aws.String(d.Get("name").(string)), ClientRequestToken: aws.String(resource.UniqueId()), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().Cloud9Tags(), + Tags: tags.IgnoreAws().Cloud9Tags(), } if v, ok := d.GetOk("automatic_stop_time_minutes"); ok { @@ -149,6 +154,7 @@ func resourceAwsCloud9EnvironmentEc2Create(d *schema.ResourceData, meta interfac func resourceAwsCloud9EnvironmentEc2Read(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloud9conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig log.Printf("[INFO] Reading Cloud9 Environment EC2 %s", d.Id()) @@ -184,8 +190,15 @@ func resourceAwsCloud9EnvironmentEc2Read(d *schema.ResourceData, meta interface{ return fmt.Errorf("error listing tags for Cloud9 EC2 Environment (%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) } log.Printf("[DEBUG] Received Cloud9 Environment EC2: %s", env) @@ -211,8 +224,8 @@ func resourceAwsCloud9EnvironmentEc2Update(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] Cloud9 Environment EC2 updated: %s", out) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") arn := d.Get("arn").(string) if err := keyvaluetags.Cloud9UpdateTags(conn, arn, o, n); err != nil { diff --git a/aws/resource_aws_cloudformation_stack.go b/aws/resource_aws_cloudformation_stack.go index 69d0cfca6c0..c59fdeac6dd 100644 --- a/aws/resource_aws_cloudformation_stack.go +++ b/aws/resource_aws_cloudformation_stack.go @@ -108,17 +108,22 @@ func resourceAwsCloudFormationStack() *schema.Resource { Optional: true, ForceNew: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "iam_role_arn": { Type: schema.TypeString, Optional: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCloudFormationStackCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cfconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) requestToken := resource.UniqueId() input := cloudformation.CreateStackInput{ @@ -160,8 +165,8 @@ func resourceAwsCloudFormationStackCreate(d *schema.ResourceData, meta interface if v, ok := d.GetOk("policy_url"); ok { input.StackPolicyURL = aws.String(v.(string)) } - if v, ok := d.GetOk("tags"); ok { - input.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().CloudformationTags() + if len(tags) > 0 { + input.Tags = tags.IgnoreAws().CloudformationTags() } if v, ok := d.GetOk("timeout_in_minutes"); ok { m := int64(v.(int)) @@ -198,6 +203,7 @@ func resourceAwsCloudFormationStackCreate(d *schema.ResourceData, meta interface func resourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cfconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := &cloudformation.DescribeStacksInput{ @@ -269,8 +275,15 @@ func resourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface{} return err } - if err := d.Set("tags", keyvaluetags.CloudformationKeyValueTags(stack.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.CloudformationKeyValueTags(stack.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) } err = d.Set("outputs", flattenCloudFormationOutputs(stack.Outputs)) @@ -290,6 +303,8 @@ func resourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface{} func resourceAwsCloudFormationStackUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cfconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) requestToken := resource.UniqueId() input := &cloudformation.UpdateStackInput{ @@ -323,8 +338,8 @@ func resourceAwsCloudFormationStackUpdate(d *schema.ResourceData, meta interface input.Parameters = expandCloudFormationParameters(v.(map[string]interface{})) } - if v, ok := d.GetOk("tags"); ok { - input.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().CloudformationTags() + if len(tags) > 0 { + input.Tags = tags.IgnoreAws().CloudformationTags() } if d.HasChange("policy_body") { diff --git a/aws/resource_aws_cloudformation_stack_set.go b/aws/resource_aws_cloudformation_stack_set.go index 6556a887348..a29e763b780 100644 --- a/aws/resource_aws_cloudformation_stack_set.go +++ b/aws/resource_aws_cloudformation_stack_set.go @@ -107,7 +107,8 @@ func resourceAwsCloudFormationStackSet() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "template_body": { Type: schema.TypeString, Optional: true, @@ -122,11 +123,15 @@ func resourceAwsCloudFormationStackSet() *schema.Resource { ConflictsWith: []string{"template_body"}, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCloudFormationStackSetCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cfconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) name := d.Get("name").(string) input := &cloudformation.CreateStackSetInput{ @@ -162,8 +167,8 @@ func resourceAwsCloudFormationStackSetCreate(d *schema.ResourceData, meta interf input.PermissionModel = aws.String(v.(string)) } - if v, ok := d.GetOk("tags"); ok { - input.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().CloudformationTags() + if len(tags) > 0 { + input.Tags = tags.IgnoreAws().CloudformationTags() } if v, ok := d.GetOk("template_body"); ok { @@ -188,6 +193,7 @@ func resourceAwsCloudFormationStackSetCreate(d *schema.ResourceData, meta interf func resourceAwsCloudFormationStackSetRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cfconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := &cloudformation.DescribeStackSetInput{ @@ -235,8 +241,15 @@ func resourceAwsCloudFormationStackSetRead(d *schema.ResourceData, meta interfac d.Set("stack_set_id", stackSet.StackSetId) - if err := d.Set("tags", keyvaluetags.CloudformationKeyValueTags(stackSet.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.CloudformationKeyValueTags(stackSet.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("template_body", stackSet.TemplateBody) @@ -246,6 +259,8 @@ func resourceAwsCloudFormationStackSetRead(d *schema.ResourceData, meta interfac func resourceAwsCloudFormationStackSetUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cfconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) input := &cloudformation.UpdateStackSetInput{ OperationId: aws.String(resource.UniqueId()), @@ -278,8 +293,8 @@ func resourceAwsCloudFormationStackSetUpdate(d *schema.ResourceData, meta interf input.PermissionModel = aws.String(v.(string)) } - if v, ok := d.GetOk("tags"); ok { - input.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().CloudformationTags() + if len(tags) > 0 { + input.Tags = tags.IgnoreAws().CloudformationTags() } if v, ok := d.GetOk("template_url"); ok { diff --git a/aws/resource_aws_cloudfront_distribution.go b/aws/resource_aws_cloudfront_distribution.go index 00c1d947908..afa102e17a8 100644 --- a/aws/resource_aws_cloudfront_distribution.go +++ b/aws/resource_aws_cloudfront_distribution.go @@ -684,18 +684,23 @@ func resourceAwsCloudFrontDistribution() *schema.Resource { Default: false, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCloudFrontDistributionCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudfrontconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) params := &cloudfront.CreateDistributionWithTagsInput{ DistributionConfigWithTags: &cloudfront.DistributionConfigWithTags{ DistributionConfig: expandDistributionConfig(d), - Tags: &cloudfront.Tags{Items: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CloudfrontTags()}, + Tags: &cloudfront.Tags{Items: tags.IgnoreAws().CloudfrontTags()}, }, } @@ -741,6 +746,7 @@ func resourceAwsCloudFrontDistributionCreate(d *schema.ResourceData, meta interf func resourceAwsCloudFrontDistributionRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudfrontconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &cloudfront.GetDistributionInput{ @@ -779,8 +785,15 @@ func resourceAwsCloudFrontDistributionRead(d *schema.ResourceData, meta interfac if err != nil { return fmt.Errorf("error listing tags for CloudFront Distribution (%s): %s", d.Id(), 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 @@ -827,8 +840,8 @@ func resourceAwsCloudFrontDistributionUpdate(d *schema.ResourceData, meta interf } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.CloudfrontUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating tags for CloudFront Distribution (%s): %s", d.Id(), err) } diff --git a/aws/resource_aws_cloudhsm_v2_cluster.go b/aws/resource_aws_cloudhsm_v2_cluster.go index 0ea4513eaad..1066fda9684 100644 --- a/aws/resource_aws_cloudhsm_v2_cluster.go +++ b/aws/resource_aws_cloudhsm_v2_cluster.go @@ -101,13 +101,18 @@ func resourceAwsCloudHsmV2Cluster() *schema.Resource { Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCloudHsmV2ClusterCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudhsmv2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) input := &cloudhsmv2.CreateClusterInput{ HsmType: aws.String(d.Get("hsm_type").(string)), @@ -115,7 +120,7 @@ func resourceAwsCloudHsmV2ClusterCreate(d *schema.ResourceData, meta interface{} } if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - input.TagList = keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().Cloudhsmv2Tags() + input.TagList = tags.IgnoreAws().Cloudhsmv2Tags() } if v, ok := d.GetOk("source_backup_identifier"); ok { @@ -149,6 +154,7 @@ func resourceAwsCloudHsmV2ClusterCreate(d *schema.ResourceData, meta interface{} func resourceAwsCloudHsmV2ClusterRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudhsmv2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig cluster, err := finder.Cluster(conn, d.Id()) @@ -197,8 +203,15 @@ func resourceAwsCloudHsmV2ClusterRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error saving Subnet IDs to state for CloudHSMv2 Cluster (%s): %s", d.Id(), err) } - if err := d.Set("tags", keyvaluetags.Cloudhsmv2KeyValueTags(cluster.TagList).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.Cloudhsmv2KeyValueTags(cluster.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) } return nil @@ -207,8 +220,8 @@ func resourceAwsCloudHsmV2ClusterRead(d *schema.ResourceData, meta interface{}) func resourceAwsCloudHsmV2ClusterUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudhsmv2conn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.Cloudhsmv2UpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating tags: %s", err) } diff --git a/aws/resource_aws_cloudtrail.go b/aws/resource_aws_cloudtrail.go index c7ead9cd092..8f9a37b3a35 100644 --- a/aws/resource_aws_cloudtrail.go +++ b/aws/resource_aws_cloudtrail.go @@ -132,7 +132,8 @@ func resourceAwsCloudTrail() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "insight_selector": { Type: schema.TypeList, Optional: true, @@ -147,12 +148,15 @@ func resourceAwsCloudTrail() *schema.Resource { }, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCloudTrailCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudtrailconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CloudtrailTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) input := cloudtrail.CreateTrailInput{ Name: aws.String(d.Get("name").(string)), @@ -160,7 +164,7 @@ func resourceAwsCloudTrailCreate(d *schema.ResourceData, meta interface{}) error } if len(tags) > 0 { - input.TagsList = tags + input.TagsList = tags.IgnoreAws().CloudtrailTags() } if v, ok := d.GetOk("cloud_watch_logs_group_arn"); ok { @@ -243,6 +247,7 @@ func resourceAwsCloudTrailCreate(d *schema.ResourceData, meta interface{}) error func resourceAwsCloudTrailRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudtrailconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := cloudtrail.DescribeTrailsInput{ @@ -297,8 +302,15 @@ func resourceAwsCloudTrailRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error listing tags for Cloudtrail (%s): %s", *trail.TrailARN, 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) } logstatus, err := cloudTrailGetLoggingStatus(conn, trail.Name) @@ -398,8 +410,8 @@ func resourceAwsCloudTrailUpdate(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error updating CloudTrail: %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.CloudtrailUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating ECR Repository (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_cloudwatch_composite_alarm.go b/aws/resource_aws_cloudwatch_composite_alarm.go index 46ac4c36a43..470eb57737e 100644 --- a/aws/resource_aws_cloudwatch_composite_alarm.go +++ b/aws/resource_aws_cloudwatch_composite_alarm.go @@ -2,6 +2,7 @@ package aws import ( "context" + "fmt" "log" "github.com/aws/aws-sdk-go/aws" @@ -82,8 +83,11 @@ func resourceAwsCloudWatchCompositeAlarm() *schema.Resource { ValidateFunc: validateArn, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } @@ -105,6 +109,7 @@ func resourceAwsCloudWatchCompositeAlarmCreate(ctx context.Context, d *schema.Re func resourceAwsCloudWatchCompositeAlarmRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*AWSClient).cloudwatchconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig name := d.Id() @@ -153,8 +158,15 @@ func resourceAwsCloudWatchCompositeAlarmRead(ctx context.Context, d *schema.Reso return diag.Errorf("error listing tags of alarm: %s", err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return diag.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 diag.FromErr(fmt.Errorf("error setting tags: %w", err)) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return diag.FromErr(fmt.Errorf("error setting tags_all: %w", err)) } return nil @@ -172,8 +184,8 @@ func resourceAwsCloudWatchCompositeAlarmUpdate(ctx context.Context, d *schema.Re } arn := d.Get("arn").(string) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.CloudwatchUpdateTags(conn, arn, o, n); err != nil { return diag.Errorf("error updating tags: %s", err) @@ -203,6 +215,9 @@ func resourceAwsCloudWatchCompositeAlarmDelete(ctx context.Context, d *schema.Re } func expandAwsCloudWatchPutCompositeAlarmInput(d *schema.ResourceData) cloudwatch.PutCompositeAlarmInput { + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) + out := cloudwatch.PutCompositeAlarmInput{ ActionsEnabled: aws.Bool(d.Get("actions_enabled").(bool)), } @@ -231,8 +246,8 @@ func expandAwsCloudWatchPutCompositeAlarmInput(d *schema.ResourceData) cloudwatc out.OKActions = expandStringSet(v.(*schema.Set)) } - if v, ok := d.GetOk("tags"); ok { - out.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().CloudwatchTags() + if len(tags) > 0 { + out.Tags = tags.IgnoreAws().CloudwatchTags() } return out diff --git a/aws/resource_aws_cloudwatch_event_bus.go b/aws/resource_aws_cloudwatch_event_bus.go index d4622141a30..ec6dce96eb8 100644 --- a/aws/resource_aws_cloudwatch_event_bus.go +++ b/aws/resource_aws_cloudwatch_event_bus.go @@ -31,21 +31,26 @@ func resourceAwsCloudWatchEventBus() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCloudWatchEventBusCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudwatcheventsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) eventBusName := d.Get("name").(string) input := &events.CreateEventBusInput{ Name: aws.String(eventBusName), } - if v, ok := d.GetOk("tags"); ok { - input.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().CloudwatcheventsTags() + if len(tags) > 0 { + input.Tags = tags.IgnoreAws().CloudwatcheventsTags() } log.Printf("[DEBUG] Creating CloudWatch Events event bus: %v", input) @@ -64,6 +69,7 @@ func resourceAwsCloudWatchEventBusCreate(d *schema.ResourceData, meta interface{ func resourceAwsCloudWatchEventBusRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudwatcheventsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := &events.DescribeEventBusInput{ @@ -90,10 +96,17 @@ func resourceAwsCloudWatchEventBusRead(d *schema.ResourceData, meta interface{}) if err != nil { return fmt.Errorf("error listing tags for CloudWatch Events event bus (%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 } @@ -101,8 +114,8 @@ func resourceAwsCloudWatchEventBusUpdate(d *schema.ResourceData, meta interface{ conn := meta.(*AWSClient).cloudwatcheventsconn arn := d.Get("arn").(string) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.CloudwatcheventsUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating CloudwWatch Events event bus (%s) tags: %w", arn, err) diff --git a/aws/resource_aws_cloudwatch_event_rule.go b/aws/resource_aws_cloudwatch_event_rule.go index b4483e4cdcb..771697ee9ee 100644 --- a/aws/resource_aws_cloudwatch_event_rule.go +++ b/aws/resource_aws_cloudwatch_event_rule.go @@ -92,13 +92,18 @@ func resourceAwsCloudWatchEventRule() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCloudWatchEventRuleCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudwatcheventsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) name := naming.Generate(d.Get("name").(string), d.Get("name_prefix").(string)) @@ -107,8 +112,8 @@ func resourceAwsCloudWatchEventRuleCreate(d *schema.ResourceData, meta interface return fmt.Errorf("Creating CloudWatch Events Rule failed: %w", err) } - if v, ok := d.GetOk("tags"); ok { - input.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().CloudwatcheventsTags() + if len(tags) > 0 { + input.Tags = tags.IgnoreAws().CloudwatcheventsTags() } log.Printf("[DEBUG] Creating CloudWatch Events Rule: %s", input) @@ -147,6 +152,7 @@ func resourceAwsCloudWatchEventRuleCreate(d *schema.ResourceData, meta interface func resourceAwsCloudWatchEventRuleRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudwatcheventsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig out, err := finder.RuleByID(conn, d.Id()) @@ -189,10 +195,17 @@ func resourceAwsCloudWatchEventRuleRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("error listing tags for CloudWatch Events 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) + } + return nil } @@ -230,8 +243,8 @@ func resourceAwsCloudWatchEventRuleUpdate(d *schema.ResourceData, meta interface } arn := d.Get("arn").(string) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.CloudwatcheventsUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating CloudwWatch Event Rule (%s) tags: %w", arn, err) diff --git a/aws/resource_aws_cloudwatch_log_group.go b/aws/resource_aws_cloudwatch_log_group.go index 83794d87e22..366195a0321 100644 --- a/aws/resource_aws_cloudwatch_log_group.go +++ b/aws/resource_aws_cloudwatch_log_group.go @@ -57,14 +57,18 @@ func resourceAwsCloudWatchLogGroup() *schema.Resource { Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCloudWatchLogGroupCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudwatchlogsconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CloudwatchlogsTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) var logGroupName string if v, ok := d.GetOk("name"); ok { @@ -86,7 +90,7 @@ func resourceAwsCloudWatchLogGroupCreate(d *schema.ResourceData, meta interface{ } if len(tags) > 0 { - params.Tags = tags + params.Tags = tags.IgnoreAws().CloudwatchlogsTags() } _, err := conn.CreateLogGroup(params) @@ -119,6 +123,7 @@ func resourceAwsCloudWatchLogGroupCreate(d *schema.ResourceData, meta interface{ func resourceAwsCloudWatchLogGroupRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudwatchlogsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig log.Printf("[DEBUG] Reading CloudWatch Log Group: %q", d.Get("name").(string)) @@ -144,8 +149,15 @@ func resourceAwsCloudWatchLogGroupRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error listing tags for CloudWatch Logs Group (%s): %s", d.Id(), 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 @@ -200,8 +212,8 @@ func resourceAwsCloudWatchLogGroupUpdate(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.CloudwatchlogsUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating CloudWatch Log Group (%s) tags: %s", d.Id(), err) diff --git a/aws/resource_aws_cloudwatch_metric_alarm.go b/aws/resource_aws_cloudwatch_metric_alarm.go index 001bf7600ad..644046bf657 100644 --- a/aws/resource_aws_cloudwatch_metric_alarm.go +++ b/aws/resource_aws_cloudwatch_metric_alarm.go @@ -237,8 +237,11 @@ func resourceAwsCloudWatchMetricAlarm() *schema.Resource { ValidateFunc: validation.StringInSlice([]string{"evaluate", "ignore"}, true), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } @@ -289,6 +292,7 @@ func resourceAwsCloudWatchMetricAlarmCreate(d *schema.ResourceData, meta interfa func resourceAwsCloudWatchMetricAlarmRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudwatchconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig resp, err := getAwsCloudWatchMetricAlarm(d, meta) @@ -369,8 +373,15 @@ func resourceAwsCloudWatchMetricAlarmRead(d *schema.ResourceData, meta interface return fmt.Errorf("error listing tags for CloudWatch Metric Alarm (%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 @@ -388,8 +399,8 @@ func resourceAwsCloudWatchMetricAlarmUpdate(d *schema.ResourceData, meta interfa log.Println("[INFO] CloudWatch Metric Alarm updated") arn := d.Get("arn").(string) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.CloudwatchUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating CloudWatch Metric Alarm (%s) tags: %s", arn, err) diff --git a/aws/resource_aws_codeartifact_domain.go b/aws/resource_aws_codeartifact_domain.go index 7d789b0dbbd..9c3e5b02750 100644 --- a/aws/resource_aws_codeartifact_domain.go +++ b/aws/resource_aws_codeartifact_domain.go @@ -56,18 +56,23 @@ func resourceAwsCodeArtifactDomain() *schema.Resource { Type: schema.TypeInt, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCodeArtifactDomainCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codeartifactconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) log.Print("[DEBUG] Creating CodeArtifact Domain") params := &codeartifact.CreateDomainInput{ Domain: aws.String(d.Get("domain").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CodeartifactTags(), + Tags: tags.IgnoreAws().CodeartifactTags(), } if v, ok := d.GetOk("encryption_key"); ok { @@ -86,6 +91,7 @@ func resourceAwsCodeArtifactDomainCreate(d *schema.ResourceData, meta interface{ func resourceAwsCodeArtifactDomainRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codeartifactconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig log.Printf("[DEBUG] Reading CodeArtifact Domain: %s", d.Id()) @@ -123,18 +129,25 @@ func resourceAwsCodeArtifactDomainRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error listing tags for CodeArtifact Domain (%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) + } + return nil } func resourceAwsCodeArtifactDomainUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codeartifactconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.CodeartifactUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating CodeArtifact Domain (%s) tags: %w", d.Id(), err) } diff --git a/aws/resource_aws_codeartifact_repository.go b/aws/resource_aws_codeartifact_repository.go index fa812f88697..ee92dbb90c3 100644 --- a/aws/resource_aws_codeartifact_repository.go +++ b/aws/resource_aws_codeartifact_repository.go @@ -86,19 +86,24 @@ func resourceAwsCodeArtifactRepository() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCodeArtifactRepositoryCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codeartifactconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) log.Print("[DEBUG] Creating CodeArtifact Repository") params := &codeartifact.CreateRepositoryInput{ Repository: aws.String(d.Get("repository").(string)), Domain: aws.String(d.Get("domain").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CodeartifactTags(), + Tags: tags.IgnoreAws().CodeartifactTags(), } if v, ok := d.GetOk("description"); ok { @@ -202,8 +207,8 @@ func resourceAwsCodeArtifactRepositoryUpdate(d *schema.ResourceData, meta interf } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.CodeartifactUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating CodeArtifact Repository (%s) tags: %w", d.Id(), err) } @@ -214,6 +219,7 @@ func resourceAwsCodeArtifactRepositoryUpdate(d *schema.ResourceData, meta interf func resourceAwsCodeArtifactRepositoryRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codeartifactconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig log.Printf("[DEBUG] Reading CodeArtifact Repository: %s", d.Id()) @@ -262,10 +268,17 @@ func resourceAwsCodeArtifactRepositoryRead(d *schema.ResourceData, meta interfac return fmt.Errorf("error listing tags for CodeArtifact Repository (%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) + } + return nil } diff --git a/aws/resource_aws_codebuild_project.go b/aws/resource_aws_codebuild_project.go index ea7bdb8d66c..71cf794a9dc 100644 --- a/aws/resource_aws_codebuild_project.go +++ b/aws/resource_aws_codebuild_project.go @@ -582,7 +582,8 @@ func resourceAwsCodeBuildProject() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "vpc_config": { Type: schema.TypeList, Optional: true, @@ -624,12 +625,15 @@ func resourceAwsCodeBuildProject() *schema.Resource { } return fmt.Errorf(`cache location is required when cache type is %q`, cacheType.(string)) }, + SetTagsDiff, ), } } func resourceAwsCodeBuildProjectCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codebuildconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) projectEnv := expandProjectEnvironment(d) projectSource := expandProjectSource(d) @@ -656,7 +660,7 @@ func resourceAwsCodeBuildProjectCreate(d *schema.ResourceData, meta interface{}) SecondaryArtifacts: projectSecondaryArtifacts, SecondarySources: projectSecondarySources, LogsConfig: projectLogsConfig, - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CodebuildTags(), + Tags: tags.IgnoreAws().CodebuildTags(), } if v, ok := d.GetOk("cache"); ok { @@ -1073,6 +1077,7 @@ func expandProjectSourceData(data map[string]interface{}) codebuild.ProjectSourc func resourceAwsCodeBuildProjectRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codebuildconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig resp, err := conn.BatchGetProjects(&codebuild.BatchGetProjectsInput{ @@ -1142,8 +1147,15 @@ func resourceAwsCodeBuildProjectRead(d *schema.ResourceData, meta interface{}) e d.Set("badge_url", "") } - if err := d.Set("tags", keyvaluetags.CodebuildKeyValueTags(project.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.CodebuildKeyValueTags(project.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 @@ -1151,6 +1163,8 @@ func resourceAwsCodeBuildProjectRead(d *schema.ResourceData, meta interface{}) e func resourceAwsCodeBuildProjectUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codebuildconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) params := &codebuild.UpdateProjectInput{ Name: aws.String(d.Get("name").(string)), @@ -1230,7 +1244,7 @@ func resourceAwsCodeBuildProjectUpdate(d *schema.ResourceData, meta interface{}) // The documentation clearly says "The replacement set of tags for this build project." // But its a slice of pointers so if not set for every update, they get removed. - params.Tags = keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CodebuildTags() + params.Tags = tags.IgnoreAws().CodebuildTags() // Handle IAM eventual consistency err := resource.Retry(iamwaiter.PropagationTimeout, func() *resource.RetryError { diff --git a/aws/resource_aws_codebuild_report_group.go b/aws/resource_aws_codebuild_report_group.go index 7007196927b..7cbc67bcd27 100644 --- a/aws/resource_aws_codebuild_report_group.go +++ b/aws/resource_aws_codebuild_report_group.go @@ -97,18 +97,23 @@ func resourceAwsCodeBuildReportGroup() *schema.Resource { Optional: true, Default: false, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCodeBuildReportGroupCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codebuildconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) createOpts := &codebuild.CreateReportGroupInput{ Name: aws.String(d.Get("name").(string)), Type: aws.String(d.Get("type").(string)), ExportConfig: expandAwsCodeBuildReportGroupExportConfig(d.Get("export_config").([]interface{})), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CodebuildTags(), + Tags: tags.IgnoreAws().CodebuildTags(), } resp, err := conn.CreateReportGroup(createOpts) @@ -123,6 +128,7 @@ func resourceAwsCodeBuildReportGroupCreate(d *schema.ResourceData, meta interfac func resourceAwsCodeBuildReportGroupRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codebuildconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig reportGroup, err := finder.ReportGroupByArn(conn, d.Id()) @@ -148,15 +154,24 @@ func resourceAwsCodeBuildReportGroupRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("error setting export config: %w", err) } - if err := d.Set("tags", keyvaluetags.CodebuildKeyValueTags(reportGroup.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + tags := keyvaluetags.CodebuildKeyValueTags(reportGroup.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 } func resourceAwsCodeBuildReportGroupUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codebuildconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) input := &codebuild.UpdateReportGroupInput{ Arn: aws.String(d.Id()), @@ -166,8 +181,8 @@ func resourceAwsCodeBuildReportGroupUpdate(d *schema.ResourceData, meta interfac input.ExportConfig = expandAwsCodeBuildReportGroupExportConfig(d.Get("export_config").([]interface{})) } - if d.HasChange("tags") { - input.Tags = keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CodebuildTags() + if d.HasChange("tags_all") { + input.Tags = tags.IgnoreAws().CodebuildTags() } _, err := conn.UpdateReportGroup(input) diff --git a/aws/resource_aws_codecommit_repository.go b/aws/resource_aws_codecommit_repository.go index fc04838ed78..c8e894087ba 100644 --- a/aws/resource_aws_codecommit_repository.go +++ b/aws/resource_aws_codecommit_repository.go @@ -59,18 +59,23 @@ func resourceAwsCodeCommitRepository() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCodeCommitRepositoryCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codecommitconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) input := &codecommit.CreateRepositoryInput{ RepositoryName: aws.String(d.Get("repository_name").(string)), RepositoryDescription: aws.String(d.Get("description").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CodecommitTags(), + Tags: tags.IgnoreAws().CodecommitTags(), } out, err := conn.CreateRepository(input) @@ -108,8 +113,8 @@ func resourceAwsCodeCommitRepositoryUpdate(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.CodecommitUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating CodeCommit Repository (%s) tags: %s", d.Get("arn").(string), err) @@ -121,6 +126,7 @@ func resourceAwsCodeCommitRepositoryUpdate(d *schema.ResourceData, meta interfac func resourceAwsCodeCommitRepositoryRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codecommitconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := &codecommit.GetRepositoryInput{ @@ -157,8 +163,15 @@ func resourceAwsCodeCommitRepositoryRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("error listing tags for CodeCommit Repository (%s): %s", d.Get("arn").(string), 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 diff --git a/aws/resource_aws_codepipeline.go b/aws/resource_aws_codepipeline.go index 00101ff30fd..c704bc9318e 100644 --- a/aws/resource_aws_codepipeline.go +++ b/aws/resource_aws_codepipeline.go @@ -169,13 +169,18 @@ func resourceAwsCodePipeline() *schema.Resource { }, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCodePipelineCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codepipelineconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) pipeline, err := expandAwsCodePipeline(d) if err != nil { @@ -183,7 +188,7 @@ func resourceAwsCodePipelineCreate(d *schema.ResourceData, meta interface{}) err } params := &codepipeline.CreatePipelineInput{ Pipeline: pipeline, - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CodepipelineTags(), + Tags: tags.IgnoreAws().CodepipelineTags(), } var resp *codepipeline.CreatePipelineOutput @@ -493,6 +498,7 @@ func flattenAwsCodePipelineActionsInputArtifacts(artifacts []*codepipeline.Input func resourceAwsCodePipelineRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codepipelineconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig resp, err := conn.GetPipeline(&codepipeline.GetPipelineInput{ @@ -537,8 +543,15 @@ func resourceAwsCodePipelineRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("error listing tags for CodePipeline (%s): %w", arn, err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags for CodePipeline (%s): %w", arn, 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 @@ -561,8 +574,8 @@ func resourceAwsCodePipelineUpdate(d *schema.ResourceData, meta interface{}) err } arn := d.Get("arn").(string) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.CodepipelineUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating CodePipeline (%s) tags: %w", arn, err) diff --git a/aws/resource_aws_codepipeline_webhook.go b/aws/resource_aws_codepipeline_webhook.go index 33882ec0ad0..17aa6191ef5 100644 --- a/aws/resource_aws_codepipeline_webhook.go +++ b/aws/resource_aws_codepipeline_webhook.go @@ -96,8 +96,11 @@ func resourceAwsCodePipelineWebhook() *schema.Resource { ForceNew: true, Required: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } @@ -131,6 +134,8 @@ func extractCodePipelineWebhookAuthConfig(authType string, authConfig map[string func resourceAwsCodePipelineWebhookCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codepipelineconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) authType := d.Get("authentication").(string) var authConfig map[string]interface{} @@ -148,7 +153,7 @@ func resourceAwsCodePipelineWebhookCreate(d *schema.ResourceData, meta interface TargetPipeline: aws.String(d.Get("target_pipeline").(string)), AuthenticationConfiguration: extractCodePipelineWebhookAuthConfig(authType, authConfig), }, - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CodepipelineTags(), + Tags: tags.IgnoreAws().CodepipelineTags(), } webhook, err := conn.PutWebhook(request) @@ -228,6 +233,7 @@ func flattenCodePipelineWebhookAuthenticationConfiguration(authConfig *codepipel func resourceAwsCodePipelineWebhookRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codepipelineconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig arn := d.Id() @@ -271,8 +277,15 @@ func resourceAwsCodePipelineWebhookRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("error setting filter: %s", err) } - if err := d.Set("tags", keyvaluetags.CodepipelineKeyValueTags(webhook.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.CodepipelineKeyValueTags(webhook.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 @@ -281,8 +294,8 @@ func resourceAwsCodePipelineWebhookRead(d *schema.ResourceData, meta interface{} func resourceAwsCodePipelineWebhookUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codepipelineconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.CodepipelineUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating CodePipeline Webhook (%s) tags: %s", d.Id(), err) diff --git a/aws/resource_aws_codestarconnections_connection.go b/aws/resource_aws_codestarconnections_connection.go index 1d58920cc97..871414b2307 100644 --- a/aws/resource_aws_codestarconnections_connection.go +++ b/aws/resource_aws_codestarconnections_connection.go @@ -47,21 +47,26 @@ func resourceAwsCodeStarConnectionsConnection() *schema.Resource { ValidateFunc: validation.StringInSlice(codestarconnections.ProviderType_Values(), false), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCodeStarConnectionsConnectionCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codestarconnectionsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) params := &codestarconnections.CreateConnectionInput{ ConnectionName: aws.String(d.Get("name").(string)), ProviderType: aws.String(d.Get("provider_type").(string)), } - if v, ok := d.GetOk("tags"); ok && len(v.(map[string]interface{})) > 0 { - params.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().CodestarconnectionsTags() + if len(tags) > 0 { + params.Tags = tags.IgnoreAws().CodestarconnectionsTags() } resp, err := conn.CreateConnection(params) @@ -76,6 +81,7 @@ func resourceAwsCodeStarConnectionsConnectionCreate(d *schema.ResourceData, meta func resourceAwsCodeStarConnectionsConnectionRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codestarconnectionsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig connection, err := finder.ConnectionByArn(conn, d.Id()) @@ -105,8 +111,15 @@ func resourceAwsCodeStarConnectionsConnectionRead(d *schema.ResourceData, meta i return fmt.Errorf("error listing tags for CodeStar Connection (%s): %w", arn, err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags for CodeStar Connection (%s): %w", arn, 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 @@ -115,8 +128,8 @@ func resourceAwsCodeStarConnectionsConnectionRead(d *schema.ResourceData, meta i func resourceAwsCodeStarConnectionsConnectionUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codestarconnectionsconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.CodestarconnectionsUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error Codestar Connection (%s) tags: %w", d.Id(), err) diff --git a/aws/resource_aws_codestarnotifications_notification_rule.go b/aws/resource_aws_codestarnotifications_notification_rule.go index dd8134b639e..bb7bdd9a6e4 100644 --- a/aws/resource_aws_codestarnotifications_notification_rule.go +++ b/aws/resource_aws_codestarnotifications_notification_rule.go @@ -79,7 +79,8 @@ func resourceAwsCodeStarNotificationsNotificationRule() *schema.Resource { }, false), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "target": { Type: schema.TypeSet, @@ -105,6 +106,8 @@ func resourceAwsCodeStarNotificationsNotificationRule() *schema.Resource { }, }, }, + + CustomizeDiff: SetTagsDiff, } } @@ -122,6 +125,8 @@ func expandCodeStarNotificationsNotificationRuleTargets(targetsData []interface{ func resourceAwsCodeStarNotificationsNotificationRuleCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codestarnotificationsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) params := &codestarnotifications.CreateNotificationRuleInput{ DetailType: aws.String(d.Get("detail_type").(string)), @@ -132,8 +137,8 @@ func resourceAwsCodeStarNotificationsNotificationRuleCreate(d *schema.ResourceDa Targets: expandCodeStarNotificationsNotificationRuleTargets(d.Get("target").(*schema.Set).List()), } - if v, ok := d.GetOk("tags"); ok { - params.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().CodestarnotificationsTags() + if len(tags) > 0 { + params.Tags = tags.IgnoreAws().CodestarnotificationsTags() } res, err := conn.CreateNotificationRule(params) @@ -148,6 +153,7 @@ func resourceAwsCodeStarNotificationsNotificationRuleCreate(d *schema.ResourceDa func resourceAwsCodeStarNotificationsNotificationRuleRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).codestarnotificationsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig rule, err := conn.DescribeNotificationRule(&codestarnotifications.DescribeNotificationRuleInput{ @@ -175,7 +181,16 @@ func resourceAwsCodeStarNotificationsNotificationRuleRead(d *schema.ResourceData d.Set("name", rule.Name) d.Set("status", rule.Status) d.Set("resource", rule.Resource) - d.Set("tags", keyvaluetags.New(rule.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()) + tags := keyvaluetags.New(rule.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) + } targets := make([]map[string]interface{}, 0, len(rule.Targets)) for _, t := range rule.Targets { @@ -262,8 +277,8 @@ func resourceAwsCodeStarNotificationsNotificationRuleUpdate(d *schema.ResourceDa return fmt.Errorf("error updating codestar notification rule: %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.CodestarnotificationsUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating codestar notification rule tags: %s", err) } diff --git a/aws/resource_aws_cognito_identity_pool.go b/aws/resource_aws_cognito_identity_pool.go index 6fcd3763eb6..d8f5a40a430 100644 --- a/aws/resource_aws_cognito_identity_pool.go +++ b/aws/resource_aws_cognito_identity_pool.go @@ -99,13 +99,18 @@ func resourceAwsCognitoIdentityPool() *schema.Resource { }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCognitoIdentityPoolCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cognitoconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) log.Print("[DEBUG] Creating Cognito Identity Pool") params := &cognitoidentity.CreateIdentityPoolInput{ @@ -133,8 +138,8 @@ func resourceAwsCognitoIdentityPoolCreate(d *schema.ResourceData, meta interface params.OpenIdConnectProviderARNs = expandStringSet(v.(*schema.Set)) } - if v, ok := d.GetOk("tags"); ok { - params.IdentityPoolTags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().CognitoidentityTags() + if len(tags) > 0 { + params.IdentityPoolTags = tags.IgnoreAws().CognitoidentityTags() } entity, err := conn.CreateIdentityPool(params) @@ -149,6 +154,7 @@ func resourceAwsCognitoIdentityPoolCreate(d *schema.ResourceData, meta interface func resourceAwsCognitoIdentityPoolRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cognitoconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig log.Printf("[DEBUG] Reading Cognito Identity Pool: %s", d.Id()) @@ -175,8 +181,15 @@ func resourceAwsCognitoIdentityPoolRead(d *schema.ResourceData, meta interface{} d.Set("identity_pool_name", ip.IdentityPoolName) d.Set("allow_unauthenticated_identities", ip.AllowUnauthenticatedIdentities) d.Set("developer_provider_name", ip.DeveloperProviderName) - if err := d.Set("tags", keyvaluetags.CognitoidentityKeyValueTags(ip.IdentityPoolTags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.CognitoidentityKeyValueTags(ip.IdentityPoolTags).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("cognito_identity_providers", flattenCognitoIdentityProviders(ip.CognitoIdentityProviders)); err != nil { @@ -236,8 +249,8 @@ func resourceAwsCognitoIdentityPoolUpdate(d *schema.ResourceData, meta interface } arn := d.Get("arn").(string) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.CognitoidentityUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating Cognito Identity Pool (%s) tags: %s", arn, err) diff --git a/aws/resource_aws_cognito_user_pool.go b/aws/resource_aws_cognito_user_pool.go index 36e394735e1..4c42300163d 100644 --- a/aws/resource_aws_cognito_user_pool.go +++ b/aws/resource_aws_cognito_user_pool.go @@ -414,7 +414,8 @@ func resourceAwsCognitoUserPool() *schema.Resource { }, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "username_attributes": { Type: schema.TypeList, Optional: true, @@ -503,11 +504,15 @@ func resourceAwsCognitoUserPool() *schema.Resource { }, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCognitoUserPoolCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cognitoidpconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) params := &cognitoidentityprovider.CreateUserPoolInput{ PoolName: aws.String(d.Get("name").(string)), @@ -673,8 +678,8 @@ func resourceAwsCognitoUserPoolCreate(d *schema.ResourceData, meta interface{}) params.SmsVerificationMessage = aws.String(v.(string)) } - if v, ok := d.GetOk("tags"); ok { - params.UserPoolTags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().CognitoidentityproviderTags() + if len(tags) > 0 { + params.UserPoolTags = tags.IgnoreAws().CognitoidentityproviderTags() } log.Printf("[DEBUG] Creating Cognito User Pool: %s", params) @@ -756,6 +761,7 @@ func resourceAwsCognitoUserPoolCreate(d *schema.ResourceData, meta interface{}) func resourceAwsCognitoUserPoolRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cognitoidpconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &cognitoidentityprovider.DescribeUserPoolInput{ @@ -852,10 +858,17 @@ func resourceAwsCognitoUserPoolRead(d *schema.ResourceData, meta interface{}) er d.Set("creation_date", resp.UserPool.CreationDate.Format(time.RFC3339)) d.Set("last_modified_date", resp.UserPool.LastModifiedDate.Format(time.RFC3339)) d.Set("name", resp.UserPool.Name) - if err := d.Set("tags", keyvaluetags.CognitoidentityKeyValueTags(resp.UserPool.UserPoolTags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + tags := keyvaluetags.CognitoidentityKeyValueTags(resp.UserPool.UserPoolTags).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) + } + input := &cognitoidentityprovider.GetUserPoolMfaConfigInput{ UserPoolId: aws.String(d.Id()), } diff --git a/aws/resource_aws_config_aggregate_authorization.go b/aws/resource_aws_config_aggregate_authorization.go index ac70ad3a7a3..a0f98c82718 100644 --- a/aws/resource_aws_config_aggregate_authorization.go +++ b/aws/resource_aws_config_aggregate_authorization.go @@ -38,8 +38,11 @@ func resourceAwsConfigAggregateAuthorization() *schema.Resource { Required: true, ForceNew: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } @@ -67,6 +70,7 @@ func resourceAwsConfigAggregateAuthorizationPut(d *schema.ResourceData, meta int func resourceAwsConfigAggregateAuthorizationRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).configconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig accountId, region, err := resourceAwsConfigAggregateAuthorizationParseID(d.Id()) @@ -104,8 +108,15 @@ func resourceAwsConfigAggregateAuthorizationRead(d *schema.ResourceData, meta in return fmt.Errorf("error listing tags for Config Aggregate Authorization (%s): %s", d.Get("arn").(string), 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 @@ -114,8 +125,8 @@ func resourceAwsConfigAggregateAuthorizationRead(d *schema.ResourceData, meta in func resourceAwsConfigAggregateAuthorizationUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).configconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.ConfigserviceUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating Config Aggregate Authorization (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_config_config_rule.go b/aws/resource_aws_config_config_rule.go index 603dcc3ce34..874151edefa 100644 --- a/aws/resource_aws_config_config_rule.go +++ b/aws/resource_aws_config_config_rule.go @@ -137,13 +137,18 @@ func resourceAwsConfigConfigRule() *schema.Resource { }, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsConfigConfigRulePut(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).configconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) name := d.Get("name").(string) ruleInput := configservice.ConfigRule{ @@ -164,7 +169,7 @@ func resourceAwsConfigConfigRulePut(d *schema.ResourceData, meta interface{}) er input := configservice.PutConfigRuleInput{ ConfigRule: &ruleInput, - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().ConfigserviceTags(), + Tags: tags.IgnoreAws().ConfigserviceTags(), } log.Printf("[DEBUG] Creating AWSConfig config rule: %s", input) err := resource.Retry(iamwaiter.PropagationTimeout, func() *resource.RetryError { @@ -193,8 +198,8 @@ func resourceAwsConfigConfigRulePut(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] AWSConfig config rule %q created", name) - if !d.IsNewResource() && d.HasChange("tags") { - o, n := d.GetChange("tags") + if !d.IsNewResource() && d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.ConfigserviceUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating Config Config Rule (%s) tags: %s", d.Get("arn").(string), err) @@ -206,6 +211,7 @@ func resourceAwsConfigConfigRulePut(d *schema.ResourceData, meta interface{}) er func resourceAwsConfigConfigRuleRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).configconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig out, err := conn.DescribeConfigRules(&configservice.DescribeConfigRulesInput{ @@ -254,8 +260,15 @@ func resourceAwsConfigConfigRuleRead(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("error listing tags for Config Config Rule (%s): %s", d.Get("arn").(string), 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 diff --git a/aws/resource_aws_config_configuration_aggregator.go b/aws/resource_aws_config_configuration_aggregator.go index 4561acec6fe..30f9a7548c1 100644 --- a/aws/resource_aws_config_configuration_aggregator.go +++ b/aws/resource_aws_config_configuration_aggregator.go @@ -33,6 +33,7 @@ func resourceAwsConfigConfigurationAggregator() *schema.Resource { customdiff.ForceNewIfChange("organization_aggregation_source", func(_ context.Context, old, new, meta interface{}) bool { return len(old.([]interface{})) == 0 && len(new.([]interface{})) > 0 }), + SetTagsDiff, ), Schema: map[string]*schema.Schema{ @@ -106,17 +107,20 @@ func resourceAwsConfigConfigurationAggregator() *schema.Resource { }, }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, } } func resourceAwsConfigConfigurationAggregatorPut(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).configconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) req := &configservice.PutConfigurationAggregatorInput{ ConfigurationAggregatorName: aws.String(d.Get("name").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().ConfigserviceTags(), + Tags: tags.IgnoreAws().ConfigserviceTags(), } if v, ok := d.GetOk("account_aggregation_source"); ok && len(v.([]interface{})) > 0 { @@ -135,8 +139,8 @@ func resourceAwsConfigConfigurationAggregatorPut(d *schema.ResourceData, meta in configAgg := resp.ConfigurationAggregator d.SetId(aws.StringValue(configAgg.ConfigurationAggregatorName)) - if !d.IsNewResource() && d.HasChange("tags") { - o, n := d.GetChange("tags") + if !d.IsNewResource() && d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") arn := aws.StringValue(configAgg.ConfigurationAggregatorArn) if err := keyvaluetags.ConfigserviceUpdateTags(conn, arn, o, n); err != nil { @@ -149,6 +153,7 @@ func resourceAwsConfigConfigurationAggregatorPut(d *schema.ResourceData, meta in func resourceAwsConfigConfigurationAggregatorRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).configconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig req := &configservice.DescribeConfigurationAggregatorsInput{ @@ -190,10 +195,17 @@ func resourceAwsConfigConfigurationAggregatorRead(d *schema.ResourceData, meta i return fmt.Errorf("error listing tags for Config Configuration Aggregator (%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) + } + return nil } diff --git a/aws/resource_aws_customer_gateway.go b/aws/resource_aws_customer_gateway.go index 8d437488034..956c8ecb526 100644 --- a/aws/resource_aws_customer_gateway.go +++ b/aws/resource_aws_customer_gateway.go @@ -59,18 +59,23 @@ func resourceAwsCustomerGateway() *schema.Resource { }, false), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "arn": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsCustomerGatewayCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).ec2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) ipAddress := d.Get("ip_address").(string) vpnType := d.Get("type").(string) @@ -95,7 +100,7 @@ func resourceAwsCustomerGatewayCreate(d *schema.ResourceData, meta interface{}) BgpAsn: aws.Int64(i64BgpAsn), PublicIp: aws.String(ipAddress), Type: aws.String(vpnType), - TagSpecifications: ec2TagSpecificationsFromMap(d.Get("tags").(map[string]interface{}), ec2.ResourceTypeCustomerGateway), + TagSpecifications: ec2TagSpecificationsFromKeyValueTags(tags, ec2.ResourceTypeCustomerGateway), } if len(deviceName) != 0 { @@ -203,6 +208,7 @@ func resourceAwsCustomerGatewayExists(vpnType, ipAddress, bgpAsn, deviceName str func resourceAwsCustomerGatewayRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).ec2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig gatewayFilter := &ec2.Filter{ @@ -240,8 +246,15 @@ func resourceAwsCustomerGatewayRead(d *schema.ResourceData, meta interface{}) er d.Set("type", customerGateway.Type) d.Set("device_name", customerGateway.DeviceName) - if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(customerGateway.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.Ec2KeyValueTags(customerGateway.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) } arn := arn.ARN{ @@ -260,8 +273,8 @@ func resourceAwsCustomerGatewayRead(d *schema.ResourceData, meta interface{}) er func resourceAwsCustomerGatewayUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).ec2conn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.Ec2UpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating EC2 Customer Gateway (%s) tags: %s", d.Id(), err) From 920c1cb952d2fb23b6a6dae580e06124e06c8a69 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Fri, 9 Apr 2021 17:52:18 -0400 Subject: [PATCH 2/5] resource/aws_cloudwatch_composite_alarm: Add missing meta --- aws/resource_aws_cloudwatch_composite_alarm.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_cloudwatch_composite_alarm.go b/aws/resource_aws_cloudwatch_composite_alarm.go index 470eb57737e..bff20d6219b 100644 --- a/aws/resource_aws_cloudwatch_composite_alarm.go +++ b/aws/resource_aws_cloudwatch_composite_alarm.go @@ -95,7 +95,7 @@ func resourceAwsCloudWatchCompositeAlarmCreate(ctx context.Context, d *schema.Re conn := meta.(*AWSClient).cloudwatchconn name := d.Get("alarm_name").(string) - input := expandAwsCloudWatchPutCompositeAlarmInput(d) + input := expandAwsCloudWatchPutCompositeAlarmInput(d, meta) _, err := conn.PutCompositeAlarmWithContext(ctx, &input) if err != nil { @@ -176,7 +176,7 @@ func resourceAwsCloudWatchCompositeAlarmUpdate(ctx context.Context, d *schema.Re conn := meta.(*AWSClient).cloudwatchconn name := d.Id() - input := expandAwsCloudWatchPutCompositeAlarmInput(d) + input := expandAwsCloudWatchPutCompositeAlarmInput(d, meta) _, err := conn.PutCompositeAlarmWithContext(ctx, &input) if err != nil { @@ -214,7 +214,7 @@ func resourceAwsCloudWatchCompositeAlarmDelete(ctx context.Context, d *schema.Re return nil } -func expandAwsCloudWatchPutCompositeAlarmInput(d *schema.ResourceData) cloudwatch.PutCompositeAlarmInput { +func expandAwsCloudWatchPutCompositeAlarmInput(d *schema.ResourceData, meta interface{}) cloudwatch.PutCompositeAlarmInput { defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) From 4dbcc2e33d8cd77fe874a4ea7a2fcb54816f8fdb Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Mon, 12 Apr 2021 10:09:51 -0400 Subject: [PATCH 3/5] docs/provider: Update tagging documentation (resources aws_c*) --- website/docs/r/cloud9_environment_ec2.html.markdown | 3 ++- website/docs/r/cloudformation_stack.html.markdown | 3 ++- website/docs/r/cloudformation_stack_set.html.markdown | 3 ++- website/docs/r/cloudfront_distribution.html.markdown | 4 +++- website/docs/r/cloudhsm_v2_cluster.html.markdown | 3 ++- website/docs/r/cloudtrail.html.markdown | 4 ++-- website/docs/r/cloudwatch_composite_alarm.html.markdown | 3 ++- website/docs/r/cloudwatch_event_bus.html.markdown | 4 ++-- website/docs/r/cloudwatch_event_rule.html.markdown | 4 ++-- website/docs/r/cloudwatch_log_group.html.markdown | 4 ++-- website/docs/r/cloudwatch_metric_alarm.html.markdown | 3 ++- website/docs/r/codeartifact_domain.html.markdown | 3 ++- website/docs/r/codeartifact_repository.html.markdown | 3 ++- website/docs/r/codebuild_project.html.markdown | 3 ++- website/docs/r/codebuild_report_group.html.markdown | 3 ++- website/docs/r/codecommit_repository.html.markdown | 3 ++- website/docs/r/codepipeline.markdown | 3 ++- website/docs/r/codepipeline_webhook.markdown | 3 ++- website/docs/r/codestarconnections_connection.markdown | 3 ++- .../r/codestarnotifications_notification_rule.markdown | 3 ++- website/docs/r/cognito_identity_pool.markdown | 3 ++- website/docs/r/cognito_user_pool.markdown | 3 ++- website/docs/r/config_aggregate_authorization.markdown | 3 ++- website/docs/r/config_config_rule.html.markdown | 3 ++- .../docs/r/config_configuration_aggregator.html.markdown | 3 ++- website/docs/r/customer_gateway.html.markdown | 9 ++------- 26 files changed, 53 insertions(+), 36 deletions(-) diff --git a/website/docs/r/cloud9_environment_ec2.html.markdown b/website/docs/r/cloud9_environment_ec2.html.markdown index efd7a096b23..9e3be519632 100644 --- a/website/docs/r/cloud9_environment_ec2.html.markdown +++ b/website/docs/r/cloud9_environment_ec2.html.markdown @@ -29,7 +29,7 @@ The following arguments are supported: * `description` - (Optional) The description of the environment. * `owner_arn` - (Optional) The ARN of the environment owner. This can be ARN of any AWS IAM principal. Defaults to the environment's creator. * `subnet_id` - (Optional) The ID of the subnet in Amazon VPC that AWS Cloud9 will use to communicate with the Amazon EC2 instance. -* `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. ## Attributes Reference @@ -37,4 +37,5 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the environment. * `arn` - The ARN of the environment. +* `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). * `type` - The type of the environment (e.g. `ssh` or `ec2`) diff --git a/website/docs/r/cloudformation_stack.html.markdown b/website/docs/r/cloudformation_stack.html.markdown index 1fbaee51000..b7cb23b9399 100644 --- a/website/docs/r/cloudformation_stack.html.markdown +++ b/website/docs/r/cloudformation_stack.html.markdown @@ -64,7 +64,7 @@ The following arguments are supported: Conflicts w/ `policy_url`. * `policy_url` - (Optional) Location of a file containing the stack policy. Conflicts w/ `policy_body`. -* `tags` - (Optional) A list of tags to associate with this stack. +* `tags` - (Optional) Map of resource tags to associate with this stack. 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. * `iam_role_arn` - (Optional) The ARN of an IAM role that AWS CloudFormation assumes to create the stack. If you don't specify a value, AWS CloudFormation uses the role that was previously associated with the stack. If no role is available, AWS CloudFormation uses a temporary session that is generated from your user credentials. * `timeout_in_minutes` - (Optional) The amount of time that can pass before the stack status becomes `CREATE_FAILED`. @@ -74,6 +74,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - A unique identifier of the stack. * `outputs` - A map of outputs from the stack. +* `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/cloudformation_stack_set.html.markdown b/website/docs/r/cloudformation_stack_set.html.markdown index f9c26c7c2ae..4b41a006014 100644 --- a/website/docs/r/cloudformation_stack_set.html.markdown +++ b/website/docs/r/cloudformation_stack_set.html.markdown @@ -95,7 +95,7 @@ The following arguments are supported: * `execution_role_name` - (Optional) Name of the IAM Role in all target accounts for StackSet operations. Defaults to `AWSCloudFormationStackSetExecutionRole` when using the `SELF_MANAGED` permission model. This should not be defined when using the `SERVICE_MANAGED` permission model. * `parameters` - (Optional) Key-value map of input parameters for the StackSet template. All template parameters, including those with a `Default`, must be configured or ignored with `lifecycle` configuration block `ignore_changes` argument. All `NoEcho` template parameters must be ignored with the `lifecycle` configuration block `ignore_changes` argument. * `permission_model` - (Optional) Describes how the IAM roles required for your StackSet are created. Valid values: `SELF_MANAGED` (default), `SERVICE_MANAGED`. -* `tags` - (Optional) Key-value map of tags to associate with this StackSet and the Stacks created from it. AWS CloudFormation also propagates these tags to supported resources that are created in the Stacks. A maximum number of 50 tags can be specified. +* `tags` - (Optional) Key-value map of tags to associate with this StackSet and the Stacks created from it. AWS CloudFormation also propagates these tags to supported resources that are created in the Stacks. A maximum number of 50 tags can be specified. 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. * `template_body` - (Optional) String containing the CloudFormation template body. Maximum size: 51,200 bytes. Conflicts with `template_url`. * `template_url` - (Optional) String containing the location of a file containing the CloudFormation template body. The URL must point to a template that is located in an Amazon S3 bucket. Maximum location file size: 460,800 bytes. Conflicts with `template_body`. @@ -106,6 +106,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - Amazon Resource Name (ARN) of the StackSet. * `id` - Name of the StackSet. * `stack_set_id` - Unique identifier of the StackSet. +* `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). ## Timeouts diff --git a/website/docs/r/cloudfront_distribution.html.markdown b/website/docs/r/cloudfront_distribution.html.markdown index 89294543994..1a61531ad74 100644 --- a/website/docs/r/cloudfront_distribution.html.markdown +++ b/website/docs/r/cloudfront_distribution.html.markdown @@ -241,7 +241,7 @@ of several sub-resources - these resources are laid out below. * `restrictions` (Required) - The [restriction configuration](#restrictions-arguments) for this distribution (maximum one). -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to 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. * `viewer_certificate` (Required) - The [SSL configuration](#viewer-certificate-arguments) for this distribution (maximum @@ -539,6 +539,8 @@ In addition to all arguments above, the following attributes are exported: distribution's information is fully propagated throughout the Amazon CloudFront system. +* `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). + * `trusted_signers` - List of nested attributes for active trusted signers, if the distribution is set up to serve private content with signed URLs * `enabled` - `true` if any of the AWS accounts listed as trusted signers have active CloudFront key pairs * `items` - List of nested attributes for each trusted signer diff --git a/website/docs/r/cloudhsm_v2_cluster.html.markdown b/website/docs/r/cloudhsm_v2_cluster.html.markdown index d7f82b60b94..b75bbec9411 100644 --- a/website/docs/r/cloudhsm_v2_cluster.html.markdown +++ b/website/docs/r/cloudhsm_v2_cluster.html.markdown @@ -67,7 +67,7 @@ The following arguments are supported: * `source_backup_identifier` - (Optional) The id of Cloud HSM v2 cluster backup to be restored. * `hsm_type` - (Required) The type of HSM module in the cluster. Currently, only `hsm1.medium` is supported. * `subnet_ids` - (Required) The IDs of subnets in which cluster will operate. -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to 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 @@ -83,6 +83,7 @@ In addition to all arguments above, the following attributes are exported: * `cluster_certificates.0.aws_hardware_certificate` - The HSM hardware certificate issued (signed) by AWS CloudHSM. * `cluster_certificates.0.hsm_certificate` - The HSM certificate issued (signed) by the HSM hardware. * `cluster_certificates.0.manufacturer_hardware_certificate` - The HSM hardware certificate issued (signed) by the hardware manufacturer. +* `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). [1]: https://docs.aws.amazon.com/cloudhsm/latest/userguide/introduction.html [2]: https://docs.aws.amazon.com/cloudhsm/latest/APIReference/Welcome.html diff --git a/website/docs/r/cloudtrail.html.markdown b/website/docs/r/cloudtrail.html.markdown index 9a631a8a202..a1509ea44cf 100644 --- a/website/docs/r/cloudtrail.html.markdown +++ b/website/docs/r/cloudtrail.html.markdown @@ -173,7 +173,7 @@ The following arguments are supported: * `kms_key_id` - (Optional) Specifies the KMS key ARN to use to encrypt the logs delivered by CloudTrail. * `event_selector` - (Optional) Specifies an event selector for enabling data event logging. Fields documented below. Please note the [CloudTrail limits](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/WhatIsCloudTrail-Limits.html) when configuring these. * `insight_selector` - (Optional) Specifies an insight selector for identifying unusual operational activity. Fields documented below. -* `tags` - (Optional) A map of tags to assign to the trail +* `tags` - (Optional) A map of tags to assign to the trail. 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. ### Event Selector Arguments For **event_selector** the following attributes are supported. @@ -201,7 +201,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The name of the trail. * `home_region` - The region in which the trail was created. * `arn` - The Amazon Resource Name of the trail. - +* `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/cloudwatch_composite_alarm.html.markdown b/website/docs/r/cloudwatch_composite_alarm.html.markdown index 452a19d417c..6056533b68d 100644 --- a/website/docs/r/cloudwatch_composite_alarm.html.markdown +++ b/website/docs/r/cloudwatch_composite_alarm.html.markdown @@ -38,7 +38,7 @@ EOF * `alarm_rule` - (Required) An expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. For syntax, see [Creating a Composite Alarm](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Create_Composite_Alarm.html). The maximum length is 10240 characters. * `insufficient_data_actions` - (Optional) The set of actions to execute when this alarm transitions to the `INSUFFICIENT_DATA` state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed. * `ok_actions` - (Optional) The set of actions to execute when this alarm transitions to an `OK` state from any other state. Each action is specified as an ARN. Up to 5 actions are allowed. -* `tags` - (Optional) A map of tags to associate with the alarm. Up to 50 tags are allowed. +* `tags` - (Optional) A map of tags to associate with the alarm. Up to 50 tags are allowed. 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 @@ -46,6 +46,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the composite alarm. * `id` - The ID of the composite alarm resource, which is equivalent to its `alarm_name`. +* `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/cloudwatch_event_bus.html.markdown b/website/docs/r/cloudwatch_event_bus.html.markdown index 61d5967f532..cff9b15fc7f 100644 --- a/website/docs/r/cloudwatch_event_bus.html.markdown +++ b/website/docs/r/cloudwatch_event_bus.html.markdown @@ -26,14 +26,14 @@ resource "aws_cloudwatch_event_bus" "messenger" { The following arguments are supported: * `name` - (Required) The name of the new event bus. The names of custom event buses can't contain the / character. Please note that a partner event bus is not supported at the moment. -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to 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 In addition to all arguments above, the following attributes are exported: * `arn` - The Amazon Resource Name (ARN) of the event bus. - +* `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/cloudwatch_event_rule.html.markdown b/website/docs/r/cloudwatch_event_rule.html.markdown index 1e1c5f1b4da..31a578ca538 100644 --- a/website/docs/r/cloudwatch_event_rule.html.markdown +++ b/website/docs/r/cloudwatch_event_rule.html.markdown @@ -70,7 +70,7 @@ The following arguments are supported: * `description` - (Optional) The description of the rule. * `role_arn` - (Optional) The Amazon Resource Name (ARN) associated with the role that is used for target invocation. * `is_enabled` - (Optional) Whether the rule should be enabled (defaults to `true`). -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to 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 @@ -78,7 +78,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The name of the rule. * `arn` - The Amazon Resource Name (ARN) of the 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/cloudwatch_log_group.html.markdown b/website/docs/r/cloudwatch_log_group.html.markdown index 2261673aab0..ae2885216ce 100644 --- a/website/docs/r/cloudwatch_log_group.html.markdown +++ b/website/docs/r/cloudwatch_log_group.html.markdown @@ -35,14 +35,14 @@ The following arguments are supported: * `kms_key_id` - (Optional) The ARN of the KMS Key to use when encrypting log data. Please note, after the AWS KMS CMK is disassociated from the log group, AWS CloudWatch Logs stops encrypting newly ingested data for the log group. All previously ingested data remains encrypted, and AWS CloudWatch Logs requires permissions for the CMK whenever the encrypted data is requested. -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to 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 In addition to all arguments above, the following attributes are exported: * `arn` - The Amazon Resource Name (ARN) specifying the log group. Any `:*` suffix added by the API, denoting all CloudWatch Log Streams under the CloudWatch Log Group, is removed for greater compatibility with other AWS services that do not accept the suffix. - +* `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/cloudwatch_metric_alarm.html.markdown b/website/docs/r/cloudwatch_metric_alarm.html.markdown index ee3e2a6d2f7..ab973b818fa 100644 --- a/website/docs/r/cloudwatch_metric_alarm.html.markdown +++ b/website/docs/r/cloudwatch_metric_alarm.html.markdown @@ -205,7 +205,7 @@ If you specify `evaluate` or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported: `ignore`, and `evaluate`. * `metric_query` (Optional) Enables you to create an alarm based on a metric math expression. You may specify at most 20. -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to 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. ~> **NOTE:** If you specify at least one `metric_query`, you may not specify a `metric_name`, `namespace`, `period` or `statistic`. If you do not specify a `metric_query`, you must specify each of these (although you may use `extended_statistic` instead of `statistic`). @@ -240,6 +240,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the CloudWatch Metric Alarm. * `id` - The ID of the health check. +* `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/codeartifact_domain.html.markdown b/website/docs/r/codeartifact_domain.html.markdown index 63eff6f334f..b486ac0b085 100644 --- a/website/docs/r/codeartifact_domain.html.markdown +++ b/website/docs/r/codeartifact_domain.html.markdown @@ -24,7 +24,7 @@ The following arguments are supported: * `domain` - (Required) The name of the domain to create. All domain names in an AWS Region that are in the same AWS account must be unique. The domain name is used as the prefix in DNS hostnames. Do not use sensitive information in a domain name because it is publicly discoverable. * `encryption_key` - (Optional) The encryption key for the domain. This is used to encrypt content stored in a domain. The KMS Key Amazon Resource Name (ARN). The default aws/codeartifact AWS KMS master key is used if this element is absent. -* `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. ## Attributes Reference @@ -36,6 +36,7 @@ In addition to all arguments above, the following attributes are exported: * `repository_count` - The number of repositories in the domain. * `created_time` - A timestamp that represents the date and time the domain was created in [RFC3339 format](https://tools.ietf.org/html/rfc3339#section-5.8). * `asset_size_bytes` - The total size of all assets in the domain. +* `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/codeartifact_repository.html.markdown b/website/docs/r/codeartifact_repository.html.markdown index 88c4e52bae3..372bcbb0eb0 100644 --- a/website/docs/r/codeartifact_repository.html.markdown +++ b/website/docs/r/codeartifact_repository.html.markdown @@ -74,7 +74,7 @@ The following arguments are supported: * `description` - (Optional) The description of the repository. * `upstream` - (Optional) A list of upstream repositories to associate with the repository. The order of the upstream repositories in the list determines their priority order when AWS CodeArtifact looks for a requested package version. see [Upstream](#upstream) * `external_connections` - An array of external connections associated with the repository. Only one external connection can be set per repository. see [External Connections](#external-connections). -* `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. ### Upstream @@ -91,6 +91,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The Name of the repository. * `arn` - The ARN of the repository. * `administrator_account` - The account number of the AWS account that manages the repository. +* `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/codebuild_project.html.markdown b/website/docs/r/codebuild_project.html.markdown index 92a0259e526..4d84aac4f54 100755 --- a/website/docs/r/codebuild_project.html.markdown +++ b/website/docs/r/codebuild_project.html.markdown @@ -240,7 +240,7 @@ The following arguments are optional: * `secondary_sources` - (Optional) Configuration block. Detailed below. * `service_role` - (Required) Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) role that enables AWS CodeBuild to interact with dependent AWS services on behalf of the AWS account. * `source_version` - (Optional) Version of the build input to be built for this project. If not specified, the latest version is used. -* `tags` - (Optional) Map of tags to assign to the resource. +* `tags` - (Optional) Map of tags to assign to 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. * `vpc_config` - (Optional) Configuration block. Detailed below. ### artifacts @@ -372,6 +372,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - ARN of the CodeBuild project. * `badge_url` - URL of the build badge when `badge_enabled` is enabled. * `id` - Name (if imported via `name`) or ARN (if created via Terraform or imported via ARN) of the CodeBuild project. +* `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/codebuild_report_group.html.markdown b/website/docs/r/codebuild_report_group.html.markdown index 4f94d9cebed..d75259c4e0f 100644 --- a/website/docs/r/codebuild_report_group.html.markdown +++ b/website/docs/r/codebuild_report_group.html.markdown @@ -66,7 +66,7 @@ The following arguments are supported: * `type` - (Required) The type of the Report Group. Valid value are `TEST` and `CODE_COVERAGE`. * `export_config` - (Required) Information about the destination where the raw data of this Report Group is exported. see [Export Config](#export-config) documented below. * `delete_reports` - (Optional) If `true`, deletes any reports that belong to a report group before deleting the report group. If `false`, you must delete any reports in the report group before deleting it. Default value is `false`. -* `tags` - (Optional) Key-value mapping of resource tags +* `tags` - (Optional) Key-value mapping 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. ### Export Config @@ -89,6 +89,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ARN of Report Group. * `arn` - The ARN of Report Group. * `created` - The date and time this Report Group was created. +* `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/codecommit_repository.html.markdown b/website/docs/r/codecommit_repository.html.markdown index 295b231b39d..dc96c8814c0 100644 --- a/website/docs/r/codecommit_repository.html.markdown +++ b/website/docs/r/codecommit_repository.html.markdown @@ -26,7 +26,7 @@ The following arguments are supported: * `repository_name` - (Required) The name for the repository. This needs to be less than 100 characters. * `description` - (Optional) The description of the repository. This needs to be less than 1000 characters * `default_branch` - (Optional) The default branch of the repository. The branch specified here needs to exist. -* `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. ## Attributes Reference @@ -36,6 +36,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the repository * `clone_url_http` - The URL to use for cloning the repository over HTTPS. * `clone_url_ssh` - The URL to use for cloning the repository over SSH. +* `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/codepipeline.markdown b/website/docs/r/codepipeline.markdown index eed175db2f5..b1e9921913d 100644 --- a/website/docs/r/codepipeline.markdown +++ b/website/docs/r/codepipeline.markdown @@ -162,7 +162,7 @@ The following arguments are supported: * `role_arn` - (Required) A service role Amazon Resource Name (ARN) that grants AWS CodePipeline permission to make calls to AWS services on your behalf. * `artifact_store` (Required) One or more artifact_store blocks. Artifact stores are documented below. * `stage` (Minimum of at least two `stage` blocks is required) A stage block. Stages are documented below. -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to 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. An `artifact_store` block supports the following arguments: @@ -205,6 +205,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The codepipeline ID. * `arn` - The codepipeline 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/codepipeline_webhook.markdown b/website/docs/r/codepipeline_webhook.markdown index 13256408006..19fc834d187 100644 --- a/website/docs/r/codepipeline_webhook.markdown +++ b/website/docs/r/codepipeline_webhook.markdown @@ -115,7 +115,7 @@ The following arguments are supported: * `filter` (Required) One or more `filter` blocks. Filter blocks are documented below. * `target_action` - (Required) The name of the action in a pipeline you want to connect to the webhook. The action must be from the source (first) stage of the pipeline. * `target_pipeline` - (Required) The name of the pipeline. -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to 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. An `authentication_configuration` block supports the following arguments: @@ -132,6 +132,7 @@ A `filter` block supports the following arguments: In addition to all arguments above, the following attributes are exported: * `id` - The CodePipeline webhook's 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). * `url` - The CodePipeline webhook's URL. POST events to this endpoint to trigger the target. ## Import diff --git a/website/docs/r/codestarconnections_connection.markdown b/website/docs/r/codestarconnections_connection.markdown index 373b6beaa0c..a122eb92eda 100644 --- a/website/docs/r/codestarconnections_connection.markdown +++ b/website/docs/r/codestarconnections_connection.markdown @@ -67,7 +67,7 @@ The following arguments are supported: * `name` - (Required) The name of the connection to be created. The name must be unique in the calling AWS account. Changing `name` will create a new resource. * `provider_type` - (Required) The name of the external provider where your third-party code repository is configured. Valid values are `Bitbucket`, `GitHub`, or `GitHubEnterpriseServer`. Changing `provider_type` will create a new resource. -* `tags` - (Optional) Map of key-value resource tags to associate with the resource. +* `tags` - (Optional) Map of key-value resource tags 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 @@ -76,6 +76,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The codestar connection ARN. * `arn` - The codestar connection ARN. * `connection_status` - The codestar connection status. Possible values are `PENDING`, `AVAILABLE` and `ERROR`. +* `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/codestarnotifications_notification_rule.markdown b/website/docs/r/codestarnotifications_notification_rule.markdown index 0fcbe934c24..99ce95bff98 100644 --- a/website/docs/r/codestarnotifications_notification_rule.markdown +++ b/website/docs/r/codestarnotifications_notification_rule.markdown @@ -62,7 +62,7 @@ The following arguments are supported: * `name` - (Required) The name of notification rule. * `resource` - (Required) The ARN of the resource to associate with the notification rule. * `status` - (Optional) The status of the notification rule. Possible values are `ENABLED` and `DISABLED`, default is `ENABLED`. -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to 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. * `target` - (Optional) Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation. An `target` block supports the following arguments: @@ -76,6 +76,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The codestar notification rule ARN. * `arn` - The codestar notification rule 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/cognito_identity_pool.markdown b/website/docs/r/cognito_identity_pool.markdown index e4865eb4fb5..f3e89f73dc2 100644 --- a/website/docs/r/cognito_identity_pool.markdown +++ b/website/docs/r/cognito_identity_pool.markdown @@ -56,7 +56,7 @@ backend and the Cognito service to communicate about the developer provider. * `openid_connect_provider_arns` (Optional) - Set of OpendID Connect provider ARNs. * `saml_provider_arns` (Optional) - An array of Amazon Resource Names (ARNs) of the SAML provider for your identity. * `supported_login_providers` (Optional) - Key-Value pairs mapping provider names to provider app IDs. -* `tags` - (Optional) A map of tags to assign to the Identity Pool. +* `tags` - (Optional) A map of tags to assign to the Identity Pool. 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. #### Cognito Identity Providers @@ -70,6 +70,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - An identity pool ID in the format REGION:GUID. * `arn` - The ARN of the identity pool. +* `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/cognito_user_pool.markdown b/website/docs/r/cognito_user_pool.markdown index d9627ad109b..39c38db602f 100644 --- a/website/docs/r/cognito_user_pool.markdown +++ b/website/docs/r/cognito_user_pool.markdown @@ -84,7 +84,7 @@ The following arguments are optional: * `sms_configuration` - (Optional) Configuration block for Short Message Service (SMS) settings. [Detailed below](#sms_configuration). These settings apply to SMS user verification and SMS Multi-Factor Authentication (MFA). Due to Cognito API restrictions, the SMS configuration cannot be removed without recreating the Cognito User Pool. For user data safety, this resource will ignore the removal of this configuration by disabling drift detection. To force resource recreation after this configuration has been applied, see the [`taint` command](https://www.terraform.io/docs/commands/taint.html). * `sms_verification_message` - (Optional) String representing the SMS verification message. Conflicts with `verification_message_template` configuration block `sms_message` argument. * `software_token_mfa_configuration` - (Optional) Configuration block for software token Mult-Factor Authentication (MFA) settings. [Detailed below](#software_token_mfa_configuration). -* `tags` - (Optional) Map of tags to assign to the User Pool. +* `tags` - (Optional) Map of tags to assign to the User Pool. 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. * `user_pool_add_ons` - (Optional) Configuration block for user pool add-ons to enable user pool advanced security mode features. [Detailed below](#user_pool_add_ons). * `username_attributes` - (Optional) Whether email addresses or phone numbers can be specified as usernames when a user signs up. Conflicts with `alias_attributes`. * `username_configuration` - (Optional) Configuration block for username configuration. [Detailed below](#username_configuration). @@ -224,6 +224,7 @@ In addition to all arguments above, the following attributes are exported: * `endpoint` - Endpoint name of the user pool. Example format: `cognito-idp.REGION.amazonaws.com/xxxx_yyyyy` * `id` - ID of the user pool. * `last_modified_date` - Date the user pool was last modified. +* `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/config_aggregate_authorization.markdown b/website/docs/r/config_aggregate_authorization.markdown index 6f6c8e65f66..0a77ffa1d16 100644 --- a/website/docs/r/config_aggregate_authorization.markdown +++ b/website/docs/r/config_aggregate_authorization.markdown @@ -25,13 +25,14 @@ The following arguments are supported: * `account_id` - (Required) Account ID * `region` - (Required) Region -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to 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 In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the authorization +* `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/config_config_rule.html.markdown b/website/docs/r/config_config_rule.html.markdown index a830efce5a3..b29be90fae5 100644 --- a/website/docs/r/config_config_rule.html.markdown +++ b/website/docs/r/config_config_rule.html.markdown @@ -120,7 +120,7 @@ The following arguments are supported: * `maximum_execution_frequency` - (Optional) The maximum frequency with which AWS Config runs evaluations for a rule. * `scope` - (Optional) Scope defines which resources can trigger an evaluation for the rule as documented below. * `source` - (Required) Source specifies the rule owner, the rule identifier, and the notifications that cause the function to evaluate your AWS resources as documented below. -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to 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. ### `scope` @@ -153,6 +153,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the config rule * `rule_id` - The ID of the config 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/config_configuration_aggregator.html.markdown b/website/docs/r/config_configuration_aggregator.html.markdown index bd91080600b..cca6a5d20e0 100644 --- a/website/docs/r/config_configuration_aggregator.html.markdown +++ b/website/docs/r/config_configuration_aggregator.html.markdown @@ -72,7 +72,7 @@ The following arguments are supported: * `name` - (Required) The name of the configuration aggregator. * `account_aggregation_source` - (Optional) The account(s) to aggregate config data from as documented below. * `organization_aggregation_source` - (Optional) The organization to aggregate config data from as documented below. -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to 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. Either `account_aggregation_source` or `organization_aggregation_source` must be specified. @@ -99,6 +99,7 @@ Either `regions` or `all_regions` (as true) must be specified. In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the aggregator +* `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/customer_gateway.html.markdown b/website/docs/r/customer_gateway.html.markdown index 0660af1c091..5189b00e36d 100644 --- a/website/docs/r/customer_gateway.html.markdown +++ b/website/docs/r/customer_gateway.html.markdown @@ -35,7 +35,7 @@ The following arguments are supported: * `ip_address` - (Required) The IP address of the gateway's Internet-routable external interface. * `type` - (Required) The type of customer gateway. The only type AWS supports at this time is "ipsec.1". -* `tags` - (Optional) Tags to apply to the gateway. +* `tags` - (Optional) Tags to apply to the gateway. 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 @@ -43,12 +43,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The amazon-assigned ID of the gateway. * `arn` - The ARN of the customer gateway. -* `bgp_asn` - The gateway's Border Gateway Protocol (BGP) Autonomous System Number (ASN). -* `device_name` - A name for the customer gateway device. -* `ip_address` - The IP address of the gateway's Internet-routable external interface. -* `type` - The type of customer gateway. -* `tags` - Tags applied to the gateway. - +* `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 From aab4ae368b5d2ea6a04dbda67ed0f0f8886f105d Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Mon, 19 Apr 2021 11:35:57 -0400 Subject: [PATCH 4/5] resource/aws_cognito_user_pool: Ensure updates include default tags Output from acceptance testing: ``` --- PASS: TestAccAWSCognitoUserPool_basic (32.72s) --- PASS: TestAccAWSCognitoUserPool_disappears (23.07s) --- PASS: TestAccAWSCognitoUserPool_MfaConfiguration_SmsConfiguration (90.95s) --- PASS: TestAccAWSCognitoUserPool_MfaConfiguration_SmsConfigurationAndSoftwareTokenMfaConfiguration (81.96s) --- PASS: TestAccAWSCognitoUserPool_MfaConfiguration_SmsConfigurationToSoftwareTokenMfaConfiguration (52.93s) --- PASS: TestAccAWSCognitoUserPool_MfaConfiguration_SoftwareTokenMfaConfiguration (46.95s) --- PASS: TestAccAWSCognitoUserPool_MfaConfiguration_SoftwareTokenMfaConfigurationToSmsConfiguration (47.99s) --- PASS: TestAccAWSCognitoUserPool_recovery (49.48s) --- PASS: TestAccAWSCognitoUserPool_schemaAttributes (52.07s) --- PASS: TestAccAWSCognitoUserPool_schemaAttributesModified (32.71s) --- PASS: TestAccAWSCognitoUserPool_schemaAttributesRemoved (32.71s) --- PASS: TestAccAWSCognitoUserPool_SmsAuthenticationMessage (45.81s) --- PASS: TestAccAWSCognitoUserPool_SmsConfiguration (80.39s) --- PASS: TestAccAWSCognitoUserPool_SmsConfiguration_ExternalId (75.83s) --- PASS: TestAccAWSCognitoUserPool_SmsConfiguration_SnsCallerArn (73.17s) --- PASS: TestAccAWSCognitoUserPool_SmsVerificationMessage (53.22s) --- PASS: TestAccAWSCognitoUserPool_update (86.20s) --- PASS: TestAccAWSCognitoUserPool_withAdminCreateUserConfiguration (43.93s) --- PASS: TestAccAWSCognitoUserPool_withAdminCreateUserConfigurationAndPasswordPolicy (24.82s) --- PASS: TestAccAWSCognitoUserPool_withAdvancedSecurityMode (69.48s) --- PASS: TestAccAWSCognitoUserPool_withAliasAttributes (52.96s) --- PASS: TestAccAWSCognitoUserPool_withDeviceConfiguration (43.98s) --- PASS: TestAccAWSCognitoUserPool_withEmailConfiguration (28.09s) --- PASS: TestAccAWSCognitoUserPool_withEmailVerificationMessage (44.74s) --- PASS: TestAccAWSCognitoUserPool_withLambdaConfig (79.27s) --- PASS: TestAccAWSCognitoUserPool_withPasswordPolicy (53.72s) --- PASS: TestAccAWSCognitoUserPool_withTags (70.01s) --- PASS: TestAccAWSCognitoUserPool_withUsernameConfiguration (53.49s) --- PASS: TestAccAWSCognitoUserPool_withVerificationMessageTemplate (53.61s) --- SKIP: TestAccAWSCognitoUserPool_withEmailConfigurationSource (0.00s) ``` --- aws/resource_aws_cognito_user_pool.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_cognito_user_pool.go b/aws/resource_aws_cognito_user_pool.go index 4c42300163d..cee7bfb9d51 100644 --- a/aws/resource_aws_cognito_user_pool.go +++ b/aws/resource_aws_cognito_user_pool.go @@ -896,6 +896,8 @@ func resourceAwsCognitoUserPoolRead(d *schema.ResourceData, meta interface{}) er func resourceAwsCognitoUserPoolUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cognitoidpconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) // Multi-Factor Authentication updates if d.HasChanges( @@ -969,6 +971,7 @@ func resourceAwsCognitoUserPoolUpdate(d *schema.ResourceData, meta interface{}) "sms_configuration", "sms_verification_message", "tags", + "tags_all", "user_pool_add_ons", "verification_message_template", "account_recovery_setting", @@ -1118,8 +1121,8 @@ func resourceAwsCognitoUserPoolUpdate(d *schema.ResourceData, meta interface{}) params.SmsVerificationMessage = aws.String(v.(string)) } - if v, ok := d.GetOk("tags"); ok { - params.UserPoolTags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().CognitoidentityproviderTags() + if len(tags) > 0 { + params.UserPoolTags = tags.IgnoreAws().CognitoidentityproviderTags() } log.Printf("[DEBUG] Updating Cognito User Pool: %s", params) From 11eb3f1b23837bfa201117bdaa19d8354795e2e3 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Wed, 21 Apr 2021 12:52:24 -0400 Subject: [PATCH 5/5] provider: Add missing default tags handling --- aws/resource_aws_cloudwatch_metric_alarm.go | 11 +++++++---- aws/resource_aws_config_aggregate_authorization.go | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/aws/resource_aws_cloudwatch_metric_alarm.go b/aws/resource_aws_cloudwatch_metric_alarm.go index 644046bf657..43bcea9333b 100644 --- a/aws/resource_aws_cloudwatch_metric_alarm.go +++ b/aws/resource_aws_cloudwatch_metric_alarm.go @@ -277,7 +277,7 @@ func resourceAwsCloudWatchMetricAlarmCreate(d *schema.ResourceData, meta interfa if err != nil { return err } - params := getAwsCloudWatchPutMetricAlarmInput(d) + params := getAwsCloudWatchPutMetricAlarmInput(d, meta) log.Printf("[DEBUG] Creating CloudWatch Metric Alarm: %#v", params) _, err = conn.PutMetricAlarm(¶ms) @@ -389,7 +389,7 @@ func resourceAwsCloudWatchMetricAlarmRead(d *schema.ResourceData, meta interface func resourceAwsCloudWatchMetricAlarmUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudwatchconn - params := getAwsCloudWatchPutMetricAlarmInput(d) + params := getAwsCloudWatchPutMetricAlarmInput(d, meta) log.Printf("[DEBUG] Updating CloudWatch Metric Alarm: %#v", params) _, err := conn.PutMetricAlarm(¶ms) @@ -429,13 +429,16 @@ func resourceAwsCloudWatchMetricAlarmDelete(d *schema.ResourceData, meta interfa return nil } -func getAwsCloudWatchPutMetricAlarmInput(d *schema.ResourceData) cloudwatch.PutMetricAlarmInput { +func getAwsCloudWatchPutMetricAlarmInput(d *schema.ResourceData, meta interface{}) cloudwatch.PutMetricAlarmInput { + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) + params := cloudwatch.PutMetricAlarmInput{ AlarmName: aws.String(d.Get("alarm_name").(string)), ComparisonOperator: aws.String(d.Get("comparison_operator").(string)), EvaluationPeriods: aws.Int64(int64(d.Get("evaluation_periods").(int))), TreatMissingData: aws.String(d.Get("treat_missing_data").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().CloudwatchTags(), + Tags: tags.IgnoreAws().CloudwatchTags(), } if v := d.Get("actions_enabled"); v != nil { diff --git a/aws/resource_aws_config_aggregate_authorization.go b/aws/resource_aws_config_aggregate_authorization.go index a0f98c82718..7c1f73f611f 100644 --- a/aws/resource_aws_config_aggregate_authorization.go +++ b/aws/resource_aws_config_aggregate_authorization.go @@ -48,6 +48,8 @@ func resourceAwsConfigAggregateAuthorization() *schema.Resource { func resourceAwsConfigAggregateAuthorizationPut(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).configconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) accountId := d.Get("account_id").(string) region := d.Get("region").(string) @@ -55,7 +57,7 @@ func resourceAwsConfigAggregateAuthorizationPut(d *schema.ResourceData, meta int req := &configservice.PutAggregationAuthorizationInput{ AuthorizedAccountId: aws.String(accountId), AuthorizedAwsRegion: aws.String(region), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().ConfigserviceTags(), + Tags: tags.IgnoreAws().ConfigserviceTags(), } _, err := conn.PutAggregationAuthorization(req)