Skip to content

Commit

Permalink
Update vpc_subnet.go
Browse files Browse the repository at this point in the history
enabling dns64 and resource_name_dns_aaaa_record_on_launch, do that after modifying the IPv6 CIDR block.
  • Loading branch information
watarukura authored and YakDriver committed Aug 11, 2023
1 parent b4d2b12 commit 4fbdd02
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions internal/service/ec2/vpc_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,20 @@ func resourceSubnetUpdate(ctx context.Context, d *schema.ResourceData, meta inte
}
}

// If we're disabling IPv6 assignment for new ENIs, do that before modifying the IPv6 CIDR block.
if d.HasChange("assign_ipv6_address_on_creation") && !d.Get("assign_ipv6_address_on_creation").(bool) {
if err := modifySubnetAssignIPv6AddressOnCreation(ctx, conn, d.Id(), false); err != nil {
return sdkdiag.AppendFromErr(diags, err)
}
}

// If we're enabling dns64 and resource_name_dns_aaaa_record_on_launch, do that after modifying the IPv6 CIDR block.
if d.HasChange("ipv6_cidr_block") {
if err := modifySubnetIPv6CIDRBlockAssociation(ctx, conn, d.Id(), d.Get("ipv6_cidr_block_association_id").(string), d.Get("ipv6_cidr_block").(string)); err != nil {
return sdkdiag.AppendFromErr(diags, err)
}
}

if d.HasChange("enable_dns64") {
if err := modifySubnetEnableDNS64(ctx, conn, d.Id(), d.Get("enable_dns64").(bool)); err != nil {
return sdkdiag.AppendFromErr(diags, err)
Expand Down Expand Up @@ -336,19 +350,6 @@ func resourceSubnetUpdate(ctx context.Context, d *schema.ResourceData, meta inte
}
}

// If we're disabling IPv6 assignment for new ENIs, do that before modifying the IPv6 CIDR block.
if d.HasChange("assign_ipv6_address_on_creation") && !d.Get("assign_ipv6_address_on_creation").(bool) {
if err := modifySubnetAssignIPv6AddressOnCreation(ctx, conn, d.Id(), false); err != nil {
return sdkdiag.AppendFromErr(diags, err)
}
}

if d.HasChange("ipv6_cidr_block") {
if err := modifySubnetIPv6CIDRBlockAssociation(ctx, conn, d.Id(), d.Get("ipv6_cidr_block_association_id").(string), d.Get("ipv6_cidr_block").(string)); err != nil {
return sdkdiag.AppendFromErr(diags, err)
}
}

// If we're enabling IPv6 assignment for new ENIs, do that after modifying the IPv6 CIDR block.
if d.HasChange("assign_ipv6_address_on_creation") && d.Get("assign_ipv6_address_on_creation").(bool) {
if err := modifySubnetAssignIPv6AddressOnCreation(ctx, conn, d.Id(), true); err != nil {
Expand Down

0 comments on commit 4fbdd02

Please sign in to comment.