provider/aws: Updates `aws_cloudformation_stack` Update timeout (#7997)

Fixes #7996

The Create func was using the timeout that we were passing to the
resource. Update func was not.

```
% make testacc TEST=./builtin/providers/aws
% TESTARGS='-run=TestAccAWSCloudFormation_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
TF_ACC=1 go test ./builtin/providers/aws -v
-run=TestAccAWSCloudFormation_ -timeout 120m
=== RUN   TestAccAWSCloudFormation_basic
--- PASS: TestAccAWSCloudFormation_basic (120.61s)
=== RUN   TestAccAWSCloudFormation_defaultParams
--- PASS: TestAccAWSCloudFormation_defaultParams (121.40s)
=== RUN   TestAccAWSCloudFormation_allAttributes
--- PASS: TestAccAWSCloudFormation_allAttributes (263.29s)
=== RUN   TestAccAWSCloudFormation_withParams
--- PASS: TestAccAWSCloudFormation_withParams (205.52s)
=== RUN   TestAccAWSCloudFormation_withUrl_withParams
--- PASS: TestAccAWSCloudFormation_withUrl_withParams (402.71s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws
1113.552s
```
This commit is contained in:
Paul Stack 2016-08-05 18:44:10 +10:00 committed by Radek Simko
parent fa2d6e35a7
commit 6899246b98
1 changed files with 9 additions and 1 deletions

View File

@ -268,6 +268,7 @@ func resourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface{}
} }
func resourceAwsCloudFormationStackUpdate(d *schema.ResourceData, meta interface{}) error { func resourceAwsCloudFormationStackUpdate(d *schema.ResourceData, meta interface{}) error {
retryTimeout := int64(30)
conn := meta.(*AWSClient).cfconn conn := meta.(*AWSClient).cfconn
input := &cloudformation.UpdateStackInput{ input := &cloudformation.UpdateStackInput{
@ -314,6 +315,13 @@ func resourceAwsCloudFormationStackUpdate(d *schema.ResourceData, meta interface
return err return err
} }
if v, ok := d.GetOk("timeout_in_minutes"); ok {
m := int64(v.(int))
if m > retryTimeout {
retryTimeout = m + 5
log.Printf("[DEBUG] CloudFormation timeout: %d", retryTimeout)
}
}
wait := resource.StateChangeConf{ wait := resource.StateChangeConf{
Pending: []string{ Pending: []string{
"UPDATE_COMPLETE_CLEANUP_IN_PROGRESS", "UPDATE_COMPLETE_CLEANUP_IN_PROGRESS",
@ -323,7 +331,7 @@ func resourceAwsCloudFormationStackUpdate(d *schema.ResourceData, meta interface
"UPDATE_ROLLBACK_COMPLETE", "UPDATE_ROLLBACK_COMPLETE",
}, },
Target: []string{"UPDATE_COMPLETE"}, Target: []string{"UPDATE_COMPLETE"},
Timeout: 15 * time.Minute, Timeout: time.Duration(retryTimeout) * time.Minute,
MinTimeout: 5 * time.Second, MinTimeout: 5 * time.Second,
Refresh: func() (interface{}, string, error) { Refresh: func() (interface{}, string, error) {
resp, err := conn.DescribeStacks(&cloudformation.DescribeStacksInput{ resp, err := conn.DescribeStacks(&cloudformation.DescribeStacksInput{