Unable to delete stack when using ipv6 block

0

I succesfully deployed a test stack with a ipv6 only subnet and a webserver publicly running on port 80 using in this subnet.

I am deleting the stack but i got this

Resource handler returned message: "The vpc ..... currently has a subnet within CIDR block ...... (Service: Ec2, Status Code: 400, Request ID: 99b10ce2-9119-49ff-8d16-e9a36648dd81)" (RequestToken: e514de8d-30fe-9adc-8a8f-45696cc2eade, HandlerErrorCode: InvalidRequest)

To avoid this, should I add a DependsOn somewhere? Why simply cloud formation doesn't wait to subnet to be killed before trying to delete the ipv6 cidr block?

If i manually click on 'delete', the stack will be of course deleted because there is no more dependencies

How to fix this bad behaviour? We need to create and destroy stack ... VERY.... often

1 Answer
1
Accepted Answer

Hello.

Since the IPv6 CIDR block should be deleted after the subnet is deleted, the “DependsOn:” should be set as follows.
I think that by doing this, "VPCIpv6CidrBlock" will be deleted after "PublicIpv6SubnetA" and the error will disappear.

  VPCIpv6CidrBlock:
    Type: AWS::EC2::VPCCidrBlock
    Properties:
      VpcId: !Ref VPC
      AmazonProvidedIpv6CidrBlock: true

  # Sottorete IPV6-only, che sarà 'pubblica' grazie a rotte, e instradamenti,
  # ancora da fare
  PublicIpv6SubnetA:
    DependsOn: VPCIpv6CidrBlock
    Type: AWS::EC2::Subnet
    Properties:
      Ipv6Native: true
      Ipv6CidrBlock: !Sub
        - ${VpcPart}${SubnetPart}
        - SubnetPart: 00::/64
          VpcPart: !Select
            - 0
            - !Split
              - 00::/56
              - !Select
                - 0
                - !GetAtt VPC.Ipv6CidrBlocks
      AvailabilityZone: !Select
        - 0
        - !GetAZs ""
      VpcId: !Ref VPC
      Tags:
        - Key: Name
          Value: Public IPV6 Subnet A
profile picture
EXPERT
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions