diff --git a/.changelog/38343.txt b/.changelog/38343.txt index eafc490828e..17669742145 100644 --- a/.changelog/38343.txt +++ b/.changelog/38343.txt @@ -4,4 +4,8 @@ resource/aws_fsx_openzfs_volume: Correctly set `tags` on Read ```release-note:bug data-source/aws_fsx_openzfs_snapshot: Correctly set `tags` on Read +``` + +```release-note:bug +data-source/aws_fsx_ontap_storage_virtual_machine: Correctly set `tags` on Read ``` \ No newline at end of file diff --git a/internal/service/fsx/ontap_storage_virtual_machine_data_source.go b/internal/service/fsx/ontap_storage_virtual_machine_data_source.go index 687dedae2e8..aedd8bd3645 100644 --- a/internal/service/fsx/ontap_storage_virtual_machine_data_source.go +++ b/internal/service/fsx/ontap_storage_virtual_machine_data_source.go @@ -20,7 +20,6 @@ import ( ) // @SDKDataSource("aws_fsx_ontap_storage_virtual_machine", name="ONTAP Storage Virtual Machine") -// @Tags func dataSourceONTAPStorageVirtualMachine() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceONTAPStorageVirtualMachineRead, @@ -197,7 +196,6 @@ func dataSourceONTAPStorageVirtualMachine() *schema.Resource { func dataSourceONTAPStorageVirtualMachineRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).FSxClient(ctx) - defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig input := &fsx.DescribeStorageVirtualMachinesInput{} @@ -224,7 +222,8 @@ func dataSourceONTAPStorageVirtualMachineRead(ctx context.Context, d *schema.Res if err := d.Set("active_directory_configuration", flattenSvmActiveDirectoryConfiguration(d, svm.ActiveDirectoryConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting active_directory_configuration: %s", err) } - d.Set(names.AttrARN, svm.ResourceARN) + arn := aws.ToString(svm.ResourceARN) + d.Set(names.AttrARN, arn) d.Set(names.AttrCreationTime, svm.CreationTime.Format(time.RFC3339)) if err := d.Set(names.AttrEndpoints, flattenSvmEndpoints(svm.Endpoints)); err != nil { return sdkdiag.AppendErrorf(diags, "setting endpoints: %s", err) @@ -241,10 +240,13 @@ func dataSourceONTAPStorageVirtualMachineRead(ctx context.Context, d *schema.Res // SVM tags aren't set in the Describe response. // setTagsOut(ctx, svm.Tags) - tags := KeyValueTags(ctx, svm.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig) + tags, err := listTags(ctx, conn, arn) - //lintignore:AWSR002 - if err := d.Set(names.AttrTags, tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + if err != nil { + return sdkdiag.AppendErrorf(diags, "listing tags for ONTAP Storage Virtual Machine (%s): %s", arn, err) + } + + if err := d.Set(names.AttrTags, tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) } diff --git a/internal/service/fsx/ontap_storage_virtual_machine_data_source_test.go b/internal/service/fsx/ontap_storage_virtual_machine_data_source_test.go index 22d6354d6ef..d2ddd55be53 100644 --- a/internal/service/fsx/ontap_storage_virtual_machine_data_source_test.go +++ b/internal/service/fsx/ontap_storage_virtual_machine_data_source_test.go @@ -81,7 +81,16 @@ func TestAccFSxONTAPStorageVirtualMachineDataSource_Filter(t *testing.T) { } func testAccONTAPStorageVirtualMachineDataSourceConfig_Id(rName string) string { - return acctest.ConfigCompose(testAccONTAPStorageVirtualMachineConfig_basic(rName), ` + return acctest.ConfigCompose(testAccONTAPStorageVirtualMachineConfig_base(rName), ` +resource "aws_fsx_ontap_storage_virtual_machine" "test" { + file_system_id = aws_fsx_ontap_file_system.test.id + name = %[1]q + + tags = { + Name = %[1]q + } +} + data "aws_fsx_ontap_storage_virtual_machine" "test" { id = aws_fsx_ontap_storage_virtual_machine.test.id } @@ -89,7 +98,16 @@ data "aws_fsx_ontap_storage_virtual_machine" "test" { } func testAccONTAPStorageVirtualMachineDataSourceConfig_Filter(rName string) string { - return acctest.ConfigCompose(testAccONTAPStorageVirtualMachineConfig_basic(rName), ` + return acctest.ConfigCompose(testAccONTAPStorageVirtualMachineConfig_base(rName), ` +resource "aws_fsx_ontap_storage_virtual_machine" "test" { + file_system_id = aws_fsx_ontap_file_system.test.id + name = %[1]q + + tags = { + Name = %[1]q + } +} + data "aws_fsx_ontap_storage_virtual_machine" "test" { filter { name = "file-system-id" diff --git a/internal/service/fsx/service_package_gen.go b/internal/service/fsx/service_package_gen.go index f91979c4cdd..ddd11413804 100644 --- a/internal/service/fsx/service_package_gen.go +++ b/internal/service/fsx/service_package_gen.go @@ -34,7 +34,6 @@ func (p *servicePackage) SDKDataSources(ctx context.Context) []*types.ServicePac Factory: dataSourceONTAPStorageVirtualMachine, TypeName: "aws_fsx_ontap_storage_virtual_machine", Name: "ONTAP Storage Virtual Machine", - Tags: &types.ServicePackageResourceTags{}, }, { Factory: dataSourceONTAPStorageVirtualMachines,