From 27359a1370cd3820b4941766c39523fd9674a50f Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Mon, 3 Feb 2020 20:35:40 -0500 Subject: [PATCH] resource/aws_cloudformation_stack_set: Wait for update operation completion and report any errors (#11726) Previously in the acceptance testing: ``` --- FAIL: TestAccAWSCloudFormationStackSet_Parameters (35.78s) testing.go:640: Step 4 error: errors during apply: Error: error updating CloudFormation Stack Set (tf-acc-test-5503547290025742409): OperationInProgressException: Another Operation on StackSet arn:aws:cloudformation:us-west-2:*******:stackset/tf-acc-test-5503547290025742409:55908c5e-ea0e-482f-b21c-2c1fb21fb1ac is in progress status code: 409, request id: c123a6e4-3577-4c85-8964-a898d81c597d on /opt/teamcity-agent/temp/buildTmp/tf-test708526898/main.tf line 7: (source code not available) testing.go:701: Error destroying resource! WARNING: Dangling resources may exist. The full state and error is shown below. Error: errors during apply: error deleting CloudFormation Stack Set (tf-acc-test-5503547290025742409): OperationInProgressException: Operation terraform-20200122114208738100000003 on StackSet arn:aws:cloudformation:us-west-2:*******:stackset/tf-acc-test-5503547290025742409:55908c5e-ea0e-482f-b21c-2c1fb21fb1ac is in progress status code: 409, request id: b8059f09-effd-494a-8f43-17a6cac30d81 ``` Output from acceptance testing: ``` --- PASS: TestAccAWSCloudFormationStackSet_Description (38.41s) --- PASS: TestAccAWSCloudFormationStackSet_disappears (41.35s) --- PASS: TestAccAWSCloudFormationStackSet_ExecutionRoleName (57.63s) --- PASS: TestAccAWSCloudFormationStackSet_Name (61.53s) --- PASS: TestAccAWSCloudFormationStackSet_basic (72.71s) --- PASS: TestAccAWSCloudFormationStackSet_TemplateUrl (73.85s) --- PASS: TestAccAWSCloudFormationStackSet_AdministrationRoleArn (78.93s) --- PASS: TestAccAWSCloudFormationStackSet_Parameters (104.93s) --- PASS: TestAccAWSCloudFormationStackSet_TemplateBody (108.84s) --- PASS: TestAccAWSCloudFormationStackSet_Tags (134.72s) ``` --- aws/resource_aws_cloudformation_stack_set.go | 11 ++++++++++- website/docs/r/cloudformation_stack_set.html.markdown | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_cloudformation_stack_set.go b/aws/resource_aws_cloudformation_stack_set.go index 683c2ec2650..eb63a7142ce 100644 --- a/aws/resource_aws_cloudformation_stack_set.go +++ b/aws/resource_aws_cloudformation_stack_set.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "regexp" + "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/cloudformation" @@ -24,6 +25,10 @@ func resourceAwsCloudFormationStackSet() *schema.Resource { State: schema.ImportStatePassthrough, }, + Timeouts: &schema.ResourceTimeout{ + Update: schema.DefaultTimeout(30 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "administration_role_arn": { Type: schema.TypeString, @@ -228,12 +233,16 @@ func resourceAwsCloudFormationStackSetUpdate(d *schema.ResourceData, meta interf } log.Printf("[DEBUG] Updating CloudFormation Stack Set: %s", input) - _, err := conn.UpdateStackSet(input) + output, err := conn.UpdateStackSet(input) if err != nil { return fmt.Errorf("error updating CloudFormation Stack Set (%s): %s", d.Id(), err) } + if err := waitForCloudFormationStackSetOperation(conn, d.Id(), aws.StringValue(output.OperationId), d.Timeout(schema.TimeoutUpdate)); err != nil { + return fmt.Errorf("error waiting for CloudFormation Stack Set (%s) update: %s", d.Id(), err) + } + return resourceAwsCloudFormationStackSetRead(d, meta) } diff --git a/website/docs/r/cloudformation_stack_set.html.markdown b/website/docs/r/cloudformation_stack_set.html.markdown index 5c9f7d1e22f..86cca2839b7 100644 --- a/website/docs/r/cloudformation_stack_set.html.markdown +++ b/website/docs/r/cloudformation_stack_set.html.markdown @@ -103,6 +103,12 @@ In addition to all arguments above, the following attributes are exported: * `id` - Name of the Stack Set. * `stack_set_id` - Unique identifier of the Stack Set. +## Timeouts + +`aws_cloudformation_stack_set` provides the following [Timeouts](/docs/configuration/resources.html#timeouts) configuration options: + +* `update` - (Default `30m`) How long to wait for a Stack Set to be updated. + ## Import CloudFormation Stack Sets can be imported using the `name`, e.g.