@@ -89,7 +89,8 @@ func TestAccAwsWorkspacesWorkspace_basic(t *testing.T) {
89
89
resource .TestCheckResourceAttr (resourceName , "workspace_properties.0.running_mode" , workspaces .RunningModeAlwaysOn ),
90
90
resource .TestCheckResourceAttr (resourceName , "workspace_properties.0.running_mode_auto_stop_timeout_in_minutes" , "0" ),
91
91
resource .TestCheckResourceAttr (resourceName , "workspace_properties.0.user_volume_size_gib" , "10" ),
92
- resource .TestCheckResourceAttr (resourceName , "tags.%" , "0" ),
92
+ resource .TestCheckResourceAttr (resourceName , "tags.%" , "1" ),
93
+ resource .TestCheckResourceAttr (resourceName , "tags.Name" , fmt .Sprintf ("tf-testacc-workspaces-workspace-%[1]s" , rName )),
93
94
),
94
95
},
95
96
{
@@ -122,7 +123,7 @@ func TestAccAwsWorkspacesWorkspace_tags(t *testing.T) {
122
123
Check : resource .ComposeAggregateTestCheckFunc (
123
124
testAccCheckAwsWorkspacesWorkspaceExists (resourceName , & v1 ),
124
125
resource .TestCheckResourceAttr (resourceName , "tags.%" , "2" ),
125
- resource .TestCheckResourceAttr (resourceName , "tags.TerraformProviderAwsTest " , "true" ),
126
+ resource .TestCheckResourceAttr (resourceName , "tags.Name " , fmt . Sprintf ( "tf-testacc-workspaces-workspace-%[1]s" , rName ) ),
126
127
resource .TestCheckResourceAttr (resourceName , "tags.Alpha" , "1" ),
127
128
),
128
129
},
@@ -136,7 +137,7 @@ func TestAccAwsWorkspacesWorkspace_tags(t *testing.T) {
136
137
Check : resource .ComposeAggregateTestCheckFunc (
137
138
testAccCheckAwsWorkspacesWorkspaceExists (resourceName , & v2 ),
138
139
resource .TestCheckResourceAttr (resourceName , "tags.%" , "2" ),
139
- resource .TestCheckResourceAttr (resourceName , "tags.TerraformProviderAwsTest " , "true" ),
140
+ resource .TestCheckResourceAttr (resourceName , "tags.Name " , fmt . Sprintf ( "tf-testacc-workspaces-workspace-%[1]s" , rName ) ),
140
141
resource .TestCheckResourceAttr (resourceName , "tags.Beta" , "2" ),
141
142
),
142
143
},
@@ -145,7 +146,7 @@ func TestAccAwsWorkspacesWorkspace_tags(t *testing.T) {
145
146
Check : resource .ComposeAggregateTestCheckFunc (
146
147
testAccCheckAwsWorkspacesWorkspaceExists (resourceName , & v3 ),
147
148
resource .TestCheckResourceAttr (resourceName , "tags.%" , "1" ),
148
- resource .TestCheckResourceAttr (resourceName , "tags.TerraformProviderAwsTest " , "true" ),
149
+ resource .TestCheckResourceAttr (resourceName , "tags.Name " , fmt . Sprintf ( "tf-testacc-workspaces-workspace-%[1]s" , rName ) ),
149
150
),
150
151
},
151
152
},
@@ -401,32 +402,44 @@ func testAccCheckAwsWorkspacesWorkspaceExists(n string, v *workspaces.Workspace)
401
402
func testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName string ) string {
402
403
return composeConfig (
403
404
testAccAwsWorkspacesDirectoryConfig_Prerequisites (rName ),
404
- `
405
+ fmt . Sprintf ( `
405
406
data "aws_workspaces_bundle" "test" {
406
407
bundle_id = "wsb-bh8rsxt14" # Value with Windows 10 (English)
407
408
}
408
409
409
410
resource "aws_workspaces_directory" "test" {
410
411
directory_id = aws_directory_service_directory.main.id
412
+
413
+ tags = {
414
+ Name = "tf-testacc-workspaces-directory-%[1]s"
415
+ }
411
416
}
412
- ` )
417
+ ` , rName ) )
413
418
}
414
419
415
420
func testAccWorkspacesWorkspaceConfig (rName string ) string {
416
- return testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ) + `
421
+ return composeConfig (
422
+ testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ),
423
+ fmt .Sprintf (`
417
424
resource "aws_workspaces_workspace" "test" {
418
425
bundle_id = data.aws_workspaces_bundle.test.id
419
426
directory_id = aws_workspaces_directory.test.id
420
427
421
428
# NOTE: WorkSpaces API doesn't allow creating users in the directory.
422
429
# However, "Administrator"" user is always present in a bare directory.
423
430
user_name = "Administrator"
431
+
432
+ tags = {
433
+ Name = "tf-testacc-workspaces-workspace-%[1]s"
434
+ }
424
435
}
425
- `
436
+ ` , rName ))
426
437
}
427
438
428
439
func testAccWorkspacesWorkspaceConfig_TagsA (rName string ) string {
429
- return testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ) + `
440
+ return composeConfig (
441
+ testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ),
442
+ fmt .Sprintf (`
430
443
resource "aws_workspaces_workspace" "test" {
431
444
bundle_id = data.aws_workspaces_bundle.test.id
432
445
directory_id = aws_workspaces_directory.test.id
@@ -436,15 +449,17 @@ resource "aws_workspaces_workspace" "test" {
436
449
user_name = "Administrator"
437
450
438
451
tags = {
439
- TerraformProviderAwsTest = true
440
- Alpha = 1
452
+ Name = "tf-testacc-workspaces-workspace-%[1]s"
453
+ Alpha = 1
441
454
}
442
455
}
443
- `
456
+ ` , rName ))
444
457
}
445
458
446
459
func testAccWorkspacesWorkspaceConfig_TagsB (rName string ) string {
447
- return testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ) + `
460
+ return composeConfig (
461
+ testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ),
462
+ fmt .Sprintf (`
448
463
resource "aws_workspaces_workspace" "test" {
449
464
bundle_id = data.aws_workspaces_bundle.test.id
450
465
directory_id = aws_workspaces_directory.test.id
@@ -454,15 +469,17 @@ resource "aws_workspaces_workspace" "test" {
454
469
user_name = "Administrator"
455
470
456
471
tags = {
457
- TerraformProviderAwsTest = true
458
- Beta = 2
472
+ Name = "tf-testacc-workspaces-workspace-%[1]s"
473
+ Beta = 2
459
474
}
460
475
}
461
- `
476
+ ` , rName ))
462
477
}
463
478
464
479
func testAccWorkspacesWorkspaceConfig_TagsC (rName string ) string {
465
- return testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ) + `
480
+ return composeConfig (
481
+ testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ),
482
+ fmt .Sprintf (`
466
483
resource "aws_workspaces_workspace" "test" {
467
484
bundle_id = data.aws_workspaces_bundle.test.id
468
485
directory_id = aws_workspaces_directory.test.id
@@ -472,14 +489,16 @@ resource "aws_workspaces_workspace" "test" {
472
489
user_name = "Administrator"
473
490
474
491
tags = {
475
- TerraformProviderAwsTest = true
492
+ Name = "tf-testacc-workspaces-workspace-%[1]s"
476
493
}
477
494
}
478
- `
495
+ ` , rName ))
479
496
}
480
497
481
498
func testAccWorkspacesWorkspaceConfig_WorkspacePropertiesA (rName string ) string {
482
- return testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ) + `
499
+ return composeConfig (
500
+ testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ),
501
+ fmt .Sprintf (`
483
502
resource "aws_workspaces_workspace" "test" {
484
503
bundle_id = data.aws_workspaces_bundle.test.id
485
504
directory_id = aws_workspaces_directory.test.id
@@ -495,14 +514,16 @@ resource "aws_workspaces_workspace" "test" {
495
514
}
496
515
497
516
tags = {
498
- TerraformProviderAwsTest = true
517
+ Name = "tf-testacc-workspaces-workspace-%[1]s"
499
518
}
500
519
}
501
- `
520
+ ` , rName ))
502
521
}
503
522
504
523
func testAccWorkspacesWorkspaceConfig_WorkspacePropertiesB (rName string ) string {
505
- return testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ) + `
524
+ return composeConfig (
525
+ testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ),
526
+ fmt .Sprintf (`
506
527
resource "aws_workspaces_workspace" "test" {
507
528
bundle_id = data.aws_workspaces_bundle.test.id
508
529
directory_id = aws_workspaces_directory.test.id
@@ -517,14 +538,16 @@ resource "aws_workspaces_workspace" "test" {
517
538
}
518
539
519
540
tags = {
520
- TerraformProviderAwsTest = true
541
+ Name = "tf-testacc-workspaces-workspace-%[1]s"
521
542
}
522
543
}
523
- `
544
+ ` , rName ))
524
545
}
525
546
526
547
func testAccWorkspacesWorkspaceConfig_WorkspacePropertiesC (rName string ) string {
527
- return testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ) + `
548
+ return composeConfig (
549
+ testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ),
550
+ fmt .Sprintf (`
528
551
resource "aws_workspaces_workspace" "test" {
529
552
bundle_id = data.aws_workspaces_bundle.test.id
530
553
directory_id = aws_workspaces_directory.test.id
@@ -535,12 +558,18 @@ resource "aws_workspaces_workspace" "test" {
535
558
536
559
workspace_properties {
537
560
}
561
+
562
+ tags = {
563
+ Name = "tf-testacc-workspaces-workspace-%[1]s"
564
+ }
538
565
}
539
- `
566
+ ` , rName ))
540
567
}
541
568
542
569
func testAccWorkspacesWorkspaceConfig_validateRootVolumeSize (rName string ) string {
543
- return testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ) + `
570
+ return composeConfig (
571
+ testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ),
572
+ fmt .Sprintf (`
544
573
resource "aws_workspaces_workspace" "test" {
545
574
bundle_id = data.aws_workspaces_bundle.test.id
546
575
directory_id = aws_workspaces_directory.test.id
@@ -555,14 +584,16 @@ resource "aws_workspaces_workspace" "test" {
555
584
}
556
585
557
586
tags = {
558
- TerraformProviderAwsTest = true
587
+ Name = "tf-testacc-workspaces-workspace-%[1]s"
559
588
}
560
589
}
561
- `
590
+ ` , rName ))
562
591
}
563
592
564
593
func testAccWorkspacesWorkspaceConfig_validateUserVolumeSize (rName string ) string {
565
- return testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ) + `
594
+ return composeConfig (
595
+ testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ),
596
+ fmt .Sprintf (`
566
597
resource "aws_workspaces_workspace" "test" {
567
598
bundle_id = data.aws_workspaces_bundle.test.id
568
599
directory_id = aws_workspaces_directory.test.id
@@ -577,14 +608,16 @@ resource "aws_workspaces_workspace" "test" {
577
608
}
578
609
579
610
tags = {
580
- TerraformProviderAwsTest = true
611
+ Name = "tf-testacc-workspaces-workspace-%[1]s"
581
612
}
582
613
}
583
- `
614
+ ` , rName ))
584
615
}
585
616
586
617
func testAccWorkspacesWorkspaceConfig_timeout (rName string ) string {
587
- return testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ) + `
618
+ return composeConfig (
619
+ testAccAwsWorkspacesWorkspaceConfig_Prerequisites (rName ),
620
+ fmt .Sprintf (`
588
621
resource "aws_workspaces_workspace" "test" {
589
622
bundle_id = data.aws_workspaces_bundle.test.id
590
623
directory_id = aws_workspaces_directory.test.id
@@ -598,8 +631,12 @@ resource "aws_workspaces_workspace" "test" {
598
631
update = "30m"
599
632
delete = "30m"
600
633
}
634
+
635
+ tags = {
636
+ Name = "tf-testacc-workspaces-workspace-%[1]s"
637
+ }
601
638
}
602
- `
639
+ ` , rName ))
603
640
}
604
641
605
642
func TestExpandWorkspaceProperties (t * testing.T ) {
0 commit comments