Skip to content

Commit

Permalink
Merge pull request #25287 from meetreks/b-aws_vpc_ipam_pool_cidr
Browse files Browse the repository at this point in the history
r/aws_vpc_ipam_pool_cidr: Better error reporting
  • Loading branch information
ewbankkit authored Jul 1, 2022
2 parents 4d69ced + e7c6db0 commit a5a281a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/25287.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_vpc_ipam_pool_cidr: Better error reporting
```
9 changes: 9 additions & 0 deletions internal/service/ec2/ipam_pool_cidr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -207,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
}

Expand All @@ -225,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
}

Expand Down
2 changes: 1 addition & 1 deletion internal/service/ec2/ipam_pool_cidr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
)

func TestAccIPAMPool_cidrIPv4Basic(t *testing.T) {
func TestAccIPAMPoolCIDR_basic(t *testing.T) {
var cidr ec2.IpamPoolCidr
resourceName := "aws_vpc_ipam_pool_cidr.test"
cidr_range := "10.0.0.0/24"
Expand Down

0 comments on commit a5a281a

Please sign in to comment.