aws / aws/aws-cdk

aws-ec2: Subnet L2 Construct does not support outpostArn and Vpc L2 Construct does not support outpost specific networking.

Open
#33,542 2 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-ec2 effort/medium feature-request p2 pr/needs-review
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

It is currently not possible to deploy a customer infrastructure onto an Outpost subnet using an L2 construct (aka ec2.Subnet). In addition, it is not possible to create a L2 Vpc using SubnetSelection if an Outpost subnet deployment is required.

### Use Case

Automated CDK-based deployment of infrastructure that includes requirement for Outpost-based subnets, and allow developers to leverage the L2 VPC construct to deploy infrastructure that configures a VPC with Subnets deployed to an Outpost, with the VPC/Outpost association automatically created, and allow developers to set default routes via the Local Gateway.

### Proposed Solution

The proposed solution is as follows:
• Add outpostArn to L2 Subnet construct
• Add the ability to create a VPC with SubnetSelection specific to outpost
• Add the ability to specify a local gateway (LGW) as part of the SubnetSelection for qualifying outpost subnet types.

example:
```typescript
const vpcCidr = this.node.tryGetContext("vpcCidr");
const outpostAvailabilityZone = this.node.tryGetContext("outpostAvailabilityZone");
const outpostArn = this.node.tryGetContext("outpostArn");
const localGatewayId = this.node.tryGetContext("localGatewayId");
const localGatewayRouteTableId = this.node.tryGetContext("localGatewayRouteTableId");
new ec2.Vpc(this, "OutpostVPC", {
cidr: vpcCidr,
maxAzs: 2,
localGatewayRouteTableIds: [localGatewayRouteTableId],
subnetConfiguration: [
{
cidrMask: 26,
name: "Public",
subnetType: ec2.SubnetType.PUBLIC,
},
{
cidrMask: 26,
name: "Private",
subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS,
},
{
cidrMask: 26,
name: "OutpostPublic",
outpostArn,
outpostAvailabilityZone: outpostAvailabilityZone,
outpostDefaultRoute: ec2.OutpostDefaultRoute.ON_PREMISE,
localGatewayId: localGatewayId,
subnetType: ec2.SubnetType.PUBLIC_OUTPOST,
},
{
cidrMask: 26,
name: "OutpostPrivate",
outpostArn,
outpostAvailabilityZone: outpostAvailabilityZone,
outpostDefaultRoute: ec2.OutpostDefaultRoute.ON_PREMISE,
localGatewayId: localGatewayId,
subnetType: ec2.SubnetType.PRIVATE_OUTPOST_WITH_EGRESS,
},
],
});
```

### Other Information

https://github.com/aws/aws-cdk/issues/17838

While we considered building our own L2 Construct, this would require considerable effort to replicate the current logic around defining subnet CIDRs, adding NAT/Internet gateways, and would result in duplication of existing code.

We have implemented the proposed solution and will raise this as a PR.

@gffloodg

### Acknowledgements

- [x] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.179.0

### Environment details (OS name and version, etc.)

macOS Sequoia 15.3.1

Contributor guide

Open the contributing guide

Research direction

Start with the ec2.Subnet and ec2.Vpc L2 construct entry points and their SubnetSelection handling. Check how outpostArn, outpost-specific subnet settings, VPC/Outpost association, and local-gateway routes are represented in the synthesized resources. Done means the example configuration is supported without custom L2 duplication, with coverage for the requested Outpost cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure, networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.