aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

feat(ec2): network interface definitions for launch templates

Open pasiorovuo opened this issue 1 year ago • 3 comments

This PR implements basic functionality for defining network interfaces as part of Launch Template.

Issue # (if applicable)

Fixes #14494

Reason for this change

Current Launch Template L2 is missing the ability to define multiple interfaces, their subnets etc. This functionality is required in advanced scenarios where instances need multiple public IP addresses or need to be multi-homed etc.

Description of changes

Multiple new types have been introduced in packages/aws-cdk-lib/aws-ec2/lib/launch-template.ts. Many of them are just renamed extends of the ec2-generated types. This made sense as the Cloudformation type definition is suitable, but I'm a bit uncertain if this violates the design requirement Do not “leak” the details or types of the CFN layer when defining your construct API.

Main type is NetworkInterface which defines the attributes for the interfaces. Additional changes are in LaunchTemplate constructor to accommodate the new functionality.

README has been updated to include a simple usage example.

Description of how you validated changes

A single test has been added. I have also verified the implementation by creating stacks in different configurations and deployed them. There too many combinations to check them all, so only a subset has been tested, unfortunately.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

pasiorovuo avatar Apr 17 '24 21:04 pasiorovuo

I do not know what the failing check is about.

pasiorovuo avatar Apr 18 '24 05:04 pasiorovuo

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

aws-cdk-automation avatar Apr 28 '24 00:04 aws-cdk-automation

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 8be843b3ee9f0ad25f91ef5562c1951b1507d47e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

aws-cdk-automation avatar Apr 28 '24 17:04 aws-cdk-automation

This seems to be overlapping in parts with https://github.com/aws/aws-cdk/pull/28901. If it would be accepted, I could update this PR to account for the new types etc. introduced by it.

pasiorovuo avatar Jun 19 '24 11:06 pasiorovuo

Hi Pasi. Thanks for looking into this! I actually had the exact same issue https://github.com/aws/aws-cdk/issues/30891 as the one you're trying to solve. Your PR looks very similar to my local prototype with the differences being in how security group IDs are handled and how the unit tests are done. I was also not sure how AWS determines default behaviors when input fields are left undefined. Left comments on those parts.

Nice work!

chenhe95 avatar Jul 24 '24 17:07 chenhe95

Hi Pasi! I am wondering if this ticket is still being worked on, since I am very invested in getting launch templates to be more configurable
Thank you for all the work so far!

chenhe95 avatar Sep 04 '24 20:09 chenhe95