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

resource/aws_route53_zone_association: Prevent deletion errors for missing Hosted Zone or VPC association #17023

Merged
merged 1 commit into from
Jan 11, 2021
Merged
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
9 changes: 9 additions & 0 deletions aws/resource_aws_route53_zone_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/route53"
"github.com/hashicorp/aws-sdk-go-base/tfawserr"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -172,6 +173,14 @@ func resourceAwsRoute53ZoneAssociationDelete(d *schema.ResourceData, meta interf

_, err = conn.DisassociateVPCFromHostedZone(input)

if tfawserr.ErrCodeEquals(err, route53.ErrCodeNoSuchHostedZone) {
return nil
}

if tfawserr.ErrCodeEquals(err, route53.ErrCodeVPCAssociationNotFound) {
return nil
}

if err != nil {
return fmt.Errorf("error disassociating Route 53 Hosted Zone (%s) from EC2 VPC (%s): %w", zoneID, vpcID, err)
}
Expand Down