Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 2 tasks
RyanFrench opened this issue Feb 21, 2025 · 1 comment · May be fixed by #33545
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr/needs-review

Comments

@RyanFrench
Copy link

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:

  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

#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

  • 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

@ashishdhingra
Copy link
Contributor

Similar reported issue #17838 which got auto-closed due to staleness.

@ashishdhingra ashishdhingra added p2 effort/medium Medium work item – several days of effort pr/needs-review and removed needs-triage This issue or PR still needs to be triaged. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr/needs-review
Projects
None yet
2 participants