Skip to content

Commit

Permalink
d/aws_fsx_ontap_storage_virtual_machine: Correctly set tags on Read.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Jul 19, 2024
1 parent 6cdefc9 commit 54c003f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .changelog/38343.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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{}
Expand All @@ -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)
Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,33 @@ 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
}
`)
}

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"
Expand Down
1 change: 0 additions & 1 deletion internal/service/fsx/service_package_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 54c003f

Please sign in to comment.