From c67f34fc7f3d0f1d27a6ab0bce3e692ea12d71c7 Mon Sep 17 00:00:00 2001 From: Pasi Orovuo Date: Thu, 18 Apr 2024 00:10:12 +0300 Subject: [PATCH 1/4] Implement basic functionality for defining network interface configurations as part of Launch Template definitions --- packages/aws-cdk-lib/aws-ec2/README.md | 29 ++ .../aws-ec2/lib/launch-template.ts | 264 +++++++++++++++++- 2 files changed, 289 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ec2/README.md b/packages/aws-cdk-lib/aws-ec2/README.md index 73bb89cb2ae89..1e20557e95845 100644 --- a/packages/aws-cdk-lib/aws-ec2/README.md +++ b/packages/aws-cdk-lib/aws-ec2/README.md @@ -2212,6 +2212,35 @@ const launchTemplate = new ec2.LaunchTemplate(this, 'LaunchTemplate', { }); ``` +Following demonstrates how to add multiple network interface cards to launch template. + +```ts +declare const vpc: ec2.Vpc; + +const sg1 = new ec2.SecurityGroup(this, 'sg1', { + vpc: vpc, +}); +const sg2 = new ec2.SecurityGroup(this, 'sg2', { + vpc: vpc, +}); + +new LaunchTemplate(stack, 'LaunchTemplate', { + machineImage: ec2.MachineImage.latestAmazonLinux2023(), + networkInterfaces: [ + { + associatePublicIpAddress: false, + deviceIndex: 0, + groups: [sg1], + }, + { + associatePublicIpAddress: false, + deviceIndex: 1, + groups: [sg2], + }, + ], +}); +``` + Please note this feature does not support Launch Configurations. ## Detailed Monitoring diff --git a/packages/aws-cdk-lib/aws-ec2/lib/launch-template.ts b/packages/aws-cdk-lib/aws-ec2/lib/launch-template.ts index 04ec805533bd9..2031a4cd15441 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/launch-template.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/launch-template.ts @@ -8,6 +8,7 @@ import { launchTemplateBlockDeviceMappings } from './private/ebs-util'; import { ISecurityGroup } from './security-group'; import { UserData } from './user-data'; import { BlockDevice } from './volume'; +import { ISubnet } from './vpc'; import * as iam from '../../aws-iam'; import { Annotations, @@ -68,6 +69,234 @@ export enum InstanceInitiatedShutdownBehavior { TERMINATE = 'terminate', }; +/** + * InterfaceType + */ +export enum InterfaceType { + /** + * efa + * + * @see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa.html + */ + EFA = 'efa', + + /** + * interface + */ + INTERFACE = 'interface', +} + +/** + * A security group connection tracking specification that enables you to set the idle timeout for connection tracking on an Elastic network interface. + * + * @see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-connection-tracking.html#connection-tracking-timeouts + */ +export interface ConnectionTrackingSpecification extends CfnLaunchTemplate.ConnectionTrackingSpecificationProperty {}; + +/** + * ENA Express uses AWS Scalable Reliable Datagram (SRD) technology to increase the maximum bandwidth used per stream and minimize tail latency of network traffic between EC2 instances. + * + * With ENA Express, you can communicate between two EC2 instances in the same subnet within the same account, or in different accounts. Both sending and receiving instances must have ENA Express enabled. + * + * To improve the reliability of network packet delivery, ENA Express reorders network packets on the receiving end by default. However, some UDP-based applications are designed to handle network packets that are out of order to reduce the overhead for packet delivery at the network layer. When ENA Express is enabled, you can specify whether UDP network traffic uses it. + */ +export interface EnaSrdSpecification extends CfnLaunchTemplate.EnaSrdSpecificationProperty {}; + +/** + * Specifies an IPv4 prefix for a network interface. + */ +export interface Ipv4PrefixSpecification extends CfnLaunchTemplate.Ipv4PrefixSpecificationProperty {}; + +/** + * Specifies an IPv6 address in an Amazon EC2 launch template. + * + * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-networkinterface.html + */ +export interface Ipv6Add extends CfnLaunchTemplate.Ipv6AddProperty {}; + +/** + * Specifies an IPv6 prefix for a network interface. + */ +export interface Ipv6PrefixSpecification extends CfnLaunchTemplate.Ipv6PrefixSpecificationProperty {}; + +/** + * Specifies a secondary private IPv4 address for a network interface. + */ +export interface PrivateIpAdd extends CfnLaunchTemplate.PrivateIpAddProperty {}; + +/** + * Specifies the parameters for a Launch Template network interface definition. + */ +export interface NetworkInterface { + /** + * Associates a Carrier IP address with eth0 for a new network interface. + * + * Use this option when you launch an instance in a Wavelength Zone and want to associate a Carrier IP address with the network interface. For more information about Carrier IP addresses, see Carrier IP addresses in the AWS Wavelength Developer Guide. + * + * @default No carrier IP address is assigned + */ + readonly associateCarrierIpAddress?: boolean; + + /** + * Associates a public IPv4 address with eth0 for a new network interface. Note that when multiple network interface cards are defined, this value must be `false` on all of them. + * + * @default No public IPv4 address is assigned + */ + readonly associatePublicIpAddress?: boolean; + + /** + * A connection tracking specification for the network interface. + * + * @default Default connection tracking timeouts are used. + * @see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-connection-tracking.html#connection-tracking-timeouts + */ + readonly connectionTrackingSpecification?: ConnectionTrackingSpecification; + + /** + * Indicates whether the network interface is deleted when the instance is terminated. + * + * @default The network interface is deleted when the instance is terminated. + */ + readonly deleteOnTermination?: boolean; + + /** + * A description for the network interface. + * + * @default An empty string. + */ + readonly description?: string; + + /** + * The device index for the network interface attachment. + * + * @default Index is `0` + */ + readonly deviceIndex: number; + + /** + * The ENA Express configuration for the network interface. + * + * @default EnaSrd is not enabled + */ + readonly enaSrdSpecification?: EnaSrdSpecification; + + /** + * One or more security groups to attach to the interface. + * + * @default No security groups are attached to the interface. + */ + readonly groups?: ISecurityGroup[]; + + /** + * The type of network interface. To create an Elastic Fabric Adapter (EFA), specify `InterfaceType.efa`. For more information, see Elastic Fabric Adapter in the Amazon Elastic Compute Cloud User Guide. + * + * @default Interface type is `InterfaceType.INTERFACE`. + */ + readonly interfaceType?: InterfaceType; + + /** + * The number of IPv4 prefixes to be automatically assigned to the network interface. You cannot use this option if you use the Ipv4Prefix option. + * + * @default One prefix is assigned + */ + readonly ipv4PrefixCount?: number; + + /** + * One or more IPv4 prefixes to be assigned to the network interface. You cannot use this option if you use the Ipv4PrefixCount option. + * + * @default A single prefix is assigned via `ipv4PrefixCount` + */ + readonly ipv4Prefixes?: Ipv4PrefixSpecification[]; + + /** + * The number of IPv6 addresses to assign to a network interface. Amazon EC2 automatically selects the IPv6 addresses from the subnet range. You can't use this option if specifying specific IPv6 addresses. + * + * @default No IPv6 addresses are assigned. + */ + readonly ipv6AddressCount?: number; + + /** + * One or more specific IPv6 addresses from the IPv6 CIDR block range of your subnet. You can't use this option if you're specifying a number of IPv6 addresses. + * + * @default No IPv6 addresses are assigned. + */ + readonly ipv6Addresses?: Ipv6Add[]; + + /** + * The number of IPv6 prefixes to be automatically assigned to the network interface. You cannot use this option if you use the Ipv6Prefix option. + * + * @default No prefixes are assigned. + */ + readonly ipv6PrefixCount?: number; + + /** + * One or more IPv6 prefixes to be assigned to the network interface. You cannot use this option if you use the Ipv6PrefixCount option. + * + * @default No prefixes are assigned. + */ + readonly ipv6Prefixes?: Ipv6PrefixSpecification[]; + + /** + * The index of the network card. Some instance types support multiple network cards. The primary network interface must be assigned to network card index 0. The default is network card index 0. + * + * @default First network interface card gets assigned index `0`. + */ + readonly networkCardIndex?: number; + + /** + * The primary IPv6 address of the network interface. When you enable an IPv6 GUA address to be a primary IPv6, the first IPv6 GUA will be made the primary IPv6 address until the instance is terminated or the network interface is detached. For more information about primary IPv6 addresses, see RunInstances. + * + * @default First IPv6 address is made primary. + */ + readonly primaryIpv6?: boolean; + + /** + * The primary private IPv4 address of the network interface. + * + * @default A random IP address is assigned from one of the subnets. + */ + readonly privateIpAddress?: string; + + /** + * One or more private IPv4 addresses. + * + * @default A random IP address is assigned from one of the subnets. + */ + readonly privateIpAddresses?: PrivateIpAdd[]; + + /** + * The number of secondary private IPv4 addresses to assign to a network interface. + * + * @default No secondary addresses are assigned + */ + readonly secondaryPrivateIpAddressCount?: number; + + /** + * List of subnets to which to place the interface in + * + * @default No subnets are defined. + */ + readonly subnet?: ISubnet; +} + +function synthesizeNetworkInterfaces(networkInterfaces: NetworkInterface[]): CfnLaunchTemplate.NetworkInterfaceProperty[] { + return networkInterfaces.map((networkInterface) => { + return { + ...networkInterface, + groups: Lazy.list({ + produce: () => { + return networkInterface.groups ? networkInterface.groups.map((sg) => sg.securityGroupId) : undefined; + }, + }), + subnetId: Lazy.string({ + produce: () => { + return networkInterface.subnet ? networkInterface.subnet.subnetId : undefined; + }, + }), + }; + }); +} + /** * Interface for LaunchTemplate-like objects. */ @@ -429,6 +658,15 @@ export interface LaunchTemplateProps { * @default - No instance profile */ readonly instanceProfile?: iam.IInstanceProfile; + + /** + * Network interface definitions for the EC2 instances. + * + * Note: If defined, overrides settings `associatePublicIpAddress` and `securityGroup`. + * + * @default: A single network interface using `associatePublicIpAddress` and `securityGroup`is created + */ + readonly networkInterfaces?: NetworkInterface[]; } /** @@ -600,6 +838,13 @@ export class LaunchTemplate extends Resource implements ILaunchTemplate, iam.IGr Annotations.of(this).addError('HttpPutResponseHopLimit must between 1 and 64'); } + // Basic validation of the provided network interface cards + if (props.networkInterfaces && props.networkInterfaces.length > 1) { + if (!props.networkInterfaces.every((nic) => !nic.associatePublicIpAddress)) { + Annotations.of(this).addError('associatePublicIpAddress must be `false` or `undefined` when defining multiple network interfaces'); + } + } + if (props.instanceProfile && props.role) { throw new Error('You cannot provide both an instanceProfile and a role'); } @@ -731,9 +976,20 @@ export class LaunchTemplate extends Resource implements ILaunchTemplate, iam.IGr }, }); - const networkInterfaces = props.associatePublicIpAddress !== undefined - ? [{ deviceIndex: 0, associatePublicIpAddress: props.associatePublicIpAddress, groups: securityGroupsToken }] - : undefined; + let networkInterfaces: NetworkInterface[] | undefined; + if (props.networkInterfaces) { + networkInterfaces = props.networkInterfaces; + } else { + networkInterfaces = props.associatePublicIpAddress !== undefined + ? [ + { + deviceIndex: 0, + associatePublicIpAddress: props.associatePublicIpAddress, + groups: props.securityGroup ? [props.securityGroup] : undefined, + }, + ] + : undefined; + } const resource = new CfnLaunchTemplate(this, 'Resource', { launchTemplateName: props?.launchTemplateName, @@ -763,7 +1019,7 @@ export class LaunchTemplate extends Resource implements ILaunchTemplate, iam.IGr tagSpecifications: tagsToken, userData: userDataToken, metadataOptions: this.renderMetadataOptions(props), - networkInterfaces, + networkInterfaces: networkInterfaces ? synthesizeNetworkInterfaces(networkInterfaces) : undefined, // Fields not yet implemented: // ========================== From ed392c24ecc4e275964e5f0d292e9a76dce872ba Mon Sep 17 00:00:00 2001 From: Pasi Orovuo Date: Thu, 18 Apr 2024 08:09:44 +0300 Subject: [PATCH 2/4] Add test and test snapshot --- .../aws-cdk-ec2-lt-metadata-1.assets.json | 4 +- .../aws-cdk-ec2-lt-metadata-1.template.json | 60 +++++++++++++ .../manifest.json | 14 ++- .../tree.json | 90 +++++++++++++++++++ .../aws-ec2/test/integ.launch-template.ts | 8 ++ 5 files changed, 173 insertions(+), 3 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.assets.json index cfbd8497058d2..8a7c5eaf62b84 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.assets.json @@ -14,7 +14,7 @@ } } }, - "3a9051d99c4e16708baeea7809cc9cf2da0cbb95e50297f9566f6e8c11e96423": { + "2a3ff681cd1c0fb4038917f3c3576010eb86c579c13d1a6e18984b5134c7ab54": { "source": { "path": "aws-cdk-ec2-lt-metadata-1.template.json", "packaging": "file" @@ -22,7 +22,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "3a9051d99c4e16708baeea7809cc9cf2da0cbb95e50297f9566f6e8c11e96423.json", + "objectKey": "2a3ff681cd1c0fb4038917f3c3576010eb86c579c13d1a6e18984b5134c7ab54.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.template.json index 487cdc3fdb7d2..c9b8a8c32d869 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.template.json @@ -265,6 +265,62 @@ } ] } + }, + "LTWithNetworkInterfacesC793C8F4": { + "Type": "AWS::EC2::LaunchTemplate", + "Properties": { + "LaunchTemplateData": { + "ImageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "NetworkInterfaces": [ + { + "AssociatePublicIpAddress": false, + "DeleteOnTermination": true, + "DeviceIndex": 0 + }, + { + "AssociatePublicIpAddress": false, + "DeleteOnTermination": true, + "DeviceIndex": 1 + } + ], + "TagSpecifications": [ + { + "ResourceType": "instance", + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-ec2-lt-metadata-1/LTWithNetworkInterfaces" + } + ] + }, + { + "ResourceType": "volume", + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-ec2-lt-metadata-1/LTWithNetworkInterfaces" + } + ] + } + ], + "UserData": { + "Fn::Base64": "#!/bin/bash" + } + }, + "TagSpecifications": [ + { + "ResourceType": "launch-template", + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-ec2-lt-metadata-1/LTWithNetworkInterfaces" + } + ] + } + ] + } } }, "Parameters": { @@ -272,6 +328,10 @@ "Type": "AWS::SSM::Parameter::Value", "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2" }, + "SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64" + }, "BootstrapVersion": { "Type": "AWS::SSM::Parameter::Value", "Default": "/cdk-bootstrap/hnb659fds/version", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/manifest.json index 86e0ca416b14d..ee2326ee3a64f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/3a9051d99c4e16708baeea7809cc9cf2da0cbb95e50297f9566f6e8c11e96423.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/2a3ff681cd1c0fb4038917f3c3576010eb86c579c13d1a6e18984b5134c7ab54.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -88,6 +88,18 @@ "data": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" } ], + "/aws-cdk-ec2-lt-metadata-1/LTWithNetworkInterfaces/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "LTWithNetworkInterfacesC793C8F4" + } + ], + "/aws-cdk-ec2-lt-metadata-1/SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": [ + { + "type": "aws:cdk:logicalId", + "data": "SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter" + } + ], "/aws-cdk-ec2-lt-metadata-1/BootstrapVersion": [ { "type": "aws:cdk:logicalId", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/tree.json index f0b2e01cefc3e..2b91050721fdb 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/tree.json @@ -316,6 +316,96 @@ "version": "0.0.0" } }, + "LTWithNetworkInterfaces": { + "id": "LTWithNetworkInterfaces", + "path": "aws-cdk-ec2-lt-metadata-1/LTWithNetworkInterfaces", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-ec2-lt-metadata-1/LTWithNetworkInterfaces/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::LaunchTemplate", + "aws:cdk:cloudformation:props": { + "launchTemplateData": { + "imageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "tagSpecifications": [ + { + "resourceType": "instance", + "tags": [ + { + "key": "Name", + "value": "aws-cdk-ec2-lt-metadata-1/LTWithNetworkInterfaces" + } + ] + }, + { + "resourceType": "volume", + "tags": [ + { + "key": "Name", + "value": "aws-cdk-ec2-lt-metadata-1/LTWithNetworkInterfaces" + } + ] + } + ], + "userData": { + "Fn::Base64": "#!/bin/bash" + }, + "networkInterfaces": [ + { + "associatePublicIpAddress": false, + "deviceIndex": 0, + "deleteOnTermination": true + }, + { + "associatePublicIpAddress": false, + "deviceIndex": 1, + "deleteOnTermination": true + } + ] + }, + "tagSpecifications": [ + { + "resourceType": "launch-template", + "tags": [ + { + "key": "Name", + "value": "aws-cdk-ec2-lt-metadata-1/LTWithNetworkInterfaces" + } + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnLaunchTemplate", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.LaunchTemplate", + "version": "0.0.0" + } + }, + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "path": "aws-cdk-ec2-lt-metadata-1/SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118", + "path": "aws-cdk-ec2-lt-metadata-1/SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, "BootstrapVersion": { "id": "BootstrapVersion", "path": "aws-cdk-ec2-lt-metadata-1/BootstrapVersion", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.ts index 39d71b394b897..0c5ba5d36bacc 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.ts @@ -36,6 +36,14 @@ new ec2.LaunchTemplate(stack, 'LTWithMachineImage', { }), }); +new ec2.LaunchTemplate(stack, 'LTWithNetworkInterfaces', { + machineImage: ec2.MachineImage.latestAmazonLinux2023(), + networkInterfaces: [ + { associatePublicIpAddress: false, deviceIndex: 0, deleteOnTermination: true }, + { associatePublicIpAddress: false, deviceIndex: 1, deleteOnTermination: true }, + ], +}); + new integ.IntegTest(app, 'LambdaTest', { testCases: [stack], diffAssets: true, From 00ce08e2b7b5b583104ef0badf372ecd5b27bcf9 Mon Sep 17 00:00:00 2001 From: Pasi Orovuo Date: Thu, 18 Apr 2024 09:52:10 +0300 Subject: [PATCH 3/4] Commit @nmussy suggestion on fixing failing build --- packages/aws-cdk-lib/aws-ec2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-ec2/README.md b/packages/aws-cdk-lib/aws-ec2/README.md index 1e20557e95845..b1deef3bc72e4 100644 --- a/packages/aws-cdk-lib/aws-ec2/README.md +++ b/packages/aws-cdk-lib/aws-ec2/README.md @@ -2224,7 +2224,7 @@ const sg2 = new ec2.SecurityGroup(this, 'sg2', { vpc: vpc, }); -new LaunchTemplate(stack, 'LaunchTemplate', { +new ec2.LaunchTemplate(stack, 'LaunchTemplate', { machineImage: ec2.MachineImage.latestAmazonLinux2023(), networkInterfaces: [ { From 2183d0340d32249e0f33675a8011e1f183d9fec6 Mon Sep 17 00:00:00 2001 From: Pasi Orovuo Date: Thu, 18 Apr 2024 13:35:08 +0300 Subject: [PATCH 4/4] Change according to @nmussy suggestion. Hopefully got it right this time --- packages/aws-cdk-lib/aws-ec2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-ec2/README.md b/packages/aws-cdk-lib/aws-ec2/README.md index b1deef3bc72e4..f8a836b8d979d 100644 --- a/packages/aws-cdk-lib/aws-ec2/README.md +++ b/packages/aws-cdk-lib/aws-ec2/README.md @@ -2224,7 +2224,7 @@ const sg2 = new ec2.SecurityGroup(this, 'sg2', { vpc: vpc, }); -new ec2.LaunchTemplate(stack, 'LaunchTemplate', { +new ec2.LaunchTemplate(this, 'LaunchTemplate', { machineImage: ec2.MachineImage.latestAmazonLinux2023(), networkInterfaces: [ {