@@ -272,14 +272,11 @@ func resourceAwsSubnetUpdate(d *schema.ResourceData, meta interface{}) error {
272272 // This could be an issue as, we could error out when we try to add the new one
273273 // We may need to roll back the state and reattach the old one if this is the case
274274
275- _ , newIpv6 := d .GetChange ("ipv6_cidr_block" )
276- n := newIpv6 .(string )
275+ newIpv6 := d .Get ("ipv6_cidr_block" ).(string )
277276
278277 if v , ok := d .GetOk ("ipv6_cidr_block_association_id" ); ok {
279278
280- _ , newIpv6AssignOnCreate := d .GetChange ("assign_ipv6_address_on_creation" )
281-
282- ipv6AssignOnCreate := newIpv6AssignOnCreate .(bool )
279+ ipv6AssignOnCreate := d .Get ("assign_ipv6_address_on_creation" ).(bool )
283280
284281 if ! ipv6AssignOnCreate {
285282 modifyOpts := & ec2.ModifySubnetAttributeInput {
@@ -294,7 +291,7 @@ func resourceAwsSubnetUpdate(d *schema.ResourceData, meta interface{}) error {
294291 _ , err := conn .ModifySubnetAttribute (modifyOpts )
295292
296293 if err != nil {
297- return err
294+ return fmt . Errorf ( "error modifying EC2 Subnet (%s) attribute: %w" , d . Id (), err )
298295 }
299296 }
300297 //Firstly we have to disassociate the old IPv6 CIDR Block
@@ -316,24 +313,22 @@ func resourceAwsSubnetUpdate(d *schema.ResourceData, meta interface{}) error {
316313 Timeout : 3 * time .Minute ,
317314 }
318315 if _ , err := stateConf .WaitForState (); err != nil {
319- return fmt .Errorf (
320- "Error waiting for IPv6 CIDR (%s) to become disassociated: %w" ,
321- d .Id (), err )
316+ return fmt .Errorf ("Error waiting for IPv6 CIDR (%s) to become disassociated: %w" , d .Id (), err )
322317 }
323318 }
324319
325- if n != "" {
320+ if newIpv6 != "" {
326321 //Now we need to try to associate the new CIDR block
327322 associatesOpts := & ec2.AssociateSubnetCidrBlockInput {
328323 SubnetId : aws .String (d .Id ()),
329- Ipv6CidrBlock : aws .String (newIpv6 .( string ) ),
324+ Ipv6CidrBlock : aws .String (newIpv6 ),
330325 }
331326
332327 resp , err := conn .AssociateSubnetCidrBlock (associatesOpts )
333328 if err != nil {
334329 //The big question here is, do we want to try to reassociate the old one??
335330 //If we have a failure here, then we may be in a situation that we have nothing associated
336- return err
331+ return fmt . Errorf ( "error associating EC2 Subnet (%s) CIDR block: %w" , d . Id (), err )
337332 }
338333
339334 // Wait for the CIDR to become associated
0 commit comments