Skip to content

Commit

Permalink
fix(ec2): deploying an isolated subnet fails when `ipv6AssignAddressO…
Browse files Browse the repository at this point in the history
…nCreation` is set to true (#28902)

This PR resolves the issue where deploying an isolated subnet with `ipv6AssignAddressOnCreation` enabled fails. 

### example
```ts
new Vpc(stack, 'TheVPC', {
        ipProtocol: IpProtocol.DUAL_STACK,
        subnetConfiguration: [
          {
            subnetType: testData.subnetType,
            name: 'subnetName',
            ipv6AssignAddressOnCreation: true,
          },
        ],
      });
```

### error
```sh
6:39:48 PM | CREATE_FAILED        | AWS::EC2::Subnet                      | vpcisolatedSubnet1Subnet06BBE51F
Template error: Fn::Select  cannot select nonexistent value at index 0
```

### solution
A dependency on the CidrBlock has been added [as discussed in issue](#28843 (comment)).

```ts
      (this.isolatedSubnets as PrivateSubnet[]).forEach((isolatedSubnet) => {
        if (this.ipv6CidrBlock !== undefined) {
          isolatedSubnet.node.addDependency(this.ipv6CidrBlock);
        }
      });
```


## Question
This modification results in the failure of existing integration tests.
I don't consider this change to be a breaking one, so I went ahead and updated the snapshot. Is that okay?
```sh
  CHANGED    aws-ec2/test/integ.vpc-dual-stack-ec2 0.776s
      Resources
[~] AWS::EC2::Subnet Ip6VpcDualStackPrivateSubnet1Subnet842B7F4C 
 └─ [+] DependsOn
     └─ ["Ip6VpcDualStackipv6cidr40BE830A"]
[~] AWS::EC2::RouteTable Ip6VpcDualStackPrivateSubnet1RouteTable5326D239 
 └─ [+] DependsOn
     └─ ["Ip6VpcDualStackipv6cidr40BE830A"]
[~] AWS::EC2::SubnetRouteTableAssociation Ip6VpcDualStackPrivateSubnet1RouteTableAssociationF1C10B6A 
 └─ [+] DependsOn
     └─ ["Ip6VpcDualStackipv6cidr40BE830A"]
[~] AWS::EC2::Subnet Ip6VpcDualStackPrivateSubnet2SubnetEB493489 
 └─ [+] DependsOn
     └─ ["Ip6VpcDualStackipv6cidr40BE830A"]
[~] AWS::EC2::RouteTable Ip6VpcDualStackPrivateSubnet2RouteTable56BF517C 
 └─ [+] DependsOn
     └─ ["Ip6VpcDualStackipv6cidr40BE830A"]
[~] AWS::EC2::SubnetRouteTableAssociation Ip6VpcDualStackPrivateSubnet2RouteTableAssociationD37A3D3D 
 └─ [+] DependsOn
     └─ ["Ip6VpcDualStackipv6cidr40BE830A"]
```

Closes #28843

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
badmintoncryer authored Feb 3, 2024
1 parent 8c79bdc commit 9de77bb
Show file tree
Hide file tree
Showing 20 changed files with 8,039 additions and 6,292 deletions.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9de77bb

Please sign in to comment.