4
4
package datasync
5
5
6
6
import (
7
+ "github.com/aws/aws-sdk-go/aws"
7
8
"github.com/aws/aws-sdk-go/service/datasync"
9
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
8
10
)
9
11
10
12
func expandProtocol (l []interface {}) * datasync.FsxProtocol {
@@ -25,7 +27,7 @@ func expandProtocol(l []interface{}) *datasync.FsxProtocol {
25
27
return protocol
26
28
}
27
29
28
- func flattenProtocol (protocol * datasync.FsxProtocol ) []interface {} {
30
+ func flattenProtocol (protocol * datasync.FsxProtocol , d * schema. ResourceData ) []interface {} {
29
31
if protocol == nil {
30
32
return []interface {}{}
31
33
}
@@ -36,7 +38,7 @@ func flattenProtocol(protocol *datasync.FsxProtocol) []interface{} {
36
38
m ["nfs" ] = flattenNFS (protocol .NFS )
37
39
}
38
40
if protocol .SMB != nil {
39
- m ["smb" ] = flattenSMB (protocol .SMB )
41
+ m ["smb" ] = flattenSMB (protocol .SMB , d )
40
42
}
41
43
42
44
return []interface {}{m }
@@ -64,7 +66,10 @@ func expandSMB(l []interface{}) *datasync.FsxProtocolSmb {
64
66
m := l [0 ].(map [string ]interface {})
65
67
66
68
protocol := & datasync.FsxProtocolSmb {
69
+ Domain : aws .String (m ["domain" ].(string )),
67
70
MountOptions : expandSMBMountOptions (m ["mount_options" ].([]interface {})),
71
+ Password : aws .String (m ["password" ].(string )),
72
+ User : aws .String (m ["user" ].(string )),
68
73
}
69
74
70
75
return protocol
@@ -83,13 +88,22 @@ func flattenNFS(nfs *datasync.FsxProtocolNfs) []interface{} {
83
88
return []interface {}{m }
84
89
}
85
90
86
- func flattenSMB (smb * datasync.FsxProtocolSmb ) []interface {} {
91
+ func flattenSMB (smb * datasync.FsxProtocolSmb , d * schema. ResourceData ) []interface {} {
87
92
if smb == nil {
88
93
return []interface {}{}
89
94
}
90
95
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
+
91
102
m := map [string ]interface {}{
103
+ "domain" : smb .Domain ,
92
104
"mount_options" : flattenSMBMountOptions (smb .MountOptions ),
105
+ "password" : password ,
106
+ "user" : smb .User ,
93
107
}
94
108
95
109
return []interface {}{m }
0 commit comments