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

r/aws_vpc_ipam_pool_cidr: Better error reporting #25287

Merged
merged 5 commits into from
Jul 1, 2022
Merged
Changes from 1 commit
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
16 changes: 11 additions & 5 deletions internal/service/ec2/ipam_pool_cidr.go
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
"github.com/hashicorp/terraform-provider-aws/internal/verify"
)

@@ -96,11 +97,8 @@ func resourceIPAMPoolCIDRCreate(d *schema.ResourceData, meta interface{}) error
cidr := aws.StringValue(output.IpamPoolCidr.Cidr)
id := encodeIPAMPoolCIDRId(cidr, pool_id)

v, err := WaitIPAMPoolCIDRAvailable(conn, id, ipamPoolCIDRCreateTimeout)

if err != nil {
outval := aws.StringValue(v.FailureReason.Message)
return fmt.Errorf("error waiting for IPAM Pool Cidr (%s) to be provision: %w", outval, err)
if _, err = WaitIPAMPoolCIDRAvailable(conn, id, ipamPoolCIDRCreateTimeout); err != nil {
return fmt.Errorf("error waiting for IPAM Pool CIDR (%s) to be provisioned: %w", id, err)
}

d.SetId(id)
@@ -210,6 +208,10 @@ func WaitIPAMPoolCIDRAvailable(conn *ec2.EC2, id string, timeout time.Duration)
outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*ec2.IpamPoolCidr); ok {
if failureReason := output.FailureReason; failureReason != nil {
tfresource.SetLastError(err, fmt.Errorf("%s: %s", aws.StringValue(failureReason.Code), aws.StringValue(failureReason.Message)))
}

return output, err
}

@@ -228,6 +230,10 @@ func WaitIPAMPoolCIDRDeleted(conn *ec2.EC2, id string, timeout time.Duration) (*
outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*ec2.IpamPoolCidr); ok {
if failureReason := output.FailureReason; failureReason != nil {
tfresource.SetLastError(err, fmt.Errorf("%s: %s", aws.StringValue(failureReason.Code), aws.StringValue(failureReason.Message)))
}

return output, err
}

You are viewing a condensed version of this merge commit. You can view the full changes here.