Skip to content

Commit

Permalink
Merge pull request #5712 from bjss/master
Browse files Browse the repository at this point in the history
Use timeout_in_minutes for Terraform timeout in AWS CloudFormation
  • Loading branch information
radeksimko committed Mar 21, 2016
2 parents 9a2ce8a + c3b3fea commit 5c21422
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions builtin/providers/aws/resource_aws_cloudformation_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func resourceAwsCloudFormationStack() *schema.Resource {
}

func resourceAwsCloudFormationStackCreate(d *schema.ResourceData, meta interface{}) error {
retryTimeout := int64(30)
conn := meta.(*AWSClient).cfconn

input := cloudformation.CreateStackInput{
Expand Down Expand Up @@ -129,7 +130,12 @@ func resourceAwsCloudFormationStackCreate(d *schema.ResourceData, meta interface
input.Tags = expandCloudFormationTags(v.(map[string]interface{}))
}
if v, ok := d.GetOk("timeout_in_minutes"); ok {
input.TimeoutInMinutes = aws.Int64(int64(v.(int)))
m := int64(v.(int))
input.TimeoutInMinutes = aws.Int64(m)
if m > retryTimeout {
retryTimeout = m + 5
log.Printf("[DEBUG] CloudFormation timeout: %d", retryTimeout)
}
}

log.Printf("[DEBUG] Creating CloudFormation Stack: %s", input)
Expand All @@ -143,7 +149,7 @@ func resourceAwsCloudFormationStackCreate(d *schema.ResourceData, meta interface
wait := resource.StateChangeConf{
Pending: []string{"CREATE_IN_PROGRESS", "ROLLBACK_IN_PROGRESS", "ROLLBACK_COMPLETE"},
Target: []string{"CREATE_COMPLETE"},
Timeout: 30 * time.Minute,
Timeout: time.Duration(retryTimeout) * time.Minute,
MinTimeout: 5 * time.Second,
Refresh: func() (interface{}, string, error) {
resp, err := conn.DescribeStacks(&cloudformation.DescribeStacksInput{
Expand Down

0 comments on commit 5c21422

Please sign in to comment.