Skip to content

Commit

Permalink
Merge pull request #3586 from domdom82/tags_timeout_from_resource
Browse files Browse the repository at this point in the history
tags should retry without time bounds on EC2 throttling
  • Loading branch information
bflad authored Nov 14, 2018
2 parents 9ba9718 + 5df2e9a commit c3c296c
Showing 1 changed file with 52 additions and 4 deletions.
56 changes: 52 additions & 4 deletions aws/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,19 @@ func setVolumeTags(conn *ec2.EC2, d *schema.ResourceData) error {
return nil
})
if err != nil {
return err
// Retry without time bounds for EC2 throttling
if isResourceTimeoutError(err) {
log.Printf("[DEBUG] Removing volume tags: %#v from %s", remove, d.Id())
_, err := conn.DeleteTags(&ec2.DeleteTagsInput{
Resources: volumeIds,
Tags: remove,
})
if err != nil {
return err
}
} else {
return err
}
}
}
if len(create) > 0 {
Expand All @@ -120,7 +132,19 @@ func setVolumeTags(conn *ec2.EC2, d *schema.ResourceData) error {
return nil
})
if err != nil {
return err
// Retry without time bounds for EC2 throttling
if isResourceTimeoutError(err) {
log.Printf("[DEBUG] Creating vol tags: %s for %s", create, d.Id())
_, err := conn.CreateTags(&ec2.CreateTagsInput{
Resources: volumeIds,
Tags: create,
})
if err != nil {
return err
}
} else {
return err
}
}
}
}
Expand Down Expand Up @@ -155,7 +179,19 @@ func setTags(conn *ec2.EC2, d *schema.ResourceData) error {
return nil
})
if err != nil {
return err
// Retry without time bounds for EC2 throttling
if isResourceTimeoutError(err) {
log.Printf("[DEBUG] Removing tags: %#v from %s", remove, d.Id())
_, err := conn.DeleteTags(&ec2.DeleteTagsInput{
Resources: []*string{aws.String(d.Id())},
Tags: remove,
})
if err != nil {
return err
}
} else {
return err
}
}
}
if len(create) > 0 {
Expand All @@ -175,7 +211,19 @@ func setTags(conn *ec2.EC2, d *schema.ResourceData) error {
return nil
})
if err != nil {
return err
// Retry without time bounds for EC2 throttling
if isResourceTimeoutError(err) {
log.Printf("[DEBUG] Creating tags: %s for %s", create, d.Id())
_, err := conn.CreateTags(&ec2.CreateTagsInput{
Resources: []*string{aws.String(d.Id())},
Tags: create,
})
if err != nil {
return err
}
} else {
return err
}
}
}
}
Expand Down

0 comments on commit c3c296c

Please sign in to comment.