Skip to content

Commit

Permalink
resource/aws_cloudformation_stack_set: Wait for update operation comp…
Browse files Browse the repository at this point in the history
…letion 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)
```
  • Loading branch information
bflad authored Feb 4, 2020
1 parent bac4934 commit 27359a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion aws/resource_aws_cloudformation_stack_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"regexp"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudformation"
Expand All @@ -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,
Expand Down Expand Up @@ -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)
}

Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/cloudformation_stack_set.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 27359a1

Please sign in to comment.