@@ -30,7 +30,72 @@ func TestAccServiceCatalogProvisionedProduct_basic(t *testing.T) {
30
30
CheckDestroy : testAccCheckProvisionedProductDestroy ,
31
31
Steps : []resource.TestStep {
32
32
{
33
- Config : testAccProvisionedProductConfig_basic (rName , domain , acctest .DefaultEmailAddress ),
33
+ Config : testAccProvisionedProductConfig_basic (rName , domain , acctest .DefaultEmailAddress , "10.1.0.0/16" ),
34
+ Check : resource .ComposeTestCheckFunc (
35
+ testAccCheckProvisionedProductExists (resourceName ),
36
+ resource .TestCheckResourceAttr (resourceName , "accept_language" , tfservicecatalog .AcceptLanguageEnglish ),
37
+ acctest .MatchResourceAttrRegionalARN (resourceName , "arn" , servicecatalog .ServiceName , regexp .MustCompile (fmt .Sprintf (`stack/%s/pp-.*` , rName ))),
38
+ acctest .CheckResourceAttrRFC3339 (resourceName , "created_time" ),
39
+ resource .TestCheckResourceAttrSet (resourceName , "last_provisioning_record_id" ),
40
+ resource .TestCheckResourceAttrSet (resourceName , "last_record_id" ),
41
+ resource .TestCheckResourceAttrSet (resourceName , "last_successful_provisioning_record_id" ),
42
+ resource .TestCheckResourceAttr (resourceName , "name" , rName ),
43
+ // One output will default to the launched CloudFormation Stack (provisioned outside terraform).
44
+ // While another output will describe the output parameter configured in the S3 object resource,
45
+ // which we can check as follows.
46
+ resource .TestCheckResourceAttr (resourceName , "outputs.#" , "2" ),
47
+ resource .TestCheckTypeSetElemNestedAttrs (resourceName , "outputs.*" , map [string ]string {
48
+ "description" : "VPC ID" ,
49
+ "key" : "VpcID" ,
50
+ }),
51
+ resource .TestMatchTypeSetElemNestedAttrs (resourceName , "outputs.*" , map [string ]* regexp.Regexp {
52
+ "value" : regexp .MustCompile (`vpc-.+` ),
53
+ }),
54
+ resource .TestCheckResourceAttrPair (resourceName , "path_id" , "data.aws_servicecatalog_launch_paths.test" , "summaries.0.path_id" ),
55
+ resource .TestCheckResourceAttrPair (resourceName , "product_id" , "aws_servicecatalog_product.test" , "id" ),
56
+ resource .TestCheckResourceAttrPair (resourceName , "provisioning_artifact_name" , "aws_servicecatalog_product.test" , "provisioning_artifact_parameters.0.name" ),
57
+ resource .TestCheckResourceAttr (resourceName , "status" , servicecatalog .StatusAvailable ),
58
+ resource .TestCheckResourceAttr (resourceName , "type" , "CFN_STACK" ),
59
+ ),
60
+ },
61
+ {
62
+ ResourceName : resourceName ,
63
+ ImportState : true ,
64
+ ImportStateVerify : true ,
65
+ ImportStateVerifyIgnore : []string {
66
+ "accept_language" ,
67
+ "ignore_errors" ,
68
+ "provisioning_artifact_name" ,
69
+ "provisioning_parameters" ,
70
+ "retain_physical_resources" ,
71
+ },
72
+ },
73
+ },
74
+ })
75
+ }
76
+
77
+ // TestAccServiceCatalogProvisionedProduct_update verifies the resource update
78
+ // of only a change in provisioning_parameters
79
+ func TestAccServiceCatalogProvisionedProduct_update (t * testing.T ) {
80
+ resourceName := "aws_servicecatalog_provisioned_product.test"
81
+
82
+ rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
83
+ domain := fmt .Sprintf ("http://%s" , acctest .RandomDomainName ())
84
+
85
+ resource .ParallelTest (t , resource.TestCase {
86
+ PreCheck : func () { acctest .PreCheck (t ) },
87
+ ErrorCheck : acctest .ErrorCheck (t , servicecatalog .EndpointsID ),
88
+ ProviderFactories : acctest .ProviderFactories ,
89
+ CheckDestroy : testAccCheckProvisionedProductDestroy ,
90
+ Steps : []resource.TestStep {
91
+ {
92
+ Config : testAccProvisionedProductConfig_basic (rName , domain , acctest .DefaultEmailAddress , "10.1.0.0/16" ),
93
+ Check : resource .ComposeTestCheckFunc (
94
+ testAccCheckProvisionedProductExists (resourceName ),
95
+ ),
96
+ },
97
+ {
98
+ Config : testAccProvisionedProductConfig_basic (rName , domain , acctest .DefaultEmailAddress , "10.10.0.0/16" ),
34
99
Check : resource .ComposeTestCheckFunc (
35
100
testAccCheckProvisionedProductExists (resourceName ),
36
101
resource .TestCheckResourceAttr (resourceName , "accept_language" , tfservicecatalog .AcceptLanguageEnglish ),
@@ -87,7 +152,7 @@ func TestAccServiceCatalogProvisionedProduct_disappears(t *testing.T) {
87
152
CheckDestroy : testAccCheckProvisionedProductDestroy ,
88
153
Steps : []resource.TestStep {
89
154
{
90
- Config : testAccProvisionedProductConfig_basic (rName , domain , acctest .DefaultEmailAddress ),
155
+ Config : testAccProvisionedProductConfig_basic (rName , domain , acctest .DefaultEmailAddress , "10.1.0.0/16" ),
91
156
Check : resource .ComposeTestCheckFunc (
92
157
testAccCheckProvisionedProductExists (resourceName ),
93
158
acctest .CheckResourceDisappears (acctest .Provider , tfservicecatalog .ResourceProvisionedProduct (), resourceName ),
@@ -298,7 +363,7 @@ data "aws_servicecatalog_launch_paths" "test" {
298
363
` , rName , domain , email )
299
364
}
300
365
301
- func testAccProvisionedProductConfig_basic (rName , domain , email string ) string {
366
+ func testAccProvisionedProductConfig_basic (rName , domain , email , vpcCidr string ) string {
302
367
return acctest .ConfigCompose (testAccProvisionedProductTemplateURLBaseConfig (rName , domain , email ),
303
368
fmt .Sprintf (`
304
369
resource "aws_servicecatalog_provisioned_product" "test" {
@@ -309,15 +374,15 @@ resource "aws_servicecatalog_provisioned_product" "test" {
309
374
310
375
provisioning_parameters {
311
376
key = "VPCPrimaryCIDR"
312
- value = "10.1.0.0/16"
377
+ value = %[2]q
313
378
}
314
379
315
380
provisioning_parameters {
316
381
key = "LeaveMeEmpty"
317
382
value = ""
318
383
}
319
384
}
320
- ` , rName ))
385
+ ` , rName , vpcCidr ))
321
386
}
322
387
323
388
func testAccProvisionedProductConfig_tags (rName , tagKey , tagValue , domain , email string ) string {
0 commit comments