@@ -15,13 +15,15 @@ import (
15
15
16
16
const (
17
17
StorageSchemaGenerateSftpPassword = "generate_sftp_password"
18
+ StorageSchemaGenerateS3AccessKey = "generate_s3_access_key"
19
+ StorageSchemaGenerateS3SecretKey = "generate_s3_secret_key"
18
20
StorageSchemaLocation = "location"
19
21
StorageSchemaName = "name"
20
22
StorageSchemaType = "type"
21
23
StorageSchemaId = "storage_id"
22
24
StorageSchemaClientId = "client_id"
23
25
StorageSchemaSftpPassword = "sftp_password"
24
- StorageSchemaKeyId = "link_key_id "
26
+ StorageSchemaKeyId = "ssh_key_id "
25
27
StorageSchemaExpires = "expires"
26
28
StorageSchemaServerAlias = "server_alias"
27
29
)
@@ -94,6 +96,18 @@ func resourceStorage() *schema.Resource {
94
96
Optional : true ,
95
97
Description : "A sftp password for new storage resource." ,
96
98
},
99
+ StorageSchemaGenerateS3AccessKey : {
100
+ Type : schema .TypeString ,
101
+ Optional : true ,
102
+ Computed : true ,
103
+ Description : "A s3 access key for new storage resource." ,
104
+ },
105
+ StorageSchemaGenerateS3SecretKey : {
106
+ Type : schema .TypeString ,
107
+ Optional : true ,
108
+ Computed : true ,
109
+ Description : "A s3 secret key for new storage resource." ,
110
+ },
97
111
StorageSchemaGenerateSftpPassword : {
98
112
Type : schema .TypeBool ,
99
113
Optional : true ,
@@ -102,14 +116,14 @@ func resourceStorage() *schema.Resource {
102
116
StorageSchemaKeyId : {
103
117
Type : schema .TypeInt ,
104
118
Optional : true ,
105
- Description : "An key id to link with new storage resource. " ,
119
+ Description : "An ssh key id to link with new sftp storage resource only. https://storage.gcorelabs.com/ssh-key/list " ,
106
120
},
107
121
},
108
122
CreateContext : resourceStorageCreate ,
109
123
ReadContext : resourceStorageRead ,
110
124
UpdateContext : resourceStorageUpdate ,
111
125
DeleteContext : resourceStorageDelete ,
112
- Description : "Represent storage resource." ,
126
+ Description : "Represent storage resource. https://storage.gcorelabs.com/storage/list " ,
113
127
}
114
128
}
115
129
@@ -151,6 +165,15 @@ func resourceStorageCreate(ctx context.Context, d *schema.ResourceData, m interf
151
165
dErr = resourceStorageRead (ctx , d , m )
152
166
}()
153
167
* id = int (result .ID )
168
+ if result .Credentials .SftpPassword != "" {
169
+ _ = d .Set (StorageSchemaSftpPassword , result .Credentials .SftpPassword )
170
+ }
171
+ if result .Credentials .S3 .AccessKey != "" {
172
+ _ = d .Set (StorageSchemaGenerateS3AccessKey , result .Credentials .S3 .AccessKey )
173
+ }
174
+ if result .Credentials .S3 .SecretKey != "" {
175
+ _ = d .Set (StorageSchemaGenerateS3SecretKey , result .Credentials .S3 .SecretKey )
176
+ }
154
177
155
178
keyId := d .Get (StorageSchemaKeyId ).(int )
156
179
if keyId == 0 {
@@ -192,10 +215,6 @@ func resourceStorageRead(ctx context.Context, d *schema.ResourceData, m interfac
192
215
}
193
216
st := result [0 ]
194
217
195
- sftpPass := ""
196
- if st .Credentials != nil {
197
- sftpPass = st .Credentials .SftpPassword
198
- }
199
218
nameParts := strings .Split (st .Name , "-" )
200
219
if len (nameParts ) > 1 {
201
220
clientID , _ := strconv .ParseInt (nameParts [0 ], 10 , 64 )
@@ -209,7 +228,6 @@ func resourceStorageRead(ctx context.Context, d *schema.ResourceData, m interfac
209
228
_ = d .Set (StorageSchemaId , st .ID )
210
229
_ = d .Set (StorageSchemaType , st .Type )
211
230
_ = d .Set (StorageSchemaLocation , st .Location )
212
- _ = d .Set (StorageSchemaSftpPassword , sftpPass )
213
231
214
232
return nil
215
233
}
0 commit comments