From 2cca02cd6bc0384aab49b5284483c60d9cd0fdfc Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Fri, 1 Mar 2024 12:11:22 -0500 Subject: [PATCH] ec2/instance: Remove tags_all from ds --- internal/service/ec2/ec2_instance.go | 18 +++++++++++------- .../service/ec2/ec2_instance_data_source.go | 8 +++----- .../service/ec2/ec2_spot_instance_request.go | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/internal/service/ec2/ec2_instance.go b/internal/service/ec2/ec2_instance.go index cd9db6f5f8a..e2e5a1b4992 100644 --- a/internal/service/ec2/ec2_instance.go +++ b/internal/service/ec2/ec2_instance.go @@ -1319,7 +1319,7 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte return sdkdiag.AppendErrorf(diags, "reading EC2 Instance (%s): %s", d.Id(), err) } - if err := readBlockDevices(ctx, d, meta, instance); err != nil { + if err := readBlockDevices(ctx, d, meta, instance, false); err != nil { return sdkdiag.AppendErrorf(diags, "reading EC2 Instance (%s): %s", d.Id(), err) } @@ -2161,8 +2161,8 @@ func modifyInstanceAttributeWithStopStart(ctx context.Context, conn *ec2.EC2, in return nil } -func readBlockDevices(ctx context.Context, d *schema.ResourceData, meta interface{}, instance *ec2.Instance) error { - ibds, err := readBlockDevicesFromInstance(ctx, d, meta, instance) +func readBlockDevices(ctx context.Context, d *schema.ResourceData, meta interface{}, instance *ec2.Instance, ds bool) error { + ibds, err := readBlockDevicesFromInstance(ctx, d, meta, instance, ds) if err != nil { return fmt.Errorf("reading block devices: %w", err) } @@ -2213,7 +2213,7 @@ func readBlockDevices(ctx context.Context, d *schema.ResourceData, meta interfac return nil } -func readBlockDevicesFromInstance(ctx context.Context, d *schema.ResourceData, meta interface{}, instance *ec2.Instance) (map[string]interface{}, error) { +func readBlockDevicesFromInstance(ctx context.Context, d *schema.ResourceData, meta interface{}, instance *ec2.Instance, ds bool) (map[string]interface{}, error) { blockDevices := make(map[string]interface{}) blockDevices["ebs"] = make([]map[string]interface{}, 0) blockDevices["root"] = nil @@ -2279,9 +2279,13 @@ func readBlockDevicesFromInstance(ctx context.Context, d *schema.ResourceData, m bd["device_name"] = aws.StringValue(instanceBd.DeviceName) } if v, ok := d.GetOk("volume_tags"); !ok || v == nil || len(v.(map[string]interface{})) == 0 { - tags := KeyValueTags(ctx, vol.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig) - bd[names.AttrTags] = tags.RemoveDefaultConfig(defaultTagsConfig).Map() - bd[names.AttrTagsAll] = tags.Map() + if ds { + bd[names.AttrTags] = KeyValueTags(ctx, vol.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig).Map() + } else { + tags := KeyValueTags(ctx, vol.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig) + bd[names.AttrTags] = tags.RemoveDefaultConfig(defaultTagsConfig).Map() + bd[names.AttrTagsAll] = tags.Map() + } } if blockDeviceIsRoot(instanceBd, instance) { diff --git a/internal/service/ec2/ec2_instance_data_source.go b/internal/service/ec2/ec2_instance_data_source.go index 470843c9629..09733231d14 100644 --- a/internal/service/ec2/ec2_instance_data_source.go +++ b/internal/service/ec2/ec2_instance_data_source.go @@ -99,8 +99,7 @@ func DataSourceInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, - names.AttrTags: tftags.TagsSchemaComputed(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchemaComputed(), "throughput": { Type: schema.TypeInt, Computed: true, @@ -334,8 +333,7 @@ func DataSourceInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, - names.AttrTags: tftags.TagsSchemaComputed(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchemaComputed(), "throughput": { Type: schema.TypeInt, Computed: true, @@ -552,7 +550,7 @@ func instanceDescriptionAttributes(ctx context.Context, d *schema.ResourceData, } // Block devices - if err := readBlockDevices(ctx, d, meta, instance); err != nil { + if err := readBlockDevices(ctx, d, meta, instance, true); err != nil { return fmt.Errorf("reading EC2 Instance (%s): %w", aws.StringValue(instance.InstanceId), err) } if _, ok := d.GetOk("ephemeral_block_device"); !ok { diff --git a/internal/service/ec2/ec2_spot_instance_request.go b/internal/service/ec2/ec2_spot_instance_request.go index 0cb13a8c114..f8226a6e1ce 100644 --- a/internal/service/ec2/ec2_spot_instance_request.go +++ b/internal/service/ec2/ec2_spot_instance_request.go @@ -317,7 +317,7 @@ func readInstance(ctx context.Context, d *schema.ResourceData, meta interface{}) "host": *instance.PrivateIpAddress, }) } - if err := readBlockDevices(ctx, d, meta, instance); err != nil { + if err := readBlockDevices(ctx, d, meta, instance, false); err != nil { return sdkdiag.AppendFromErr(diags, err) }