diff --git a/internal/service/dataexchange/data_set.go b/internal/service/dataexchange/data_set.go index f4bec95a768..c7f8ed5fe6d 100644 --- a/internal/service/dataexchange/data_set.go +++ b/internal/service/dataexchange/data_set.go @@ -15,9 +15,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dataexchange_data_set") +// @SDKResource("aws_dataexchange_data_set", name="Data Set") +// @Tags(identifierAttribute="arn") func ResourceDataSet() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceDataSetCreate, @@ -48,8 +50,8 @@ func ResourceDataSet() *schema.Resource { Type: schema.TypeString, Required: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, } @@ -58,17 +60,12 @@ func ResourceDataSet() *schema.Resource { func resourceDataSetCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataExchangeConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := &dataexchange.CreateDataSetInput{ Name: aws.String(d.Get("name").(string)), AssetType: aws.String(d.Get("asset_type").(string)), Description: aws.String(d.Get("description").(string)), - } - - if len(tags) > 0 { - input.Tags = Tags(tags.IgnoreAWS()) + Tags: GetTagsIn(ctx), } out, err := conn.CreateDataSetWithContext(ctx, input) @@ -84,8 +81,6 @@ func resourceDataSetCreate(ctx context.Context, d *schema.ResourceData, meta int func resourceDataSetRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataExchangeConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig dataSet, err := FindDataSetById(ctx, conn, d.Id()) @@ -104,15 +99,7 @@ func resourceDataSetRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set("description", dataSet.Description) d.Set("arn", dataSet.Arn) - tags := KeyValueTags(ctx, dataSet.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } + SetTagsOut(ctx, dataSet.Tags) return diags } @@ -141,14 +128,6 @@ func resourceDataSetUpdate(ctx context.Context, d *schema.ResourceData, meta int } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataExchange DataSet (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceDataSetRead(ctx, d, meta)...) } diff --git a/internal/service/dataexchange/revision.go b/internal/service/dataexchange/revision.go index fcc46ead58b..ced2b95ec7e 100644 --- a/internal/service/dataexchange/revision.go +++ b/internal/service/dataexchange/revision.go @@ -17,9 +17,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dataexchange_revision") +// @SDKResource("aws_dataexchange_revision", name="Revision") +// @Tags(identifierAttribute="arn") func ResourceRevision() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceRevisionCreate, @@ -49,8 +51,8 @@ func ResourceRevision() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, } @@ -59,16 +61,11 @@ func ResourceRevision() *schema.Resource { func resourceRevisionCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataExchangeConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := &dataexchange.CreateRevisionInput{ DataSetId: aws.String(d.Get("data_set_id").(string)), Comment: aws.String(d.Get("comment").(string)), - } - - if len(tags) > 0 { - input.Tags = Tags(tags.IgnoreAWS()) + Tags: GetTagsIn(ctx), } out, err := conn.CreateRevisionWithContext(ctx, input) @@ -84,8 +81,6 @@ func resourceRevisionCreate(ctx context.Context, d *schema.ResourceData, meta in func resourceRevisionRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataExchangeConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig dataSetId, revisionId, err := RevisionParseResourceID(d.Id()) if err != nil { @@ -109,15 +104,7 @@ func resourceRevisionRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set("arn", revision.Arn) d.Set("revision_id", revision.Id) - tags := KeyValueTags(ctx, revision.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } + SetTagsOut(ctx, revision.Tags) return diags } @@ -143,14 +130,6 @@ func resourceRevisionUpdate(ctx context.Context, d *schema.ResourceData, meta in } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataExchange Revision (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceRevisionRead(ctx, d, meta)...) } diff --git a/internal/service/dataexchange/service_package_gen.go b/internal/service/dataexchange/service_package_gen.go index df3b2723584..791fe62b309 100644 --- a/internal/service/dataexchange/service_package_gen.go +++ b/internal/service/dataexchange/service_package_gen.go @@ -28,10 +28,18 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceDataSet, TypeName: "aws_dataexchange_data_set", + Name: "Data Set", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceRevision, TypeName: "aws_dataexchange_revision", + Name: "Revision", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, } } diff --git a/internal/service/datapipeline/pipeline.go b/internal/service/datapipeline/pipeline.go index 14192c5e429..e086c070db5 100644 --- a/internal/service/datapipeline/pipeline.go +++ b/internal/service/datapipeline/pipeline.go @@ -17,9 +17,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_datapipeline_pipeline") +// @SDKResource("aws_datapipeline_pipeline", name="Pipeline") +// @Tags(identifierAttribute="id") func ResourcePipeline() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourcePipelineCreate, @@ -43,8 +45,8 @@ func ResourcePipeline() *schema.Resource { ForceNew: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, @@ -54,15 +56,12 @@ func ResourcePipeline() *schema.Resource { func resourcePipelineCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataPipelineConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) uniqueID := id.UniqueId() - input := datapipeline.CreatePipelineInput{ Name: aws.String(d.Get("name").(string)), UniqueId: aws.String(uniqueID), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("description"); ok { @@ -83,8 +82,6 @@ func resourcePipelineCreate(ctx context.Context, d *schema.ResourceData, meta in func resourcePipelineRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataPipelineConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig v, err := PipelineRetrieve(ctx, d.Id(), conn) if tfawserr.ErrCodeEquals(err, datapipeline.ErrCodePipelineNotFoundException) || tfawserr.ErrCodeEquals(err, datapipeline.ErrCodePipelineDeletedException) || v == nil { @@ -98,31 +95,16 @@ func resourcePipelineRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set("name", v.Name) d.Set("description", v.Description) - tags := KeyValueTags(ctx, v.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } + SetTagsOut(ctx, v.Tags) return diags } func resourcePipelineUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).DataPipelineConn() - - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating Datapipeline Pipeline (%s) tags: %s", d.Id(), err) - } - } + // Tags only. return append(diags, resourcePipelineRead(ctx, d, meta)...) } diff --git a/internal/service/datapipeline/service_package_gen.go b/internal/service/datapipeline/service_package_gen.go index 793cc3fcb00..abf49bb5660 100644 --- a/internal/service/datapipeline/service_package_gen.go +++ b/internal/service/datapipeline/service_package_gen.go @@ -37,6 +37,10 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourcePipeline, TypeName: "aws_datapipeline_pipeline", + Name: "Pipeline", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourcePipelineDefinition, diff --git a/internal/service/datasync/agent.go b/internal/service/datasync/agent.go index 84ce9a89f44..89c7fdf2733 100644 --- a/internal/service/datasync/agent.go +++ b/internal/service/datasync/agent.go @@ -21,9 +21,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_datasync_agent") +// @SDKResource("aws_datasync_agent", name="Agent") +// @Tags(identifierAttribute="id") func ResourceAgent() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceAgentCreate, @@ -79,8 +81,8 @@ func ResourceAgent() *schema.Resource { ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "vpc_endpoint_id": { Type: schema.TypeString, Optional: true, @@ -95,8 +97,6 @@ func ResourceAgent() *schema.Resource { func resourceAgentCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) activationKey := d.Get("activation_key").(string) agentIpAddress := d.Get("ip_address").(string) @@ -174,7 +174,7 @@ func resourceAgentCreate(ctx context.Context, d *schema.ResourceData, meta inter input := &datasync.CreateAgentInput{ ActivationKey: aws.String(activationKey), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("name"); ok { @@ -214,8 +214,6 @@ func resourceAgentCreate(ctx context.Context, d *schema.ResourceData, meta inter func resourceAgentRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig output, err := FindAgentByARN(ctx, conn, d.Id()) @@ -243,23 +241,6 @@ func resourceAgentRead(ctx context.Context, d *schema.ResourceData, meta interfa d.Set("vpc_endpoint_id", "") } - tags, err := ListTags(ctx, conn, d.Id()) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DataSync Agent (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -280,14 +261,6 @@ func resourceAgentUpdate(ctx context.Context, d *schema.ResourceData, meta inter } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataSync Agent (%s) tags: %s", d.Id(), err) - } - } - return append(diags, resourceAgentRead(ctx, d, meta)...) } diff --git a/internal/service/datasync/location_efs.go b/internal/service/datasync/location_efs.go index c3ed028be31..2743a3984ad 100644 --- a/internal/service/datasync/location_efs.go +++ b/internal/service/datasync/location_efs.go @@ -16,9 +16,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/flex" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_datasync_location_efs") +// @SDKResource("aws_datasync_location_efs", name="Location EFS") +// @Tags(identifierAttribute="id") func ResourceLocationEFS() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceLocationEFSCreate, @@ -99,8 +101,8 @@ func ResourceLocationEFS() *schema.Resource { return false }, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, @@ -114,14 +116,12 @@ func ResourceLocationEFS() *schema.Resource { func resourceLocationEFSCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := &datasync.CreateLocationEfsInput{ Ec2Config: expandEC2Config(d.Get("ec2_config").([]interface{})), EfsFilesystemArn: aws.String(d.Get("efs_file_system_arn").(string)), Subdirectory: aws.String(d.Get("subdirectory").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("access_point_arn"); ok { @@ -150,8 +150,6 @@ func resourceLocationEFSCreate(ctx context.Context, d *schema.ResourceData, meta func resourceLocationEFSRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig input := &datasync.DescribeLocationEfsInput{ LocationArn: aws.String(d.Id()), @@ -188,37 +186,13 @@ func resourceLocationEFSRead(ctx context.Context, d *schema.ResourceData, meta i d.Set("file_system_access_role_arn", output.FileSystemAccessRoleArn) d.Set("in_transit_encryption", output.InTransitEncryption) - tags, err := ListTags(ctx, conn, d.Id()) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DataSync Location EFS (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } func resourceLocationEFSUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).DataSyncConn() - - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataSync Location EFS (%s) tags: %s", d.Id(), err) - } - } + // Tags only. return append(diags, resourceLocationEFSRead(ctx, d, meta)...) } diff --git a/internal/service/datasync/location_fsx_lustre_file_system.go b/internal/service/datasync/location_fsx_lustre_file_system.go index 300980577f3..b4056e5d7d2 100644 --- a/internal/service/datasync/location_fsx_lustre_file_system.go +++ b/internal/service/datasync/location_fsx_lustre_file_system.go @@ -19,9 +19,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_datasync_location_fsx_lustre_file_system") +// @SDKResource("aws_datasync_location_fsx_lustre_file_system", name="Location FSx Lustre File System") +// @Tags(identifierAttribute="id") func ResourceLocationFSxLustreFileSystem() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceLocationFSxLustreFileSystemCreate, @@ -74,8 +76,8 @@ func ResourceLocationFSxLustreFileSystem() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringLenBetween(1, 4096), }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, @@ -93,14 +95,12 @@ func ResourceLocationFSxLustreFileSystem() *schema.Resource { func resourceLocationFSxLustreFileSystemCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) - fsxArn := d.Get("fsx_filesystem_arn").(string) + fsxArn := d.Get("fsx_filesystem_arn").(string) input := &datasync.CreateLocationFsxLustreInput{ FsxFilesystemArn: aws.String(fsxArn), SecurityGroupArns: flex.ExpandStringSet(d.Get("security_group_arns").(*schema.Set)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("subdirectory"); ok { @@ -121,8 +121,6 @@ func resourceLocationFSxLustreFileSystemCreate(ctx context.Context, d *schema.Re func resourceLocationFSxLustreFileSystemRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig output, err := FindFSxLustreLocationByARN(ctx, conn, d.Id()) @@ -154,37 +152,13 @@ func resourceLocationFSxLustreFileSystemRead(ctx context.Context, d *schema.Reso return sdkdiag.AppendErrorf(diags, "setting creation_time: %s", err) } - tags, err := ListTags(ctx, conn, d.Id()) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DataSync Location Fsx Lustre (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } func resourceLocationFSxLustreFileSystemUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).DataSyncConn() - - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataSync Location Fsx Lustre File System (%s) tags: %s", d.Id(), err) - } - } + // Tags only. return append(diags, resourceLocationFSxLustreFileSystemRead(ctx, d, meta)...) } diff --git a/internal/service/datasync/location_fsx_openzfs_file_system.go b/internal/service/datasync/location_fsx_openzfs_file_system.go index 165e2a72d37..e16abf57a58 100644 --- a/internal/service/datasync/location_fsx_openzfs_file_system.go +++ b/internal/service/datasync/location_fsx_openzfs_file_system.go @@ -19,9 +19,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_datasync_location_fsx_openzfs_file_system") +// @SDKResource("aws_datasync_location_fsx_openzfs_file_system", name="Location OpenZFS File System") +// @Tags(identifierAttribute="id") func ResourceLocationFSxOpenZFSFileSystem() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceLocationFSxOpenZFSFileSystemCreate, @@ -111,8 +113,8 @@ func ResourceLocationFSxOpenZFSFileSystem() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringLenBetween(1, 4096), }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, @@ -130,15 +132,13 @@ func ResourceLocationFSxOpenZFSFileSystem() *schema.Resource { func resourceLocationFSxOpenZFSFileSystemCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) - fsxArn := d.Get("fsx_filesystem_arn").(string) + fsxArn := d.Get("fsx_filesystem_arn").(string) input := &datasync.CreateLocationFsxOpenZfsInput{ FsxFilesystemArn: aws.String(fsxArn), Protocol: expandProtocol(d.Get("protocol").([]interface{})), SecurityGroupArns: flex.ExpandStringSet(d.Get("security_group_arns").(*schema.Set)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("subdirectory"); ok { @@ -159,8 +159,6 @@ func resourceLocationFSxOpenZFSFileSystemCreate(ctx context.Context, d *schema.R func resourceLocationFSxOpenZFSFileSystemRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig output, err := FindFSxOpenZFSLocationByARN(ctx, conn, d.Id()) @@ -196,37 +194,13 @@ func resourceLocationFSxOpenZFSFileSystemRead(ctx context.Context, d *schema.Res return sdkdiag.AppendErrorf(diags, "setting protocol: %s", err) } - tags, err := ListTags(ctx, conn, d.Id()) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DataSync Location Fsx OpenZfs (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } func resourceLocationFSxOpenZFSFileSystemUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).DataSyncConn() - - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataSync Location Fsx OpenZfs File System (%s) tags: %s", d.Id(), err) - } - } + // Tags only. return append(diags, resourceLocationFSxOpenZFSFileSystemRead(ctx, d, meta)...) } diff --git a/internal/service/datasync/location_fsx_windows_file_system.go b/internal/service/datasync/location_fsx_windows_file_system.go index 4b41dce5c5b..7d76a1a0bf0 100644 --- a/internal/service/datasync/location_fsx_windows_file_system.go +++ b/internal/service/datasync/location_fsx_windows_file_system.go @@ -18,9 +18,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/flex" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_datasync_location_fsx_windows_file_system") +// @SDKResource("aws_datasync_location_fsx_windows_file_system", name="Location FSx Windows File System") +// @Tags(identifierAttribute="id") func ResourceLocationFSxWindowsFileSystem() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceLocationFSxWindowsFileSystemCreate, @@ -92,8 +94,8 @@ func ResourceLocationFSxWindowsFileSystem() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringLenBetween(1, 4096), }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, @@ -111,16 +113,14 @@ func ResourceLocationFSxWindowsFileSystem() *schema.Resource { func resourceLocationFSxWindowsFileSystemCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) - fsxArn := d.Get("fsx_filesystem_arn").(string) + fsxArn := d.Get("fsx_filesystem_arn").(string) input := &datasync.CreateLocationFsxWindowsInput{ FsxFilesystemArn: aws.String(fsxArn), User: aws.String(d.Get("user").(string)), Password: aws.String(d.Get("password").(string)), SecurityGroupArns: flex.ExpandStringSet(d.Get("security_group_arns").(*schema.Set)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("subdirectory"); ok { @@ -144,8 +144,6 @@ func resourceLocationFSxWindowsFileSystemCreate(ctx context.Context, d *schema.R func resourceLocationFSxWindowsFileSystemRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig input := &datasync.DescribeLocationFsxWindowsInput{ LocationArn: aws.String(d.Id()), @@ -184,37 +182,13 @@ func resourceLocationFSxWindowsFileSystemRead(ctx context.Context, d *schema.Res return sdkdiag.AppendErrorf(diags, "setting creation_time: %s", err) } - tags, err := ListTags(ctx, conn, d.Id()) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DataSync Location Fsx Windows (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } func resourceLocationFSxWindowsFileSystemUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).DataSyncConn() - - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataSync Location Fsx Windows File System (%s) tags: %s", d.Id(), err) - } - } + // Tags only. return append(diags, resourceLocationFSxWindowsFileSystemRead(ctx, d, meta)...) } diff --git a/internal/service/datasync/location_hdfs.go b/internal/service/datasync/location_hdfs.go index 258e50281fb..6e870dc3c09 100644 --- a/internal/service/datasync/location_hdfs.go +++ b/internal/service/datasync/location_hdfs.go @@ -17,9 +17,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_datasync_location_hdfs") +// @SDKResource("aws_datasync_location_hdfs", name="Location HDFS") +// @Tags(identifierAttribute="id") func ResourceLocationHDFS() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceLocationHDFSCreate, @@ -139,8 +141,8 @@ func ResourceLocationHDFS() *schema.Resource { return false }, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, @@ -154,15 +156,13 @@ func ResourceLocationHDFS() *schema.Resource { func resourceLocationHDFSCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := &datasync.CreateLocationHdfsInput{ AgentArns: flex.ExpandStringSet(d.Get("agent_arns").(*schema.Set)), NameNodes: expandHDFSNameNodes(d.Get("name_node").(*schema.Set)), AuthenticationType: aws.String(d.Get("authentication_type").(string)), Subdirectory: aws.String(d.Get("subdirectory").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("simple_user"); ok { @@ -211,8 +211,6 @@ func resourceLocationHDFSCreate(ctx context.Context, d *schema.ResourceData, met func resourceLocationHDFSRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig output, err := FindLocationHDFSByARN(ctx, conn, d.Id()) @@ -251,23 +249,6 @@ func resourceLocationHDFSRead(ctx context.Context, d *schema.ResourceData, meta return sdkdiag.AppendErrorf(diags, "setting qop_configuration: %s", err) } - tags, err := ListTags(ctx, conn, d.Id()) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DataSync Location HDFS (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -334,13 +315,6 @@ func resourceLocationHDFSUpdate(ctx context.Context, d *schema.ResourceData, met } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataSync HDFS location (%s) tags: %s", d.Id(), err) - } - } return append(diags, resourceLocationHDFSRead(ctx, d, meta)...) } diff --git a/internal/service/datasync/location_nfs.go b/internal/service/datasync/location_nfs.go index 78803f3a4e9..bfa4bfed14f 100644 --- a/internal/service/datasync/location_nfs.go +++ b/internal/service/datasync/location_nfs.go @@ -16,9 +16,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/flex" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_datasync_location_nfs") +// @SDKResource("aws_datasync_location_nfs", name="Location NFS") +// @Tags(identifierAttribute="id") func ResourceLocationNFS() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceLocationNFSCreate, @@ -90,8 +92,8 @@ func ResourceLocationNFS() *schema.Resource { return false }, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, @@ -105,14 +107,12 @@ func ResourceLocationNFS() *schema.Resource { func resourceLocationNFSCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := &datasync.CreateLocationNfsInput{ OnPremConfig: expandOnPremConfig(d.Get("on_prem_config").([]interface{})), ServerHostname: aws.String(d.Get("server_hostname").(string)), Subdirectory: aws.String(d.Get("subdirectory").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("mount_options"); ok { @@ -133,8 +133,6 @@ func resourceLocationNFSCreate(ctx context.Context, d *schema.ResourceData, meta func resourceLocationNFSRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig input := &datasync.DescribeLocationNfsInput{ LocationArn: aws.String(d.Id()), @@ -172,23 +170,6 @@ func resourceLocationNFSRead(ctx context.Context, d *schema.ResourceData, meta i d.Set("subdirectory", subdirectory) d.Set("uri", output.LocationUri) - tags, err := ListTags(ctx, conn, d.Id()) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DataSync Location NFS (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -213,14 +194,6 @@ func resourceLocationNFSUpdate(ctx context.Context, d *schema.ResourceData, meta } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataSync Location NFS (%s) tags: %s", d.Id(), err) - } - } - return append(diags, resourceLocationNFSRead(ctx, d, meta)...) } diff --git a/internal/service/datasync/location_object_storage.go b/internal/service/datasync/location_object_storage.go index 92bb695868f..106866fa819 100644 --- a/internal/service/datasync/location_object_storage.go +++ b/internal/service/datasync/location_object_storage.go @@ -18,9 +18,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_datasync_location_object_storage") +// @SDKResource("aws_datasync_location_object_storage", name="Location Object Storage") +// @Tags(identifierAttribute="id") func ResourceLocationObjectStorage() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceLocationObjectStorageCreate, @@ -90,8 +92,8 @@ func ResourceLocationObjectStorage() *schema.Resource { Computed: true, ValidateFunc: validation.StringLenBetween(1, 4096), }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, @@ -105,15 +107,13 @@ func ResourceLocationObjectStorage() *schema.Resource { func resourceLocationObjectStorageCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := &datasync.CreateLocationObjectStorageInput{ AgentArns: flex.ExpandStringSet(d.Get("agent_arns").(*schema.Set)), Subdirectory: aws.String(d.Get("subdirectory").(string)), BucketName: aws.String(d.Get("bucket_name").(string)), ServerHostname: aws.String(d.Get("server_hostname").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("access_key"); ok { @@ -150,8 +150,6 @@ func resourceLocationObjectStorageCreate(ctx context.Context, d *schema.Resource func resourceLocationObjectStorageRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig output, err := FindLocationObjectStorageByARN(ctx, conn, d.Id()) @@ -192,23 +190,6 @@ func resourceLocationObjectStorageRead(ctx context.Context, d *schema.ResourceDa d.Set("uri", uri) - tags, err := ListTags(ctx, conn, d.Id()) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DataSync Location Object Storage (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -252,14 +233,6 @@ func resourceLocationObjectStorageUpdate(ctx context.Context, d *schema.Resource } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataSync Location Object Storage (%s) tags: %s", d.Id(), err) - } - } - return append(diags, resourceLocationObjectStorageRead(ctx, d, meta)...) } diff --git a/internal/service/datasync/location_s3.go b/internal/service/datasync/location_s3.go index 3bec222a7b0..c15991693be 100644 --- a/internal/service/datasync/location_s3.go +++ b/internal/service/datasync/location_s3.go @@ -18,9 +18,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_datasync_location_s3") +// @SDKResource("aws_datasync_location_s3", name="Location S3") +// @Tags(identifierAttribute="id") func ResourceLocationS3() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceLocationS3Create, @@ -89,8 +91,8 @@ func ResourceLocationS3() *schema.Resource { return false }, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, @@ -104,14 +106,12 @@ func ResourceLocationS3() *schema.Resource { func resourceLocationS3Create(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := &datasync.CreateLocationS3Input{ S3BucketArn: aws.String(d.Get("s3_bucket_arn").(string)), S3Config: expandS3Config(d.Get("s3_config").([]interface{})), Subdirectory: aws.String(d.Get("subdirectory").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("agent_arns"); ok { @@ -164,8 +164,6 @@ func resourceLocationS3Create(ctx context.Context, d *schema.ResourceData, meta func resourceLocationS3Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig input := &datasync.DescribeLocationS3Input{ LocationArn: aws.String(d.Id()), @@ -199,37 +197,13 @@ func resourceLocationS3Read(ctx context.Context, d *schema.ResourceData, meta in d.Set("subdirectory", subdirectory) d.Set("uri", output.LocationUri) - tags, err := ListTags(ctx, conn, d.Id()) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DataSync Location S3 (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } func resourceLocationS3Update(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).DataSyncConn() - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataSync Location S3 (%s) tags: %s", d.Id(), err) - } - } + // Tags only. return append(diags, resourceLocationS3Read(ctx, d, meta)...) } diff --git a/internal/service/datasync/location_smb.go b/internal/service/datasync/location_smb.go index 3ff612b62c9..347037e4de1 100644 --- a/internal/service/datasync/location_smb.go +++ b/internal/service/datasync/location_smb.go @@ -15,9 +15,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/flex" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_datasync_location_smb") +// @SDKResource("aws_datasync_location_smb", name="Location SMB") +// @Tags(identifierAttribute="id") func ResourceLocationSMB() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceLocationSMBCreate, @@ -91,8 +93,8 @@ func ResourceLocationSMB() *schema.Resource { }, */ }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "uri": { Type: schema.TypeString, Computed: true, @@ -111,8 +113,6 @@ func ResourceLocationSMB() *schema.Resource { func resourceLocationSMBCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := &datasync.CreateLocationSmbInput{ AgentArns: flex.ExpandStringSet(d.Get("agent_arns").(*schema.Set)), @@ -120,7 +120,7 @@ func resourceLocationSMBCreate(ctx context.Context, d *schema.ResourceData, meta Password: aws.String(d.Get("password").(string)), ServerHostname: aws.String(d.Get("server_hostname").(string)), Subdirectory: aws.String(d.Get("subdirectory").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), User: aws.String(d.Get("user").(string)), } @@ -141,8 +141,6 @@ func resourceLocationSMBCreate(ctx context.Context, d *schema.ResourceData, meta func resourceLocationSMBRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig input := &datasync.DescribeLocationSmbInput{ LocationArn: aws.String(d.Id()), @@ -161,17 +159,6 @@ func resourceLocationSMBRead(ctx context.Context, d *schema.ResourceData, meta i return sdkdiag.AppendErrorf(diags, "reading DataSync Location SMB (%s): %s", d.Id(), err) } - tagsInput := &datasync.ListTagsForResourceInput{ - ResourceArn: output.LocationArn, - } - - log.Printf("[DEBUG] Reading DataSync Location SMB tags: %s", tagsInput) - tagsOutput, err := conn.ListTagsForResourceWithContext(ctx, tagsInput) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "reading DataSync Location SMB (%s) tags: %s", d.Id(), err) - } - subdirectory, err := SubdirectoryFromLocationURI(aws.StringValue(output.LocationUri)) if err != nil { @@ -189,20 +176,7 @@ func resourceLocationSMBRead(ctx context.Context, d *schema.ResourceData, meta i } d.Set("subdirectory", subdirectory) - - tags := KeyValueTags(ctx, tagsOutput.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - d.Set("user", output.User) - d.Set("uri", output.LocationUri) return diags @@ -232,13 +206,6 @@ func resourceLocationSMBUpdate(ctx context.Context, d *schema.ResourceData, meta } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataSync SMB location (%s) tags: %s", d.Id(), err) - } - } return append(diags, resourceLocationSMBRead(ctx, d, meta)...) } diff --git a/internal/service/datasync/service_package_gen.go b/internal/service/datasync/service_package_gen.go index 5eac26d4f7c..386c6492883 100644 --- a/internal/service/datasync/service_package_gen.go +++ b/internal/service/datasync/service_package_gen.go @@ -28,46 +28,90 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceAgent, TypeName: "aws_datasync_agent", + Name: "Agent", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourceLocationEFS, TypeName: "aws_datasync_location_efs", + Name: "Location EFS", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourceLocationFSxLustreFileSystem, TypeName: "aws_datasync_location_fsx_lustre_file_system", + Name: "Location FSx Lustre File System", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourceLocationFSxOpenZFSFileSystem, TypeName: "aws_datasync_location_fsx_openzfs_file_system", + Name: "Location OpenZFS File System", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourceLocationFSxWindowsFileSystem, TypeName: "aws_datasync_location_fsx_windows_file_system", + Name: "Location FSx Windows File System", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourceLocationHDFS, TypeName: "aws_datasync_location_hdfs", + Name: "Location HDFS", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourceLocationNFS, TypeName: "aws_datasync_location_nfs", + Name: "Location NFS", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourceLocationObjectStorage, TypeName: "aws_datasync_location_object_storage", + Name: "Location Object Storage", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourceLocationS3, TypeName: "aws_datasync_location_s3", + Name: "Location S3", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourceLocationSMB, TypeName: "aws_datasync_location_smb", + Name: "Location SMB", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourceTask, TypeName: "aws_datasync_task", + Name: "Task", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, } } diff --git a/internal/service/datasync/task.go b/internal/service/datasync/task.go index d73db8ee0f6..6cd26de96b4 100644 --- a/internal/service/datasync/task.go +++ b/internal/service/datasync/task.go @@ -19,9 +19,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_datasync_task") +// @SDKResource("aws_datasync_task", name="Task") +// @Tags(identifierAttribute="id") func ResourceTask() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceTaskCreate, @@ -209,8 +211,8 @@ func ResourceTask() *schema.Resource { ForceNew: true, ValidateFunc: verify.ValidARN, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, @@ -220,14 +222,12 @@ func ResourceTask() *schema.Resource { func resourceTaskCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := &datasync.CreateTaskInput{ DestinationLocationArn: aws.String(d.Get("destination_location_arn").(string)), Options: expandOptions(d.Get("options").([]interface{})), SourceLocationArn: aws.String(d.Get("source_location_arn").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("cloudwatch_log_group_arn"); ok { @@ -268,8 +268,6 @@ func resourceTaskCreate(ctx context.Context, d *schema.ResourceData, meta interf func resourceTaskRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DataSyncConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig output, err := FindTaskByARN(ctx, conn, d.Id()) @@ -301,23 +299,6 @@ func resourceTaskRead(ctx context.Context, d *schema.ResourceData, meta interfac } d.Set("source_location_arn", output.SourceLocationArn) - tags, err := ListTags(ctx, conn, d.Id()) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DataSync Task (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -359,14 +340,6 @@ func resourceTaskUpdate(ctx context.Context, d *schema.ResourceData, meta interf } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DataSync Task (%s) tags: %s", d.Id(), err) - } - } - return append(diags, resourceTaskRead(ctx, d, meta)...) } diff --git a/internal/service/dax/cluster.go b/internal/service/dax/cluster.go index 8da60721af4..03772f6d545 100644 --- a/internal/service/dax/cluster.go +++ b/internal/service/dax/cluster.go @@ -22,9 +22,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dax_cluster") +// @SDKResource("aws_dax_cluster", name="Cluster") +// @Tags(identifierAttribute="arn") func ResourceCluster() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceClusterCreate, @@ -153,8 +155,8 @@ func ResourceCluster() *schema.Resource { Computed: true, ForceNew: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "port": { Type: schema.TypeInt, Computed: true, @@ -200,8 +202,6 @@ func ResourceCluster() *schema.Resource { func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DAXConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) clusterName := d.Get("cluster_name").(string) iamRoleArn := d.Get("iam_role_arn").(string) @@ -209,56 +209,54 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int numNodes := int64(d.Get("replication_factor").(int)) subnetGroupName := d.Get("subnet_group_name").(string) securityIdSet := d.Get("security_group_ids").(*schema.Set) - securityIds := flex.ExpandStringSet(securityIdSet) - - req := &dax.CreateClusterInput{ + input := &dax.CreateClusterInput{ ClusterName: aws.String(clusterName), IamRoleArn: aws.String(iamRoleArn), NodeType: aws.String(nodeType), ReplicationFactor: aws.Int64(numNodes), SecurityGroupIds: securityIds, SubnetGroupName: aws.String(subnetGroupName), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } // optionals can be defaulted by AWS if v, ok := d.GetOk("description"); ok { - req.Description = aws.String(v.(string)) + input.Description = aws.String(v.(string)) } if v, ok := d.GetOk("cluster_endpoint_encryption_type"); ok { - req.ClusterEndpointEncryptionType = aws.String(v.(string)) + input.ClusterEndpointEncryptionType = aws.String(v.(string)) } if v, ok := d.GetOk("parameter_group_name"); ok { - req.ParameterGroupName = aws.String(v.(string)) + input.ParameterGroupName = aws.String(v.(string)) } if v, ok := d.GetOk("maintenance_window"); ok { - req.PreferredMaintenanceWindow = aws.String(v.(string)) + input.PreferredMaintenanceWindow = aws.String(v.(string)) } if v, ok := d.GetOk("notification_topic_arn"); ok { - req.NotificationTopicArn = aws.String(v.(string)) + input.NotificationTopicArn = aws.String(v.(string)) } preferredAZs := d.Get("availability_zones").(*schema.Set) if preferredAZs.Len() > 0 { - req.AvailabilityZones = flex.ExpandStringSet(preferredAZs) + input.AvailabilityZones = flex.ExpandStringSet(preferredAZs) } if v, ok := d.GetOk("server_side_encryption"); ok && len(v.([]interface{})) > 0 { options := v.([]interface{}) s := options[0].(map[string]interface{}) - req.SSESpecification = expandEncryptAtRestOptions(s) + input.SSESpecification = expandEncryptAtRestOptions(s) } // IAM roles take some time to propagate var resp *dax.CreateClusterOutput err := retry.RetryContext(ctx, propagationTimeout, func() *retry.RetryError { var err error - resp, err = conn.CreateClusterWithContext(ctx, req) + resp, err = conn.CreateClusterWithContext(ctx, input) if err != nil { if tfawserr.ErrMessageContains(err, dax.ErrCodeInvalidParameterValueException, "No permission to assume role") { log.Print("[DEBUG] Retrying create of DAX cluster") @@ -269,7 +267,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int return nil }) if tfresource.TimedOut(err) { - resp, err = conn.CreateClusterWithContext(ctx, req) + resp, err = conn.CreateClusterWithContext(ctx, input) } if err != nil { return sdkdiag.AppendErrorf(diags, "Error creating DAX cluster: %s", err) @@ -303,8 +301,6 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DAXConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig req := &dax.DescribeClustersInput{ ClusterNames: []*string{aws.String(d.Id())}, @@ -365,23 +361,6 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter return sdkdiag.AppendErrorf(diags, "setting server_side_encryption: %s", err) } - tags, err := ListTags(ctx, conn, aws.StringValue(c.ClusterArn)) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DAX Cluster (%s): %s", aws.StringValue(c.ClusterArn), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -389,14 +368,6 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta int var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DAXConn() - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DAX Cluster (%s) tags: %s", d.Get("arn").(string), err) - } - } - req := &dax.UpdateClusterInput{ ClusterName: aws.String(d.Id()), } diff --git a/internal/service/dax/service_package_gen.go b/internal/service/dax/service_package_gen.go index 6581220a7ab..115e80e5e40 100644 --- a/internal/service/dax/service_package_gen.go +++ b/internal/service/dax/service_package_gen.go @@ -28,6 +28,10 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceCluster, TypeName: "aws_dax_cluster", + Name: "Cluster", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceParameterGroup, diff --git a/internal/service/deploy/app.go b/internal/service/deploy/app.go index 27133fee8a8..dbf29440ec0 100644 --- a/internal/service/deploy/app.go +++ b/internal/service/deploy/app.go @@ -17,9 +17,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_codedeploy_app") +// @SDKResource("aws_codedeploy_app", name="App") +// @Tags(identifierAttribute="arn") func ResourceApp() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceAppCreate, @@ -89,8 +91,8 @@ func ResourceApp() *schema.Resource { Type: schema.TypeBool, Computed: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, @@ -100,17 +102,13 @@ func ResourceApp() *schema.Resource { func resourceAppCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeployConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) application := d.Get("name").(string) computePlatform := d.Get("compute_platform").(string) - log.Printf("[DEBUG] Creating CodeDeploy application %s", application) - resp, err := conn.CreateApplicationWithContext(ctx, &codedeploy.CreateApplicationInput{ ApplicationName: aws.String(application), ComputePlatform: aws.String(computePlatform), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), }) if err != nil { return sdkdiag.AppendErrorf(diags, "creating CodeDeploy Application (%s): %s", application, err) @@ -129,8 +127,6 @@ func resourceAppCreate(ctx context.Context, d *schema.ResourceData, meta interfa func resourceAppRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeployConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig application := resourceAppParseID(d.Id()) name := d.Get("name").(string) @@ -174,23 +170,6 @@ func resourceAppRead(ctx context.Context, d *schema.ResourceData, meta interface d.Set("github_account_name", app.GitHubAccountName) d.Set("linked_to_github", app.LinkedToGitHub) - tags, err := ListTags(ctx, conn, appArn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for CodeDeploy application (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -211,14 +190,6 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta interface{ } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating CodeDeploy Application (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceAppRead(ctx, d, meta)...) } diff --git a/internal/service/deploy/deployment_group.go b/internal/service/deploy/deployment_group.go index 2c8878638ce..dc463fbefef 100644 --- a/internal/service/deploy/deployment_group.go +++ b/internal/service/deploy/deployment_group.go @@ -24,9 +24,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_codedeploy_deployment_group") +// @SDKResource("aws_codedeploy_deployment_group", name="Deployment Group") +// @Tags(identifierAttribute="arn") func ResourceDeploymentGroup() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceDeploymentGroupCreate, @@ -480,8 +482,8 @@ func ResourceDeploymentGroup() *schema.Resource { }, Set: resourceTriggerHashConfig, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, @@ -491,18 +493,15 @@ func ResourceDeploymentGroup() *schema.Resource { func resourceDeploymentGroupCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeployConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) - // required fields + applicationName := d.Get("app_name").(string) deploymentGroupName := d.Get("deployment_group_name").(string) serviceRoleArn := d.Get("service_role_arn").(string) - input := codedeploy.CreateDeploymentGroupInput{ ApplicationName: aws.String(applicationName), DeploymentGroupName: aws.String(deploymentGroupName), ServiceRoleArn: aws.String(serviceRoleArn), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if attr, ok := d.GetOk("deployment_style"); ok { @@ -592,10 +591,6 @@ func resourceDeploymentGroupCreate(ctx context.Context, d *schema.ResourceData, func resourceDeploymentGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeployConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig - - log.Printf("[DEBUG] Reading CodeDeploy DeploymentGroup %s", d.Id()) deploymentGroupName := d.Get("deployment_group_name").(string) resp, err := conn.GetDeploymentGroupWithContext(ctx, &codedeploy.GetDeploymentGroupInput{ @@ -680,23 +675,6 @@ func resourceDeploymentGroupRead(ctx context.Context, d *schema.ResourceData, me return sdkdiag.AppendErrorf(diags, "setting blue_green_deployment_config: %s", err) } - tags, err := ListTags(ctx, conn, groupArn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for CodeDeploy Deployment Group (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -816,14 +794,6 @@ func resourceDeploymentGroupUpdate(ctx context.Context, d *schema.ResourceData, } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating CodeDeploy Deployment Group (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceDeploymentGroupRead(ctx, d, meta)...) } diff --git a/internal/service/deploy/service_package_gen.go b/internal/service/deploy/service_package_gen.go index a9de11d7bf4..616d8e73f6b 100644 --- a/internal/service/deploy/service_package_gen.go +++ b/internal/service/deploy/service_package_gen.go @@ -28,6 +28,10 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceApp, TypeName: "aws_codedeploy_app", + Name: "App", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceDeploymentConfig, @@ -36,6 +40,10 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceDeploymentGroup, TypeName: "aws_codedeploy_deployment_group", + Name: "Deployment Group", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, } } diff --git a/internal/service/detective/graph.go b/internal/service/detective/graph.go index 094bd82ef03..bc0dddb2c33 100644 --- a/internal/service/detective/graph.go +++ b/internal/service/detective/graph.go @@ -14,9 +14,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_detective_graph") +// @SDKResource("aws_detective_graph", name="Graph") +// @Tags(identifierAttribute="id") func ResourceGraph() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceGraphCreate, @@ -35,8 +37,8 @@ func ResourceGraph() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, } @@ -45,13 +47,8 @@ func ResourceGraph() *schema.Resource { func resourceGraphCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.AWSClient).DetectiveConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) - - input := &detective.CreateGraphInput{} - - if len(tags) > 0 { - input.Tags = Tags(tags.IgnoreAWS()) + input := &detective.CreateGraphInput{ + Tags: GetTagsIn(ctx), } var output *detective.CreateGraphOutput @@ -85,9 +82,6 @@ func resourceGraphCreate(ctx context.Context, d *schema.ResourceData, meta inter func resourceGraphRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.AWSClient).DetectiveConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig - resp, err := FindGraphByARN(ctx, conn, d.Id()) if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, detective.ErrCodeResourceNotFoundException) || resp == nil { @@ -101,35 +95,11 @@ func resourceGraphRead(ctx context.Context, d *schema.ResourceData, meta interfa d.Set("created_time", aws.TimeValue(resp.CreatedTime).Format(time.RFC3339)) d.Set("graph_arn", resp.Arn) - tags, err := ListTags(ctx, conn, aws.StringValue(resp.Arn)) - - if err != nil { - return diag.Errorf("error listing tags for Detective Graph (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - if err = d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return diag.Errorf("error setting `%s` for Detective Graph (%s): %s", "tags", d.Id(), err) - } - - if err = d.Set("tags_all", tags.Map()); err != nil { - return diag.Errorf("error setting `%s` for Detective Graph (%s): %s", "tags_all", d.Id(), err) - } - return nil } func resourceGraphUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - conn := meta.(*conns.AWSClient).DetectiveConn() - - if d.HasChange("tags") { - o, n := d.GetChange("tags") - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return diag.Errorf("error updating detective Graph tags (%s): %s", d.Id(), err) - } - } - + // Tags only. return resourceGraphRead(ctx, d, meta) } diff --git a/internal/service/detective/service_package_gen.go b/internal/service/detective/service_package_gen.go index 376b613026c..f92832db39e 100644 --- a/internal/service/detective/service_package_gen.go +++ b/internal/service/detective/service_package_gen.go @@ -28,6 +28,10 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceGraph, TypeName: "aws_detective_graph", + Name: "Graph", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourceInvitationAccepter, diff --git a/internal/service/devicefarm/device_pool.go b/internal/service/devicefarm/device_pool.go index 86fb0ee883f..bac13847d92 100644 --- a/internal/service/devicefarm/device_pool.go +++ b/internal/service/devicefarm/device_pool.go @@ -18,9 +18,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_devicefarm_device_pool") +// @SDKResource("aws_devicefarm_device_pool", name="Device Pool") +// @Tags(identifierAttribute="arn") func ResourceDevicePool() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceDevicePoolCreate, @@ -81,8 +83,8 @@ func ResourceDevicePool() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, } @@ -91,8 +93,6 @@ func ResourceDevicePool() *schema.Resource { func resourceDevicePoolCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeviceFarmConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) name := d.Get("name").(string) input := &devicefarm.CreateDevicePoolInput{ @@ -119,7 +119,7 @@ func resourceDevicePoolCreate(ctx context.Context, d *schema.ResourceData, meta log.Printf("[DEBUG] Successsfully Created DeviceFarm DevicePool: %s", arn) d.SetId(arn) - if len(tags) > 0 { + if tags := KeyValueTags(ctx, GetTagsIn(ctx)); len(tags) > 0 { if err := UpdateTags(ctx, conn, arn, nil, tags); err != nil { return sdkdiag.AppendErrorf(diags, "updating DeviceFarm DevicePool (%s) tags: %s", arn, err) } @@ -131,8 +131,6 @@ func resourceDevicePoolCreate(ctx context.Context, d *schema.ResourceData, meta func resourceDevicePoolRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeviceFarmConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig devicePool, err := FindDevicePoolByARN(ctx, conn, d.Id()) @@ -163,23 +161,6 @@ func resourceDevicePoolRead(ctx context.Context, d *schema.ResourceData, meta in return sdkdiag.AppendErrorf(diags, "setting rule: %s", err) } - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DeviceFarm DevicePool (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -219,14 +200,6 @@ func resourceDevicePoolUpdate(ctx context.Context, d *schema.ResourceData, meta } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DeviceFarm DevicePool (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceDevicePoolRead(ctx, d, meta)...) } diff --git a/internal/service/devicefarm/instance_profile.go b/internal/service/devicefarm/instance_profile.go index 5c467e9de73..f2988defd8b 100644 --- a/internal/service/devicefarm/instance_profile.go +++ b/internal/service/devicefarm/instance_profile.go @@ -16,9 +16,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_devicefarm_instance_profile") +// @SDKResource("aws_devicefarm_instance_profile", name="Instance Profile") +// @Tags(identifierAttribute="arn") func ResourceInstanceProfile() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceInstanceProfileCreate, @@ -58,8 +60,8 @@ func ResourceInstanceProfile() *schema.Resource { Optional: true, Default: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, } @@ -68,8 +70,6 @@ func ResourceInstanceProfile() *schema.Resource { func resourceInstanceProfileCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeviceFarmConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := &devicefarm.CreateInstanceProfileInput{ Name: aws.String(d.Get("name").(string)), @@ -100,7 +100,7 @@ func resourceInstanceProfileCreate(ctx context.Context, d *schema.ResourceData, log.Printf("[DEBUG] Successsfully Created DeviceFarm Instance Profile: %s", arn) d.SetId(arn) - if len(tags) > 0 { + if tags := KeyValueTags(ctx, GetTagsIn(ctx)); len(tags) > 0 { if err := UpdateTags(ctx, conn, arn, nil, tags); err != nil { return sdkdiag.AppendErrorf(diags, "updating DeviceFarm Instance Profile (%s) tags: %s", arn, err) } @@ -112,8 +112,6 @@ func resourceInstanceProfileCreate(ctx context.Context, d *schema.ResourceData, func resourceInstanceProfileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeviceFarmConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig instaceProf, err := FindInstanceProfileByARN(ctx, conn, d.Id()) @@ -135,23 +133,6 @@ func resourceInstanceProfileRead(ctx context.Context, d *schema.ResourceData, me d.Set("package_cleanup", instaceProf.PackageCleanup) d.Set("reboot_after_use", instaceProf.RebootAfterUse) - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DeviceFarm Instance Profile (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -191,14 +172,6 @@ func resourceInstanceProfileUpdate(ctx context.Context, d *schema.ResourceData, } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DeviceFarm Instance Profile (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceInstanceProfileRead(ctx, d, meta)...) } diff --git a/internal/service/devicefarm/network_profile.go b/internal/service/devicefarm/network_profile.go index f24cfa8a6a3..d9b557de2eb 100644 --- a/internal/service/devicefarm/network_profile.go +++ b/internal/service/devicefarm/network_profile.go @@ -15,9 +15,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_devicefarm_network_profile") +// @SDKResource("aws_devicefarm_network_profile", name="Network Profile") +// @Tags(identifierAttribute="arn") func ResourceNetworkProfile() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceNetworkProfileCreate, @@ -96,8 +98,8 @@ func ResourceNetworkProfile() *schema.Resource { Default: devicefarm.NetworkProfileTypePrivate, ValidateFunc: validation.StringInSlice(devicefarm.NetworkProfileType_Values(), false), }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, } @@ -106,8 +108,6 @@ func ResourceNetworkProfile() *schema.Resource { func resourceNetworkProfileCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeviceFarmConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := &devicefarm.CreateNetworkProfileInput{ Name: aws.String(d.Get("name").(string)), @@ -163,7 +163,7 @@ func resourceNetworkProfileCreate(ctx context.Context, d *schema.ResourceData, m log.Printf("[DEBUG] Successsfully Created DeviceFarm Network Profile: %s", arn) d.SetId(arn) - if len(tags) > 0 { + if tags := KeyValueTags(ctx, GetTagsIn(ctx)); len(tags) > 0 { if err := UpdateTags(ctx, conn, arn, nil, tags); err != nil { return sdkdiag.AppendErrorf(diags, "updating DeviceFarm Network Profile (%s) tags: %s", arn, err) } @@ -175,8 +175,6 @@ func resourceNetworkProfileCreate(ctx context.Context, d *schema.ResourceData, m func resourceNetworkProfileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeviceFarmConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig project, err := FindNetworkProfileByARN(ctx, conn, d.Id()) @@ -211,23 +209,6 @@ func resourceNetworkProfileRead(ctx context.Context, d *schema.ResourceData, met d.Set("project_arn", projectArn) - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DeviceFarm Network Profile (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -291,14 +272,6 @@ func resourceNetworkProfileUpdate(ctx context.Context, d *schema.ResourceData, m } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DeviceFarm Network Profile (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceNetworkProfileRead(ctx, d, meta)...) } diff --git a/internal/service/devicefarm/project.go b/internal/service/devicefarm/project.go index 524977d3a01..0ce8908fa0e 100644 --- a/internal/service/devicefarm/project.go +++ b/internal/service/devicefarm/project.go @@ -15,9 +15,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_devicefarm_project") +// @SDKResource("aws_devicefarm_project", name="Project") +// @Tags(identifierAttribute="arn") func ResourceProject() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceProjectCreate, @@ -43,8 +45,8 @@ func ResourceProject() *schema.Resource { Type: schema.TypeInt, Optional: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, } @@ -53,8 +55,6 @@ func ResourceProject() *schema.Resource { func resourceProjectCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeviceFarmConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) name := d.Get("name").(string) input := &devicefarm.CreateProjectInput{ @@ -75,7 +75,7 @@ func resourceProjectCreate(ctx context.Context, d *schema.ResourceData, meta int log.Printf("[DEBUG] Successsfully Created DeviceFarm Project: %s", arn) d.SetId(arn) - if len(tags) > 0 { + if tags := KeyValueTags(ctx, GetTagsIn(ctx)); len(tags) > 0 { if err := UpdateTags(ctx, conn, arn, nil, tags); err != nil { return sdkdiag.AppendErrorf(diags, "updating DeviceFarm Project (%s) tags: %s", arn, err) } @@ -87,8 +87,6 @@ func resourceProjectCreate(ctx context.Context, d *schema.ResourceData, meta int func resourceProjectRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeviceFarmConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig project, err := FindProjectByARN(ctx, conn, d.Id()) @@ -107,23 +105,6 @@ func resourceProjectRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set("arn", arn) d.Set("default_job_timeout_minutes", project.DefaultJobTimeoutMinutes) - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DeviceFarm Project (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -151,14 +132,6 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, meta int } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DeviceFarm Project (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceProjectRead(ctx, d, meta)...) } diff --git a/internal/service/devicefarm/service_package_gen.go b/internal/service/devicefarm/service_package_gen.go index 546bef5f0c2..e370bef7ca4 100644 --- a/internal/service/devicefarm/service_package_gen.go +++ b/internal/service/devicefarm/service_package_gen.go @@ -28,22 +28,42 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceDevicePool, TypeName: "aws_devicefarm_device_pool", + Name: "Device Pool", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceInstanceProfile, TypeName: "aws_devicefarm_instance_profile", + Name: "Instance Profile", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceNetworkProfile, TypeName: "aws_devicefarm_network_profile", + Name: "Network Profile", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceProject, TypeName: "aws_devicefarm_project", + Name: "Project", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceTestGridProject, TypeName: "aws_devicefarm_test_grid_project", + Name: "Test Grid Project", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceUpload, diff --git a/internal/service/devicefarm/test_grid_project.go b/internal/service/devicefarm/test_grid_project.go index 8f2eeb02ed7..1024c0b73c1 100644 --- a/internal/service/devicefarm/test_grid_project.go +++ b/internal/service/devicefarm/test_grid_project.go @@ -16,9 +16,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_devicefarm_test_grid_project") +// @SDKResource("aws_devicefarm_test_grid_project", name="Test Grid Project") +// @Tags(identifierAttribute="arn") func ResourceTestGridProject() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceTestGridProjectCreate, @@ -44,8 +46,8 @@ func ResourceTestGridProject() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "vpc_config": { Type: schema.TypeList, Optional: true, @@ -79,8 +81,6 @@ func ResourceTestGridProject() *schema.Resource { func resourceTestGridProjectCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeviceFarmConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) name := d.Get("name").(string) input := &devicefarm.CreateTestGridProjectInput{ @@ -105,7 +105,7 @@ func resourceTestGridProjectCreate(ctx context.Context, d *schema.ResourceData, log.Printf("[DEBUG] Successsfully Created DeviceFarm Test Grid Project: %s", arn) d.SetId(arn) - if len(tags) > 0 { + if tags := KeyValueTags(ctx, GetTagsIn(ctx)); len(tags) > 0 { if err := UpdateTags(ctx, conn, arn, nil, tags); err != nil { return sdkdiag.AppendErrorf(diags, "updating DeviceFarm Test Grid Project (%s) tags: %s", arn, err) } @@ -117,8 +117,6 @@ func resourceTestGridProjectCreate(ctx context.Context, d *schema.ResourceData, func resourceTestGridProjectRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DeviceFarmConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig project, err := FindTestGridProjectByARN(ctx, conn, d.Id()) @@ -140,23 +138,6 @@ func resourceTestGridProjectRead(ctx context.Context, d *schema.ResourceData, me return sdkdiag.AppendErrorf(diags, "setting vpc_config: %s", err) } - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DeviceFarm Test Grid Project (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -184,14 +165,6 @@ func resourceTestGridProjectUpdate(ctx context.Context, d *schema.ResourceData, } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DeviceFarm Test Grid Project (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceTestGridProjectRead(ctx, d, meta)...) } diff --git a/internal/service/directconnect/connection.go b/internal/service/directconnect/connection.go index 4673e16e78e..4c33147e7b5 100644 --- a/internal/service/directconnect/connection.go +++ b/internal/service/directconnect/connection.go @@ -17,9 +17,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dx_connection") +// @SDKResource("aws_dx_connection", name="Connection") +// @Tags(identifierAttribute="arn") func ResourceConnection() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceConnectionCreate, @@ -102,8 +104,8 @@ func ResourceConnection() *schema.Resource { Default: false, Optional: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "vlan_id": { Type: schema.TypeString, Computed: true, @@ -117,8 +119,6 @@ func ResourceConnection() *schema.Resource { func resourceConnectionCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) name := d.Get("name").(string) input := &directconnect.CreateConnectionInput{ @@ -126,16 +126,13 @@ func resourceConnectionCreate(ctx context.Context, d *schema.ResourceData, meta ConnectionName: aws.String(name), Location: aws.String(d.Get("location").(string)), RequestMACSec: aws.Bool(d.Get("request_macsec").(bool)), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("provider_name"); ok { input.ProviderName = aws.String(v.(string)) } - if len(tags) > 0 { - input.Tags = Tags(tags.IgnoreAWS()) - } - log.Printf("[DEBUG] Creating Direct Connect Connection: %s", input) output, err := conn.CreateConnectionWithContext(ctx, input) @@ -151,8 +148,6 @@ func resourceConnectionCreate(ctx context.Context, d *schema.ResourceData, meta func resourceConnectionRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig connection, err := FindConnectionByID(ctx, conn, d.Id()) @@ -193,23 +188,6 @@ func resourceConnectionRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("request_macsec", aws.Bool(false)) } - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for Direct Connect Connection (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -234,15 +212,6 @@ func resourceConnectionUpdate(ctx context.Context, d *schema.ResourceData, meta } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - arn := d.Get("arn").(string) - - if err := UpdateTags(ctx, conn, arn, o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating Direct Connect Connection (%s) tags: %s", d.Id(), err) - } - } - return append(diags, resourceConnectionRead(ctx, d, meta)...) } diff --git a/internal/service/directconnect/hosted_private_virtual_interface_accepter.go b/internal/service/directconnect/hosted_private_virtual_interface_accepter.go index 162913f9988..23ee433e8ce 100644 --- a/internal/service/directconnect/hosted_private_virtual_interface_accepter.go +++ b/internal/service/directconnect/hosted_private_virtual_interface_accepter.go @@ -15,9 +15,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dx_hosted_private_virtual_interface_accepter") +// @SDKResource("aws_dx_hosted_private_virtual_interface_accepter", name="Hosted Private Virtual Interface") +// @Tags(identifierAttribute="arn") func ResourceHostedPrivateVirtualInterfaceAccepter() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceHostedPrivateVirtualInterfaceAccepterCreate, @@ -39,8 +41,8 @@ func ResourceHostedPrivateVirtualInterfaceAccepter() *schema.Resource { ForceNew: true, ConflictsWith: []string{"vpn_gateway_id"}, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "virtual_interface_id": { Type: schema.TypeString, Required: true, @@ -104,14 +106,18 @@ func resourceHostedPrivateVirtualInterfaceAccepterCreate(ctx context.Context, d return sdkdiag.AppendFromErr(diags, err) } + if tags := KeyValueTags(ctx, GetTagsIn(ctx)); len(tags) > 0 { + if err := UpdateTags(ctx, conn, arn, nil, tags); err != nil { + return sdkdiag.AppendErrorf(diags, "updating Direct Connect hosted private virtual interface (%s) tags: %s", arn, err) + } + } + return append(diags, resourceHostedPrivateVirtualInterfaceAccepterUpdate(ctx, d, meta)...) } func resourceHostedPrivateVirtualInterfaceAccepterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig vif, err := virtualInterfaceRead(ctx, d.Id(), conn) if err != nil { @@ -134,24 +140,6 @@ func resourceHostedPrivateVirtualInterfaceAccepterRead(ctx context.Context, d *s d.Set("virtual_interface_id", vif.VirtualInterfaceId) d.Set("vpn_gateway_id", vif.VirtualGatewayId) - arn := d.Get("arn").(string) - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for Direct Connect hosted private virtual interface (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } diff --git a/internal/service/directconnect/hosted_public_virtual_interface_accepter.go b/internal/service/directconnect/hosted_public_virtual_interface_accepter.go index b449feab2e2..951f5d7ceb2 100644 --- a/internal/service/directconnect/hosted_public_virtual_interface_accepter.go +++ b/internal/service/directconnect/hosted_public_virtual_interface_accepter.go @@ -15,9 +15,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dx_hosted_public_virtual_interface_accepter") +// @SDKResource("aws_dx_hosted_public_virtual_interface_accepter", name="Hosted Public Virtual Interface") +// @Tags(identifierAttribute="arn") func ResourceHostedPublicVirtualInterfaceAccepter() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceHostedPublicVirtualInterfaceAccepterCreate, @@ -33,8 +35,8 @@ func ResourceHostedPublicVirtualInterfaceAccepter() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "virtual_interface_id": { Type: schema.TypeString, Required: true, @@ -80,14 +82,18 @@ func resourceHostedPublicVirtualInterfaceAccepterCreate(ctx context.Context, d * return sdkdiag.AppendFromErr(diags, err) } + if tags := KeyValueTags(ctx, GetTagsIn(ctx)); len(tags) > 0 { + if err := UpdateTags(ctx, conn, arn, nil, tags); err != nil { + return sdkdiag.AppendErrorf(diags, "updating Direct Connect hosted public virtual interface (%s) tags: %s", arn, err) + } + } + return append(diags, resourceHostedPublicVirtualInterfaceAccepterUpdate(ctx, d, meta)...) } func resourceHostedPublicVirtualInterfaceAccepterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig vif, err := virtualInterfaceRead(ctx, d.Id(), conn) if err != nil { @@ -109,24 +115,6 @@ func resourceHostedPublicVirtualInterfaceAccepterRead(ctx context.Context, d *sc d.Set("virtual_interface_id", vif.VirtualInterfaceId) - arn := d.Get("arn").(string) - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for Direct Connect hosted public virtual interface (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } diff --git a/internal/service/directconnect/hosted_transit_virtual_interface_accepter.go b/internal/service/directconnect/hosted_transit_virtual_interface_accepter.go index 81ce620e4b8..d152e9a5b0f 100644 --- a/internal/service/directconnect/hosted_transit_virtual_interface_accepter.go +++ b/internal/service/directconnect/hosted_transit_virtual_interface_accepter.go @@ -15,9 +15,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dx_hosted_transit_virtual_interface_accepter") +// @SDKResource("aws_dx_hosted_transit_virtual_interface_accepter", name="Hosted Transit Virtual Interface") +// @Tags(identifierAttribute="arn") func ResourceHostedTransitVirtualInterfaceAccepter() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceHostedTransitVirtualInterfaceAccepterCreate, @@ -38,8 +40,8 @@ func ResourceHostedTransitVirtualInterfaceAccepter() *schema.Resource { Required: true, ForceNew: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "virtual_interface_id": { Type: schema.TypeString, Required: true, @@ -86,14 +88,18 @@ func resourceHostedTransitVirtualInterfaceAccepterCreate(ctx context.Context, d return sdkdiag.AppendFromErr(diags, err) } + if tags := KeyValueTags(ctx, GetTagsIn(ctx)); len(tags) > 0 { + if err := UpdateTags(ctx, conn, arn, nil, tags); err != nil { + return sdkdiag.AppendErrorf(diags, "updating Direct Connect hosted transit virtual interface (%s) tags: %s", arn, err) + } + } + return append(diags, resourceHostedTransitVirtualInterfaceAccepterUpdate(ctx, d, meta)...) } func resourceHostedTransitVirtualInterfaceAccepterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig vif, err := virtualInterfaceRead(ctx, d.Id(), conn) if err != nil { @@ -114,24 +120,6 @@ func resourceHostedTransitVirtualInterfaceAccepterRead(ctx context.Context, d *s d.Set("dx_gateway_id", vif.DirectConnectGatewayId) d.Set("virtual_interface_id", vif.VirtualInterfaceId) - arn := d.Get("arn").(string) - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for Direct Connect hosted transit virtual interface (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } diff --git a/internal/service/directconnect/lag.go b/internal/service/directconnect/lag.go index 3d7ac6cb237..600368f6fea 100644 --- a/internal/service/directconnect/lag.go +++ b/internal/service/directconnect/lag.go @@ -16,9 +16,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dx_lag") +// @SDKResource("aws_dx_lag", name="LAG") +// @Tags(identifierAttribute="arn") func ResourceLag() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceLagCreate, @@ -77,8 +79,8 @@ func ResourceLag() *schema.Resource { Computed: true, ForceNew: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, @@ -88,14 +90,13 @@ func ResourceLag() *schema.Resource { func resourceLagCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) name := d.Get("name").(string) input := &directconnect.CreateLagInput{ ConnectionsBandwidth: aws.String(d.Get("connections_bandwidth").(string)), LagName: aws.String(name), Location: aws.String(d.Get("location").(string)), + Tags: GetTagsIn(ctx), } var connectionIDSpecified bool @@ -111,10 +112,6 @@ func resourceLagCreate(ctx context.Context, d *schema.ResourceData, meta interfa input.ProviderName = aws.String(v.(string)) } - if len(tags) > 0 { - input.Tags = Tags(tags.IgnoreAWS()) - } - log.Printf("[DEBUG] Creating Direct Connect LAG: %s", input) output, err := conn.CreateLagWithContext(ctx, input) @@ -139,8 +136,6 @@ func resourceLagCreate(ctx context.Context, d *schema.ResourceData, meta interfa func resourceLagRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig lag, err := FindLagByID(ctx, conn, d.Id()) @@ -170,23 +165,6 @@ func resourceLagRead(ctx context.Context, d *schema.ResourceData, meta interface d.Set("owner_account_id", lag.OwnerAccount) d.Set("provider_name", lag.ProviderName) - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for Direct Connect LAG (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -208,15 +186,6 @@ func resourceLagUpdate(ctx context.Context, d *schema.ResourceData, meta interfa } } - arn := d.Get("arn").(string) - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, arn, o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating Direct Connect LAG (%s) tags: %s", arn, err) - } - } - return append(diags, resourceLagRead(ctx, d, meta)...) } diff --git a/internal/service/directconnect/private_virtual_interface.go b/internal/service/directconnect/private_virtual_interface.go index bcab3773f8e..ae09c894aae 100644 --- a/internal/service/directconnect/private_virtual_interface.go +++ b/internal/service/directconnect/private_virtual_interface.go @@ -17,9 +17,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dx_private_virtual_interface") +// @SDKResource("aws_dx_private_virtual_interface", name="Private Virtual Interface") +// @Tags(identifierAttribute="arn") func ResourcePrivateVirtualInterface() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourcePrivateVirtualInterfaceCreate, @@ -105,8 +107,8 @@ func ResourcePrivateVirtualInterface() *schema.Resource { Type: schema.TypeBool, Optional: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "vlan": { Type: schema.TypeInt, Required: true, @@ -134,8 +136,6 @@ func ResourcePrivateVirtualInterface() *schema.Resource { func resourcePrivateVirtualInterfaceCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) vgwIdRaw, vgwOk := d.GetOk("vpn_gateway_id") dxgwIdRaw, dxgwOk := d.GetOk("dx_gateway_id") @@ -150,6 +150,7 @@ func resourcePrivateVirtualInterfaceCreate(ctx context.Context, d *schema.Resour Asn: aws.Int64(int64(d.Get("bgp_asn").(int))), EnableSiteLink: aws.Bool(d.Get("sitelink_enabled").(bool)), Mtu: aws.Int64(int64(d.Get("mtu").(int))), + Tags: GetTagsIn(ctx), VirtualInterfaceName: aws.String(d.Get("name").(string)), Vlan: aws.Int64(int64(d.Get("vlan").(int))), }, @@ -169,9 +170,6 @@ func resourcePrivateVirtualInterfaceCreate(ctx context.Context, d *schema.Resour if v, ok := d.GetOk("customer_address"); ok { req.NewPrivateVirtualInterface.CustomerAddress = aws.String(v.(string)) } - if len(tags) > 0 { - req.NewPrivateVirtualInterface.Tags = Tags(tags.IgnoreAWS()) - } log.Printf("[DEBUG] Creating Direct Connect private virtual interface: %s", req) resp, err := conn.CreatePrivateVirtualInterfaceWithContext(ctx, req) @@ -191,8 +189,6 @@ func resourcePrivateVirtualInterfaceCreate(ctx context.Context, d *schema.Resour func resourcePrivateVirtualInterfaceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig vif, err := virtualInterfaceRead(ctx, d.Id(), conn) if err != nil { @@ -228,23 +224,6 @@ func resourcePrivateVirtualInterfaceRead(ctx context.Context, d *schema.Resource d.Set("vlan", vif.Vlan) d.Set("vpn_gateway_id", vif.VirtualGatewayId) - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for Direct Connect private virtual interface (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } diff --git a/internal/service/directconnect/public_virtual_interface.go b/internal/service/directconnect/public_virtual_interface.go index 27a3ffa520c..dcb782a4e45 100644 --- a/internal/service/directconnect/public_virtual_interface.go +++ b/internal/service/directconnect/public_virtual_interface.go @@ -18,9 +18,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dx_public_virtual_interface") +// @SDKResource("aws_dx_public_virtual_interface", name="Public Virtual Interface") +// @Tags(identifierAttribute="arn") func ResourcePublicVirtualInterface() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourcePublicVirtualInterfaceCreate, @@ -97,8 +99,8 @@ func ResourcePublicVirtualInterface() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, MinItems: 1, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "vlan": { Type: schema.TypeInt, Required: true, @@ -117,14 +119,13 @@ func ResourcePublicVirtualInterface() *schema.Resource { func resourcePublicVirtualInterfaceCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) req := &directconnect.CreatePublicVirtualInterfaceInput{ ConnectionId: aws.String(d.Get("connection_id").(string)), NewPublicVirtualInterface: &directconnect.NewPublicVirtualInterface{ AddressFamily: aws.String(d.Get("address_family").(string)), Asn: aws.Int64(int64(d.Get("bgp_asn").(int))), + Tags: GetTagsIn(ctx), VirtualInterfaceName: aws.String(d.Get("name").(string)), Vlan: aws.Int64(int64(d.Get("vlan").(int))), }, @@ -141,9 +142,6 @@ func resourcePublicVirtualInterfaceCreate(ctx context.Context, d *schema.Resourc if v, ok := d.GetOk("route_filter_prefixes"); ok { req.NewPublicVirtualInterface.RouteFilterPrefixes = expandRouteFilterPrefixes(v.(*schema.Set).List()) } - if len(tags) > 0 { - req.NewPublicVirtualInterface.Tags = Tags(tags.IgnoreAWS()) - } log.Printf("[DEBUG] Creating Direct Connect public virtual interface: %s", req) resp, err := conn.CreatePublicVirtualInterfaceWithContext(ctx, req) @@ -163,8 +161,6 @@ func resourcePublicVirtualInterfaceCreate(ctx context.Context, d *schema.Resourc func resourcePublicVirtualInterfaceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig vif, err := virtualInterfaceRead(ctx, d.Id(), conn) if err != nil { @@ -198,23 +194,6 @@ func resourcePublicVirtualInterfaceRead(ctx context.Context, d *schema.ResourceD } d.Set("vlan", vif.Vlan) - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for Direct Connect public virtual interface (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } diff --git a/internal/service/directconnect/service_package_gen.go b/internal/service/directconnect/service_package_gen.go index 3a3e120eab1..c9801bbb68f 100644 --- a/internal/service/directconnect/service_package_gen.go +++ b/internal/service/directconnect/service_package_gen.go @@ -53,6 +53,10 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceConnection, TypeName: "aws_dx_connection", + Name: "Connection", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceConnectionAssociation, @@ -85,6 +89,10 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceHostedPrivateVirtualInterfaceAccepter, TypeName: "aws_dx_hosted_private_virtual_interface_accepter", + Name: "Hosted Private Virtual Interface", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceHostedPublicVirtualInterface, @@ -93,6 +101,10 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceHostedPublicVirtualInterfaceAccepter, TypeName: "aws_dx_hosted_public_virtual_interface_accepter", + Name: "Hosted Public Virtual Interface", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceHostedTransitVirtualInterface, @@ -101,10 +113,18 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceHostedTransitVirtualInterfaceAccepter, TypeName: "aws_dx_hosted_transit_virtual_interface_accepter", + Name: "Hosted Transit Virtual Interface", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceLag, TypeName: "aws_dx_lag", + Name: "LAG", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceMacSecKeyAssociation, @@ -113,14 +133,26 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourcePrivateVirtualInterface, TypeName: "aws_dx_private_virtual_interface", + Name: "Private Virtual Interface", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourcePublicVirtualInterface, TypeName: "aws_dx_public_virtual_interface", + Name: "Public Virtual Interface", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceTransitVirtualInterface, TypeName: "aws_dx_transit_virtual_interface", + Name: "Transit Virtual Interface", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, } } diff --git a/internal/service/directconnect/transit_virtual_interface.go b/internal/service/directconnect/transit_virtual_interface.go index 7ea710a664c..a23428fa3d6 100644 --- a/internal/service/directconnect/transit_virtual_interface.go +++ b/internal/service/directconnect/transit_virtual_interface.go @@ -17,9 +17,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dx_transit_virtual_interface") +// @SDKResource("aws_dx_transit_virtual_interface", name="Transit Virtual Interface") +// @Tags(identifierAttribute="arn") func ResourceTransitVirtualInterface() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceTransitVirtualInterfaceCreate, @@ -104,8 +106,8 @@ func ResourceTransitVirtualInterface() *schema.Resource { Type: schema.TypeBool, Optional: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "vlan": { Type: schema.TypeInt, Required: true, @@ -127,8 +129,6 @@ func ResourceTransitVirtualInterface() *schema.Resource { func resourceTransitVirtualInterfaceCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) req := &directconnect.CreateTransitVirtualInterfaceInput{ ConnectionId: aws.String(d.Get("connection_id").(string)), @@ -138,6 +138,7 @@ func resourceTransitVirtualInterfaceCreate(ctx context.Context, d *schema.Resour DirectConnectGatewayId: aws.String(d.Get("dx_gateway_id").(string)), EnableSiteLink: aws.Bool(d.Get("sitelink_enabled").(bool)), Mtu: aws.Int64(int64(d.Get("mtu").(int))), + Tags: GetTagsIn(ctx), VirtualInterfaceName: aws.String(d.Get("name").(string)), Vlan: aws.Int64(int64(d.Get("vlan").(int))), }, @@ -151,9 +152,6 @@ func resourceTransitVirtualInterfaceCreate(ctx context.Context, d *schema.Resour if v, ok := d.GetOk("customer_address"); ok { req.NewTransitVirtualInterface.CustomerAddress = aws.String(v.(string)) } - if len(tags) > 0 { - req.NewTransitVirtualInterface.Tags = Tags(tags.IgnoreAWS()) - } log.Printf("[DEBUG] Creating Direct Connect transit virtual interface: %s", req) resp, err := conn.CreateTransitVirtualInterfaceWithContext(ctx, req) @@ -173,8 +171,6 @@ func resourceTransitVirtualInterfaceCreate(ctx context.Context, d *schema.Resour func resourceTransitVirtualInterfaceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DirectConnectConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig vif, err := virtualInterfaceRead(ctx, d.Id(), conn) if err != nil { @@ -209,23 +205,6 @@ func resourceTransitVirtualInterfaceRead(ctx context.Context, d *schema.Resource d.Set("sitelink_enabled", vif.SiteLinkEnabled) d.Set("vlan", vif.Vlan) - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for Direct Connect transit virtual interface (%s): %s", arn, err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } diff --git a/internal/service/directconnect/vif.go b/internal/service/directconnect/vif.go index bb56eba1f59..e1951081fc4 100644 --- a/internal/service/directconnect/vif.go +++ b/internal/service/directconnect/vif.go @@ -55,15 +55,6 @@ func virtualInterfaceUpdate(ctx context.Context, d *schema.ResourceData, meta in } } - arn := d.Get("arn").(string) - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, arn, o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating Direct Connect virtual interface (%s) tags: %s", arn, err) - } - } - return diags } diff --git a/internal/service/dlm/lifecycle_policy.go b/internal/service/dlm/lifecycle_policy.go index 620d1781b81..580f6afd9ba 100644 --- a/internal/service/dlm/lifecycle_policy.go +++ b/internal/service/dlm/lifecycle_policy.go @@ -18,9 +18,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dlm_lifecycle_policy") +// @SDKResource("aws_dlm_lifecycle_policy", name="Lifecycle Policy") +// @Tags(identifierAttribute="arn") func ResourceLifecyclePolicy() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceLifecyclePolicyCreate, @@ -487,8 +489,8 @@ func ResourceLifecyclePolicy() *schema.Resource { Default: dlm.SettablePolicyStateValuesEnabled, ValidateFunc: validation.StringInSlice(dlm.SettablePolicyStateValues_Values(), false), }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, @@ -498,18 +500,13 @@ func ResourceLifecyclePolicy() *schema.Resource { func resourceLifecyclePolicyCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DLMConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := dlm.CreateLifecyclePolicyInput{ Description: aws.String(d.Get("description").(string)), ExecutionRoleArn: aws.String(d.Get("execution_role_arn").(string)), PolicyDetails: expandPolicyDetails(d.Get("policy_details").([]interface{})), State: aws.String(d.Get("state").(string)), - } - - if len(tags) > 0 { - input.Tags = Tags(tags.IgnoreAWS()) + Tags: GetTagsIn(ctx), } log.Printf("[INFO] Creating DLM lifecycle policy: %s", input) @@ -529,8 +526,6 @@ func resourceLifecyclePolicyCreate(ctx context.Context, d *schema.ResourceData, func resourceLifecyclePolicyRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DLMConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig log.Printf("[INFO] Reading DLM lifecycle policy: %s", d.Id()) out, err := conn.GetLifecyclePolicyWithContext(ctx, &dlm.GetLifecyclePolicyInput{ @@ -555,16 +550,7 @@ func resourceLifecyclePolicyRead(ctx context.Context, d *schema.ResourceData, me return sdkdiag.AppendErrorf(diags, "setting policy details %s", err) } - tags := KeyValueTags(ctx, out.Policy.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } + SetTagsOut(ctx, out.Policy.Tags) return diags } @@ -598,13 +584,6 @@ func resourceLifecyclePolicyUpdate(ctx context.Context, d *schema.ResourceData, } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating tags: %s", err) - } - } - return append(diags, resourceLifecyclePolicyRead(ctx, d, meta)...) } diff --git a/internal/service/dlm/service_package_gen.go b/internal/service/dlm/service_package_gen.go index 6654ad98c1b..74415ef323c 100644 --- a/internal/service/dlm/service_package_gen.go +++ b/internal/service/dlm/service_package_gen.go @@ -28,6 +28,10 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceLifecyclePolicy, TypeName: "aws_dlm_lifecycle_policy", + Name: "Lifecycle Policy", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, } } diff --git a/internal/service/dms/certificate.go b/internal/service/dms/certificate.go index ed3f0d4ac1b..97b0ce711bc 100644 --- a/internal/service/dms/certificate.go +++ b/internal/service/dms/certificate.go @@ -16,9 +16,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dms_certificate") +// @SDKResource("aws_dms_certificate", name="Certificate") +// @Tags(identifierAttribute="certificate_arn") func ResourceCertificate() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceCertificateCreate, @@ -58,8 +60,8 @@ func ResourceCertificate() *schema.Resource { ForceNew: true, Sensitive: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, @@ -69,13 +71,11 @@ func ResourceCertificate() *schema.Resource { func resourceCertificateCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) - certificateID := d.Get("certificate_id").(string) + certificateID := d.Get("certificate_id").(string) request := &dms.ImportCertificateInput{ CertificateIdentifier: aws.String(certificateID), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } pem, pemSet := d.GetOk("certificate_pem") @@ -111,8 +111,6 @@ func resourceCertificateCreate(ctx context.Context, d *schema.ResourceData, meta func resourceCertificateRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig response, err := conn.DescribeCertificatesWithContext(ctx, &dms.DescribeCertificatesInput{ Filters: []*dms.Filter{ @@ -144,38 +142,13 @@ func resourceCertificateRead(ctx context.Context, d *schema.ResourceData, meta i resourceCertificateSetState(d, response.Certificates[0]) - tags, err := ListTags(ctx, conn, d.Get("certificate_arn").(string)) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DMS Certificate (%s): %s", d.Get("certificate_arn").(string), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } func resourceCertificateUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).DMSConn() - if d.HasChange("tags_all") { - arn := d.Get("certificate_arn").(string) - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, arn, o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DMS Certificate (%s) tags: %s", arn, err) - } - } + // Tags only. return append(diags, resourceCertificateRead(ctx, d, meta)...) } diff --git a/internal/service/dms/endpoint.go b/internal/service/dms/endpoint.go index e674a1a329b..11b2b8ec14d 100644 --- a/internal/service/dms/endpoint.go +++ b/internal/service/dms/endpoint.go @@ -22,9 +22,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dms_endpoint") +// @SDKResource("aws_dms_endpoint", name="Endpoint") +// @Tags(identifierAttribute="endpoint_arn") func ResourceEndpoint() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceEndpointCreate, @@ -674,8 +676,8 @@ func ResourceEndpoint() *schema.Resource { Optional: true, ValidateFunc: validation.StringInSlice(dms.DmsSslModeValue_Values(), false), }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "username": { Type: schema.TypeString, Optional: true, @@ -696,15 +698,13 @@ func ResourceEndpoint() *schema.Resource { func resourceEndpointCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) endpointID := d.Get("endpoint_id").(string) input := &dms.CreateEndpointInput{ EndpointIdentifier: aws.String(endpointID), EndpointType: aws.String(d.Get("endpoint_type").(string)), EngineName: aws.String(d.Get("engine_name").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("certificate_arn"); ok { @@ -949,8 +949,6 @@ func resourceEndpointCreate(ctx context.Context, d *schema.ResourceData, meta in func resourceEndpointRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig endpoint, err := FindEndpointByID(ctx, conn, d.Id()) @@ -970,23 +968,6 @@ func resourceEndpointRead(ctx context.Context, d *schema.ResourceData, meta inte return sdkdiag.AppendErrorf(diags, "reading DMS Endpoint (%s): %s", d.Id(), err) } - tags, err := ListTags(ctx, conn, d.Get("endpoint_arn").(string)) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DMS Endpoint (%s): %s", d.Get("endpoint_arn").(string), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -1329,15 +1310,6 @@ func resourceEndpointUpdate(ctx context.Context, d *schema.ResourceData, meta in } } - if d.HasChange("tags_all") { - arn := d.Get("endpoint_arn").(string) - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, arn, o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DMS Endpoint (%s) tags: %s", arn, err) - } - } - return append(diags, resourceEndpointRead(ctx, d, meta)...) } diff --git a/internal/service/dms/event_subscription.go b/internal/service/dms/event_subscription.go index fb7c62f06ba..e4da3fae399 100644 --- a/internal/service/dms/event_subscription.go +++ b/internal/service/dms/event_subscription.go @@ -19,9 +19,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/flex" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dms_event_subscription") +// @SDKResource("aws_dms_event_subscription", name="Event Subscription") +// @Tags(identifierAttribute="arn") func ResourceEventSubscription() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceEventSubscriptionCreate, @@ -82,8 +84,8 @@ func ResourceEventSubscription() *schema.Resource { "replication-task", }, false), }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, @@ -93,15 +95,13 @@ func ResourceEventSubscription() *schema.Resource { func resourceEventSubscriptionCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, 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: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("event_categories"); ok { @@ -137,59 +137,9 @@ func resourceEventSubscriptionCreate(ctx context.Context, d *schema.ResourceData return append(diags, resourceEventSubscriptionRead(ctx, d, meta)...) } -func resourceEventSubscriptionUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).DMSConn() - - if d.HasChanges("enabled", "event_categories", "sns_topic_arn", "source_type") { - request := &dms.ModifyEventSubscriptionInput{ - 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)), - } - - if v, ok := d.GetOk("event_categories"); ok { - request.EventCategories = flex.ExpandStringSet(v.(*schema.Set)) - } - - _, err := conn.ModifyEventSubscriptionWithContext(ctx, request) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "updating DMS Event Subscription (%s): %s", d.Id(), err) - } - - stateConf := &retry.StateChangeConf{ - Pending: []string{"modifying"}, - Target: []string{"active"}, - Refresh: resourceEventSubscriptionStateRefreshFunc(ctx, conn, d.Id()), - Timeout: d.Timeout(schema.TimeoutUpdate), - MinTimeout: 10 * time.Second, - Delay: 10 * time.Second, - } - - _, err = stateConf.WaitForStateContext(ctx) - if err != nil { - return sdkdiag.AppendErrorf(diags, "waiting for DMS Event Subscription (%s) modification: %s", d.Id(), err) - } - } - - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DMS Event Subscription (%s) tags: %s", d.Get("arn").(string), err) - } - } - - return append(diags, resourceEventSubscriptionRead(ctx, d, meta)...) -} - func resourceEventSubscriptionRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig request := &dms.DescribeEventSubscriptionsInput{ SubscriptionName: aws.String(d.Id()), @@ -231,24 +181,47 @@ func resourceEventSubscriptionRead(ctx context.Context, d *schema.ResourceData, d.Set("event_categories", flex.FlattenStringList(subscription.EventCategoriesList)) d.Set("source_ids", flex.FlattenStringList(subscription.SourceIdsList)) - tags, err := ListTags(ctx, conn, arn) + return diags +} - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DMS Event Subscription (%s): %s", arn, err) - } +func resourceEventSubscriptionUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + var diags diag.Diagnostics + conn := meta.(*conns.AWSClient).DMSConn() - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) + if d.HasChanges("enabled", "event_categories", "sns_topic_arn", "source_type") { + request := &dms.ModifyEventSubscriptionInput{ + 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)), + } - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } + if v, ok := d.GetOk("event_categories"); ok { + request.EventCategories = flex.ExpandStringSet(v.(*schema.Set)) + } - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) + _, err := conn.ModifyEventSubscriptionWithContext(ctx, request) + + if err != nil { + return sdkdiag.AppendErrorf(diags, "updating DMS Event Subscription (%s): %s", d.Id(), err) + } + + stateConf := &retry.StateChangeConf{ + Pending: []string{"modifying"}, + Target: []string{"active"}, + Refresh: resourceEventSubscriptionStateRefreshFunc(ctx, conn, d.Id()), + Timeout: d.Timeout(schema.TimeoutUpdate), + MinTimeout: 10 * time.Second, + Delay: 10 * time.Second, + } + + _, err = stateConf.WaitForStateContext(ctx) + if err != nil { + return sdkdiag.AppendErrorf(diags, "waiting for DMS Event Subscription (%s) modification: %s", d.Id(), err) + } } - return diags + return append(diags, resourceEventSubscriptionRead(ctx, d, meta)...) } func resourceEventSubscriptionDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/internal/service/dms/replication_instance.go b/internal/service/dms/replication_instance.go index 7977829acb5..c441126f11a 100644 --- a/internal/service/dms/replication_instance.go +++ b/internal/service/dms/replication_instance.go @@ -17,9 +17,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/flex" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dms_replication_instance") +// @SDKResource("aws_dms_replication_instance", name="Replication Instance") +// @Tags(identifierAttribute="replication_instance_arn") func ResourceReplicationInstance() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceReplicationInstanceCreate, @@ -124,8 +126,8 @@ func ResourceReplicationInstance() *schema.Resource { Optional: true, ForceNew: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "vpc_security_group_ids": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, @@ -142,8 +144,6 @@ func ResourceReplicationInstance() *schema.Resource { func resourceReplicationInstanceCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) request := &dms.CreateReplicationInstanceInput{ AutoMinorVersionUpgrade: aws.Bool(d.Get("auto_minor_version_upgrade").(bool)), @@ -151,7 +151,7 @@ func resourceReplicationInstanceCreate(ctx context.Context, d *schema.ResourceDa 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: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } // WARNING: GetOk returns the zero value for the type if the key is omitted in config. This means for optional @@ -210,8 +210,6 @@ func resourceReplicationInstanceCreate(ctx context.Context, d *schema.ResourceDa func resourceReplicationInstanceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig response, err := conn.DescribeReplicationInstancesWithContext(ctx, &dms.DescribeReplicationInstancesInput{ Filters: []*dms.Filter{ @@ -271,23 +269,6 @@ func resourceReplicationInstanceRead(ctx context.Context, d *schema.ResourceData return sdkdiag.AppendErrorf(diags, "setting vpc_security_group_ids: %s", err) } - tags, err := ListTags(ctx, conn, d.Get("replication_instance_arn").(string)) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DMS Replication Instance (%s): %s", d.Get("replication_instance_arn").(string), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -350,15 +331,6 @@ func resourceReplicationInstanceUpdate(ctx context.Context, d *schema.ResourceDa } } - if d.HasChange("tags_all") { - arn := d.Get("replication_instance_arn").(string) - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, arn, o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DMS Replication Instance (%s) tags: %s", arn, err) - } - } - if hasChanges { _, err := conn.ModifyReplicationInstanceWithContext(ctx, request) if err != nil { diff --git a/internal/service/dms/replication_subnet_group.go b/internal/service/dms/replication_subnet_group.go index efd57d27039..a02f70fc727 100644 --- a/internal/service/dms/replication_subnet_group.go +++ b/internal/service/dms/replication_subnet_group.go @@ -22,7 +22,8 @@ import ( "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dms_replication_subnet_group") +// @SDKResource("aws_dms_replication_subnet_group", name="Replication Subnet Group") +// @Tags(identifierAttribute="replication_subnet_group_arn") func ResourceReplicationSubnetGroup() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceReplicationSubnetGroupCreate, @@ -62,8 +63,8 @@ func ResourceReplicationSubnetGroup() *schema.Resource { MinItems: 2, Required: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "vpc_id": { Type: schema.TypeString, Computed: true, @@ -81,14 +82,12 @@ const ( func resourceReplicationSubnetGroupCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, 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: flex.ExpandStringSet(d.Get("subnet_ids").(*schema.Set)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } log.Println("[DEBUG] DMS create replication subnet group:", request) @@ -126,8 +125,6 @@ func resourceReplicationSubnetGroupCreate(ctx context.Context, d *schema.Resourc func resourceReplicationSubnetGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig response, err := conn.DescribeReplicationSubnetGroupsWithContext(ctx, &dms.DescribeReplicationSubnetGroupsInput{ Filters: []*dms.Filter{ @@ -178,23 +175,6 @@ func resourceReplicationSubnetGroupRead(ctx context.Context, d *schema.ResourceD d.Set("subnet_ids", subnet_ids) d.Set("vpc_id", group.VpcId) - tags, err := ListTags(ctx, conn, arn) - - if err != nil { - return create.DiagError(names.DMS, create.ErrActionReading, ResNameReplicationSubnetGroup, d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return create.DiagSettingError(names.DMS, ResNameReplicationSubnetGroup, d.Id(), "tags", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return create.DiagSettingError(names.DMS, ResNameReplicationSubnetGroup, d.Id(), "tags_all", err) - } - return diags } @@ -213,15 +193,6 @@ func resourceReplicationSubnetGroupUpdate(ctx context.Context, d *schema.Resourc request.ReplicationSubnetGroupDescription = aws.String(d.Get("replication_subnet_group_description").(string)) } - if d.HasChange("tags_all") { - arn := d.Get("replication_subnet_group_arn").(string) - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, arn, o, n); err != nil { - return create.DiagError(names.DMS, create.ErrActionUpdating, ResNameReplicationSubnetGroup, d.Id(), err) - } - } - log.Println("[DEBUG] DMS update replication subnet group:", request) _, err := conn.ModifyReplicationSubnetGroupWithContext(ctx, request) diff --git a/internal/service/dms/replication_task.go b/internal/service/dms/replication_task.go index 6a819a7d19e..d5864702854 100644 --- a/internal/service/dms/replication_task.go +++ b/internal/service/dms/replication_task.go @@ -19,9 +19,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dms_replication_task") +// @SDKResource("aws_dms_replication_task", name="Replication Task") +// @Tags(identifierAttribute="replication_task_arn") func ResourceReplicationTask() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceReplicationTaskCreate, @@ -98,8 +100,8 @@ func ResourceReplicationTask() *schema.Resource { ValidateFunc: validation.StringIsJSON, DiffSuppressFunc: verify.SuppressEquivalentJSONDiffs, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "target_endpoint_arn": { Type: schema.TypeString, Required: true, @@ -115,8 +117,6 @@ func ResourceReplicationTask() *schema.Resource { func resourceReplicationTaskCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) taskId := d.Get("replication_task_id").(string) @@ -126,7 +126,7 @@ func resourceReplicationTaskCreate(ctx context.Context, d *schema.ResourceData, ReplicationTaskIdentifier: aws.String(taskId), SourceEndpointArn: aws.String(d.Get("source_endpoint_arn").(string)), TableMappings: aws.String(d.Get("table_mappings").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), TargetEndpointArn: aws.String(d.Get("target_endpoint_arn").(string)), } @@ -171,8 +171,6 @@ func resourceReplicationTaskCreate(ctx context.Context, d *schema.ResourceData, func resourceReplicationTaskRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig task, err := FindReplicationTaskByID(ctx, conn, d.Id()) @@ -207,23 +205,6 @@ func resourceReplicationTaskRead(ctx context.Context, d *schema.ResourceData, me d.Set("replication_task_settings", settings) - tags, err := ListTags(ctx, conn, d.Get("replication_task_arn").(string)) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DMS Replication Task (%s): %s", d.Get("replication_task_arn").(string), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -297,15 +278,6 @@ func resourceReplicationTaskUpdate(ctx context.Context, d *schema.ResourceData, } } - if d.HasChange("tags_all") { - arn := d.Get("replication_task_arn").(string) - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, arn, o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DMS Replication Task (%s) tags: %s", arn, err) - } - } - return append(diags, resourceReplicationTaskRead(ctx, d, meta)...) } diff --git a/internal/service/dms/s3_endpoint.go b/internal/service/dms/s3_endpoint.go index 20f1f2ba46c..65857ef32fa 100644 --- a/internal/service/dms/s3_endpoint.go +++ b/internal/service/dms/s3_endpoint.go @@ -24,7 +24,8 @@ import ( "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_dms_s3_endpoint") +// @SDKResource("aws_dms_s3_endpoint", name="S3 Endpoint") +// @Tags(identifierAttribute="endpoint_arn") func ResourceS3Endpoint() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceS3EndpointCreate, @@ -88,8 +89,8 @@ func ResourceS3Endpoint() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), /////// S3-Specific Settings "add_column_name": { @@ -319,14 +320,12 @@ const ( func resourceS3EndpointCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) input := &dms.CreateEndpointInput{ EndpointIdentifier: aws.String(d.Get("endpoint_id").(string)), EndpointType: aws.String(d.Get("endpoint_type").(string)), EngineName: aws.String("s3"), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("certificate_arn"); ok { @@ -389,8 +388,6 @@ func resourceS3EndpointCreate(ctx context.Context, d *schema.ResourceData, meta func resourceS3EndpointRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DMSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig endpoint, err := FindEndpointByID(ctx, conn, d.Id()) @@ -474,22 +471,6 @@ func resourceS3EndpointRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("external_table_definition", p) - tags, err := ListTags(ctx, conn, d.Get("endpoint_arn").(string)) - if err != nil { - return create.DiagError(names.DMS, create.ErrActionReading, ResNameS3Endpoint, d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return create.DiagError(names.DMS, create.ErrActionReading, ResNameS3Endpoint, d.Id(), err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return create.DiagError(names.DMS, create.ErrActionReading, ResNameS3Endpoint, d.Id(), err) - } - return diags } @@ -552,15 +533,6 @@ func resourceS3EndpointUpdate(ctx context.Context, d *schema.ResourceData, meta } } - if d.HasChange("tags_all") { - arn := d.Get("endpoint_arn").(string) - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, arn, o, n); err != nil { - return create.DiagError(names.DMS, create.ErrActionUpdating, ResNameS3Endpoint, d.Id(), err) - } - } - return append(diags, resourceS3EndpointRead(ctx, d, meta)...) } diff --git a/internal/service/dms/service_package_gen.go b/internal/service/dms/service_package_gen.go index 182d2bd260f..b3d84ef47ab 100644 --- a/internal/service/dms/service_package_gen.go +++ b/internal/service/dms/service_package_gen.go @@ -28,30 +28,58 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceCertificate, TypeName: "aws_dms_certificate", + Name: "Certificate", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "certificate_arn", + }, }, { Factory: ResourceEndpoint, TypeName: "aws_dms_endpoint", + Name: "Endpoint", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "endpoint_arn", + }, }, { Factory: ResourceEventSubscription, TypeName: "aws_dms_event_subscription", + Name: "Event Subscription", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceReplicationInstance, TypeName: "aws_dms_replication_instance", + Name: "Replication Instance", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "replication_instance_arn", + }, }, { Factory: ResourceReplicationSubnetGroup, TypeName: "aws_dms_replication_subnet_group", + Name: "Replication Subnet Group", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "replication_subnet_group_arn", + }, }, { Factory: ResourceReplicationTask, TypeName: "aws_dms_replication_task", + Name: "Replication Task", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "replication_task_arn", + }, }, { Factory: ResourceS3Endpoint, TypeName: "aws_dms_s3_endpoint", + Name: "S3 Endpoint", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "endpoint_arn", + }, }, } } diff --git a/internal/service/docdb/cluster.go b/internal/service/docdb/cluster.go index 1b2ed19799d..8c145df90d8 100644 --- a/internal/service/docdb/cluster.go +++ b/internal/service/docdb/cluster.go @@ -22,9 +22,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_docdb_cluster") +// @SDKResource("aws_docdb_cluster", name="Cluster") +// @Tags(identifierAttribute="arn") func ResourceCluster() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceClusterCreate, @@ -257,8 +259,8 @@ func ResourceCluster() *schema.Resource { Optional: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, @@ -277,8 +279,6 @@ func resourceClusterImport(ctx context.Context, func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DocDBConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, 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 @@ -305,7 +305,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int 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.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if attr := d.Get("availability_zones").(*schema.Set); attr.Len() > 0 { @@ -394,7 +394,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int 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.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if attr, ok := d.GetOk("global_cluster_identifier"); ok { @@ -515,8 +515,6 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DocDBConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig input := &docdb.DescribeDBClustersInput{ DBClusterIdentifier: aws.String(d.Id()), @@ -613,23 +611,6 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter return sdkdiag.AppendErrorf(diags, "setting vpc_security_group_ids: %s", err) } - tags, err := ListTags(ctx, conn, d.Get("arn").(string)) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DocumentDB Cluster (%s): %s", d.Get("arn").(string), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -752,14 +733,6 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta int } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DocumentDB Cluster (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceClusterRead(ctx, d, meta)...) } diff --git a/internal/service/docdb/cluster_instance.go b/internal/service/docdb/cluster_instance.go index 14cf474347e..597904a52cb 100644 --- a/internal/service/docdb/cluster_instance.go +++ b/internal/service/docdb/cluster_instance.go @@ -19,9 +19,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_docdb_cluster_instance") +// @SDKResource("aws_docdb_cluster_instance", name="Cluster Instance") +// @Tags(identifierAttribute="arn") func ResourceClusterInstance() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceClusterInstanceCreate, @@ -162,8 +164,8 @@ func ResourceClusterInstance() *schema.Resource { Type: schema.TypeBool, Computed: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "writer": { Type: schema.TypeBool, Computed: true, @@ -177,49 +179,47 @@ func ResourceClusterInstance() *schema.Resource { func resourceClusterInstanceCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DocDBConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) - createOpts := &docdb.CreateDBInstanceInput{ + input := &docdb.CreateDBInstanceInput{ DBInstanceClass: aws.String(d.Get("instance_class").(string)), DBClusterIdentifier: aws.String(d.Get("cluster_identifier").(string)), 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.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if attr, ok := d.GetOk("availability_zone"); ok { - createOpts.AvailabilityZone = aws.String(attr.(string)) + input.AvailabilityZone = aws.String(attr.(string)) } if attr, ok := d.GetOk("enable_performance_insights"); ok { - createOpts.EnablePerformanceInsights = aws.Bool(attr.(bool)) + input.EnablePerformanceInsights = aws.Bool(attr.(bool)) } if v, ok := d.GetOk("identifier"); ok { - createOpts.DBInstanceIdentifier = aws.String(v.(string)) + input.DBInstanceIdentifier = aws.String(v.(string)) } else { if v, ok := d.GetOk("identifier_prefix"); ok { - createOpts.DBInstanceIdentifier = aws.String(id.PrefixedUniqueId(v.(string))) + input.DBInstanceIdentifier = aws.String(id.PrefixedUniqueId(v.(string))) } else { - createOpts.DBInstanceIdentifier = aws.String(id.PrefixedUniqueId("tf-")) + input.DBInstanceIdentifier = aws.String(id.PrefixedUniqueId("tf-")) } } if attr, ok := d.GetOk("performance_insights_kms_key_id"); ok { - createOpts.PerformanceInsightsKMSKeyId = aws.String(attr.(string)) + input.PerformanceInsightsKMSKeyId = aws.String(attr.(string)) } if attr, ok := d.GetOk("preferred_maintenance_window"); ok { - createOpts.PreferredMaintenanceWindow = aws.String(attr.(string)) + input.PreferredMaintenanceWindow = aws.String(attr.(string)) } - log.Printf("[DEBUG] Creating DocDB Instance opts: %s", createOpts) + log.Printf("[DEBUG] Creating DocDB Instance opts: %s", input) var resp *docdb.CreateDBInstanceOutput err := retry.RetryContext(ctx, propagationTimeout, func() *retry.RetryError { var err error - resp, err = conn.CreateDBInstanceWithContext(ctx, createOpts) + resp, err = conn.CreateDBInstanceWithContext(ctx, input) if err != nil { if tfawserr.ErrMessageContains(err, "InvalidParameterValue", "IAM role ARN value is invalid or does not include the required permissions") { return retry.RetryableError(err) @@ -229,7 +229,7 @@ func resourceClusterInstanceCreate(ctx context.Context, d *schema.ResourceData, return nil }) if tfresource.TimedOut(err) { - resp, err = conn.CreateDBInstanceWithContext(ctx, createOpts) + resp, err = conn.CreateDBInstanceWithContext(ctx, input) } if err != nil { return sdkdiag.AppendErrorf(diags, "creating DocDB Instance: %s", err) @@ -259,8 +259,6 @@ func resourceClusterInstanceCreate(ctx context.Context, d *schema.ResourceData, func resourceClusterInstanceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DocDBConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig db, err := resourceInstanceRetrieve(ctx, conn, d.Id()) if !d.IsNewResource() && tfresource.NotFound(err) { @@ -331,23 +329,6 @@ func resourceClusterInstanceRead(ctx context.Context, d *schema.ResourceData, me d.Set("storage_encrypted", db.StorageEncrypted) d.Set("ca_cert_identifier", db.CACertificateIdentifier) - tags, err := ListTags(ctx, conn, d.Get("arn").(string)) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DocumentDB Cluster Instance (%s): %s", d.Get("arn").(string), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -431,14 +412,6 @@ func resourceClusterInstanceUpdate(ctx context.Context, d *schema.ResourceData, } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DocumentDB Cluster Instance (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceClusterInstanceRead(ctx, d, meta)...) } diff --git a/internal/service/docdb/cluster_parameter_group.go b/internal/service/docdb/cluster_parameter_group.go index 9bdc66517c8..2625c11331f 100644 --- a/internal/service/docdb/cluster_parameter_group.go +++ b/internal/service/docdb/cluster_parameter_group.go @@ -19,11 +19,13 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) const clusterParameterGroupMaxParamsBulkEdit = 20 -// @SDKResource("aws_docdb_cluster_parameter_group") +// @SDKResource("aws_docdb_cluster_parameter_group", name="Cluster Parameter Group") +// @Tags(identifierAttribute="arn") func ResourceClusterParameterGroup() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceClusterParameterGroupCreate, @@ -91,9 +93,8 @@ func ResourceClusterParameterGroup() *schema.Resource { }, }, }, - - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, @@ -103,8 +104,6 @@ func ResourceClusterParameterGroup() *schema.Resource { func resourceClusterParameterGroupCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DocDBConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) var groupName string if v, ok := d.GetOk("name"); ok { @@ -115,21 +114,21 @@ func resourceClusterParameterGroupCreate(ctx context.Context, d *schema.Resource groupName = id.UniqueId() } - createOpts := docdb.CreateDBClusterParameterGroupInput{ + input := docdb.CreateDBClusterParameterGroupInput{ DBClusterParameterGroupName: aws.String(groupName), DBParameterGroupFamily: aws.String(d.Get("family").(string)), Description: aws.String(d.Get("description").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } - log.Printf("[DEBUG] Create DocDB Cluster Parameter Group: %#v", createOpts) + log.Printf("[DEBUG] Create DocDB Cluster Parameter Group: %#v", input) - resp, err := conn.CreateDBClusterParameterGroupWithContext(ctx, &createOpts) + resp, err := conn.CreateDBClusterParameterGroupWithContext(ctx, &input) if err != nil { return sdkdiag.AppendErrorf(diags, "Error creating DocDB Cluster Parameter Group: %s", err) } - d.SetId(aws.StringValue(createOpts.DBClusterParameterGroupName)) + d.SetId(aws.StringValue(input.DBClusterParameterGroupName)) d.Set("arn", resp.DBClusterParameterGroup.DBClusterParameterGroupArn) @@ -139,8 +138,6 @@ func resourceClusterParameterGroupCreate(ctx context.Context, d *schema.Resource func resourceClusterParameterGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DocDBConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig describeOpts := &docdb.DescribeDBClusterParameterGroupsInput{ DBClusterParameterGroupName: aws.String(d.Id()), @@ -180,23 +177,6 @@ func resourceClusterParameterGroupRead(ctx context.Context, d *schema.ResourceDa return sdkdiag.AppendErrorf(diags, "setting docdb cluster parameter: %s", err) } - tags, err := ListTags(ctx, conn, d.Get("arn").(string)) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DocumentDB Cluster Parameter Group (%s): %s", d.Get("arn").(string), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -241,14 +221,6 @@ func resourceClusterParameterGroupUpdate(ctx context.Context, d *schema.Resource } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DocumentDB Cluster Parameter Group (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceClusterParameterGroupRead(ctx, d, meta)...) } diff --git a/internal/service/docdb/event_subscription.go b/internal/service/docdb/event_subscription.go index 194bb162baa..74330a0024e 100644 --- a/internal/service/docdb/event_subscription.go +++ b/internal/service/docdb/event_subscription.go @@ -16,9 +16,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_docdb_event_subscription") +// @SDKResource("aws_docdb_event_subscription", name="Event Subscription") +// @Tags(identifierAttribute="arn") func ResourceEventSubscription() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceEventSubscriptionCreate, @@ -85,8 +87,8 @@ func ResourceEventSubscription() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, @@ -95,15 +97,13 @@ func ResourceEventSubscription() *schema.Resource { func resourceEventSubscriptionCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.AWSClient).DocDBConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) name := create.Name(d.Get("name").(string), d.Get("name_prefix").(string)) input := &docdb.CreateEventSubscriptionInput{ Enabled: aws.Bool(d.Get("enabled").(bool)), SnsTopicArn: aws.String(d.Get("sns_topic_arn").(string)), SubscriptionName: aws.String(name), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("event_categories"); ok && v.(*schema.Set).Len() > 0 { @@ -136,8 +136,6 @@ func resourceEventSubscriptionCreate(ctx context.Context, d *schema.ResourceData func resourceEventSubscriptionRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.AWSClient).DocDBConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig output, err := FindEventSubscriptionByID(ctx, conn, d.Id()) @@ -161,23 +159,6 @@ func resourceEventSubscriptionRead(ctx context.Context, d *schema.ResourceData, d.Set("source_ids", aws.StringValueSlice(output.SourceIdsList)) d.Set("source_type", output.SourceType) - tags, err := ListTags(ctx, conn, d.Get("arn").(string)) - - if err != nil { - return diag.Errorf("listing tags for DocDB Event Subscription (%s): %s", d.Get("arn").(string), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return diag.Errorf("setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return diag.Errorf("setting tags_all: %s", err) - } - return nil } @@ -218,14 +199,6 @@ func resourceEventSubscriptionUpdate(ctx context.Context, d *schema.ResourceData } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return diag.Errorf("updating DocDB Cluster Event Subscription (%s) tags: %s", d.Get("arn").(string), err) - } - } - if d.HasChange("source_ids") { o, n := d.GetChange("source_ids") if o == nil { diff --git a/internal/service/docdb/service_package_gen.go b/internal/service/docdb/service_package_gen.go index 601df25a5c3..3f2203dfb9e 100644 --- a/internal/service/docdb/service_package_gen.go +++ b/internal/service/docdb/service_package_gen.go @@ -37,14 +37,26 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceCluster, TypeName: "aws_docdb_cluster", + Name: "Cluster", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceClusterInstance, TypeName: "aws_docdb_cluster_instance", + Name: "Cluster Instance", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceClusterParameterGroup, TypeName: "aws_docdb_cluster_parameter_group", + Name: "Cluster Parameter Group", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceClusterSnapshot, @@ -53,6 +65,10 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceEventSubscription, TypeName: "aws_docdb_event_subscription", + Name: "Event Subscription", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, { Factory: ResourceGlobalCluster, @@ -61,6 +77,10 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceSubnetGroup, TypeName: "aws_docdb_subnet_group", + Name: "Subnet Group", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "arn", + }, }, } } diff --git a/internal/service/docdb/subnet_group.go b/internal/service/docdb/subnet_group.go index 525cf274f62..bbc0b19c0d6 100644 --- a/internal/service/docdb/subnet_group.go +++ b/internal/service/docdb/subnet_group.go @@ -19,9 +19,11 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_docdb_subnet_group") +// @SDKResource("aws_docdb_subnet_group", name="Subnet Group") +// @Tags(identifierAttribute="arn") func ResourceSubnetGroup() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceSubnetGroupCreate, @@ -69,8 +71,8 @@ func ResourceSubnetGroup() *schema.Resource { Set: schema.HashString, }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, @@ -80,8 +82,6 @@ func ResourceSubnetGroup() *schema.Resource { func resourceSubnetGroupCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DocDBConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) subnetIds := flex.ExpandStringSet(d.Get("subnet_ids").(*schema.Set)) @@ -94,15 +94,15 @@ func resourceSubnetGroupCreate(ctx context.Context, d *schema.ResourceData, meta groupName = id.UniqueId() } - createOpts := docdb.CreateDBSubnetGroupInput{ + input := docdb.CreateDBSubnetGroupInput{ DBSubnetGroupName: aws.String(groupName), DBSubnetGroupDescription: aws.String(d.Get("description").(string)), SubnetIds: subnetIds, - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } - log.Printf("[DEBUG] Create DocDB Subnet Group: %#v", createOpts) - _, err := conn.CreateDBSubnetGroupWithContext(ctx, &createOpts) + log.Printf("[DEBUG] Create DocDB Subnet Group: %#v", input) + _, err := conn.CreateDBSubnetGroupWithContext(ctx, &input) if err != nil { return sdkdiag.AppendErrorf(diags, "creating DocDB Subnet Group: %s", err) } @@ -115,8 +115,6 @@ func resourceSubnetGroupCreate(ctx context.Context, d *schema.ResourceData, meta func resourceSubnetGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DocDBConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig describeOpts := docdb.DescribeDBSubnetGroupsInput{ DBSubnetGroupName: aws.String(d.Id()), @@ -154,23 +152,6 @@ func resourceSubnetGroupRead(ctx context.Context, d *schema.ResourceData, meta i return sdkdiag.AppendErrorf(diags, "setting subnet_ids: %s", err) } - tags, err := ListTags(ctx, conn, d.Get("arn").(string)) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for DocumentDB Subnet Group (%s): %s", d.Get("arn").(string), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -196,14 +177,6 @@ func resourceSubnetGroupUpdate(ctx context.Context, d *schema.ResourceData, meta } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Get("arn").(string), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating DocumentDB Subnet Group (%s) tags: %s", d.Get("arn").(string), err) - } - } - return append(diags, resourceSubnetGroupRead(ctx, d, meta)...) } diff --git a/internal/service/ds/directory.go b/internal/service/ds/directory.go index 87e1a882e40..d98f95c2a96 100644 --- a/internal/service/ds/directory.go +++ b/internal/service/ds/directory.go @@ -18,13 +18,15 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) const ( directoryApplicationDeauthorizedPropagationTimeout = 2 * time.Minute ) -// @SDKResource("aws_directory_service_directory") +// @SDKResource("aws_directory_service_directory", name="Directory") +// @Tags(identifierAttribute="id") func ResourceDirectory() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceDirectoryCreate, @@ -154,8 +156,8 @@ func ResourceDirectory() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringInSlice(directoryservice.DirectorySize_Values(), false), }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), "type": { Type: schema.TypeString, Optional: true, @@ -198,8 +200,6 @@ func ResourceDirectory() *schema.Resource { func resourceDirectoryCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{}))) name := d.Get("name").(string) switch directoryType := d.Get("type").(string); directoryType { @@ -207,7 +207,7 @@ func resourceDirectoryCreate(ctx context.Context, d *schema.ResourceData, meta i input := &directoryservice.ConnectDirectoryInput{ Name: aws.String(name), Password: aws.String(d.Get("password").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("connect_settings"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { @@ -241,7 +241,7 @@ func resourceDirectoryCreate(ctx context.Context, d *schema.ResourceData, meta i input := &directoryservice.CreateMicrosoftADInput{ Name: aws.String(name), Password: aws.String(d.Get("password").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("description"); ok { @@ -272,7 +272,7 @@ func resourceDirectoryCreate(ctx context.Context, d *schema.ResourceData, meta i input := &directoryservice.CreateDirectoryInput{ Name: aws.String(name), Password: aws.String(d.Get("password").(string)), - Tags: Tags(tags.IgnoreAWS()), + Tags: GetTagsIn(ctx), } if v, ok := d.GetOk("description"); ok { @@ -331,8 +331,6 @@ func resourceDirectoryCreate(ctx context.Context, d *schema.ResourceData, meta i func resourceDirectoryRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DSConn() - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig dir, err := FindDirectoryByID(ctx, conn, d.Id()) @@ -381,23 +379,6 @@ func resourceDirectoryRead(ctx context.Context, d *schema.ResourceData, meta int d.Set("vpc_settings", nil) } - tags, err := ListTags(ctx, conn, d.Id()) - - if err != nil { - return sdkdiag.AppendErrorf(diags, "listing tags for Directory Service Directory (%s): %s", d.Id(), err) - } - - tags = tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - - //lintignore:AWSR002 - if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } - - if err := d.Set("tags_all", tags.Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags_all: %s", err) - } - return diags } @@ -423,14 +404,6 @@ func resourceDirectoryUpdate(ctx context.Context, d *schema.ResourceData, meta i } } - if d.HasChange("tags_all") { - o, n := d.GetChange("tags_all") - - if err := UpdateTags(ctx, conn, d.Id(), o, n); err != nil { - return sdkdiag.AppendErrorf(diags, "updating Directory Service Directory (%s) tags: %s", d.Id(), err) - } - } - return append(diags, resourceDirectoryRead(ctx, d, meta)...) } diff --git a/internal/service/ds/service_package_gen.go b/internal/service/ds/service_package_gen.go index 25af8a590e5..8d230d0c2ef 100644 --- a/internal/service/ds/service_package_gen.go +++ b/internal/service/ds/service_package_gen.go @@ -37,6 +37,10 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka { Factory: ResourceDirectory, TypeName: "aws_directory_service_directory", + Name: "Directory", + Tags: &types.ServicePackageResourceTags{ + IdentifierAttribute: "id", + }, }, { Factory: ResourceLogSubscription,