From 15ef072c327ef307fe013a5cf48e48778ab90208 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 29 Aug 2023 16:16:45 -0400 Subject: [PATCH 1/6] r/aws_datasync_location_fsx_openzfs_file_system: Fix 'Invalid address to set: []string{"protocol", "0", "smb"}' errors. --- .../service/datasync/common_fsx_protocol_functions.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/service/datasync/common_fsx_protocol_functions.go b/internal/service/datasync/common_fsx_protocol_functions.go index d28f27919e1..ceb140f1dd4 100644 --- a/internal/service/datasync/common_fsx_protocol_functions.go +++ b/internal/service/datasync/common_fsx_protocol_functions.go @@ -27,9 +27,13 @@ func flattenProtocol(protocol *datasync.FsxProtocol) []interface{} { return []interface{}{} } - m := map[string]interface{}{ - "nfs": flattenNFS(protocol.NFS), - "smb": flattenSMB(protocol.SMB), + m := map[string]interface{}{} + + if protocol.NFS != nil { + m["nfs"] = flattenNFS(protocol.NFS) + } + if protocol.SMB != nil { + m["smb"] = flattenSMB(protocol.SMB) } return []interface{}{m} From 2aa4507b3ae38aa6e58ff8fba460d423a37abfaf Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 29 Aug 2023 16:17:24 -0400 Subject: [PATCH 2/6] r/aws_datasync_location_fsx_openzfs_file_system: Fix 'Missing resource instance key' errors in acceptance tests. --- .../datasync/location_fsx_openzfs_file_system_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/service/datasync/location_fsx_openzfs_file_system_test.go b/internal/service/datasync/location_fsx_openzfs_file_system_test.go index 47f722862d1..6ae6e7dccd2 100644 --- a/internal/service/datasync/location_fsx_openzfs_file_system_test.go +++ b/internal/service/datasync/location_fsx_openzfs_file_system_test.go @@ -256,9 +256,13 @@ resource "aws_security_group" "test" { resource "aws_fsx_openzfs_file_system" "test" { storage_capacity = 64 - subnet_ids = [aws_subnet.test.id] + subnet_ids = aws_subnet.test[*].id deployment_type = "SINGLE_AZ_1" throughput_capacity = 64 + + tags = { + Name = %[1]q + } } `, rName)) } From c585923f9822514d88665198858485e1d68d04ea Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 29 Aug 2023 16:17:45 -0400 Subject: [PATCH 3/6] Tag FSx file systems. --- .../service/datasync/location_fsx_lustre_file_system_test.go | 4 ++++ .../service/datasync/location_fsx_ontap_file_system_test.go | 4 ++++ .../service/datasync/location_fsx_windows_file_system_test.go | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/internal/service/datasync/location_fsx_lustre_file_system_test.go b/internal/service/datasync/location_fsx_lustre_file_system_test.go index 76e065feefa..6e1ca72b198 100644 --- a/internal/service/datasync/location_fsx_lustre_file_system_test.go +++ b/internal/service/datasync/location_fsx_lustre_file_system_test.go @@ -261,6 +261,10 @@ resource "aws_fsx_lustre_file_system" "test" { storage_capacity = 1200 subnet_ids = aws_subnet.test[*].id deployment_type = data.aws_partition.current.partition == "aws-us-gov" ? "SCRATCH_2" : null # GovCloud does not support SCRATCH_1 + + tags = { + Name = %[1]q + } } `, rName)) } diff --git a/internal/service/datasync/location_fsx_ontap_file_system_test.go b/internal/service/datasync/location_fsx_ontap_file_system_test.go index b3e6973a8ba..7ea0bad5bf9 100644 --- a/internal/service/datasync/location_fsx_ontap_file_system_test.go +++ b/internal/service/datasync/location_fsx_ontap_file_system_test.go @@ -262,6 +262,10 @@ resource "aws_fsx_ontap_file_system" "test" { deployment_type = "SINGLE_AZ_1" throughput_capacity = 512 preferred_subnet_id = aws_subnet.test[0].id + + tags = { + Name = %[1]q + } } resource "aws_fsx_ontap_storage_virtual_machine" "test" { diff --git a/internal/service/datasync/location_fsx_windows_file_system_test.go b/internal/service/datasync/location_fsx_windows_file_system_test.go index 40cbf0cf87b..dd6eae48978 100644 --- a/internal/service/datasync/location_fsx_windows_file_system_test.go +++ b/internal/service/datasync/location_fsx_windows_file_system_test.go @@ -284,6 +284,10 @@ resource "aws_fsx_windows_file_system" "test" { storage_capacity = 32 subnet_ids = [aws_subnet.test[0].id] throughput_capacity = 8 + + tags = { + Name = %[1]q + } } `, rName)) } From f011c3c5622aaae64faacfbb3cfc7c7a782be2b8 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 29 Aug 2023 16:19:31 -0400 Subject: [PATCH 4/6] Add CHANGELOG entry. --- .changelog/#####.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/#####.txt diff --git a/.changelog/#####.txt b/.changelog/#####.txt new file mode 100644 index 00000000000..7fad6bec0cf --- /dev/null +++ b/.changelog/#####.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_datasync_location_fsx_openzfs_file_system: Fix `setting protocol: Invalid address to set` errors +``` \ No newline at end of file From c6f6ce232e2a47aef19fe2403bc5aede5913d4ec Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 29 Aug 2023 16:21:09 -0400 Subject: [PATCH 5/6] Correct CHANGELOG entry file name. --- .changelog/{#####.txt => 33225.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .changelog/{#####.txt => 33225.txt} (100%) diff --git a/.changelog/#####.txt b/.changelog/33225.txt similarity index 100% rename from .changelog/#####.txt rename to .changelog/33225.txt From 17bf01c53b29d995862b3347291da356e27da699 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 29 Aug 2023 16:38:26 -0400 Subject: [PATCH 6/6] r/aws_datasync_location_fsx_openzfs_file_system: Fix expander. --- .../datasync/common_fsx_protocol_functions.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/internal/service/datasync/common_fsx_protocol_functions.go b/internal/service/datasync/common_fsx_protocol_functions.go index ceb140f1dd4..3a3a007b2a2 100644 --- a/internal/service/datasync/common_fsx_protocol_functions.go +++ b/internal/service/datasync/common_fsx_protocol_functions.go @@ -13,13 +13,16 @@ func expandProtocol(l []interface{}) *datasync.FsxProtocol { } m := l[0].(map[string]interface{}) + protocol := &datasync.FsxProtocol{} - Protocol := &datasync.FsxProtocol{ - NFS: expandNFS(m["nfs"].([]interface{})), - SMB: expandSMB(m["smb"].([]interface{})), + if v, ok := m["nfs"].([]interface{}); ok { + protocol.NFS = expandNFS(v) + } + if v, ok := m["smb"].([]interface{}); ok { + protocol.SMB = expandSMB(v) } - return Protocol + return protocol } func flattenProtocol(protocol *datasync.FsxProtocol) []interface{} { @@ -46,11 +49,11 @@ func expandNFS(l []interface{}) *datasync.FsxProtocolNfs { m := l[0].(map[string]interface{}) - Protocol := &datasync.FsxProtocolNfs{ + protocol := &datasync.FsxProtocolNfs{ MountOptions: expandNFSMountOptions(m["mount_options"].([]interface{})), } - return Protocol + return protocol } func expandSMB(l []interface{}) *datasync.FsxProtocolSmb { @@ -60,11 +63,11 @@ func expandSMB(l []interface{}) *datasync.FsxProtocolSmb { m := l[0].(map[string]interface{}) - Protocol := &datasync.FsxProtocolSmb{ + protocol := &datasync.FsxProtocolSmb{ MountOptions: expandSMBMountOptions(m["mount_options"].([]interface{})), } - return Protocol + return protocol } // todo: go another level down?