@@ -40,11 +40,16 @@ func TestAccDataSyncLocationFSxONTAPFileSystem_basic(t *testing.T) {
40
40
Steps : []resource.TestStep {
41
41
{
42
42
Config : testAccLocationFSxONTAPFileSystemConfig_basic (rName ),
43
- Check : resource .ComposeTestCheckFunc (
43
+ Check : resource .ComposeAggregateTestCheckFunc (
44
44
testAccCheckLocationFSxONTAPExists (ctx , resourceName , & v ),
45
45
acctest .MatchResourceAttrRegionalARN (resourceName , "arn" , "datasync" , regexache .MustCompile (`location/loc-.+` )),
46
46
resource .TestCheckResourceAttrSet (resourceName , "creation_time" ),
47
47
resource .TestCheckResourceAttrPair (resourceName , "fsx_filesystem_arn" , fsResourceName , "arn" ),
48
+ resource .TestCheckResourceAttr (resourceName , "protocol.#" , "1" ),
49
+ resource .TestCheckResourceAttr (resourceName , "protocol.0.nfs.#" , "1" ),
50
+ resource .TestCheckResourceAttr (resourceName , "protocol.0.nfs.0.mount_options.#" , "1" ),
51
+ resource .TestCheckResourceAttr (resourceName , "protocol.0.nfs.0.mount_options.0.version" , "NFS3" ),
52
+ resource .TestCheckResourceAttr (resourceName , "protocol.0.smb.#" , "0" ),
48
53
resource .TestCheckResourceAttr (resourceName , "subdirectory" , "/" ),
49
54
resource .TestCheckResourceAttrPair (resourceName , "storage_virtual_machine_arn" , svmResourceName , "arn" ),
50
55
resource .TestCheckResourceAttr (resourceName , "tags.%" , "0" ),
@@ -89,6 +94,50 @@ func TestAccDataSyncLocationFSxONTAPFileSystem_disappears(t *testing.T) {
89
94
})
90
95
}
91
96
97
+ func TestAccDataSyncLocationFSxONTAPFileSystem_smb (t * testing.T ) {
98
+ ctx := acctest .Context (t )
99
+ rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
100
+ netBiosName := "tftest-" + sdkacctest .RandString (7 )
101
+ domainNetbiosName := "tftest" + sdkacctest .RandString (4 )
102
+ domainName := domainNetbiosName + ".local"
103
+ var v datasync.DescribeLocationFsxOntapOutput
104
+ resourceName := "aws_datasync_location_fsx_ontap_file_system.test"
105
+
106
+ resource .ParallelTest (t , resource.TestCase {
107
+ PreCheck : func () {
108
+ acctest .PreCheck (ctx , t )
109
+ acctest .PreCheckPartitionHasService (t , fsx .EndpointsID )
110
+ testAccPreCheck (ctx , t )
111
+ },
112
+ ErrorCheck : acctest .ErrorCheck (t , datasync .EndpointsID ),
113
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
114
+ CheckDestroy : testAccCheckLocationFSxONTAPDestroy (ctx ),
115
+ Steps : []resource.TestStep {
116
+ {
117
+ Config : testAccLocationFSxONTAPFileSystemConfig_smb (rName , netBiosName , domainNetbiosName , domainName ),
118
+ Check : resource .ComposeAggregateTestCheckFunc (
119
+ testAccCheckLocationFSxONTAPExists (ctx , resourceName , & v ),
120
+ resource .TestCheckResourceAttr (resourceName , "protocol.#" , "1" ),
121
+ resource .TestCheckResourceAttr (resourceName , "protocol.0.nfs.#" , "0" ),
122
+ resource .TestCheckResourceAttr (resourceName , "protocol.0.smb.#" , "1" ),
123
+ resource .TestCheckResourceAttr (resourceName , "protocol.0.smb.0.domain" , domainName ),
124
+ resource .TestCheckResourceAttr (resourceName , "protocol.0.smb.0.mount_options.#" , "1" ),
125
+ resource .TestCheckResourceAttr (resourceName , "protocol.0.smb.0.mount_options.0.version" , "SMB3" ),
126
+ resource .TestCheckResourceAttr (resourceName , "protocol.0.smb.0.password" , "MyPassw0rd1" ),
127
+ resource .TestCheckResourceAttr (resourceName , "protocol.0.smb.0.user" , "Admin" ),
128
+ ),
129
+ },
130
+ {
131
+ ResourceName : resourceName ,
132
+ ImportState : true ,
133
+ ImportStateVerify : true ,
134
+ ImportStateVerifyIgnore : []string {"protocol.0.smb.0.password" }, // Not returned from API.
135
+ ImportStateIdFunc : testAccLocationFSxONTAPImportStateID (resourceName ),
136
+ },
137
+ },
138
+ })
139
+ }
140
+
92
141
func TestAccDataSyncLocationFSxONTAPFileSystem_subdirectory (t * testing.T ) {
93
142
ctx := acctest .Context (t )
94
143
rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
@@ -231,8 +280,8 @@ func testAccLocationFSxONTAPImportStateID(n string) resource.ImportStateIdFunc {
231
280
}
232
281
}
233
282
234
- func testAccFSxOntapFileSystemConfig_base (rName string ) string {
235
- return acctest .ConfigCompose (acctest .ConfigVPCWithSubnets (rName , 1 ), fmt .Sprintf (`
283
+ func testAccFSxOntapFileSystemConfig_base (rName string , nSubnets int , deploymentType string ) string {
284
+ return acctest .ConfigCompose (acctest .ConfigVPCWithSubnets (rName , nSubnets ), fmt .Sprintf (`
236
285
resource "aws_security_group" "test" {
237
286
name = %[1]q
238
287
vpc_id = aws_vpc.test.id
@@ -259,24 +308,44 @@ resource "aws_security_group" "test" {
259
308
resource "aws_fsx_ontap_file_system" "test" {
260
309
storage_capacity = 1024
261
310
subnet_ids = aws_subnet.test[*].id
262
- deployment_type = "SINGLE_AZ_1"
311
+ deployment_type = %[2]q
263
312
throughput_capacity = 512
264
313
preferred_subnet_id = aws_subnet.test[0].id
265
314
266
315
tags = {
267
316
Name = %[1]q
268
317
}
269
318
}
319
+ ` , rName , deploymentType ))
320
+ }
270
321
322
+ func testAccFSxOntapFileSystemConfig_baseNFS (rName string ) string {
323
+ return acctest .ConfigCompose (testAccFSxOntapFileSystemConfig_base (rName , 1 , "SINGLE_AZ_1" ), fmt .Sprintf (`
271
324
resource "aws_fsx_ontap_storage_virtual_machine" "test" {
272
325
file_system_id = aws_fsx_ontap_file_system.test.id
273
326
name = %[1]q
274
327
}
275
328
` , rName ))
276
329
}
277
330
331
+ func testAccFSxOntapFileSystemConfig_baseSMB (rName , domainName string ) string {
332
+ return acctest .ConfigCompose (testAccFSxOntapFileSystemConfig_base (rName , 2 , "MULTI_AZ_1" ), fmt .Sprintf (`
333
+ resource "aws_directory_service_directory" "test" {
334
+ edition = "Standard"
335
+ name = %[1]q
336
+ password = "MyPassw0rd1"
337
+ type = "MicrosoftAD"
338
+
339
+ vpc_settings {
340
+ subnet_ids = aws_subnet.test[*].id
341
+ vpc_id = aws_vpc.test.id
342
+ }
343
+ }
344
+ ` , domainName ))
345
+ }
346
+
278
347
func testAccLocationFSxONTAPFileSystemConfig_basic (rName string ) string {
279
- return acctest .ConfigCompose (testAccFSxOntapFileSystemConfig_base (rName ), `
348
+ return acctest .ConfigCompose (testAccFSxOntapFileSystemConfig_baseNFS (rName ), `
280
349
resource "aws_datasync_location_fsx_ontap_file_system" "test" {
281
350
security_group_arns = [aws_security_group.test.arn]
282
351
storage_virtual_machine_arn = aws_fsx_ontap_storage_virtual_machine.test.arn
@@ -292,8 +361,48 @@ resource "aws_datasync_location_fsx_ontap_file_system" "test" {
292
361
` )
293
362
}
294
363
364
+ func testAccLocationFSxONTAPFileSystemConfig_smb (rName , netBiosName , domainNetbiosName , domainName string ) string {
365
+ return acctest .ConfigCompose (testAccFSxOntapFileSystemConfig_baseSMB (rName , domainName ), fmt .Sprintf (`
366
+ resource "aws_fsx_ontap_storage_virtual_machine" "test" {
367
+ file_system_id = aws_fsx_ontap_file_system.test.id
368
+ name = %[1]q
369
+ depends_on = [aws_directory_service_directory.test]
370
+
371
+ active_directory_configuration {
372
+ netbios_name = %[2]q
373
+ self_managed_active_directory_configuration {
374
+ dns_ips = aws_directory_service_directory.test.dns_ip_addresses
375
+ domain_name = %[3]q
376
+ password = "MyPassw0rd1"
377
+ username = "Admin"
378
+ organizational_unit_distinguished_name = "OU=computers,OU=%[4]s"
379
+ file_system_administrators_group = "Admins"
380
+ }
381
+ }
382
+ }
383
+
384
+ resource "aws_datasync_location_fsx_ontap_file_system" "test" {
385
+ security_group_arns = [aws_security_group.test.arn]
386
+ storage_virtual_machine_arn = aws_fsx_ontap_storage_virtual_machine.test.arn
387
+
388
+ protocol {
389
+ smb {
390
+ domain = %[3]q
391
+
392
+ mount_options {
393
+ version = "SMB3"
394
+ }
395
+
396
+ password = "MyPassw0rd1"
397
+ user = "Admin"
398
+ }
399
+ }
400
+ }
401
+ ` , rName , netBiosName , domainName , domainNetbiosName ))
402
+ }
403
+
295
404
func testAccLocationFSxONTAPFileSystemConfig_subdirectory (rName , subdirectory string ) string {
296
- return acctest .ConfigCompose (testAccFSxOntapFileSystemConfig_base (rName ), fmt .Sprintf (`
405
+ return acctest .ConfigCompose (testAccFSxOntapFileSystemConfig_baseNFS (rName ), fmt .Sprintf (`
297
406
resource "aws_datasync_location_fsx_ontap_file_system" "test" {
298
407
security_group_arns = [aws_security_group.test.arn]
299
408
storage_virtual_machine_arn = aws_fsx_ontap_storage_virtual_machine.test.arn
@@ -311,7 +420,7 @@ resource "aws_datasync_location_fsx_ontap_file_system" "test" {
311
420
}
312
421
313
422
func testAccLocationFSxONTAPFileSystemConfig_tags1 (rName , key1 , value1 string ) string {
314
- return acctest .ConfigCompose (testAccFSxOntapFileSystemConfig_base (rName ), fmt .Sprintf (`
423
+ return acctest .ConfigCompose (testAccFSxOntapFileSystemConfig_baseNFS (rName ), fmt .Sprintf (`
315
424
resource "aws_datasync_location_fsx_ontap_file_system" "test" {
316
425
security_group_arns = [aws_security_group.test.arn]
317
426
storage_virtual_machine_arn = aws_fsx_ontap_storage_virtual_machine.test.arn
@@ -332,7 +441,7 @@ resource "aws_datasync_location_fsx_ontap_file_system" "test" {
332
441
}
333
442
334
443
func testAccLocationFSxONTAPFileSystemConfig_tags2 (rName , key1 , value1 , key2 , value2 string ) string {
335
- return acctest .ConfigCompose (testAccFSxOntapFileSystemConfig_base (rName ), fmt .Sprintf (`
444
+ return acctest .ConfigCompose (testAccFSxOntapFileSystemConfig_baseNFS (rName ), fmt .Sprintf (`
336
445
resource "aws_datasync_location_fsx_ontap_file_system" "test" {
337
446
security_group_arns = [aws_security_group.test.arn]
338
447
storage_virtual_machine_arn = aws_fsx_ontap_storage_virtual_machine.test.arn
0 commit comments