Skip to content

Commit 165cc9d

Browse files
committed
aws_datasync_location_fsx_ontap_file_system: fix missing fields in smb
block
1 parent 93743ec commit 165cc9d

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

internal/service/datasync/common_fsx_protocol_functions.go

+17-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
package datasync
55

66
import (
7+
"github.com/aws/aws-sdk-go/aws"
78
"github.com/aws/aws-sdk-go/service/datasync"
9+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
810
)
911

1012
func expandProtocol(l []interface{}) *datasync.FsxProtocol {
@@ -25,7 +27,7 @@ func expandProtocol(l []interface{}) *datasync.FsxProtocol {
2527
return protocol
2628
}
2729

28-
func flattenProtocol(protocol *datasync.FsxProtocol) []interface{} {
30+
func flattenProtocol(protocol *datasync.FsxProtocol, d *schema.ResourceData) []interface{} {
2931
if protocol == nil {
3032
return []interface{}{}
3133
}
@@ -36,7 +38,7 @@ func flattenProtocol(protocol *datasync.FsxProtocol) []interface{} {
3638
m["nfs"] = flattenNFS(protocol.NFS)
3739
}
3840
if protocol.SMB != nil {
39-
m["smb"] = flattenSMB(protocol.SMB)
41+
m["smb"] = flattenSMB(protocol.SMB, d)
4042
}
4143

4244
return []interface{}{m}
@@ -64,7 +66,10 @@ func expandSMB(l []interface{}) *datasync.FsxProtocolSmb {
6466
m := l[0].(map[string]interface{})
6567

6668
protocol := &datasync.FsxProtocolSmb{
69+
Domain: aws.String(m["domain"].(string)),
6770
MountOptions: expandSMBMountOptions(m["mount_options"].([]interface{})),
71+
Password: aws.String(m["password"].(string)),
72+
User: aws.String(m["user"].(string)),
6873
}
6974

7075
return protocol
@@ -83,13 +88,22 @@ func flattenNFS(nfs *datasync.FsxProtocolNfs) []interface{} {
8388
return []interface{}{m}
8489
}
8590

86-
func flattenSMB(smb *datasync.FsxProtocolSmb) []interface{} {
91+
func flattenSMB(smb *datasync.FsxProtocolSmb, d *schema.ResourceData) []interface{} {
8792
if smb == nil {
8893
return []interface{}{}
8994
}
9095

96+
// Need to store the value for "password" from config in the state since it is write-only in the Describe API
97+
password := ""
98+
if d != nil {
99+
password = d.Get("protocol.0.smb.0.password").(string)
100+
}
101+
91102
m := map[string]interface{}{
103+
"domain": smb.Domain,
92104
"mount_options": flattenSMBMountOptions(smb.MountOptions),
105+
"password": password,
106+
"user": smb.User,
93107
}
94108

95109
return []interface{}{m}

internal/service/datasync/location_fsx_ontap_file_system.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func resourceLocationFSxONTAPFileSystemRead(ctx context.Context, d *schema.Resou
244244
d.Set("arn", output.LocationArn)
245245
d.Set("creation_time", output.CreationTime.Format(time.RFC3339))
246246
d.Set("fsx_filesystem_arn", output.FsxFilesystemArn)
247-
if err := d.Set("protocol", flattenProtocol(output.Protocol)); err != nil {
247+
if err := d.Set("protocol", flattenProtocol(output.Protocol, d)); err != nil {
248248
return sdkdiag.AppendErrorf(diags, "setting protocol: %s", err)
249249
}
250250
d.Set("security_group_arns", aws.StringValueSlice(output.SecurityGroupArns))

internal/service/datasync/location_fsx_openzfs_file_system.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func resourceLocationFSxOpenZFSFileSystemRead(ctx context.Context, d *schema.Res
185185
d.Set("arn", output.LocationArn)
186186
d.Set("creation_time", output.CreationTime.Format(time.RFC3339))
187187
d.Set("fsx_filesystem_arn", d.Get("fsx_filesystem_arn"))
188-
if err := d.Set("protocol", flattenProtocol(output.Protocol)); err != nil {
188+
if err := d.Set("protocol", flattenProtocol(output.Protocol, d)); err != nil {
189189
return sdkdiag.AppendErrorf(diags, "setting protocol: %s", err)
190190
}
191191
d.Set("security_group_arns", aws.StringValueSlice(output.SecurityGroupArns))

0 commit comments

Comments
 (0)