From 53e50bd1e87eb9631d6d9e2703a20a13015bd1bb Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Wed, 21 Apr 2021 13:13:30 -0400 Subject: [PATCH] provider: Support default tags (resources aws_d*) (#18732) * provider: Support default tags (resources aws_d*) Reference: https://github.com/hashicorp/terraform-provider-aws/issues/7926 * docs/provider: Update tagging documentation (resources aws_d*) * resource/aws_dynamodb_table: Fix rebasing issues --- aws/dx_vif.go | 4 +- aws/resource_aws_datapipeline_pipeline.go | 25 +++++++--- aws/resource_aws_datasync_agent.go | 25 +++++++--- aws/resource_aws_datasync_location_efs.go | 25 +++++++--- ...tasync_location_fsx_windows_file_system.go | 23 +++++++-- aws/resource_aws_datasync_location_nfs.go | 25 +++++++--- aws/resource_aws_datasync_location_s3.go | 25 +++++++--- aws/resource_aws_datasync_location_smb.go | 25 +++++++--- aws/resource_aws_datasync_task.go | 25 +++++++--- aws/resource_aws_dax_cluster.go | 26 +++++++--- aws/resource_aws_db_cluster_snapshot.go | 25 +++++++--- aws/resource_aws_db_event_subscription.go | 27 +++++++---- aws/resource_aws_db_instance.go | 35 +++++++++----- aws/resource_aws_db_option_group.go | 26 +++++++--- aws/resource_aws_db_parameter_group.go | 26 +++++++--- aws/resource_aws_db_proxy.go | 26 +++++++--- aws/resource_aws_db_security_group.go | 26 +++++++--- aws/resource_aws_db_snapshot.go | 26 +++++++--- aws/resource_aws_db_subnet_group.go | 26 +++++++--- aws/resource_aws_default_network_acl.go | 9 ++-- aws/resource_aws_default_route_table.go | 11 +++-- aws/resource_aws_default_security_group.go | 27 ++++++++--- ...esource_aws_directory_service_directory.go | 48 +++++++++++++------ aws/resource_aws_dlm_lifecycle_policy.go | 27 ++++++++--- aws/resource_aws_dms_certificate.go | 23 +++++++-- aws/resource_aws_dms_endpoint.go | 25 +++++++--- aws/resource_aws_dms_event_subscription.go | 25 +++++++--- aws/resource_aws_dms_replication_instance.go | 25 +++++++--- ...source_aws_dms_replication_subnet_group.go | 25 +++++++--- aws/resource_aws_dms_replication_task.go | 25 +++++++--- aws/resource_aws_docdb_cluster.go | 28 +++++++---- aws/resource_aws_docdb_cluster_instance.go | 26 +++++++--- ...ource_aws_docdb_cluster_parameter_group.go | 26 +++++++--- aws/resource_aws_docdb_subnet_group.go | 26 +++++++--- aws/resource_aws_dx_connection.go | 27 ++++++++--- ...sted_private_virtual_interface_accepter.go | 17 +++++-- ...osted_public_virtual_interface_accepter.go | 17 +++++-- ...sted_transit_virtual_interface_accepter.go | 17 +++++-- aws/resource_aws_dx_lag.go | 27 ++++++++--- ...source_aws_dx_private_virtual_interface.go | 23 +++++++-- ...esource_aws_dx_public_virtual_interface.go | 27 ++++++++--- ...source_aws_dx_transit_virtual_interface.go | 23 +++++++-- aws/resource_aws_dynamodb_table.go | 30 +++++++++--- .../r/datapipeline_pipeline.html.markdown | 3 +- website/docs/r/datasync_agent.html.markdown | 3 +- .../r/datasync_location_efs.html.markdown | 3 +- ...tion_fsx_windows_file_system.html.markdown | 3 +- .../r/datasync_location_nfs.html.markdown | 3 +- .../docs/r/datasync_location_s3.html.markdown | 3 +- .../r/datasync_location_smb.html.markdown | 3 +- website/docs/r/datasync_task.html.markdown | 3 +- website/docs/r/dax_cluster.html.markdown | 4 +- .../docs/r/db_cluster_snapshot.html.markdown | 3 +- .../r/db_event_subscription.html.markdown | 3 +- website/docs/r/db_instance.html.markdown | 3 +- website/docs/r/db_option_group.html.markdown | 3 +- .../docs/r/db_parameter_group.html.markdown | 3 +- website/docs/r/db_proxy.html.markdown | 3 +- .../docs/r/db_security_group.html.markdown | 4 +- website/docs/r/db_snapshot.html.markdown | 3 +- website/docs/r/db_subnet_group.html.markdown | 4 +- .../docs/r/default_network_acl.html.markdown | 3 +- .../docs/r/default_route_table.html.markdown | 3 +- .../r/default_security_group.html.markdown | 3 +- .../directory_service_directory.html.markdown | 3 +- website/docs/r/dlm_lifecycle_policy.markdown | 3 +- website/docs/r/dms_certificate.html.markdown | 3 +- website/docs/r/dms_endpoint.html.markdown | 3 +- .../r/dms_event_subscription.html.markdown | 2 + .../r/dms_replication_instance.html.markdown | 3 +- ...dms_replication_subnet_group.html.markdown | 3 +- .../docs/r/dms_replication_task.html.markdown | 3 +- website/docs/r/docdb_cluster.html.markdown | 3 +- .../r/docdb_cluster_instance.html.markdown | 3 +- ...ocdb_cluster_parameter_group.html.markdown | 4 +- .../docs/r/docdb_subnet_group.html.markdown | 4 +- website/docs/r/dx_connection.html.markdown | 3 +- ...e_virtual_interface_accepter.html.markdown | 3 +- ...c_virtual_interface_accepter.html.markdown | 3 +- ...t_virtual_interface_accepter.html.markdown | 3 +- website/docs/r/dx_lag.html.markdown | 3 +- ...dx_private_virtual_interface.html.markdown | 3 +- .../dx_public_virtual_interface.html.markdown | 3 +- ...dx_transit_virtual_interface.html.markdown | 3 +- website/docs/r/dynamodb_table.html.markdown | 3 +- 85 files changed, 872 insertions(+), 313 deletions(-) diff --git a/aws/dx_vif.go b/aws/dx_vif.go index b12997e5d93..4b2aea8edbc 100644 --- a/aws/dx_vif.go +++ b/aws/dx_vif.go @@ -41,8 +41,8 @@ func dxVirtualInterfaceUpdate(d *schema.ResourceData, meta interface{}) error { } 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.DirectconnectUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating Direct Connect virtual interface (%s) tags: %s", arn, err) diff --git a/aws/resource_aws_datapipeline_pipeline.go b/aws/resource_aws_datapipeline_pipeline.go index 64f8161cdf3..ce198036fe6 100644 --- a/aws/resource_aws_datapipeline_pipeline.go +++ b/aws/resource_aws_datapipeline_pipeline.go @@ -35,20 +35,25 @@ func resourceAwsDataPipelinePipeline() *schema.Resource { ForceNew: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDataPipelinePipelineCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datapipelineconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) uniqueID := resource.UniqueId() input := datapipeline.CreatePipelineInput{ Name: aws.String(d.Get("name").(string)), UniqueId: aws.String(uniqueID), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatapipelineTags(), + Tags: tags.IgnoreAws().DatapipelineTags(), } if v, ok := d.GetOk("description"); ok { @@ -68,6 +73,7 @@ func resourceAwsDataPipelinePipelineCreate(d *schema.ResourceData, meta interfac func resourceAwsDataPipelinePipelineRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datapipelineconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig v, err := resourceAwsDataPipelinePipelineRetrieve(d.Id(), conn) @@ -82,8 +88,15 @@ func resourceAwsDataPipelinePipelineRead(d *schema.ResourceData, meta interface{ d.Set("name", v.Name) d.Set("description", v.Description) - if err := d.Set("tags", keyvaluetags.DatapipelineKeyValueTags(v.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.DatapipelineKeyValueTags(v.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 @@ -92,8 +105,8 @@ func resourceAwsDataPipelinePipelineRead(d *schema.ResourceData, meta interface{ func resourceAwsDataPipelinePipelineUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datapipelineconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatapipelineUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating Datapipeline Pipeline (%s) tags: %s", d.Id(), err) diff --git a/aws/resource_aws_datasync_agent.go b/aws/resource_aws_datasync_agent.go index fc5ded31666..90c4b334335 100644 --- a/aws/resource_aws_datasync_agent.go +++ b/aws/resource_aws_datasync_agent.go @@ -50,13 +50,18 @@ func resourceAwsDataSyncAgent() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDataSyncAgentCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) region := meta.(*AWSClient).region activationKey := d.Get("activation_key").(string) @@ -125,7 +130,7 @@ func resourceAwsDataSyncAgentCreate(d *schema.ResourceData, meta interface{}) er input := &datasync.CreateAgentInput{ ActivationKey: aws.String(activationKey), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatasyncTags(), + Tags: tags.IgnoreAws().DatasyncTags(), } if v, ok := d.GetOk("name"); ok { @@ -169,6 +174,7 @@ func resourceAwsDataSyncAgentCreate(d *schema.ResourceData, meta interface{}) er func resourceAwsDataSyncAgentRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := &datasync.DescribeAgentInput{ @@ -197,8 +203,15 @@ func resourceAwsDataSyncAgentRead(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("error listing tags for DataSync Agent (%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 @@ -220,8 +233,8 @@ func resourceAwsDataSyncAgentUpdate(d *schema.ResourceData, meta interface{}) er } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatasyncUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating DataSync Agent (%s) tags: %s", d.Id(), err) diff --git a/aws/resource_aws_datasync_location_efs.go b/aws/resource_aws_datasync_location_efs.go index e796b16d1df..a8dc8f9782f 100644 --- a/aws/resource_aws_datasync_location_efs.go +++ b/aws/resource_aws_datasync_location_efs.go @@ -71,23 +71,28 @@ func resourceAwsDataSyncLocationEfs() *schema.Resource { return false }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDataSyncLocationEfsCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) input := &datasync.CreateLocationEfsInput{ Ec2Config: expandDataSyncEc2Config(d.Get("ec2_config").([]interface{})), EfsFilesystemArn: aws.String(d.Get("efs_file_system_arn").(string)), Subdirectory: aws.String(d.Get("subdirectory").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatasyncTags(), + Tags: tags.IgnoreAws().DatasyncTags(), } log.Printf("[DEBUG] Creating DataSync Location EFS: %s", input) @@ -103,6 +108,7 @@ func resourceAwsDataSyncLocationEfsCreate(d *schema.ResourceData, meta interface func resourceAwsDataSyncLocationEfsRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := &datasync.DescribeLocationEfsInput{ @@ -143,8 +149,15 @@ func resourceAwsDataSyncLocationEfsRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("error listing tags for DataSync Location EFS (%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 @@ -153,8 +166,8 @@ func resourceAwsDataSyncLocationEfsRead(d *schema.ResourceData, meta interface{} func resourceAwsDataSyncLocationEfsUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatasyncUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating DataSync Location EFS (%s) tags: %s", d.Id(), err) diff --git a/aws/resource_aws_datasync_location_fsx_windows_file_system.go b/aws/resource_aws_datasync_location_fsx_windows_file_system.go index c3a85982ad2..b2e1651d793 100644 --- a/aws/resource_aws_datasync_location_fsx_windows_file_system.go +++ b/aws/resource_aws_datasync_location_fsx_windows_file_system.go @@ -84,7 +84,8 @@ func resourceAwsDataSyncLocationFsxWindowsFileSystem() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringLenBetween(1, 4096), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, @@ -94,11 +95,15 @@ func resourceAwsDataSyncLocationFsxWindowsFileSystem() *schema.Resource { Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDataSyncLocationFsxWindowsFileSystemCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) fsxArn := d.Get("fsx_filesystem_arn").(string) input := &datasync.CreateLocationFsxWindowsInput{ @@ -106,7 +111,7 @@ func resourceAwsDataSyncLocationFsxWindowsFileSystemCreate(d *schema.ResourceDat User: aws.String(d.Get("user").(string)), Password: aws.String(d.Get("password").(string)), SecurityGroupArns: expandStringSet(d.Get("security_group_arns").(*schema.Set)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatasyncTags(), + Tags: tags.IgnoreAws().DatasyncTags(), } if v, ok := d.GetOk("subdirectory"); ok { @@ -130,6 +135,7 @@ func resourceAwsDataSyncLocationFsxWindowsFileSystemCreate(d *schema.ResourceDat func resourceAwsDataSyncLocationFsxWindowsFileSystemRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := &datasync.DescribeLocationFsxWindowsInput{ @@ -175,18 +181,25 @@ func resourceAwsDataSyncLocationFsxWindowsFileSystemRead(d *schema.ResourceData, return fmt.Errorf("error listing tags for DataSync Location Fsx Windows (%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 } func resourceAwsDataSyncLocationFsxWindowsFileSystemUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatasyncUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating DataSync Location Fsx Windows File System (%s) tags: %w", d.Id(), err) diff --git a/aws/resource_aws_datasync_location_nfs.go b/aws/resource_aws_datasync_location_nfs.go index fa8e7cea9d0..f73404988ae 100644 --- a/aws/resource_aws_datasync_location_nfs.go +++ b/aws/resource_aws_datasync_location_nfs.go @@ -64,23 +64,28 @@ func resourceAwsDataSyncLocationNfs() *schema.Resource { return false }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDataSyncLocationNfsCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) input := &datasync.CreateLocationNfsInput{ OnPremConfig: expandDataSyncOnPremConfig(d.Get("on_prem_config").([]interface{})), ServerHostname: aws.String(d.Get("server_hostname").(string)), Subdirectory: aws.String(d.Get("subdirectory").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatasyncTags(), + Tags: tags.IgnoreAws().DatasyncTags(), } log.Printf("[DEBUG] Creating DataSync Location NFS: %s", input) @@ -96,6 +101,7 @@ func resourceAwsDataSyncLocationNfsCreate(d *schema.ResourceData, meta interface func resourceAwsDataSyncLocationNfsRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := &datasync.DescribeLocationNfsInput{ @@ -136,8 +142,15 @@ func resourceAwsDataSyncLocationNfsRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("error listing tags for DataSync Location NFS (%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 @@ -146,8 +159,8 @@ func resourceAwsDataSyncLocationNfsRead(d *schema.ResourceData, meta interface{} func resourceAwsDataSyncLocationNfsUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatasyncUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating DataSync Location NFS (%s) tags: %s", d.Id(), err) diff --git a/aws/resource_aws_datasync_location_s3.go b/aws/resource_aws_datasync_location_s3.go index 472fdc34d8e..03fc43d3923 100644 --- a/aws/resource_aws_datasync_location_s3.go +++ b/aws/resource_aws_datasync_location_s3.go @@ -66,23 +66,28 @@ func resourceAwsDataSyncLocationS3() *schema.Resource { return false }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDataSyncLocationS3Create(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) input := &datasync.CreateLocationS3Input{ S3BucketArn: aws.String(d.Get("s3_bucket_arn").(string)), S3Config: expandDataSyncS3Config(d.Get("s3_config").([]interface{})), Subdirectory: aws.String(d.Get("subdirectory").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatasyncTags(), + Tags: tags.IgnoreAws().DatasyncTags(), } log.Printf("[DEBUG] Creating DataSync Location S3: %s", input) @@ -126,6 +131,7 @@ func resourceAwsDataSyncLocationS3Create(d *schema.ResourceData, meta interface{ func resourceAwsDataSyncLocationS3Read(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := &datasync.DescribeLocationS3Input{ @@ -166,8 +172,15 @@ func resourceAwsDataSyncLocationS3Read(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error listing tags for DataSync Location S3 (%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 @@ -176,8 +189,8 @@ func resourceAwsDataSyncLocationS3Read(d *schema.ResourceData, meta interface{}) func resourceAwsDataSyncLocationS3Update(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatasyncUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating DataSync Location S3 (%s) tags: %s", d.Id(), err) diff --git a/aws/resource_aws_datasync_location_smb.go b/aws/resource_aws_datasync_location_smb.go index 8655d6b73e9..7acf7bb951c 100644 --- a/aws/resource_aws_datasync_location_smb.go +++ b/aws/resource_aws_datasync_location_smb.go @@ -87,7 +87,8 @@ func resourceAwsDataSyncLocationSmb() *schema.Resource { }, */ }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, @@ -98,11 +99,15 @@ func resourceAwsDataSyncLocationSmb() *schema.Resource { ForceNew: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDataSyncLocationSmbCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) input := &datasync.CreateLocationSmbInput{ AgentArns: expandStringSet(d.Get("agent_arns").(*schema.Set)), @@ -110,7 +115,7 @@ func resourceAwsDataSyncLocationSmbCreate(d *schema.ResourceData, meta interface Password: aws.String(d.Get("password").(string)), ServerHostname: aws.String(d.Get("server_hostname").(string)), Subdirectory: aws.String(d.Get("subdirectory").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatasyncTags(), + Tags: tags.IgnoreAws().DatasyncTags(), User: aws.String(d.Get("user").(string)), } @@ -131,6 +136,7 @@ func resourceAwsDataSyncLocationSmbCreate(d *schema.ResourceData, meta interface func resourceAwsDataSyncLocationSmbRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := &datasync.DescribeLocationSmbInput{ @@ -179,8 +185,15 @@ func resourceAwsDataSyncLocationSmbRead(d *schema.ResourceData, meta interface{} d.Set("subdirectory", subdirectory) - if err := d.Set("tags", keyvaluetags.DatasyncKeyValueTags(tagsOutput.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.DatasyncKeyValueTags(tagsOutput.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("user", output.User) @@ -193,8 +206,8 @@ func resourceAwsDataSyncLocationSmbRead(d *schema.ResourceData, meta interface{} func resourceAwsDataSyncLocationSmbUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatasyncUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating Datasync SMB location (%s) tags: %s", d.Id(), err) diff --git a/aws/resource_aws_datasync_task.go b/aws/resource_aws_datasync_task.go index 07e6cbf4431..564cabfe37d 100644 --- a/aws/resource_aws_datasync_task.go +++ b/aws/resource_aws_datasync_task.go @@ -157,19 +157,24 @@ func resourceAwsDataSyncTask() *schema.Resource { ForceNew: true, ValidateFunc: validation.NoZeroValues, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDataSyncTaskCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) input := &datasync.CreateTaskInput{ DestinationLocationArn: aws.String(d.Get("destination_location_arn").(string)), Options: expandDataSyncOptions(d.Get("options").([]interface{})), SourceLocationArn: aws.String(d.Get("source_location_arn").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatasyncTags(), + Tags: tags.IgnoreAws().DatasyncTags(), } if v, ok := d.GetOk("cloudwatch_log_group_arn"); ok { @@ -198,6 +203,7 @@ func resourceAwsDataSyncTaskCreate(d *schema.ResourceData, meta interface{}) err func resourceAwsDataSyncTaskRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).datasyncconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := &datasync.DescribeTaskInput{ @@ -234,8 +240,15 @@ func resourceAwsDataSyncTaskRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("error listing tags for DataSync Task (%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 @@ -257,8 +270,8 @@ func resourceAwsDataSyncTaskUpdate(d *schema.ResourceData, meta interface{}) err } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatasyncUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating DataSync Task (%s) tags: %s", d.Id(), err) diff --git a/aws/resource_aws_dax_cluster.go b/aws/resource_aws_dax_cluster.go index 8d04c12c3a6..1a564d83862 100644 --- a/aws/resource_aws_dax_cluster.go +++ b/aws/resource_aws_dax_cluster.go @@ -131,7 +131,8 @@ func resourceAwsDaxCluster() *schema.Resource { Computed: true, ForceNew: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "port": { Type: schema.TypeInt, Computed: true, @@ -169,11 +170,15 @@ func resourceAwsDaxCluster() *schema.Resource { }, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDaxClusterCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).daxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) clusterName := d.Get("cluster_name").(string) iamRoleArn := d.Get("iam_role_arn").(string) @@ -183,7 +188,6 @@ func resourceAwsDaxClusterCreate(d *schema.ResourceData, meta interface{}) error securityIdSet := d.Get("security_group_ids").(*schema.Set) securityIds := expandStringSet(securityIdSet) - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DaxTags() req := &dax.CreateClusterInput{ ClusterName: aws.String(clusterName), @@ -192,7 +196,7 @@ func resourceAwsDaxClusterCreate(d *schema.ResourceData, meta interface{}) error ReplicationFactor: aws.Int64(numNodes), SecurityGroupIds: securityIds, SubnetGroupName: aws.String(subnetGroupName), - Tags: tags, + Tags: tags.IgnoreAws().DaxTags(), } // optionals can be defaulted by AWS @@ -271,6 +275,7 @@ func resourceAwsDaxClusterCreate(d *schema.ResourceData, meta interface{}) error func resourceAwsDaxClusterRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).daxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig req := &dax.DescribeClustersInput{ @@ -337,8 +342,15 @@ func resourceAwsDaxClusterRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error listing tags for DAX Cluster (%s): %s", aws.StringValue(c.ClusterArn), 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 @@ -347,8 +359,8 @@ func resourceAwsDaxClusterRead(d *schema.ResourceData, meta interface{}) error { func resourceAwsDaxClusterUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).daxconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DaxUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating DAX Cluster (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_db_cluster_snapshot.go b/aws/resource_aws_db_cluster_snapshot.go index c7377b9bdc4..4da0d953054 100644 --- a/aws/resource_aws_db_cluster_snapshot.go +++ b/aws/resource_aws_db_cluster_snapshot.go @@ -102,18 +102,23 @@ func resourceAwsDbClusterSnapshot() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDbClusterSnapshotCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) params := &rds.CreateDBClusterSnapshotInput{ DBClusterIdentifier: aws.String(d.Get("db_cluster_identifier").(string)), DBClusterSnapshotIdentifier: aws.String(d.Get("db_cluster_snapshot_identifier").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().RdsTags(), + Tags: tags.IgnoreAws().RdsTags(), } err := resource.Retry(rdsDbClusterSnapshotCreateTimeout, func() *resource.RetryError { @@ -155,6 +160,7 @@ func resourceAwsDbClusterSnapshotCreate(d *schema.ResourceData, meta interface{} func resourceAwsDbClusterSnapshotRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &rds.DescribeDBClusterSnapshotsInput{ @@ -202,8 +208,15 @@ func resourceAwsDbClusterSnapshotRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error listing tags for RDS DB Cluster Snapshot (%s): %s", d.Get("db_cluster_snapshot_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 @@ -212,8 +225,8 @@ func resourceAwsDbClusterSnapshotRead(d *schema.ResourceData, meta interface{}) func resourceAwsdbClusterSnapshotUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.RdsUpdateTags(conn, d.Get("db_cluster_snapshot_arn").(string), o, n); err != nil { return fmt.Errorf("error updating RDS DB Cluster Snapshot (%s) tags: %s", d.Get("db_cluster_snapshot_arn").(string), err) diff --git a/aws/resource_aws_db_event_subscription.go b/aws/resource_aws_db_event_subscription.go index 0a7383489d6..de59c9f33b8 100644 --- a/aws/resource_aws_db_event_subscription.go +++ b/aws/resource_aws_db_event_subscription.go @@ -80,13 +80,18 @@ func resourceAwsDbEventSubscription() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDbEventSubscriptionCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) var name string if v, ok := d.GetOk("name"); ok { name = v.(string) @@ -96,8 +101,6 @@ func resourceAwsDbEventSubscriptionCreate(d *schema.ResourceData, meta interface name = resource.UniqueId() } - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().RdsTags() - sourceIdsSet := d.Get("source_ids").(*schema.Set) sourceIds := make([]*string, sourceIdsSet.Len()) for i, sourceId := range sourceIdsSet.List() { @@ -117,7 +120,7 @@ func resourceAwsDbEventSubscriptionCreate(d *schema.ResourceData, meta interface SourceIds: sourceIds, SourceType: aws.String(d.Get("source_type").(string)), EventCategories: eventCategories, - Tags: tags, + Tags: tags.IgnoreAws().RdsTags(), } log.Println("[DEBUG] Create RDS Event Subscription:", request) @@ -152,6 +155,7 @@ func resourceAwsDbEventSubscriptionCreate(d *schema.ResourceData, meta interface func resourceAwsDbEventSubscriptionRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig sub, err := resourceAwsDbEventSubscriptionRetrieve(d.Id(), conn) @@ -201,8 +205,15 @@ func resourceAwsDbEventSubscriptionRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("error listing tags for RDS Event Subscription (%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 @@ -298,8 +309,8 @@ func resourceAwsDbEventSubscriptionUpdate(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.RdsUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating RDS Event Subscription (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_db_instance.go b/aws/resource_aws_db_instance.go index 58a62640689..91e5e0bd92f 100644 --- a/aws/resource_aws_db_instance.go +++ b/aws/resource_aws_db_instance.go @@ -529,13 +529,18 @@ func resourceAwsDbInstance() *schema.Resource { Default: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) // Some API calls (e.g. CreateDBInstanceReadReplica and // RestoreDBInstanceFromDBSnapshot do not support all parameters to @@ -553,8 +558,6 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error // we expect everything to be in sync before returning completion. var requiresRebootDbInstance bool - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().RdsTags() - var identifier string if v, ok := d.GetOk("identifier"); ok { identifier = v.(string) @@ -577,7 +580,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error DBInstanceIdentifier: aws.String(identifier), PubliclyAccessible: aws.Bool(d.Get("publicly_accessible").(bool)), SourceDBInstanceIdentifier: aws.String(v.(string)), - Tags: tags, + Tags: tags.IgnoreAws().RdsTags(), } if attr, ok := d.GetOk("allocated_storage"); ok { @@ -739,7 +742,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error StorageEncrypted: aws.Bool(d.Get("storage_encrypted").(bool)), SourceEngine: aws.String(s3_bucket["source_engine"].(string)), SourceEngineVersion: aws.String(s3_bucket["source_engine_version"].(string)), - Tags: tags, + Tags: tags.IgnoreAws().RdsTags(), } if attr, ok := d.GetOk("multi_az"); ok { @@ -892,7 +895,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error DBSnapshotIdentifier: aws.String(d.Get("snapshot_identifier").(string)), DeletionProtection: aws.Bool(d.Get("deletion_protection").(bool)), PubliclyAccessible: aws.Bool(d.Get("publicly_accessible").(bool)), - Tags: tags, + Tags: tags.IgnoreAws().RdsTags(), } if attr, ok := d.GetOk("name"); ok { @@ -1080,7 +1083,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error input.DBInstanceClass = aws.String(d.Get("instance_class").(string)) input.DeletionProtection = aws.Bool(d.Get("deletion_protection").(bool)) input.PubliclyAccessible = aws.Bool(d.Get("publicly_accessible").(bool)) - input.Tags = tags + input.Tags = tags.IgnoreAws().RdsTags() input.TargetDBInstanceIdentifier = aws.String(d.Get("identifier").(string)) if v, ok := d.GetOk("availability_zone"); ok { @@ -1189,7 +1192,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error StorageEncrypted: aws.Bool(d.Get("storage_encrypted").(bool)), AutoMinorVersionUpgrade: aws.Bool(d.Get("auto_minor_version_upgrade").(bool)), PubliclyAccessible: aws.Bool(d.Get("publicly_accessible").(bool)), - Tags: tags, + Tags: tags.IgnoreAws().RdsTags(), CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)), } @@ -1385,6 +1388,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig v, err := resourceAwsDbInstanceRetrieve(d.Id(), conn) @@ -1478,8 +1482,15 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error listing tags for RDS DB Instance (%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) } // Create an empty schema.Set to hold all vpc security group ids @@ -1811,8 +1822,8 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.RdsUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating RDS DB Instance (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_db_option_group.go b/aws/resource_aws_db_option_group.go index 067cbd8a54c..b25c26a28e6 100644 --- a/aws/resource_aws_db_option_group.go +++ b/aws/resource_aws_db_option_group.go @@ -118,14 +118,18 @@ func resourceAwsDbOptionGroup() *schema.Resource { Set: resourceAwsDbOptionHash, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDbOptionGroupCreate(d *schema.ResourceData, meta interface{}) error { rdsconn := meta.(*AWSClient).rdsconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().RdsTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) var groupName string if v, ok := d.GetOk("name"); ok { @@ -141,7 +145,7 @@ func resourceAwsDbOptionGroupCreate(d *schema.ResourceData, meta interface{}) er MajorEngineVersion: aws.String(d.Get("major_engine_version").(string)), OptionGroupDescription: aws.String(d.Get("option_group_description").(string)), OptionGroupName: aws.String(groupName), - Tags: tags, + Tags: tags.IgnoreAws().RdsTags(), } log.Printf("[DEBUG] Create DB Option Group: %#v", createOpts) @@ -161,6 +165,7 @@ func resourceAwsDbOptionGroupCreate(d *schema.ResourceData, meta interface{}) er func resourceAwsDbOptionGroupRead(d *schema.ResourceData, meta interface{}) error { rdsconn := meta.(*AWSClient).rdsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &rds.DescribeOptionGroupsInput{ @@ -210,8 +215,15 @@ func resourceAwsDbOptionGroupRead(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("error listing tags for RDS Option Group (%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 @@ -291,8 +303,8 @@ func resourceAwsDbOptionGroupUpdate(d *schema.ResourceData, meta interface{}) er } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.RdsUpdateTags(rdsconn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating RDS Option Group (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_db_parameter_group.go b/aws/resource_aws_db_parameter_group.go index 43b1d411813..b3142204a29 100644 --- a/aws/resource_aws_db_parameter_group.go +++ b/aws/resource_aws_db_parameter_group.go @@ -87,14 +87,18 @@ func resourceAwsDbParameterGroup() *schema.Resource { Set: resourceAwsDbParameterHash, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{}) error { rdsconn := meta.(*AWSClient).rdsconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().RdsTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) var groupName string if v, ok := d.GetOk("name"); ok { @@ -110,7 +114,7 @@ func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{}) DBParameterGroupName: aws.String(groupName), DBParameterGroupFamily: aws.String(d.Get("family").(string)), Description: aws.String(d.Get("description").(string)), - Tags: tags, + Tags: tags.IgnoreAws().RdsTags(), } log.Printf("[DEBUG] Create DB Parameter Group: %#v", createOpts) @@ -128,6 +132,7 @@ func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{}) func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) error { rdsconn := meta.(*AWSClient).rdsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig describeOpts := rds.DescribeDBParameterGroupsInput{ @@ -234,8 +239,15 @@ func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("error listing tags for RDS DB Parameter Group (%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 @@ -328,8 +340,8 @@ func resourceAwsDbParameterGroupUpdate(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.RdsUpdateTags(rdsconn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating RDS DB Parameter Group (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_db_proxy.go b/aws/resource_aws_db_proxy.go index 1f63eaa7527..ad5953a561c 100644 --- a/aws/resource_aws_db_proxy.go +++ b/aws/resource_aws_db_proxy.go @@ -108,21 +108,25 @@ func resourceAwsDbProxy() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDbProxyCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().RdsTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) params := rds.CreateDBProxyInput{ Auth: expandDbProxyAuth(d.Get("auth").(*schema.Set).List()), DBProxyName: aws.String(d.Get("name").(string)), EngineFamily: aws.String(d.Get("engine_family").(string)), RoleArn: aws.String(d.Get("role_arn").(string)), - Tags: tags, + Tags: tags.IgnoreAws().RdsTags(), VpcSubnetIds: expandStringSet(d.Get("vpc_subnet_ids").(*schema.Set)), } @@ -243,6 +247,7 @@ func flattenDbProxyAuths(userAuthConfigs []*rds.UserAuthConfigInfo) []interface{ func resourceAwsDbProxyRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := rds.DescribeDBProxiesInput{ @@ -294,8 +299,15 @@ func resourceAwsDbProxyRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error listing tags for RDS DB Proxy (%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 @@ -356,8 +368,8 @@ func resourceAwsDbProxyUpdate(d *schema.ResourceData, meta interface{}) error { } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.RdsUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("Error updating RDS DB Proxy (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_db_security_group.go b/aws/resource_aws_db_security_group.go index 9243c2786db..e285b90380c 100644 --- a/aws/resource_aws_db_security_group.go +++ b/aws/resource_aws_db_security_group.go @@ -76,14 +76,18 @@ func resourceAwsDbSecurityGroup() *schema.Resource { Set: resourceAwsDbSecurityGroupIngressHash, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDbSecurityGroupCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().RdsTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) var err error var errs []error @@ -91,7 +95,7 @@ func resourceAwsDbSecurityGroupCreate(d *schema.ResourceData, meta interface{}) opts := rds.CreateDBSecurityGroupInput{ DBSecurityGroupName: aws.String(d.Get("name").(string)), DBSecurityGroupDescription: aws.String(d.Get("description").(string)), - Tags: tags, + Tags: tags.IgnoreAws().RdsTags(), } log.Printf("[DEBUG] DB Security Group create configuration: %#v", opts) @@ -141,6 +145,7 @@ func resourceAwsDbSecurityGroupCreate(d *schema.ResourceData, meta interface{}) } func resourceAwsDbSecurityGroupRead(d *schema.ResourceData, meta interface{}) error { + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig sg, err := resourceAwsDbSecurityGroupRetrieve(d, meta) @@ -188,8 +193,15 @@ func resourceAwsDbSecurityGroupRead(d *schema.ResourceData, meta interface{}) er return fmt.Errorf("error listing tags for RDS DB Security Group (%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 @@ -198,8 +210,8 @@ func resourceAwsDbSecurityGroupRead(d *schema.ResourceData, meta interface{}) er func resourceAwsDbSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.RdsUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating RDS DB Security Group (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_db_snapshot.go b/aws/resource_aws_db_snapshot.go index 1e5255216e2..1db3a063c3c 100644 --- a/aws/resource_aws_db_snapshot.go +++ b/aws/resource_aws_db_snapshot.go @@ -106,20 +106,24 @@ func resourceAwsDbSnapshot() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDbSnapshotCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().RdsTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) dBInstanceIdentifier := d.Get("db_instance_identifier").(string) params := &rds.CreateDBSnapshotInput{ DBInstanceIdentifier: aws.String(dBInstanceIdentifier), DBSnapshotIdentifier: aws.String(d.Get("db_snapshot_identifier").(string)), - Tags: tags, + Tags: tags.IgnoreAws().RdsTags(), } resp, err := conn.CreateDBSnapshot(params) @@ -148,6 +152,7 @@ func resourceAwsDbSnapshotCreate(d *schema.ResourceData, meta interface{}) error func resourceAwsDbSnapshotRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &rds.DescribeDBSnapshotsInput{ @@ -193,8 +198,15 @@ func resourceAwsDbSnapshotRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error listing tags for RDS DB Snapshot (%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 @@ -221,8 +233,8 @@ func resourceAwsDbSnapshotDelete(d *schema.ResourceData, meta interface{}) error func resourceAwsDbSnapshotUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).rdsconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.RdsUpdateTags(conn, d.Get("db_snapshot_arn").(string), o, n); err != nil { return fmt.Errorf("error updating RDS DB Snapshot (%s) tags: %s", d.Get("db_snapshot_arn").(string), err) diff --git a/aws/resource_aws_db_subnet_group.go b/aws/resource_aws_db_subnet_group.go index 9571be370e0..7a58a3013fc 100644 --- a/aws/resource_aws_db_subnet_group.go +++ b/aws/resource_aws_db_subnet_group.go @@ -60,14 +60,18 @@ func resourceAwsDbSubnetGroup() *schema.Resource { Set: schema.HashString, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) error { rdsconn := meta.(*AWSClient).rdsconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().RdsTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) subnetIdsSet := d.Get("subnet_ids").(*schema.Set) subnetIds := make([]*string, subnetIdsSet.Len()) @@ -88,7 +92,7 @@ func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) er DBSubnetGroupName: aws.String(groupName), DBSubnetGroupDescription: aws.String(d.Get("description").(string)), SubnetIds: subnetIds, - Tags: tags, + Tags: tags.IgnoreAws().RdsTags(), } log.Printf("[DEBUG] Create DB Subnet Group: %#v", createOpts) @@ -104,6 +108,7 @@ func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) er func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) error { rdsconn := meta.(*AWSClient).rdsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig describeOpts := rds.DescribeDBSubnetGroupsInput{ @@ -158,8 +163,15 @@ func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("error listing tags for RDS DB Subnet Group (%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 @@ -190,8 +202,8 @@ func resourceAwsDbSubnetGroupUpdate(d *schema.ResourceData, meta interface{}) er } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.RdsUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating RDS DB Subnet Group (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_default_network_acl.go b/aws/resource_aws_default_network_acl.go index a0ad9d815c5..51ec984d1c7 100644 --- a/aws/resource_aws_default_network_acl.go +++ b/aws/resource_aws_default_network_acl.go @@ -183,13 +183,16 @@ func resourceAwsDefaultNetworkAcl() *schema.Resource { Set: resourceAwsNetworkAclEntryHash, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "owner_id": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } @@ -272,8 +275,8 @@ func resourceAwsDefaultNetworkAclUpdate(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.Ec2UpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating EC2 Default Network ACL (%s) tags: %s", d.Id(), err) diff --git a/aws/resource_aws_default_route_table.go b/aws/resource_aws_default_route_table.go index fdf9f14d686..c61c9dfb954 100644 --- a/aws/resource_aws_default_route_table.go +++ b/aws/resource_aws_default_route_table.go @@ -125,7 +125,8 @@ func resourceAwsDefaultRouteTable() *schema.Resource { Set: resourceAwsRouteTableHash, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "arn": { Type: schema.TypeString, @@ -137,11 +138,15 @@ func resourceAwsDefaultRouteTable() *schema.Resource { Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDefaultRouteTableCreate(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{}))) routeTableID := d.Get("default_route_table_id").(string) routeTable, err := finder.RouteTableByID(conn, routeTableID) @@ -160,8 +165,8 @@ func resourceAwsDefaultRouteTableCreate(d *schema.ResourceData, meta interface{} return err } - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - if err := keyvaluetags.Ec2CreateTags(conn, d.Id(), v); err != nil { + if len(tags) > 0 { + if err := keyvaluetags.Ec2CreateTags(conn, d.Id(), tags); err != nil { return fmt.Errorf("error adding tags: %w", err) } } diff --git a/aws/resource_aws_default_security_group.go b/aws/resource_aws_default_security_group.go index 59177072b9a..e9cc15c11a1 100644 --- a/aws/resource_aws_default_security_group.go +++ b/aws/resource_aws_default_security_group.go @@ -177,7 +177,8 @@ func resourceAwsDefaultSecurityGroup() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), // This is not implemented. Added to prevent breaking changes. "revoke_rules_on_delete": { Type: schema.TypeBool, @@ -185,11 +186,15 @@ func resourceAwsDefaultSecurityGroup() *schema.Resource { Optional: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDefaultSecurityGroupCreate(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{}))) securityGroupOpts := &ec2.DescribeSecurityGroupsInput{ Filters: []*ec2.Filter{ { @@ -243,8 +248,8 @@ func resourceAwsDefaultSecurityGroupCreate(d *schema.ResourceData, meta interfac log.Printf("[INFO] Default Security Group ID: %s", d.Id()) - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - if err := keyvaluetags.Ec2CreateTags(conn, d.Id(), v); err != nil { + if len(tags) > 0 { + if err := keyvaluetags.Ec2CreateTags(conn, d.Id(), tags); err != nil { return fmt.Errorf("error adding EC2 Default Security Group (%s) tags: %w", d.Id(), err) } } @@ -258,6 +263,7 @@ func resourceAwsDefaultSecurityGroupCreate(d *schema.ResourceData, meta interfac func resourceAwsDefaultSecurityGroupRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).ec2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig group, err := finder.SecurityGroupByID(conn, d.Id()) @@ -303,8 +309,15 @@ func resourceAwsDefaultSecurityGroupRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("error setting Egress rule set for (%s): %w", d.Id(), err) } - if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(group.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags for (%s): %w", d.Id(), err) + tags := keyvaluetags.Ec2KeyValueTags(group.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 @@ -335,8 +348,8 @@ func resourceAwsDefaultSecurityGroupUpdate(d *schema.ResourceData, meta interfac } } - if d.HasChange("tags") && !d.IsNewResource() { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") && !d.IsNewResource() { + o, n := d.GetChange("tags_all") if err := keyvaluetags.Ec2UpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating EC2 Security Group (%s) tags: %w", d.Id(), err) diff --git a/aws/resource_aws_directory_service_directory.go b/aws/resource_aws_directory_service_directory.go index 3fbb8a36232..ca74e62535e 100644 --- a/aws/resource_aws_directory_service_directory.go +++ b/aws/resource_aws_directory_service_directory.go @@ -63,7 +63,8 @@ func resourceAwsDirectoryServiceDirectory() *schema.Resource { Computed: true, ForceNew: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "vpc_settings": { Type: schema.TypeList, MaxItems: 1, @@ -181,6 +182,8 @@ func resourceAwsDirectoryServiceDirectory() *schema.Resource { }, false), }, }, + + CustomizeDiff: SetTagsDiff, } } @@ -232,11 +235,14 @@ func buildConnectSettings(d *schema.ResourceData) (connectSettings *directoryser return connectSettings, nil } -func createDirectoryConnector(dsconn *directoryservice.DirectoryService, d *schema.ResourceData) (directoryId string, err error) { +func createDirectoryConnector(dsconn *directoryservice.DirectoryService, d *schema.ResourceData, meta interface{}) (directoryId string, err error) { + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) + input := directoryservice.ConnectDirectoryInput{ Name: aws.String(d.Get("name").(string)), Password: aws.String(d.Get("password").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DirectoryserviceTags(), + Tags: tags.IgnoreAws().DirectoryserviceTags(), } if v, ok := d.GetOk("description"); ok { @@ -267,11 +273,14 @@ func createDirectoryConnector(dsconn *directoryservice.DirectoryService, d *sche return *out.DirectoryId, nil } -func createSimpleDirectoryService(dsconn *directoryservice.DirectoryService, d *schema.ResourceData) (directoryId string, err error) { +func createSimpleDirectoryService(dsconn *directoryservice.DirectoryService, d *schema.ResourceData, meta interface{}) (directoryId string, err error) { + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) + input := directoryservice.CreateDirectoryInput{ Name: aws.String(d.Get("name").(string)), Password: aws.String(d.Get("password").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DirectoryserviceTags(), + Tags: tags.IgnoreAws().DirectoryserviceTags(), } if v, ok := d.GetOk("description"); ok { @@ -302,11 +311,14 @@ func createSimpleDirectoryService(dsconn *directoryservice.DirectoryService, d * return *out.DirectoryId, nil } -func createActiveDirectoryService(dsconn *directoryservice.DirectoryService, d *schema.ResourceData) (directoryId string, err error) { +func createActiveDirectoryService(dsconn *directoryservice.DirectoryService, d *schema.ResourceData, meta interface{}) (directoryId string, err error) { + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) + input := directoryservice.CreateMicrosoftADInput{ Name: aws.String(d.Get("name").(string)), Password: aws.String(d.Get("password").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DirectoryserviceTags(), + Tags: tags.IgnoreAws().DirectoryserviceTags(), } if v, ok := d.GetOk("description"); ok { @@ -362,11 +374,11 @@ func resourceAwsDirectoryServiceDirectoryCreate(d *schema.ResourceData, meta int directoryType := d.Get("type").(string) if directoryType == directoryservice.DirectoryTypeAdconnector { - directoryId, err = createDirectoryConnector(dsconn, d) + directoryId, err = createDirectoryConnector(dsconn, d, meta) } else if directoryType == directoryservice.DirectoryTypeMicrosoftAd { - directoryId, err = createActiveDirectoryService(dsconn, d) + directoryId, err = createActiveDirectoryService(dsconn, d, meta) } else if directoryType == directoryservice.DirectoryTypeSimpleAd { - directoryId, err = createSimpleDirectoryService(dsconn, d) + directoryId, err = createSimpleDirectoryService(dsconn, d, meta) } if err != nil { @@ -440,8 +452,8 @@ func resourceAwsDirectoryServiceDirectoryUpdate(d *schema.ResourceData, meta int } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DirectoryserviceUpdateTags(dsconn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating Directory Service Directory (%s) tags: %s", d.Id(), err) @@ -453,6 +465,7 @@ func resourceAwsDirectoryServiceDirectoryUpdate(d *schema.ResourceData, meta int func resourceAwsDirectoryServiceDirectoryRead(d *schema.ResourceData, meta interface{}) error { dsconn := meta.(*AWSClient).dsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := directoryservice.DescribeDirectoriesInput{ @@ -510,8 +523,15 @@ func resourceAwsDirectoryServiceDirectoryRead(d *schema.ResourceData, meta inter return fmt.Errorf("error listing tags for Directory Service Directory (%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 diff --git a/aws/resource_aws_dlm_lifecycle_policy.go b/aws/resource_aws_dlm_lifecycle_policy.go index f52ed13360a..84ddf345ff0 100644 --- a/aws/resource_aws_dlm_lifecycle_policy.go +++ b/aws/resource_aws_dlm_lifecycle_policy.go @@ -137,13 +137,18 @@ func resourceAwsDlmLifecyclePolicy() *schema.Resource { dlm.SettablePolicyStateValuesEnabled, }, false), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDlmLifecyclePolicyCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dlmconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) input := dlm.CreateLifecyclePolicyInput{ Description: aws.String(d.Get("description").(string)), @@ -152,8 +157,8 @@ func resourceAwsDlmLifecyclePolicyCreate(d *schema.ResourceData, meta interface{ State: aws.String(d.Get("state").(string)), } - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - input.Tags = keyvaluetags.New(v).IgnoreAws().DlmTags() + if len(tags) > 0 { + input.Tags = tags.IgnoreAws().DlmTags() } log.Printf("[INFO] Creating DLM lifecycle policy: %s", input) @@ -169,6 +174,7 @@ func resourceAwsDlmLifecyclePolicyCreate(d *schema.ResourceData, meta interface{ func resourceAwsDlmLifecyclePolicyRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dlmconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig log.Printf("[INFO] Reading DLM lifecycle policy: %s", d.Id()) @@ -194,8 +200,15 @@ func resourceAwsDlmLifecyclePolicyRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error setting policy details %s", err) } - if err := d.Set("tags", keyvaluetags.DlmKeyValueTags(out.Policy.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.DlmKeyValueTags(out.Policy.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 @@ -234,8 +247,8 @@ func resourceAwsDlmLifecyclePolicyUpdate(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.DlmUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating tags: %s", err) } diff --git a/aws/resource_aws_dms_certificate.go b/aws/resource_aws_dms_certificate.go index 1acb17759f7..dee8cd39588 100644 --- a/aws/resource_aws_dms_certificate.go +++ b/aws/resource_aws_dms_certificate.go @@ -53,18 +53,23 @@ func resourceAwsDmsCertificate() *schema.Resource { ForceNew: true, Sensitive: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDmsCertificateCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) certificateID := d.Get("certificate_id").(string) request := &dms.ImportCertificateInput{ CertificateIdentifier: aws.String(certificateID), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatabasemigrationserviceTags(), + Tags: tags.IgnoreAws().DatabasemigrationserviceTags(), } pem, pemSet := d.GetOk("certificate_pem") @@ -99,6 +104,7 @@ func resourceAwsDmsCertificateCreate(d *schema.ResourceData, meta interface{}) e func resourceAwsDmsCertificateRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig response, err := conn.DescribeCertificates(&dms.DescribeCertificatesInput{ @@ -140,19 +146,26 @@ func resourceAwsDmsCertificateRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("error listing tags for DMS Certificate (%s): %w", d.Get("certificate_arn").(string), 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 resourceAwsDmsCertificateUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn - if d.HasChange("tags") { + if d.HasChange("tags_all") { arn := d.Get("certificate_arn").(string) - o, n := d.GetChange("tags") + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatabasemigrationserviceUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating DMS Certificate (%s) tags: %w", arn, err) diff --git a/aws/resource_aws_dms_endpoint.go b/aws/resource_aws_dms_endpoint.go index 9aad32ba2e4..b747aa67249 100644 --- a/aws/resource_aws_dms_endpoint.go +++ b/aws/resource_aws_dms_endpoint.go @@ -328,23 +328,28 @@ func resourceAwsDmsEndpoint() *schema.Resource { dms.DmsSslModeValueVerifyFull, }, false), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "username": { Type: schema.TypeString, Optional: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDmsEndpointCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) request := &dms.CreateEndpointInput{ EndpointIdentifier: aws.String(d.Get("endpoint_id").(string)), EndpointType: aws.String(d.Get("endpoint_type").(string)), EngineName: aws.String(d.Get("engine_name").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatabasemigrationserviceTags(), + Tags: tags.IgnoreAws().DatabasemigrationserviceTags(), } switch d.Get("engine_name").(string) { @@ -461,6 +466,7 @@ func resourceAwsDmsEndpointCreate(d *schema.ResourceData, meta interface{}) erro func resourceAwsDmsEndpointRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig response, err := conn.DescribeEndpoints(&dms.DescribeEndpointsInput{ @@ -491,8 +497,15 @@ func resourceAwsDmsEndpointRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("error listing tags for DMS Endpoint (%s): %s", d.Get("endpoint_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 @@ -543,9 +556,9 @@ func resourceAwsDmsEndpointUpdate(d *schema.ResourceData, meta interface{}) erro hasChanges = true } - if d.HasChange("tags") { + if d.HasChange("tags_all") { arn := d.Get("endpoint_arn").(string) - o, n := d.GetChange("tags") + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatabasemigrationserviceUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating DMS Endpoint (%s) tags: %s", arn, err) diff --git a/aws/resource_aws_dms_event_subscription.go b/aws/resource_aws_dms_event_subscription.go index 8c90c7c900c..643cc77fba0 100644 --- a/aws/resource_aws_dms_event_subscription.go +++ b/aws/resource_aws_dms_event_subscription.go @@ -74,20 +74,25 @@ func resourceAwsDmsEventSubscription() *schema.Resource { "replication-task", }, false), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDmsEventSubscriptionCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) request := &dms.CreateEventSubscriptionInput{ Enabled: aws.Bool(d.Get("enabled").(bool)), SnsTopicArn: aws.String(d.Get("sns_topic_arn").(string)), SubscriptionName: aws.String(d.Get("name").(string)), SourceType: aws.String(d.Get("source_type").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatabasemigrationserviceTags(), + Tags: tags.IgnoreAws().DatabasemigrationserviceTags(), } if v, ok := d.GetOk("event_categories"); ok { @@ -159,8 +164,8 @@ func resourceAwsDmsEventSubscriptionUpdate(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.DatabasemigrationserviceUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating DMS Event Subscription (%s) tags: %s", d.Get("arn").(string), err) @@ -172,6 +177,7 @@ func resourceAwsDmsEventSubscriptionUpdate(d *schema.ResourceData, meta interfac func resourceAwsDmsEventSubscriptionRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig request := &dms.DescribeEventSubscriptionsInput{ @@ -220,8 +226,15 @@ func resourceAwsDmsEventSubscriptionRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("error listing tags for DMS Event Subscription (%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 diff --git a/aws/resource_aws_dms_replication_instance.go b/aws/resource_aws_dms_replication_instance.go index 2fc4c92f9de..0a6a0b3c75c 100644 --- a/aws/resource_aws_dms_replication_instance.go +++ b/aws/resource_aws_dms_replication_instance.go @@ -117,7 +117,8 @@ func resourceAwsDmsReplicationInstance() *schema.Resource { Optional: true, ForceNew: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "vpc_security_group_ids": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, @@ -126,11 +127,15 @@ func resourceAwsDmsReplicationInstance() *schema.Resource { Optional: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDmsReplicationInstanceCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) request := &dms.CreateReplicationInstanceInput{ AutoMinorVersionUpgrade: aws.Bool(d.Get("auto_minor_version_upgrade").(bool)), @@ -138,7 +143,7 @@ func resourceAwsDmsReplicationInstanceCreate(d *schema.ResourceData, meta interf MultiAZ: aws.Bool(d.Get("multi_az").(bool)), ReplicationInstanceClass: aws.String(d.Get("replication_instance_class").(string)), ReplicationInstanceIdentifier: aws.String(d.Get("replication_instance_id").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatabasemigrationserviceTags(), + Tags: tags.IgnoreAws().DatabasemigrationserviceTags(), } // WARNING: GetOk returns the zero value for the type if the key is omitted in config. This means for optional @@ -196,6 +201,7 @@ func resourceAwsDmsReplicationInstanceCreate(d *schema.ResourceData, meta interf func resourceAwsDmsReplicationInstanceRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig response, err := conn.DescribeReplicationInstances(&dms.DescribeReplicationInstancesInput{ @@ -262,8 +268,15 @@ func resourceAwsDmsReplicationInstanceRead(d *schema.ResourceData, meta interfac return fmt.Errorf("error listing tags for DMS Replication Instance (%s): %s", d.Get("replication_instance_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 @@ -327,9 +340,9 @@ func resourceAwsDmsReplicationInstanceUpdate(d *schema.ResourceData, meta interf } } - if d.HasChange("tags") { + if d.HasChange("tags_all") { arn := d.Get("replication_instance_arn").(string) - o, n := d.GetChange("tags") + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatabasemigrationserviceUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating DMS Replication Instance (%s) tags: %s", arn, err) diff --git a/aws/resource_aws_dms_replication_subnet_group.go b/aws/resource_aws_dms_replication_subnet_group.go index 5a13040c780..3d2d52c45b6 100644 --- a/aws/resource_aws_dms_replication_subnet_group.go +++ b/aws/resource_aws_dms_replication_subnet_group.go @@ -43,23 +43,28 @@ func resourceAwsDmsReplicationSubnetGroup() *schema.Resource { Set: schema.HashString, Required: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "vpc_id": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDmsReplicationSubnetGroupCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) request := &dms.CreateReplicationSubnetGroupInput{ ReplicationSubnetGroupIdentifier: aws.String(d.Get("replication_subnet_group_id").(string)), ReplicationSubnetGroupDescription: aws.String(d.Get("replication_subnet_group_description").(string)), SubnetIds: expandStringSet(d.Get("subnet_ids").(*schema.Set)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatabasemigrationserviceTags(), + Tags: tags.IgnoreAws().DatabasemigrationserviceTags(), } log.Println("[DEBUG] DMS create replication subnet group:", request) @@ -75,6 +80,7 @@ func resourceAwsDmsReplicationSubnetGroupCreate(d *schema.ResourceData, meta int func resourceAwsDmsReplicationSubnetGroupRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig response, err := conn.DescribeReplicationSubnetGroups(&dms.DescribeReplicationSubnetGroupsInput{ @@ -115,8 +121,15 @@ func resourceAwsDmsReplicationSubnetGroupRead(d *schema.ResourceData, meta inter return fmt.Errorf("error listing tags for DMS Replication Subnet Group (%s): %s", arn, err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } return nil @@ -136,9 +149,9 @@ func resourceAwsDmsReplicationSubnetGroupUpdate(d *schema.ResourceData, meta int request.ReplicationSubnetGroupDescription = aws.String(d.Get("replication_subnet_group_description").(string)) } - if d.HasChange("tags") { + if d.HasChange("tags_all") { arn := d.Get("replication_subnet_group_arn").(string) - o, n := d.GetChange("tags") + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatabasemigrationserviceUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating DMS Replication Subnet Group (%s) tags: %s", arn, err) diff --git a/aws/resource_aws_dms_replication_task.go b/aws/resource_aws_dms_replication_task.go index dc946b38618..814b2cc3669 100644 --- a/aws/resource_aws_dms_replication_task.go +++ b/aws/resource_aws_dms_replication_task.go @@ -76,7 +76,8 @@ func resourceAwsDmsReplicationTask() *schema.Resource { ValidateFunc: validation.StringIsJSON, DiffSuppressFunc: suppressEquivalentJsonDiffs, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "target_endpoint_arn": { Type: schema.TypeString, Required: true, @@ -84,11 +85,15 @@ func resourceAwsDmsReplicationTask() *schema.Resource { ValidateFunc: validateArn, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDmsReplicationTaskCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) request := &dms.CreateReplicationTaskInput{ MigrationType: aws.String(d.Get("migration_type").(string)), @@ -96,7 +101,7 @@ func resourceAwsDmsReplicationTaskCreate(d *schema.ResourceData, meta interface{ ReplicationTaskIdentifier: aws.String(d.Get("replication_task_id").(string)), SourceEndpointArn: aws.String(d.Get("source_endpoint_arn").(string)), TableMappings: aws.String(d.Get("table_mappings").(string)), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DatabasemigrationserviceTags(), + Tags: tags.IgnoreAws().DatabasemigrationserviceTags(), TargetEndpointArn: aws.String(d.Get("target_endpoint_arn").(string)), } @@ -142,6 +147,7 @@ func resourceAwsDmsReplicationTaskCreate(d *schema.ResourceData, meta interface{ func resourceAwsDmsReplicationTaskRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dmsconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig response, err := conn.DescribeReplicationTasks(&dms.DescribeReplicationTasksInput{ @@ -172,8 +178,15 @@ func resourceAwsDmsReplicationTaskRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error listing tags for DMS Replication Task (%s): %s", d.Get("replication_task_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 @@ -211,9 +224,9 @@ func resourceAwsDmsReplicationTaskUpdate(d *schema.ResourceData, meta interface{ hasChanges = true } - if d.HasChange("tags") { + if d.HasChange("tags_all") { arn := d.Get("replication_task_arn").(string) - o, n := d.GetChange("tags") + o, n := d.GetChange("tags_all") if err := keyvaluetags.DatabasemigrationserviceUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating DMS Replication Task (%s) tags: %s", arn, err) diff --git a/aws/resource_aws_docdb_cluster.go b/aws/resource_aws_docdb_cluster.go index 0fc7936aa54..420585a7c46 100644 --- a/aws/resource_aws_docdb_cluster.go +++ b/aws/resource_aws_docdb_cluster.go @@ -242,8 +242,11 @@ func resourceAwsDocDBCluster() *schema.Resource { Optional: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } @@ -258,7 +261,8 @@ func resourceAwsDocDBClusterImport( func resourceAwsDocDBClusterCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).docdbconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DocdbTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) // Some API calls (e.g. RestoreDBClusterFromSnapshot do not support all // parameters to correctly apply all settings in one pass. For missing @@ -285,7 +289,7 @@ func resourceAwsDocDBClusterCreate(d *schema.ResourceData, meta interface{}) err Engine: aws.String(d.Get("engine").(string)), SnapshotIdentifier: aws.String(d.Get("snapshot_identifier").(string)), DeletionProtection: aws.Bool(d.Get("deletion_protection").(bool)), - Tags: tags, + Tags: tags.IgnoreAws().DocdbTags(), } if attr := d.Get("availability_zones").(*schema.Set); attr.Len() > 0 { @@ -368,7 +372,7 @@ func resourceAwsDocDBClusterCreate(d *schema.ResourceData, meta interface{}) err MasterUserPassword: aws.String(d.Get("master_password").(string)), MasterUsername: aws.String(d.Get("master_username").(string)), DeletionProtection: aws.Bool(d.Get("deletion_protection").(bool)), - Tags: tags, + Tags: tags.IgnoreAws().DocdbTags(), } if attr, ok := d.GetOk("port"); ok { @@ -485,6 +489,7 @@ func resourceAwsDocDBClusterCreate(d *schema.ResourceData, meta interface{}) err func resourceAwsDocDBClusterRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).docdbconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig input := &docdb.DescribeDBClustersInput{ @@ -575,8 +580,15 @@ func resourceAwsDocDBClusterRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("error listing tags for DocumentDB Cluster (%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 @@ -674,8 +686,8 @@ func resourceAwsDocDBClusterUpdate(d *schema.ResourceData, meta interface{}) err } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DocdbUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating DocumentDB Cluster (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_docdb_cluster_instance.go b/aws/resource_aws_docdb_cluster_instance.go index 0aeb939cab3..71e4c980006 100644 --- a/aws/resource_aws_docdb_cluster_instance.go +++ b/aws/resource_aws_docdb_cluster_instance.go @@ -166,19 +166,23 @@ func resourceAwsDocDBClusterInstance() *schema.Resource { Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "writer": { Type: schema.TypeBool, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDocDBClusterInstanceCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).docdbconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DocdbTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) createOpts := &docdb.CreateDBInstanceInput{ DBInstanceClass: aws.String(d.Get("instance_class").(string)), @@ -186,7 +190,7 @@ func resourceAwsDocDBClusterInstanceCreate(d *schema.ResourceData, meta interfac Engine: aws.String(d.Get("engine").(string)), PromotionTier: aws.Int64(int64(d.Get("promotion_tier").(int))), AutoMinorVersionUpgrade: aws.Bool(d.Get("auto_minor_version_upgrade").(bool)), - Tags: tags, + Tags: tags.IgnoreAws().DocdbTags(), } if attr, ok := d.GetOk("availability_zone"); ok { @@ -250,6 +254,7 @@ func resourceAwsDocDBClusterInstanceCreate(d *schema.ResourceData, meta interfac func resourceAwsDocDBClusterInstanceRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).docdbconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig db, err := resourceAwsDocDBInstanceRetrieve(d.Id(), conn) @@ -323,8 +328,15 @@ func resourceAwsDocDBClusterInstanceRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("error listing tags for DocumentDB Cluster Instance (%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 @@ -402,8 +414,8 @@ func resourceAwsDocDBClusterInstanceUpdate(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.DocdbUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating DocumentDB Cluster Instance (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_docdb_cluster_parameter_group.go b/aws/resource_aws_docdb_cluster_parameter_group.go index 8e05358fd0b..505c2824c6b 100644 --- a/aws/resource_aws_docdb_cluster_parameter_group.go +++ b/aws/resource_aws_docdb_cluster_parameter_group.go @@ -84,15 +84,19 @@ func resourceAwsDocDBClusterParameterGroup() *schema.Resource { }, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDocDBClusterParameterGroupCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).docdbconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DocdbTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) var groupName string if v, ok := d.GetOk("name"); ok { @@ -107,7 +111,7 @@ func resourceAwsDocDBClusterParameterGroupCreate(d *schema.ResourceData, meta in DBClusterParameterGroupName: aws.String(groupName), DBParameterGroupFamily: aws.String(d.Get("family").(string)), Description: aws.String(d.Get("description").(string)), - Tags: tags, + Tags: tags.IgnoreAws().DocdbTags(), } log.Printf("[DEBUG] Create DocDB Cluster Parameter Group: %#v", createOpts) @@ -126,6 +130,7 @@ func resourceAwsDocDBClusterParameterGroupCreate(d *schema.ResourceData, meta in func resourceAwsDocDBClusterParameterGroupRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).docdbconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig describeOpts := &docdb.DescribeDBClusterParameterGroupsInput{ @@ -172,8 +177,15 @@ func resourceAwsDocDBClusterParameterGroupRead(d *schema.ResourceData, meta inte return fmt.Errorf("error listing tags for DocumentDB Cluster Parameter Group (%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 @@ -225,8 +237,8 @@ func resourceAwsDocDBClusterParameterGroupUpdate(d *schema.ResourceData, meta in } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DocdbUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating DocumentDB Cluster Parameter Group (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_docdb_subnet_group.go b/aws/resource_aws_docdb_subnet_group.go index ff1cef0d9fd..095613151aa 100644 --- a/aws/resource_aws_docdb_subnet_group.go +++ b/aws/resource_aws_docdb_subnet_group.go @@ -59,14 +59,18 @@ func resourceAwsDocDBSubnetGroup() *schema.Resource { Set: schema.HashString, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDocDBSubnetGroupCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).docdbconn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DocdbTags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) subnetIds := expandStringSet(d.Get("subnet_ids").(*schema.Set)) @@ -83,7 +87,7 @@ func resourceAwsDocDBSubnetGroupCreate(d *schema.ResourceData, meta interface{}) DBSubnetGroupName: aws.String(groupName), DBSubnetGroupDescription: aws.String(d.Get("description").(string)), SubnetIds: subnetIds, - Tags: tags, + Tags: tags.IgnoreAws().DocdbTags(), } log.Printf("[DEBUG] Create DocDB Subnet Group: %#v", createOpts) @@ -99,6 +103,7 @@ func resourceAwsDocDBSubnetGroupCreate(d *schema.ResourceData, meta interface{}) func resourceAwsDocDBSubnetGroupRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).docdbconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig describeOpts := docdb.DescribeDBSubnetGroupsInput{ @@ -142,8 +147,15 @@ func resourceAwsDocDBSubnetGroupRead(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("error listing tags for DocumentDB Subnet Group (%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 @@ -170,8 +182,8 @@ func resourceAwsDocDBSubnetGroupUpdate(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.DocdbUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating DocumentDB Subnet Group (%s) tags: %s", d.Get("arn").(string), err) diff --git a/aws/resource_aws_dx_connection.go b/aws/resource_aws_dx_connection.go index 48778945c90..b458a7d9e4e 100644 --- a/aws/resource_aws_dx_connection.go +++ b/aws/resource_aws_dx_connection.go @@ -48,7 +48,8 @@ func resourceAwsDxConnection() *schema.Resource { Type: schema.TypeBool, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "has_logical_redundancy": { Type: schema.TypeString, Computed: true, @@ -58,11 +59,15 @@ func resourceAwsDxConnection() *schema.Resource { Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDxConnectionCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) req := &directconnect.CreateConnectionInput{ Bandwidth: aws.String(d.Get("bandwidth").(string)), @@ -70,8 +75,8 @@ func resourceAwsDxConnectionCreate(d *schema.ResourceData, meta interface{}) err Location: aws.String(d.Get("location").(string)), } - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - req.Tags = keyvaluetags.New(v).IgnoreAws().DirectconnectTags() + if len(tags) > 0 { + req.Tags = tags.IgnoreAws().DirectconnectTags() } log.Printf("[DEBUG] Creating Direct Connect connection: %#v", req) @@ -87,6 +92,7 @@ func resourceAwsDxConnectionCreate(d *schema.ResourceData, meta interface{}) err func resourceAwsDxConnectionRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig resp, err := conn.DescribeConnections(&directconnect.DescribeConnectionsInput{ @@ -140,8 +146,15 @@ func resourceAwsDxConnectionRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("error listing tags for Direct Connect connection (%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 @@ -151,8 +164,8 @@ func resourceAwsDxConnectionUpdate(d *schema.ResourceData, meta interface{}) err conn := meta.(*AWSClient).dxconn 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.DirectconnectUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating Direct Connect connection (%s) tags: %s", arn, err) diff --git a/aws/resource_aws_dx_hosted_private_virtual_interface_accepter.go b/aws/resource_aws_dx_hosted_private_virtual_interface_accepter.go index c02087be59f..c1e676221eb 100644 --- a/aws/resource_aws_dx_hosted_private_virtual_interface_accepter.go +++ b/aws/resource_aws_dx_hosted_private_virtual_interface_accepter.go @@ -33,7 +33,8 @@ func resourceAwsDxHostedPrivateVirtualInterfaceAccepter() *schema.Resource { ForceNew: true, ConflictsWith: []string{"vpn_gateway_id"}, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "virtual_interface_id": { Type: schema.TypeString, Required: true, @@ -51,6 +52,8 @@ func resourceAwsDxHostedPrivateVirtualInterfaceAccepter() *schema.Resource { Create: schema.DefaultTimeout(10 * time.Minute), Delete: schema.DefaultTimeout(10 * time.Minute), }, + + CustomizeDiff: SetTagsDiff, } } @@ -100,6 +103,7 @@ func resourceAwsDxHostedPrivateVirtualInterfaceAccepterCreate(d *schema.Resource func resourceAwsDxHostedPrivateVirtualInterfaceAccepterRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig vif, err := dxVirtualInterfaceRead(d.Id(), conn) @@ -130,8 +134,15 @@ func resourceAwsDxHostedPrivateVirtualInterfaceAccepterRead(d *schema.ResourceDa return fmt.Errorf("error listing tags for Direct Connect hosted private virtual interface (%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 diff --git a/aws/resource_aws_dx_hosted_public_virtual_interface_accepter.go b/aws/resource_aws_dx_hosted_public_virtual_interface_accepter.go index e55d418b657..89b82a531b8 100644 --- a/aws/resource_aws_dx_hosted_public_virtual_interface_accepter.go +++ b/aws/resource_aws_dx_hosted_public_virtual_interface_accepter.go @@ -27,7 +27,8 @@ func resourceAwsDxHostedPublicVirtualInterfaceAccepter() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "virtual_interface_id": { Type: schema.TypeString, Required: true, @@ -39,6 +40,8 @@ func resourceAwsDxHostedPublicVirtualInterfaceAccepter() *schema.Resource { Create: schema.DefaultTimeout(10 * time.Minute), Delete: schema.DefaultTimeout(10 * time.Minute), }, + + CustomizeDiff: SetTagsDiff, } } @@ -75,6 +78,7 @@ func resourceAwsDxHostedPublicVirtualInterfaceAccepterCreate(d *schema.ResourceD func resourceAwsDxHostedPublicVirtualInterfaceAccepterRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig vif, err := dxVirtualInterfaceRead(d.Id(), conn) @@ -104,8 +108,15 @@ func resourceAwsDxHostedPublicVirtualInterfaceAccepterRead(d *schema.ResourceDat return fmt.Errorf("error listing tags for Direct Connect hosted public virtual interface (%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 diff --git a/aws/resource_aws_dx_hosted_transit_virtual_interface_accepter.go b/aws/resource_aws_dx_hosted_transit_virtual_interface_accepter.go index df7a8749854..0994f762ea9 100644 --- a/aws/resource_aws_dx_hosted_transit_virtual_interface_accepter.go +++ b/aws/resource_aws_dx_hosted_transit_virtual_interface_accepter.go @@ -32,7 +32,8 @@ func resourceAwsDxHostedTransitVirtualInterfaceAccepter() *schema.Resource { Required: true, ForceNew: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "virtual_interface_id": { Type: schema.TypeString, Required: true, @@ -44,6 +45,8 @@ func resourceAwsDxHostedTransitVirtualInterfaceAccepter() *schema.Resource { Create: schema.DefaultTimeout(10 * time.Minute), Delete: schema.DefaultTimeout(10 * time.Minute), }, + + CustomizeDiff: SetTagsDiff, } } @@ -81,6 +84,7 @@ func resourceAwsDxHostedTransitVirtualInterfaceAccepterCreate(d *schema.Resource func resourceAwsDxHostedTransitVirtualInterfaceAccepterRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig vif, err := dxVirtualInterfaceRead(d.Id(), conn) @@ -109,8 +113,15 @@ func resourceAwsDxHostedTransitVirtualInterfaceAccepterRead(d *schema.ResourceDa return fmt.Errorf("error listing tags for Direct Connect hosted transit virtual interface (%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 diff --git a/aws/resource_aws_dx_lag.go b/aws/resource_aws_dx_lag.go index 0e98112493f..75c4ee41aac 100644 --- a/aws/resource_aws_dx_lag.go +++ b/aws/resource_aws_dx_lag.go @@ -52,17 +52,22 @@ func resourceAwsDxLag() *schema.Resource { Type: schema.TypeBool, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "has_logical_redundancy": { Type: schema.TypeString, Computed: true, }, }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDxLagCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) req := &directconnect.CreateLagInput{ ConnectionsBandwidth: aws.String(d.Get("connections_bandwidth").(string)), @@ -71,8 +76,8 @@ func resourceAwsDxLagCreate(d *schema.ResourceData, meta interface{}) error { NumberOfConnections: aws.Int64(int64(1)), } - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - req.Tags = keyvaluetags.New(v).IgnoreAws().DirectconnectTags() + if len(tags) > 0 { + req.Tags = tags.IgnoreAws().DirectconnectTags() } log.Printf("[DEBUG] Creating Direct Connect LAG: %#v", req) @@ -99,6 +104,7 @@ func resourceAwsDxLagCreate(d *schema.ResourceData, meta interface{}) error { func resourceAwsDxLagRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig resp, err := conn.DescribeLags(&directconnect.DescribeLagsInput{ @@ -152,8 +158,15 @@ func resourceAwsDxLagRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error listing tags for Direct Connect LAG (%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 @@ -176,8 +189,8 @@ func resourceAwsDxLagUpdate(d *schema.ResourceData, meta interface{}) error { } 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.DirectconnectUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating Direct Connect LAG (%s) tags: %s", arn, err) diff --git a/aws/resource_aws_dx_private_virtual_interface.go b/aws/resource_aws_dx_private_virtual_interface.go index 2fdb81a2d45..cc01ccc284d 100644 --- a/aws/resource_aws_dx_private_virtual_interface.go +++ b/aws/resource_aws_dx_private_virtual_interface.go @@ -95,7 +95,8 @@ func resourceAwsDxPrivateVirtualInterface() *schema.Resource { Required: true, ForceNew: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "vlan": { Type: schema.TypeInt, Required: true, @@ -115,11 +116,15 @@ func resourceAwsDxPrivateVirtualInterface() *schema.Resource { Update: schema.DefaultTimeout(10 * time.Minute), Delete: schema.DefaultTimeout(10 * time.Minute), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDxPrivateVirtualInterfaceCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) vgwIdRaw, vgwOk := d.GetOk("vpn_gateway_id") dxgwIdRaw, dxgwOk := d.GetOk("dx_gateway_id") @@ -153,8 +158,8 @@ func resourceAwsDxPrivateVirtualInterfaceCreate(d *schema.ResourceData, meta int if v, ok := d.GetOk("customer_address"); ok { req.NewPrivateVirtualInterface.CustomerAddress = aws.String(v.(string)) } - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - req.NewPrivateVirtualInterface.Tags = keyvaluetags.New(v).IgnoreAws().DirectconnectTags() + if len(tags) > 0 { + req.NewPrivateVirtualInterface.Tags = tags.IgnoreAws().DirectconnectTags() } log.Printf("[DEBUG] Creating Direct Connect private virtual interface: %s", req) @@ -174,6 +179,7 @@ func resourceAwsDxPrivateVirtualInterfaceCreate(d *schema.ResourceData, meta int func resourceAwsDxPrivateVirtualInterfaceRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig vif, err := dxVirtualInterfaceRead(d.Id(), conn) @@ -215,8 +221,15 @@ func resourceAwsDxPrivateVirtualInterfaceRead(d *schema.ResourceData, meta inter return fmt.Errorf("error listing tags for Direct Connect private virtual interface (%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 diff --git a/aws/resource_aws_dx_public_virtual_interface.go b/aws/resource_aws_dx_public_virtual_interface.go index 79419b843d7..8ba4d5c373d 100644 --- a/aws/resource_aws_dx_public_virtual_interface.go +++ b/aws/resource_aws_dx_public_virtual_interface.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/service/directconnect" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" @@ -24,7 +25,10 @@ func resourceAwsDxPublicVirtualInterface() *schema.Resource { Importer: &schema.ResourceImporter{ State: resourceAwsDxPublicVirtualInterfaceImport, }, - CustomizeDiff: resourceAwsDxPublicVirtualInterfaceCustomizeDiff, + CustomizeDiff: customdiff.Sequence( + resourceAwsDxPublicVirtualInterfaceCustomizeDiff, + SetTagsDiff, + ), Schema: map[string]*schema.Schema{ "address_family": { @@ -88,7 +92,8 @@ func resourceAwsDxPublicVirtualInterface() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, MinItems: 1, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "vlan": { Type: schema.TypeInt, Required: true, @@ -106,6 +111,8 @@ func resourceAwsDxPublicVirtualInterface() *schema.Resource { func resourceAwsDxPublicVirtualInterfaceCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) req := &directconnect.CreatePublicVirtualInterfaceInput{ ConnectionId: aws.String(d.Get("connection_id").(string)), @@ -128,8 +135,8 @@ func resourceAwsDxPublicVirtualInterfaceCreate(d *schema.ResourceData, meta inte if v, ok := d.GetOk("route_filter_prefixes"); ok { req.NewPublicVirtualInterface.RouteFilterPrefixes = expandDxRouteFilterPrefixes(v.(*schema.Set)) } - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - req.NewPublicVirtualInterface.Tags = keyvaluetags.New(v).IgnoreAws().DirectconnectTags() + if len(tags) > 0 { + req.NewPublicVirtualInterface.Tags = tags.IgnoreAws().DirectconnectTags() } log.Printf("[DEBUG] Creating Direct Connect public virtual interface: %s", req) @@ -149,6 +156,7 @@ func resourceAwsDxPublicVirtualInterfaceCreate(d *schema.ResourceData, meta inte func resourceAwsDxPublicVirtualInterfaceRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig vif, err := dxVirtualInterfaceRead(d.Id(), conn) @@ -189,8 +197,15 @@ func resourceAwsDxPublicVirtualInterfaceRead(d *schema.ResourceData, meta interf return fmt.Errorf("error listing tags for Direct Connect public virtual interface (%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 diff --git a/aws/resource_aws_dx_transit_virtual_interface.go b/aws/resource_aws_dx_transit_virtual_interface.go index b15681f6ca5..57ec561800d 100644 --- a/aws/resource_aws_dx_transit_virtual_interface.go +++ b/aws/resource_aws_dx_transit_virtual_interface.go @@ -94,7 +94,8 @@ func resourceAwsDxTransitVirtualInterface() *schema.Resource { Required: true, ForceNew: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "vlan": { Type: schema.TypeInt, Required: true, @@ -108,11 +109,15 @@ func resourceAwsDxTransitVirtualInterface() *schema.Resource { Update: schema.DefaultTimeout(10 * time.Minute), Delete: schema.DefaultTimeout(10 * time.Minute), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsDxTransitVirtualInterfaceCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) req := &directconnect.CreateTransitVirtualInterfaceInput{ ConnectionId: aws.String(d.Get("connection_id").(string)), @@ -134,8 +139,8 @@ func resourceAwsDxTransitVirtualInterfaceCreate(d *schema.ResourceData, meta int if v, ok := d.GetOk("customer_address"); ok { req.NewTransitVirtualInterface.CustomerAddress = aws.String(v.(string)) } - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - req.NewTransitVirtualInterface.Tags = keyvaluetags.New(v).IgnoreAws().DirectconnectTags() + if len(tags) > 0 { + req.NewTransitVirtualInterface.Tags = tags.IgnoreAws().DirectconnectTags() } log.Printf("[DEBUG] Creating Direct Connect transit virtual interface: %s", req) @@ -155,6 +160,7 @@ func resourceAwsDxTransitVirtualInterfaceCreate(d *schema.ResourceData, meta int func resourceAwsDxTransitVirtualInterfaceRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dxconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig vif, err := dxVirtualInterfaceRead(d.Id(), conn) @@ -195,8 +201,15 @@ func resourceAwsDxTransitVirtualInterfaceRead(d *schema.ResourceData, meta inter return fmt.Errorf("error listing tags for Direct Connect transit virtual interface (%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 diff --git a/aws/resource_aws_dynamodb_table.go b/aws/resource_aws_dynamodb_table.go index 5c7985acf50..6c89d75b909 100644 --- a/aws/resource_aws_dynamodb_table.go +++ b/aws/resource_aws_dynamodb_table.go @@ -63,6 +63,7 @@ func resourceAwsDynamoDbTable() *schema.Resource { } return nil }, + SetTagsDiff, ), SchemaVersion: 1, @@ -283,7 +284,8 @@ func resourceAwsDynamoDbTable() *schema.Resource { dynamodb.StreamViewTypeKeysOnly, }, false), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "ttl": { Type: schema.TypeList, Optional: true, @@ -299,6 +301,12 @@ func resourceAwsDynamoDbTable() *schema.Resource { Optional: true, Default: false, }, + "kms_key_arn": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validateArn, + }, }, }, DiffSuppressFunc: suppressMissingOptionalConfigurationBlock, @@ -313,6 +321,8 @@ func resourceAwsDynamoDbTable() *schema.Resource { func resourceAwsDynamoDbTableCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dynamodbconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) keySchemaMap := map[string]interface{}{ "hash_key": d.Get("hash_key").(string), @@ -323,13 +333,11 @@ func resourceAwsDynamoDbTableCreate(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] Creating DynamoDB table with key schema: %#v", keySchemaMap) - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().DynamodbTags() - req := &dynamodb.CreateTableInput{ TableName: aws.String(d.Get("name").(string)), BillingMode: aws.String(d.Get("billing_mode").(string)), KeySchema: expandDynamoDbKeySchema(keySchemaMap), - Tags: tags, + Tags: tags.IgnoreAws().DynamodbTags(), } billingMode := d.Get("billing_mode").(string) @@ -463,6 +471,7 @@ func resourceAwsDynamoDbTableCreate(d *schema.ResourceData, meta interface{}) er func resourceAwsDynamoDbTableRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).dynamodbconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig result, err := conn.DescribeTable(&dynamodb.DescribeTableInput{ @@ -575,10 +584,17 @@ func resourceAwsDynamoDbTableRead(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("error listing tags for DynamoDB Table (%s): %w", d.Get("arn").(string), 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 } @@ -745,8 +761,8 @@ func resourceAwsDynamoDbTableUpdate(d *schema.ResourceData, meta interface{}) er } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.DynamodbUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { return fmt.Errorf("error updating DynamoDB Table (%s) tags: %w", d.Id(), err) } diff --git a/website/docs/r/datapipeline_pipeline.html.markdown b/website/docs/r/datapipeline_pipeline.html.markdown index 1be26a3e65b..0adf0d8b7aa 100644 --- a/website/docs/r/datapipeline_pipeline.html.markdown +++ b/website/docs/r/datapipeline_pipeline.html.markdown @@ -24,13 +24,14 @@ The following arguments are supported: * `name` - (Required) The name of Pipeline. * `description` - (Optional) The description of 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. ## Attributes Reference In addition to all arguments above, the following attributes are exported: * `id` - The identifier of the client certificate. +* `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/datasync_agent.html.markdown b/website/docs/r/datasync_agent.html.markdown index 11646cbe1e1..8c501c2b1c6 100644 --- a/website/docs/r/datasync_agent.html.markdown +++ b/website/docs/r/datasync_agent.html.markdown @@ -28,7 +28,7 @@ The following arguments are supported: * `name` - (Required) Name of the DataSync Agent. * `activation_key` - (Optional) DataSync Agent activation key during resource creation. Conflicts with `ip_address`. If an `ip_address` is provided instead, Terraform will retrieve the `activation_key` as part of the resource creation. * `ip_address` - (Optional) DataSync Agent IP address to retrieve activation key during resource creation. Conflicts with `activation_key`. DataSync Agent must be accessible on port 80 from where Terraform is running. -* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Agent. +* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Agent. 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: * `id` - Amazon Resource Name (ARN) of the DataSync Agent. * `arn` - Amazon Resource Name (ARN) of the DataSync Agent. +* `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/datasync_location_efs.html.markdown b/website/docs/r/datasync_location_efs.html.markdown index 1e816e52644..701a26d5bef 100644 --- a/website/docs/r/datasync_location_efs.html.markdown +++ b/website/docs/r/datasync_location_efs.html.markdown @@ -34,7 +34,7 @@ The following arguments are supported: * `ec2_config` - (Required) Configuration block containing EC2 configurations for connecting to the EFS File System. * `efs_file_system_arn` - (Required) Amazon Resource Name (ARN) of EFS File System. * `subdirectory` - (Optional) Subdirectory to perform actions as source or destination. Default `/`. -* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Location. +* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Location. 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. ### ec2_config Argument Reference @@ -49,6 +49,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - Amazon Resource Name (ARN) of the DataSync Location. * `arn` - Amazon Resource Name (ARN) of the DataSync Location. +* `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/datasync_location_fsx_windows_file_system.html.markdown b/website/docs/r/datasync_location_fsx_windows_file_system.html.markdown index 9bab3cafac1..c9e746f827c 100644 --- a/website/docs/r/datasync_location_fsx_windows_file_system.html.markdown +++ b/website/docs/r/datasync_location_fsx_windows_file_system.html.markdown @@ -31,7 +31,7 @@ The following arguments are supported: * `domain` - (Optional) The name of the Windows domain that the FSx for Windows server belongs to. * `security_group_arns` - (Optional) The Amazon Resource Names (ARNs) of the security groups that are to use to configure the FSx for Windows file system. * `subdirectory` - (Optional) Subdirectory to perform actions as source or destination. -* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Location. +* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Location. 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 @@ -39,6 +39,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - Amazon Resource Name (ARN) of the DataSync Location. * `arn` - Amazon Resource Name (ARN) of the DataSync Location. +* `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). * `uri` - The URL of the FSx for Windows location that was described. * `creation_time` - The time that the FSx for Windows location was created. diff --git a/website/docs/r/datasync_location_nfs.html.markdown b/website/docs/r/datasync_location_nfs.html.markdown index dc91763895a..af8ffddac58 100644 --- a/website/docs/r/datasync_location_nfs.html.markdown +++ b/website/docs/r/datasync_location_nfs.html.markdown @@ -32,7 +32,7 @@ The following arguments are supported: * `on_prem_config` - (Required) Configuration block containing information for connecting to the NFS File System. * `server_hostname` - (Required) Specifies the IP address or DNS name of the NFS server. The DataSync Agent(s) use this to mount the NFS server. * `subdirectory` - (Required) Subdirectory to perform actions as source or destination. Should be exported by the NFS server. -* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Location. +* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Location. 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. ### on_prem_config Argument Reference @@ -46,6 +46,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - Amazon Resource Name (ARN) of the DataSync Location. * `arn` - Amazon Resource Name (ARN) of the DataSync Location. +* `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/datasync_location_s3.html.markdown b/website/docs/r/datasync_location_s3.html.markdown index 3e4a50ebba1..467f4858b7d 100644 --- a/website/docs/r/datasync_location_s3.html.markdown +++ b/website/docs/r/datasync_location_s3.html.markdown @@ -30,7 +30,7 @@ The following arguments are supported: * `s3_bucket_arn` - (Required) Amazon Resource Name (ARN) of the S3 Bucket. * `s3_config` - (Required) Configuration block containing information for connecting to S3. * `subdirectory` - (Required) Prefix to perform actions as source or destination. -* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Location. +* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Location. 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. ### s3_config Argument Reference @@ -44,6 +44,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - Amazon Resource Name (ARN) of the DataSync Location. * `arn` - Amazon Resource Name (ARN) of the DataSync Location. +* `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/datasync_location_smb.html.markdown b/website/docs/r/datasync_location_smb.html.markdown index 298a8e4690c..77e9a6ce315 100644 --- a/website/docs/r/datasync_location_smb.html.markdown +++ b/website/docs/r/datasync_location_smb.html.markdown @@ -36,7 +36,7 @@ The following arguments are supported: * `password` - (Required) The password of the user who can mount the share and has file permissions in the SMB. * `server_hostname` - (Required) Specifies the IP address or DNS name of the SMB server. The DataSync Agent(s) use this to mount the SMB share. * `subdirectory` - (Required) Subdirectory to perform actions as source or destination. Should be exported by the NFS server. -* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Location. +* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Location. 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` - (Required) The user who can mount the share and has file and folder permissions in the SMB share. ### mount_options Argument Reference @@ -50,6 +50,7 @@ The following arguments are supported inside the `mount_options` configuration b In addition to all arguments above, the following attributes are exported: * `arn` - Amazon Resource Name (ARN) of the DataSync Location. +* `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/datasync_task.html.markdown b/website/docs/r/datasync_task.html.markdown index 5260306e0be..67e94802f24 100644 --- a/website/docs/r/datasync_task.html.markdown +++ b/website/docs/r/datasync_task.html.markdown @@ -33,7 +33,7 @@ The following arguments are supported: * `cloudwatch_log_group_arn` - (Optional) Amazon Resource Name (ARN) of the CloudWatch Log Group that is used to monitor and log events in the sync task. * `name` - (Optional) Name of the DataSync Task. * `options` - (Optional) Configuration block containing option that controls the default behavior when you start an execution of this DataSync Task. For each individual task execution, you can override these options by specifying an overriding configuration in those executions. -* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Task. +* `tags` - (Optional) Key-value pairs of resource tags to assign to the DataSync Task. 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. ### options Argument Reference @@ -58,6 +58,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - Amazon Resource Name (ARN) of the DataSync Task. * `arn` - Amazon Resource Name (ARN) of the DataSync Task. +* `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/dax_cluster.html.markdown b/website/docs/r/dax_cluster.html.markdown index c49ff1b550b..3a93eab0471 100644 --- a/website/docs/r/dax_cluster.html.markdown +++ b/website/docs/r/dax_cluster.html.markdown @@ -64,7 +64,7 @@ with the cluster * `subnet_group_name` – (Optional) Name of the subnet group to be used for the cluster -* `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. The `server_side_encryption` object supports the following: @@ -87,6 +87,8 @@ consisting of a DNS name and a port number * `port` - The port used by the configuration endpoint +* `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 `aws_dax_cluster` provides the following diff --git a/website/docs/r/db_cluster_snapshot.html.markdown b/website/docs/r/db_cluster_snapshot.html.markdown index 4723271772a..2314de33607 100644 --- a/website/docs/r/db_cluster_snapshot.html.markdown +++ b/website/docs/r/db_cluster_snapshot.html.markdown @@ -25,7 +25,7 @@ The following arguments are supported: * `db_cluster_identifier` - (Required) The DB Cluster Identifier from which to take the snapshot. * `db_cluster_snapshot_identifier` - (Required) The Identifier for the snapshot. -* `tags` - (Optional) A map of tags to assign to the DB cluster. +* `tags` - (Optional) A map of tags to assign to the DB cluster. 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 @@ -42,6 +42,7 @@ In addition to all arguments above, the following attributes are exported: * `source_db_cluster_snapshot_identifier` - The DB Cluster Snapshot Arn that the DB Cluster Snapshot was copied from. It only has value in case of cross customer or cross region copy. * `storage_encrypted` - Specifies whether the DB cluster snapshot is encrypted. * `status` - The status of this DB Cluster Snapshot. +* `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). * `vpc_id` - The VPC ID associated with the DB cluster snapshot. ## Timeouts diff --git a/website/docs/r/db_event_subscription.html.markdown b/website/docs/r/db_event_subscription.html.markdown index 3a19d2553ed..2823595bfe1 100644 --- a/website/docs/r/db_event_subscription.html.markdown +++ b/website/docs/r/db_event_subscription.html.markdown @@ -62,7 +62,7 @@ The following arguments are supported: * `source_type` - (Optional) The type of source that will be generating the events. Valid options are `db-instance`, `db-security-group`, `db-parameter-group`, `db-snapshot`, `db-cluster` or `db-cluster-snapshot`. If not set, all sources will be subscribed to. * `event_categories` - (Optional) A list of event categories for a SourceType that you want to subscribe to. See http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Events.html or run `aws rds describe-event-categories`. * `enabled` - (Optional) A boolean flag to enable/disable the subscription. 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 @@ -71,6 +71,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The name of the RDS event notification subscription * `arn` - The Amazon Resource Name of the RDS event notification subscription * `customer_aws_id` - The AWS customer account associated with the RDS event notification subscription +* `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/db_instance.html.markdown b/website/docs/r/db_instance.html.markdown index 852c82927fb..85434e5e02b 100644 --- a/website/docs/r/db_instance.html.markdown +++ b/website/docs/r/db_instance.html.markdown @@ -195,7 +195,7 @@ default is `false` if not specified. * `storage_type` - (Optional) One of "standard" (magnetic), "gp2" (general purpose SSD), or "io1" (provisioned IOPS SSD). The default is "io1" if `iops` is specified, "gp2" if not. -* `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. * `timezone` - (Optional) Time zone of the DB instance. `timezone` is currently only supported by Microsoft SQL Server. The `timezone` can only be set on creation. See [MSSQL User @@ -292,6 +292,7 @@ in a Route 53 Alias record). * `resource_id` - The RDS Resource ID of this instance. * `status` - The RDS instance status. * `storage_encrypted` - Specifies whether the DB instance is encrypted. +* `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). * `username` - The master username for the database. On Oracle and Microsoft SQL instances the following is exported additionally: diff --git a/website/docs/r/db_option_group.html.markdown b/website/docs/r/db_option_group.html.markdown index dc2057fb192..237cb316be0 100644 --- a/website/docs/r/db_option_group.html.markdown +++ b/website/docs/r/db_option_group.html.markdown @@ -60,7 +60,7 @@ The following arguments are supported: * `engine_name` - (Required) Specifies the name of the engine that this option group should be associated with. * `major_engine_version` - (Required) Specifies the major version of the engine that this option group should be associated with. * `option` - (Optional) A list of Options to apply. -* `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. Option blocks support the following: @@ -82,6 +82,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The db option group name. * `arn` - The ARN of the db option group. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Timeouts diff --git a/website/docs/r/db_parameter_group.html.markdown b/website/docs/r/db_parameter_group.html.markdown index 5463ac99a09..bd2b2c8d027 100644 --- a/website/docs/r/db_parameter_group.html.markdown +++ b/website/docs/r/db_parameter_group.html.markdown @@ -46,7 +46,7 @@ The following arguments are supported: * `family` - (Required, Forces new resource) The family of the DB parameter group. * `description` - (Optional, Forces new resource) The description of the DB parameter group. Defaults to "Managed by Terraform". * `parameter` - (Optional) A list of DB parameters to apply. Note that parameters may differ from a family to an other. Full list of all parameters can be discovered via [`aws rds describe-db-parameters`](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-parameters.html) after initial creation of the group. -* `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. Parameter blocks support the following: @@ -62,6 +62,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The db parameter group name. * `arn` - The ARN of the db parameter group. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/db_proxy.html.markdown b/website/docs/r/db_proxy.html.markdown index f7b8ed6a42e..3c94a1d4e80 100644 --- a/website/docs/r/db_proxy.html.markdown +++ b/website/docs/r/db_proxy.html.markdown @@ -50,7 +50,7 @@ The following arguments are supported: * `role_arn` - (Required) The Amazon Resource Name (ARN) of the IAM role that the proxy uses to access secrets in AWS Secrets Manager. * `vpc_security_group_ids` - (Optional) One or more VPC security group IDs to associate with the new proxy. * `vpc_subnet_ids` - (Required) One or more VPC subnet IDs to associate with the new proxy. -* `tags` - (Optional) A mapping of tags to assign to the resource. +* `tags` - (Optional) A mapping 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. `auth` blocks support the following: @@ -67,6 +67,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The Amazon Resource Name (ARN) for the proxy. * `arn` - The Amazon Resource Name (ARN) for the proxy. * `endpoint` - The endpoint that you can use to connect to the proxy. You include the endpoint value in the connection string for a database client application. +* `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/db_security_group.html.markdown b/website/docs/r/db_security_group.html.markdown index c8af799f62e..2817cb32a5d 100644 --- a/website/docs/r/db_security_group.html.markdown +++ b/website/docs/r/db_security_group.html.markdown @@ -32,7 +32,7 @@ The following arguments are supported: * `name` - (Required) The name of the DB security group. * `description` - (Optional) The description of the DB security group. Defaults to "Managed by Terraform". * `ingress` - (Required) A list of ingress rules. -* `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. Ingress blocks support the following: @@ -48,7 +48,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The db security group ID. * `arn` - The arn of the DB security group. - +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/db_snapshot.html.markdown b/website/docs/r/db_snapshot.html.markdown index bfe3582eb53..f6c835179f1 100644 --- a/website/docs/r/db_snapshot.html.markdown +++ b/website/docs/r/db_snapshot.html.markdown @@ -39,7 +39,7 @@ The following arguments are supported: * `db_instance_identifier` - (Required) The DB Instance Identifier from which to take the snapshot. * `db_snapshot_identifier` - (Required) The Identifier for the snapshot. -* `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 @@ -60,6 +60,7 @@ In addition to all arguments above, the following attributes are exported: * `source_region` - The region that the DB snapshot was created in or copied from. * `status` - Specifies the status of this DB snapshot. * `storage_type` - Specifies the storage type associated with DB snapshot. +* `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). * `vpc_id` - Specifies the storage type associated with DB snapshot. ## Timeouts diff --git a/website/docs/r/db_subnet_group.html.markdown b/website/docs/r/db_subnet_group.html.markdown index 7cc216e582e..ab09f175414 100644 --- a/website/docs/r/db_subnet_group.html.markdown +++ b/website/docs/r/db_subnet_group.html.markdown @@ -33,7 +33,7 @@ The following arguments are supported: * `name_prefix` - (Optional, Forces new resource) Creates a unique name beginning with the specified prefix. Conflicts with `name`. * `description` - (Optional) The description of the DB subnet group. Defaults to "Managed by Terraform". * `subnet_ids` - (Required) A list of VPC subnet IDs. -* `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 @@ -41,7 +41,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The db subnet group name. * `arn` - The ARN of the db subnet group. - +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/default_network_acl.html.markdown b/website/docs/r/default_network_acl.html.markdown index eca4fe266bb..fc6331b2fb3 100644 --- a/website/docs/r/default_network_acl.html.markdown +++ b/website/docs/r/default_network_acl.html.markdown @@ -126,7 +126,7 @@ The following arguments are optional: * `egress` - (Optional) Configuration block for an egress rule. Detailed below. * `ingress` - (Optional) Configuration block for an ingress rule. Detailed below. * `subnet_ids` - (Optional) List of Subnet IDs to apply the ACL to. See the notes below on managing Subnets in the Default Network ACL -* `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. ### egress and ingress @@ -156,6 +156,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - ARN of the Default Network ACL * `id` - ID of the Default Network ACL * `owner_id` - ID of the AWS account that owns the Default Network ACL +* `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). * `vpc_id` - ID of the associated VPC [aws-network-acls]: http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_ACLs.html diff --git a/website/docs/r/default_route_table.html.markdown b/website/docs/r/default_route_table.html.markdown index 23f5199cbe9..db79fd7435b 100644 --- a/website/docs/r/default_route_table.html.markdown +++ b/website/docs/r/default_route_table.html.markdown @@ -62,7 +62,7 @@ The following arguments are optional: * `propagating_vgws` - (Optional) List of virtual gateways for propagation. * `route` - (Optional) Configuration block of routes. Detailed below. This argument is processed in [attribute-as-blocks mode](https://www.terraform.io/docs/configuration/attr-as-blocks.html). This means that omitting this argument is interpreted as ignoring any existing routes. To remove all managed routes an empty list should be specified. See the example above. -* `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. ### route @@ -94,6 +94,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - ID of the route table. * `arn` - The ARN of the route table. * `owner_id` - ID of the AWS account that owns the route table. +* `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). * `vpc_id` - ID of the VPC. ## Import diff --git a/website/docs/r/default_security_group.html.markdown b/website/docs/r/default_security_group.html.markdown index 13557964dec..7e9f50ab6e9 100644 --- a/website/docs/r/default_security_group.html.markdown +++ b/website/docs/r/default_security_group.html.markdown @@ -79,7 +79,7 @@ The following arguments are optional: * `egress` - (Optional, VPC only) Configuration block. Detailed below. * `ingress` - (Optional) Configuration block. Detailed below. -* `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_id` - (Optional, Forces new resource) VPC ID. **Note that changing the `vpc_id` will _not_ restore any default security group rules that were modified, added, or removed.** It will be left in its current state. ### egress and ingress @@ -105,6 +105,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - ID of the security group. * `name` - Name of the security group. * `owner_id` - Owner ID. +* `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). [aws-default-security-groups]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html#default-security-group diff --git a/website/docs/r/directory_service_directory.html.markdown b/website/docs/r/directory_service_directory.html.markdown index af971f81748..9332a8c5fed 100644 --- a/website/docs/r/directory_service_directory.html.markdown +++ b/website/docs/r/directory_service_directory.html.markdown @@ -135,7 +135,7 @@ The following arguments are supported: * `enable_sso` - (Optional) Whether to enable single-sign on for the directory. Requires `alias`. Defaults to `false`. * `type` (Optional) - The directory type (`SimpleAD`, `ADConnector` or `MicrosoftAD` are accepted values). Defaults to `SimpleAD`. * `edition` - (Optional) The MicrosoftAD edition (`Standard` or `Enterprise`). Defaults to `Enterprise` (applies to MicrosoftAD type only). -* `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. **vpc_settings** supports the following: @@ -157,6 +157,7 @@ In addition to all arguments above, the following attributes are exported: * `access_url` - The access URL for the directory, such as `http://alias.awsapps.com`. * `dns_ip_addresses` - A list of IP addresses of the DNS servers for the directory or connector. * `security_group_id` - The ID of the security group created by the directory. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). `connect_settings` (for `ADConnector`) is also exported with the following attributes: diff --git a/website/docs/r/dlm_lifecycle_policy.markdown b/website/docs/r/dlm_lifecycle_policy.markdown index ee494757d03..9d869b70c0c 100644 --- a/website/docs/r/dlm_lifecycle_policy.markdown +++ b/website/docs/r/dlm_lifecycle_policy.markdown @@ -108,7 +108,7 @@ The following arguments are supported: * `execution_role_arn` - (Required) The ARN of an IAM role that is able to be assumed by the DLM service. * `policy_details` - (Required) See the [`policy_details` configuration](#policy-details-arguments) block. Max of 1. * `state` - (Optional) Whether the lifecycle policy should be enabled or disabled. `ENABLED` or `DISABLED` are valid values. Defaults to `ENABLED`. -* `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. #### Policy Details arguments @@ -142,6 +142,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - Amazon Resource Name (ARN) of the DLM Lifecycle Policy. * `id` - Identifier of the DLM Lifecycle Policy. +* `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/dms_certificate.html.markdown b/website/docs/r/dms_certificate.html.markdown index 2a40eca204a..6fac6857e5d 100644 --- a/website/docs/r/dms_certificate.html.markdown +++ b/website/docs/r/dms_certificate.html.markdown @@ -38,13 +38,14 @@ The following arguments are supported: * `certificate_pem` - (Optional) The contents of the .pem X.509 certificate file for the certificate. Either `certificate_pem` or `certificate_wallet` must be set. * `certificate_wallet` - (Optional) The contents of the Oracle Wallet certificate for use with SSL, provided as a base64-encoded String. Either `certificate_pem` or `certificate_wallet` must be set. -* `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: * `certificate_arn` - The Amazon Resource Name (ARN) for the certificate. +* `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/dms_endpoint.html.markdown b/website/docs/r/dms_endpoint.html.markdown index f9d964913f3..3c43a8ed9ca 100644 --- a/website/docs/r/dms_endpoint.html.markdown +++ b/website/docs/r/dms_endpoint.html.markdown @@ -66,7 +66,7 @@ The following arguments are supported: * `server_name` - (Optional) The host name of the server. * `service_access_role` - (Optional) The Amazon Resource Name (ARN) used by the service access IAM role for dynamodb endpoints. * `ssl_mode` - (Optional, Default: none) The SSL mode to use for the connection. Can be one of `none | require | verify-ca | verify-full` -* `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. * `username` - (Optional) The user name to be used to login to the endpoint database. ### elasticsearch_settings Arguments @@ -132,6 +132,7 @@ The `s3_settings` configuration block supports the following arguments: In addition to all arguments above, the following attributes are exported: * `endpoint_arn` - The Amazon Resource Name (ARN) for the endpoint. +* `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/dms_event_subscription.html.markdown b/website/docs/r/dms_event_subscription.html.markdown index 72907fe7a1b..de9ac440af5 100644 --- a/website/docs/r/dms_event_subscription.html.markdown +++ b/website/docs/r/dms_event_subscription.html.markdown @@ -37,12 +37,14 @@ The following arguments are supported: * `source_type` - (Optional, Default: all events) Type of source for events. Valid values: `replication-instance` or `replication-task` * `source_ids` - (Required) Ids of sources to listen to. * `sns_topic_arn` - (Required) SNS topic arn to send events on. +* `tags` - (Optional) Map of resource 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` - Amazon Resource Name (ARN) of the DMS Event Subscription. +* `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/dms_replication_instance.html.markdown b/website/docs/r/dms_replication_instance.html.markdown index efacf1bb933..84f53d18d93 100644 --- a/website/docs/r/dms_replication_instance.html.markdown +++ b/website/docs/r/dms_replication_instance.html.markdown @@ -115,7 +115,7 @@ The following arguments are supported: - Cannot contain two consecutive hyphens. * `replication_subnet_group_id` - (Optional) A subnet group to associate with the replication instance. -* `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. * `vpc_security_group_ids` - (Optional) A list of VPC security group IDs to be used with the replication instance. The VPC security groups must work with the VPC containing the replication instance. ## Attributes Reference @@ -125,6 +125,7 @@ In addition to all arguments above, the following attributes are exported: * `replication_instance_arn` - The Amazon Resource Name (ARN) of the replication instance. * `replication_instance_private_ips` - A list of the private IP addresses of the replication instance. * `replication_instance_public_ips` - A list of the public IP addresses of the replication instance. +* `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/dms_replication_subnet_group.html.markdown b/website/docs/r/dms_replication_subnet_group.html.markdown index d3f7746530b..0fbf150882f 100644 --- a/website/docs/r/dms_replication_subnet_group.html.markdown +++ b/website/docs/r/dms_replication_subnet_group.html.markdown @@ -39,12 +39,13 @@ The following arguments are supported: - Must not be "default". * `subnet_ids` - (Required) A list of the EC2 subnet IDs for the subnet group. -* `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: +* `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). * `vpc_id` - The ID of the VPC the subnet group is in. ## Import diff --git a/website/docs/r/dms_replication_task.html.markdown b/website/docs/r/dms_replication_task.html.markdown index a648dc10789..b34c5700b87 100644 --- a/website/docs/r/dms_replication_task.html.markdown +++ b/website/docs/r/dms_replication_task.html.markdown @@ -48,7 +48,7 @@ The following arguments are supported: * `replication_task_settings` - (Optional) An escaped JSON string that contains the task settings. For a complete list of task settings, see [Task Settings for AWS Database Migration Service Tasks](http://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.CustomizingTasks.TaskSettings.html). * `source_endpoint_arn` - (Required) The Amazon Resource Name (ARN) string that uniquely identifies the source endpoint. * `table_mappings` - (Required) An escaped JSON string that contains the table mappings. For information on table mapping see [Using Table Mapping with an AWS Database Migration Service Task to Select and Filter Data](http://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.CustomizingTasks.TableMapping.html) -* `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_endpoint_arn` - (Required) The Amazon Resource Name (ARN) string that uniquely identifies the target endpoint. ## Attributes Reference @@ -56,6 +56,7 @@ The following arguments are supported: In addition to all arguments above, the following attributes are exported: * `replication_task_arn` - The Amazon Resource Name (ARN) for the replication task. +* `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/docdb_cluster.html.markdown b/website/docs/r/docdb_cluster.html.markdown index bc4d549ba5e..dfe012ac92b 100644 --- a/website/docs/r/docdb_cluster.html.markdown +++ b/website/docs/r/docdb_cluster.html.markdown @@ -71,7 +71,7 @@ Default: A 30-minute window selected at random from an 8-hour block of time per * `skip_final_snapshot` - (Optional) Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from `final_snapshot_identifier`. Default is `false`. * `snapshot_identifier` - (Optional) Specifies whether or not to create this cluster from a snapshot. You can use either the name or ARN when specifying a DB cluster snapshot, or the ARN when specifying a DB snapshot. * `storage_encrypted` - (Optional) Specifies whether the DB cluster is encrypted. The default is `false`. -* `tags` - (Optional) A map of tags to assign to the DB cluster. +* `tags` - (Optional) A map of tags to assign to the DB cluster. 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_security_group_ids` - (Optional) List of VPC security groups to associate with the Cluster @@ -87,6 +87,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The DocDB Cluster Identifier * `maintenance_window` - The instance maintenance window * `reader_endpoint` - A read-only endpoint for the DocDB cluster, automatically load-balanced across replicas +* `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/docdb_cluster_instance.html.markdown b/website/docs/r/docdb_cluster_instance.html.markdown index bf7b97a2ec8..b8bcbc2c61f 100644 --- a/website/docs/r/docdb_cluster_instance.html.markdown +++ b/website/docs/r/docdb_cluster_instance.html.markdown @@ -68,7 +68,7 @@ The following arguments are supported: * `preferred_maintenance_window` - (Optional) The window to perform maintenance in. Syntax: "ddd:hh24:mi-ddd:hh24:mi". Eg: "Mon:00:00-Mon:03:00". * `promotion_tier` - (Optional) Default 0. Failover Priority setting on instance level. The reader who has lower tier has higher priority to get promoter to writer. -* `tags` - (Optional) A map of tags to assign to the instance. +* `tags` - (Optional) A map of tags to assign to the instance. 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: * `port` - The database port * `preferred_backup_window` - The daily time range during which automated backups are created if automated backups are enabled. * `storage_encrypted` - Specifies whether the DB cluster is encrypted. +* `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). * `writer` – Boolean indicating if this instance is writable. `False` indicates this instance is a read replica. * `ca_cert_identifier` - (Optional) The identifier of the CA certificate for the DB instance. diff --git a/website/docs/r/docdb_cluster_parameter_group.html.markdown b/website/docs/r/docdb_cluster_parameter_group.html.markdown index 9a8fcad44ef..2bbb22b60cd 100644 --- a/website/docs/r/docdb_cluster_parameter_group.html.markdown +++ b/website/docs/r/docdb_cluster_parameter_group.html.markdown @@ -34,7 +34,7 @@ The following arguments are supported: * `family` - (Required, Forces new resource) The family of the documentDB cluster parameter group. * `description` - (Optional, Forces new resource) The description of the documentDB cluster parameter group. Defaults to "Managed by Terraform". * `parameter` - (Optional) A list of documentDB parameters to apply. Setting parameters to system default values may show a difference on imported resources. -* `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. Parameter blocks support the following: @@ -48,7 +48,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The documentDB cluster parameter group name. * `arn` - The ARN of the documentDB cluster parameter group. - +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/docdb_subnet_group.html.markdown b/website/docs/r/docdb_subnet_group.html.markdown index a6a4a906f49..7102b9fe142 100644 --- a/website/docs/r/docdb_subnet_group.html.markdown +++ b/website/docs/r/docdb_subnet_group.html.markdown @@ -31,7 +31,7 @@ The following arguments are supported: * `name_prefix` - (Optional, Forces new resource) Creates a unique name beginning with the specified prefix. Conflicts with `name`. * `description` - (Optional) The description of the docDB subnet group. Defaults to "Managed by Terraform". * `subnet_ids` - (Required) A list of VPC subnet IDs. -* `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 @@ -39,7 +39,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The docDB subnet group name. * `arn` - The ARN of the docDB subnet group. - +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/dx_connection.html.markdown b/website/docs/r/dx_connection.html.markdown index ce0192570a9..c476b2b224c 100644 --- a/website/docs/r/dx_connection.html.markdown +++ b/website/docs/r/dx_connection.html.markdown @@ -27,7 +27,7 @@ The following arguments are supported: * `name` - (Required) The name of the connection. * `bandwidth` - (Required) The bandwidth of the connection. Valid values for dedicated connections: 1Gbps, 10Gbps. Valid values for hosted connections: 50Mbps, 100Mbps, 200Mbps, 300Mbps, 400Mbps, 500Mbps, 1Gbps, 2Gbps, 5Gbps and 10Gbps. Case sensitive. * `location` - (Required) The AWS Direct Connect location where the connection is located. See [DescribeLocations](https://docs.aws.amazon.com/directconnect/latest/APIReference/API_DescribeLocations.html) for the list of AWS Direct Connect locations. Use `locationCode`. -* `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 @@ -38,6 +38,7 @@ In addition to all arguments above, the following attributes are exported: * `jumbo_frame_capable` - Boolean value representing if jumbo frames have been enabled for this connection. * `has_logical_redundancy` - Indicates whether the connection supports a secondary BGP peer in the same address family (IPv4/IPv6). * `aws_device` - The Direct Connect endpoint on which the physical connection terminates. +* `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/dx_hosted_private_virtual_interface_accepter.html.markdown b/website/docs/r/dx_hosted_private_virtual_interface_accepter.html.markdown index 00730b61c20..8350a9ea87c 100644 --- a/website/docs/r/dx_hosted_private_virtual_interface_accepter.html.markdown +++ b/website/docs/r/dx_hosted_private_virtual_interface_accepter.html.markdown @@ -65,7 +65,7 @@ The following arguments are supported: * `virtual_interface_id` - (Required) The ID of the Direct Connect virtual interface to accept. * `dx_gateway_id` - (Optional) The ID of the Direct Connect gateway to which to connect the virtual interface. -* `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. * `vpn_gateway_id` - (Optional) The ID of the [virtual private gateway](vpn_gateway.html) to which to connect the virtual interface. ### Removing `aws_dx_hosted_private_virtual_interface_accepter` from your configuration @@ -82,6 +82,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the virtual interface. * `arn` - The ARN of the virtual interface. +* `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/dx_hosted_public_virtual_interface_accepter.html.markdown b/website/docs/r/dx_hosted_public_virtual_interface_accepter.html.markdown index 1ddb6722349..742ce39f514 100644 --- a/website/docs/r/dx_hosted_public_virtual_interface_accepter.html.markdown +++ b/website/docs/r/dx_hosted_public_virtual_interface_accepter.html.markdown @@ -63,7 +63,7 @@ resource "aws_dx_hosted_public_virtual_interface_accepter" "accepter" { The following arguments are supported: * `virtual_interface_id` - (Required) The ID of the Direct Connect virtual interface to accept. -* `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. ### Removing `aws_dx_hosted_public_virtual_interface_accepter` from your configuration @@ -80,6 +80,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the virtual interface. * `arn` - The ARN of the virtual interface. +* `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/dx_hosted_transit_virtual_interface_accepter.html.markdown b/website/docs/r/dx_hosted_transit_virtual_interface_accepter.html.markdown index eac517290ae..2d367b3b2a8 100644 --- a/website/docs/r/dx_hosted_transit_virtual_interface_accepter.html.markdown +++ b/website/docs/r/dx_hosted_transit_virtual_interface_accepter.html.markdown @@ -70,7 +70,7 @@ The following arguments are supported: * `dx_gateway_id` - (Required) The ID of the [Direct Connect gateway](dx_gateway.html) to which to connect the virtual interface. * `virtual_interface_id` - (Required) The ID of the Direct Connect virtual interface to accept. -* `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,6 +78,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the virtual interface. * `arn` - The ARN of the virtual interface. +* `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/dx_lag.html.markdown b/website/docs/r/dx_lag.html.markdown index 5a299088458..9ce28168101 100644 --- a/website/docs/r/dx_lag.html.markdown +++ b/website/docs/r/dx_lag.html.markdown @@ -31,7 +31,7 @@ The following arguments are supported: * `connections_bandwidth` - (Required) The bandwidth of the individual physical connections bundled by the LAG. Valid values: 50Mbps, 100Mbps, 200Mbps, 300Mbps, 400Mbps, 500Mbps, 1Gbps, 2Gbps, 5Gbps and 10Gbps. Case sensitive. * `location` - (Required) The AWS Direct Connect location in which the LAG should be allocated. See [DescribeLocations](https://docs.aws.amazon.com/directconnect/latest/APIReference/API_DescribeLocations.html) for the list of AWS Direct Connect locations. Use `locationCode`. * `force_destroy` - (Optional, Default:false) A boolean that indicates all connections associated with the LAG should be deleted so that the LAG can be destroyed without error. These objects are *not* recoverable. -* `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 @@ -41,6 +41,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the LAG. * `jumbo_frame_capable` -Indicates whether jumbo frames (9001 MTU) are supported. * `has_logical_redundancy` - Indicates whether the LAG supports a secondary BGP peer in the same address family (IPv4/IPv6). +* `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/dx_private_virtual_interface.html.markdown b/website/docs/r/dx_private_virtual_interface.html.markdown index 4a6d521ad93..4796630e1cd 100644 --- a/website/docs/r/dx_private_virtual_interface.html.markdown +++ b/website/docs/r/dx_private_virtual_interface.html.markdown @@ -38,7 +38,7 @@ The MTU of a virtual private interface can be either `1500` or `9001` (jumbo fra * `bgp_auth_key` - (Optional) The authentication key for BGP configuration. * `customer_address` - (Optional) The IPv4 CIDR destination address to which Amazon should send traffic. Required for IPv4 BGP peers. * `dx_gateway_id` - (Optional) The ID of the Direct Connect gateway to which to connect the virtual interface. -* `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. * `vpn_gateway_id` - (Optional) The ID of the [virtual private gateway](vpn_gateway.html) to which to connect the virtual interface. ## Attributes Reference @@ -49,6 +49,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the virtual interface. * `jumbo_frame_capable` - Indicates whether jumbo frames (9001 MTU) are supported. * `aws_device` - The Direct Connect endpoint on which the virtual interface terminates. +* `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/dx_public_virtual_interface.html.markdown b/website/docs/r/dx_public_virtual_interface.html.markdown index 0b093788a53..7ff955e7e73 100644 --- a/website/docs/r/dx_public_virtual_interface.html.markdown +++ b/website/docs/r/dx_public_virtual_interface.html.markdown @@ -44,7 +44,7 @@ The following arguments are supported: * `bgp_auth_key` - (Optional) The authentication key for BGP configuration. * `customer_address` - (Optional) The IPv4 CIDR destination address to which Amazon should send traffic. Required for IPv4 BGP peers. * `route_filter_prefixes` - (Required) A list of routes to be advertised to the AWS network in this 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 @@ -53,6 +53,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the virtual interface. * `arn` - The ARN of the virtual interface. * `aws_device` - The Direct Connect endpoint on which the virtual interface terminates. +* `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/dx_transit_virtual_interface.html.markdown b/website/docs/r/dx_transit_virtual_interface.html.markdown index 8ab1a308421..5c052c28c72 100644 --- a/website/docs/r/dx_transit_virtual_interface.html.markdown +++ b/website/docs/r/dx_transit_virtual_interface.html.markdown @@ -45,7 +45,7 @@ The following arguments are supported: * `customer_address` - (Optional) The IPv4 CIDR destination address to which Amazon should send traffic. Required for IPv4 BGP peers. * `mtu` - (Optional) The maximum transmission unit (MTU) is the size, in bytes, of the largest permissible packet that can be passed over the connection. The MTU of a virtual transit interface can be either `1500` or `8500` (jumbo frames). Default is `1500`. -* `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 @@ -55,6 +55,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the virtual interface. * `aws_device` - The Direct Connect endpoint on which the virtual interface terminates. * `jumbo_frame_capable` - Indicates whether jumbo frames (8500 MTU) are supported. +* `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/dynamodb_table.html.markdown b/website/docs/r/dynamodb_table.html.markdown index 6aa1b9d39f7..227a34f3713 100644 --- a/website/docs/r/dynamodb_table.html.markdown +++ b/website/docs/r/dynamodb_table.html.markdown @@ -117,7 +117,7 @@ attributes, etc. * `stream_enabled` - (Optional) Indicates whether Streams are to be enabled (true) or disabled (false). * `stream_view_type` - (Optional) When an item in the table is modified, StreamViewType determines what information is written to the table's stream. Valid values are `KEYS_ONLY`, `NEW_IMAGE`, `OLD_IMAGE`, `NEW_AND_OLD_IMAGES`. * `server_side_encryption` - (Optional) Encryption at rest options. AWS DynamoDB tables are automatically encrypted at rest with an AWS owned Customer Master Key if this argument isn't specified. -* `tags` - (Optional) A map of tags to populate on the created table. +* `tags` - (Optional) A map of tags to populate on the created table. 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. * `point_in_time_recovery` - (Optional) Point-in-time recovery options. ### Timeouts @@ -209,6 +209,7 @@ In addition to all arguments above, the following attributes are exported: a unique identifier for the stream on its own. However, the combination of AWS customer ID, table name and this field is guaranteed to be unique. It can be used for creating CloudWatch Alarms. Only available when `stream_enabled = true` +* `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