Skip to content

Commit

Permalink
Merge pull request #33225 from hashicorp/b-aws_datasync_location_fsx_…
Browse files Browse the repository at this point in the history
…openzfs_file_system.InvalidAddress

r/aws_datasync_location_fsx_openzfs_file_system: Fix `setting protocol: Invalid address to set` errors
  • Loading branch information
ewbankkit authored Aug 30, 2023
2 parents cf53100 + 17bf01c commit 60c060a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .changelog/33225.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_datasync_location_fsx_openzfs_file_system: Fix `setting protocol: Invalid address to set` errors
```
29 changes: 18 additions & 11 deletions internal/service/datasync/common_fsx_protocol_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,30 @@ 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{} {
if protocol == nil {
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}
Expand All @@ -42,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 {
Expand All @@ -56,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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 60c060a

Please sign in to comment.