Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for timeouts on aws_eip resource #3769

Merged
merged 1 commit into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions aws/resource_aws_eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ func resourceAwsEip() *schema.Resource {
State: schema.ImportStatePassthrough,
},

Timeouts: &schema.ResourceTimeout{
Read: schema.DefaultTimeout(15 * time.Minute),
Update: schema.DefaultTimeout(5 * time.Minute),
Delete: schema.DefaultTimeout(3 * time.Minute),
},

Schema: map[string]*schema.Schema{
"vpc": &schema.Schema{
Type: schema.TypeBool,
Expand Down Expand Up @@ -145,7 +151,7 @@ func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error {
var describeAddresses *ec2.DescribeAddressesOutput

if d.IsNewResource() {
err := resource.Retry(15*time.Minute, func() *resource.RetryError {
err := resource.Retry(d.Timeout(schema.TimeoutRead), func() *resource.RetryError {
describeAddresses, err = ec2conn.DescribeAddresses(req)
if err != nil {
awsErr, ok := err.(awserr.Error)
Expand Down Expand Up @@ -276,7 +282,7 @@ func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error {

log.Printf("[DEBUG] EIP associate configuration: %s (domain: %s)", assocOpts, domain)

err := resource.Retry(5*time.Minute, func() *resource.RetryError {
err := resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError {
_, err := ec2conn.AssociateAddress(assocOpts)
if err != nil {
if isAWSErr(err, "InvalidAllocationID.NotFound", "") {
Expand Down Expand Up @@ -323,7 +329,7 @@ func resourceAwsEipDelete(d *schema.ResourceData, meta interface{}) error {
}

domain := resourceAwsEipDomain(d)
return resource.Retry(3*time.Minute, func() *resource.RetryError {
return resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError {
var err error
switch domain {
case "vpc":
Expand Down
7 changes: 7 additions & 0 deletions website/docs/r/eip.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ The following additional attributes are exported:
* `instance` - Contains the ID of the attached instance.
* `network_interface` - Contains the ID of the attached network interface.

## Timeouts
`aws_eip` provides the following [Timeouts](/docs/configuration/resources.html#timeouts) configuration options:

- `read` - (Default `15 minutes`) How long to wait querying for information about EIPs.
- `update` - (Default `5 minutes`) How long to wait for an EIP to be updated.
- `delete` - (Default `3 minutes`) How long to wait for an EIP to be deleted.

## Import

EIPs in a VPC can be imported using their Allocation ID, e.g.
Expand Down