diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/cdk.out new file mode 100644 index 0000000000000..7925065efbcc4 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"31.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integ-ec2-machine-image-test.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integ-ec2-machine-image-test.assets.json new file mode 100644 index 0000000000000..8381633003d10 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integ-ec2-machine-image-test.assets.json @@ -0,0 +1,19 @@ +{ + "version": "31.0.0", + "files": { + "09b19c98d056dc3ddd9d9852de04232c8c27cdfbb4aa83797c6f9e1e118068d5": { + "source": { + "path": "integ-ec2-machine-image-test.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "09b19c98d056dc3ddd9d9852de04232c8c27cdfbb4aa83797c6f9e1e118068d5.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integ-ec2-machine-image-test.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integ-ec2-machine-image-test.template.json new file mode 100644 index 0000000000000..0a742ab93e8b0 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integ-ec2-machine-image-test.template.json @@ -0,0 +1,849 @@ +{ + "Resources": { + "Vpc8378EB38": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc" + } + ] + } + }, + "VpcPublicSubnet1Subnet5C2D37C4": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": "test-region-1a", + "CidrBlock": "10.0.0.0/19", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1RouteTable6C95E38E": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1RouteTableAssociation97140677": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + } + } + }, + "VpcPublicSubnet1DefaultRoute3DA9E72A": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ] + }, + "VpcPublicSubnet1EIPD7E02669": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1NATGateway4D7517AA": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet1EIPD7E02669", + "AllocationId" + ] + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PublicSubnet1" + } + ] + }, + "DependsOn": [ + "VpcPublicSubnet1DefaultRoute3DA9E72A", + "VpcPublicSubnet1RouteTableAssociation97140677" + ] + }, + "VpcPublicSubnet2Subnet691E08A3": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": "test-region-1b", + "CidrBlock": "10.0.32.0/19", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPublicSubnet2RouteTable94F7E489": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPublicSubnet2RouteTableAssociationDD5762D8": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + } + }, + "VpcPublicSubnet2DefaultRoute97F91067": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ] + }, + "VpcPublicSubnet2EIP3C605A87": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPublicSubnet2NATGateway9182C01D": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "SubnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + }, + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet2EIP3C605A87", + "AllocationId" + ] + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PublicSubnet2" + } + ] + }, + "DependsOn": [ + "VpcPublicSubnet2DefaultRoute97F91067", + "VpcPublicSubnet2RouteTableAssociationDD5762D8" + ] + }, + "VpcPublicSubnet3SubnetBE12F0B6": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": "test-region-1c", + "CidrBlock": "10.0.64.0/19", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PublicSubnet3" + } + ] + } + }, + "VpcPublicSubnet3RouteTable93458DBB": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PublicSubnet3" + } + ] + } + }, + "VpcPublicSubnet3RouteTableAssociation1F1EDF02": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet3RouteTable93458DBB" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet3SubnetBE12F0B6" + } + } + }, + "VpcPublicSubnet3DefaultRoute4697774F": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet3RouteTable93458DBB" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ] + }, + "VpcPublicSubnet3EIP3A666A23": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PublicSubnet3" + } + ] + } + }, + "VpcPublicSubnet3NATGateway7640CD1D": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "SubnetId": { + "Ref": "VpcPublicSubnet3SubnetBE12F0B6" + }, + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet3EIP3A666A23", + "AllocationId" + ] + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PublicSubnet3" + } + ] + }, + "DependsOn": [ + "VpcPublicSubnet3DefaultRoute4697774F", + "VpcPublicSubnet3RouteTableAssociation1F1EDF02" + ] + }, + "VpcPrivateSubnet1Subnet536B997A": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": "test-region-1a", + "CidrBlock": "10.0.96.0/19", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PrivateSubnet1" + } + ] + } + }, + "VpcPrivateSubnet1RouteTableB2C5B500": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PrivateSubnet1" + } + ] + } + }, + "VpcPrivateSubnet1RouteTableAssociation70C59FA6": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + } + } + }, + "VpcPrivateSubnet1DefaultRouteBE02A9ED": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet1NATGateway4D7517AA" + } + } + }, + "VpcPrivateSubnet2Subnet3788AAA1": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": "test-region-1b", + "CidrBlock": "10.0.128.0/19", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PrivateSubnet2" + } + ] + } + }, + "VpcPrivateSubnet2RouteTableA678073B": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PrivateSubnet2" + } + ] + } + }, + "VpcPrivateSubnet2RouteTableAssociationA89CAD56": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet2Subnet3788AAA1" + } + } + }, + "VpcPrivateSubnet2DefaultRoute060D2087": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet2NATGateway9182C01D" + } + } + }, + "VpcPrivateSubnet3SubnetF258B56E": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": "test-region-1c", + "CidrBlock": "10.0.160.0/19", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PrivateSubnet3" + } + ] + } + }, + "VpcPrivateSubnet3RouteTableD98824C7": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc/PrivateSubnet3" + } + ] + } + }, + "VpcPrivateSubnet3RouteTableAssociation16BDDC43": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet3RouteTableD98824C7" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet3SubnetF258B56E" + } + } + }, + "VpcPrivateSubnet3DefaultRoute94B74F0D": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet3RouteTableD98824C7" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet3NATGateway7640CD1D" + } + } + }, + "VpcIGWD7BA715C": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/Vpc" + } + ] + } + }, + "VpcVPCGWBF912B6E": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "InternetGatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "amzn2InstanceSecurityGroup63173C03": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "integ-ec2-machine-image-test/amzn2/InstanceSecurityGroup", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1" + } + ], + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/amzn2" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "amzn2InstanceRole3F1DBBD2": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ec2.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/amzn2" + } + ] + } + }, + "amzn2InstanceProfileC501DBD1": { + "Type": "AWS::IAM::InstanceProfile", + "Properties": { + "Roles": [ + { + "Ref": "amzn2InstanceRole3F1DBBD2" + } + ] + } + }, + "amzn25D7FDCED": { + "Type": "AWS::EC2::Instance", + "Properties": { + "AvailabilityZone": "test-region-1a", + "IamInstanceProfile": { + "Ref": "amzn2InstanceProfileC501DBD1" + }, + "ImageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amikernel510hvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "InstanceType": "t3.nano", + "SecurityGroupIds": [ + { + "Fn::GetAtt": [ + "amzn2InstanceSecurityGroup63173C03", + "GroupId" + ] + } + ], + "SubnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/amzn2" + } + ], + "UserData": { + "Fn::Base64": "#!/bin/bash" + } + }, + "DependsOn": [ + "amzn2InstanceRole3F1DBBD2" + ] + }, + "al2022InstanceSecurityGroupD2B46A06": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "integ-ec2-machine-image-test/al2022/InstanceSecurityGroup", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1" + } + ], + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/al2022" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "al2022InstanceRole6711C818": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ec2.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/al2022" + } + ] + } + }, + "al2022InstanceProfileAA7ED3DD": { + "Type": "AWS::IAM::InstanceProfile", + "Properties": { + "Roles": [ + { + "Ref": "al2022InstanceRole6711C818" + } + ] + } + }, + "al20225AC492C0": { + "Type": "AWS::EC2::Instance", + "Properties": { + "AvailabilityZone": "test-region-1a", + "IamInstanceProfile": { + "Ref": "al2022InstanceProfileAA7ED3DD" + }, + "ImageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestal2022amikernel515x8664C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "InstanceType": "t3.nano", + "SecurityGroupIds": [ + { + "Fn::GetAtt": [ + "al2022InstanceSecurityGroupD2B46A06", + "GroupId" + ] + } + ], + "SubnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/al2022" + } + ], + "UserData": { + "Fn::Base64": "#!/bin/bash" + } + }, + "DependsOn": [ + "al2022InstanceRole6711C818" + ] + }, + "al2023InstanceSecurityGroupB018A9BC": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "integ-ec2-machine-image-test/al2023/InstanceSecurityGroup", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1" + } + ], + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/al2023" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "al2023InstanceRoleECC2D6DD": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ec2.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/al2023" + } + ] + } + }, + "al2023InstanceProfileAB8077E0": { + "Type": "AWS::IAM::InstanceProfile", + "Properties": { + "Roles": [ + { + "Ref": "al2023InstanceRoleECC2D6DD" + } + ] + } + }, + "al20231AC01FE4": { + "Type": "AWS::EC2::Instance", + "Properties": { + "AvailabilityZone": "test-region-1a", + "IamInstanceProfile": { + "Ref": "al2023InstanceProfileAB8077E0" + }, + "ImageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "InstanceType": "t3.nano", + "SecurityGroupIds": [ + { + "Fn::GetAtt": [ + "al2023InstanceSecurityGroupB018A9BC", + "GroupId" + ] + } + ], + "SubnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-ec2-machine-image-test/al2023" + } + ], + "UserData": { + "Fn::Base64": "#!/bin/bash" + } + }, + "DependsOn": [ + "al2023InstanceRoleECC2D6DD" + ] + } + }, + "Parameters": { + "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amikernel510hvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.10-hvm-x86_64-gp2" + }, + "SsmParameterValueawsserviceamiamazonlinuxlatestal2022amikernel515x8664C96584B6F00A464EAD1953AFF4B05118Parameter": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/aws/service/ami-amazon-linux-latest/al2022-ami-kernel-5.15-x86_64" + }, + "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", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integ.json new file mode 100644 index 0000000000000..63242ceb48d4e --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integ.json @@ -0,0 +1,13 @@ +{ + "enableLookups": true, + "version": "31.0.0", + "testCases": { + "integ-test/DefaultTest": { + "stacks": [ + "integ-ec2-machine-image-test" + ], + "assertionStack": "integ-test/DefaultTest/DeployAssert", + "assertionStackName": "integtestDefaultTestDeployAssert24D5C536" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integtestDefaultTestDeployAssert24D5C536.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integtestDefaultTestDeployAssert24D5C536.assets.json new file mode 100644 index 0000000000000..ecd9f6bd2a455 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integtestDefaultTestDeployAssert24D5C536.assets.json @@ -0,0 +1,19 @@ +{ + "version": "31.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "integtestDefaultTestDeployAssert24D5C536.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integtestDefaultTestDeployAssert24D5C536.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integtestDefaultTestDeployAssert24D5C536.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/integtestDefaultTestDeployAssert24D5C536.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/manifest.json new file mode 100644 index 0000000000000..ce2fed289c1b9 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/manifest.json @@ -0,0 +1,393 @@ +{ + "version": "31.0.0", + "artifacts": { + "integ-ec2-machine-image-test.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "integ-ec2-machine-image-test.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "integ-ec2-machine-image-test": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "integ-ec2-machine-image-test.template.json", + "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}/09b19c98d056dc3ddd9d9852de04232c8c27cdfbb4aa83797c6f9e1e118068d5.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "integ-ec2-machine-image-test.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "integ-ec2-machine-image-test.assets" + ], + "metadata": { + "/integ-ec2-machine-image-test/Vpc/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Vpc8378EB38" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1Subnet5C2D37C4" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1RouteTable6C95E38E" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1RouteTableAssociation97140677" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1DefaultRoute3DA9E72A" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet1/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1EIPD7E02669" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet1/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1NATGateway4D7517AA" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2Subnet691E08A3" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2RouteTable94F7E489" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2RouteTableAssociationDD5762D8" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2DefaultRoute97F91067" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet2/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2EIP3C605A87" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet2/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2NATGateway9182C01D" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet3/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet3SubnetBE12F0B6" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet3/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet3RouteTable93458DBB" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet3/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet3RouteTableAssociation1F1EDF02" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet3/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet3DefaultRoute4697774F" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet3/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet3EIP3A666A23" + } + ], + "/integ-ec2-machine-image-test/Vpc/PublicSubnet3/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet3NATGateway7640CD1D" + } + ], + "/integ-ec2-machine-image-test/Vpc/PrivateSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1Subnet536B997A" + } + ], + "/integ-ec2-machine-image-test/Vpc/PrivateSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1RouteTableB2C5B500" + } + ], + "/integ-ec2-machine-image-test/Vpc/PrivateSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1RouteTableAssociation70C59FA6" + } + ], + "/integ-ec2-machine-image-test/Vpc/PrivateSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1DefaultRouteBE02A9ED" + } + ], + "/integ-ec2-machine-image-test/Vpc/PrivateSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2Subnet3788AAA1" + } + ], + "/integ-ec2-machine-image-test/Vpc/PrivateSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2RouteTableA678073B" + } + ], + "/integ-ec2-machine-image-test/Vpc/PrivateSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2RouteTableAssociationA89CAD56" + } + ], + "/integ-ec2-machine-image-test/Vpc/PrivateSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2DefaultRoute060D2087" + } + ], + "/integ-ec2-machine-image-test/Vpc/PrivateSubnet3/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet3SubnetF258B56E" + } + ], + "/integ-ec2-machine-image-test/Vpc/PrivateSubnet3/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet3RouteTableD98824C7" + } + ], + "/integ-ec2-machine-image-test/Vpc/PrivateSubnet3/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet3RouteTableAssociation16BDDC43" + } + ], + "/integ-ec2-machine-image-test/Vpc/PrivateSubnet3/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet3DefaultRoute94B74F0D" + } + ], + "/integ-ec2-machine-image-test/Vpc/IGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcIGWD7BA715C" + } + ], + "/integ-ec2-machine-image-test/Vpc/VPCGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcVPCGWBF912B6E" + } + ], + "/integ-ec2-machine-image-test/amzn2/InstanceSecurityGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "amzn2InstanceSecurityGroup63173C03" + } + ], + "/integ-ec2-machine-image-test/amzn2/InstanceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "amzn2InstanceRole3F1DBBD2" + } + ], + "/integ-ec2-machine-image-test/amzn2/InstanceProfile": [ + { + "type": "aws:cdk:logicalId", + "data": "amzn2InstanceProfileC501DBD1" + } + ], + "/integ-ec2-machine-image-test/amzn2/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "amzn25D7FDCED" + } + ], + "/integ-ec2-machine-image-test/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": [ + { + "type": "aws:cdk:logicalId", + "data": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amikernel510hvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" + } + ], + "/integ-ec2-machine-image-test/al2022/InstanceSecurityGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "al2022InstanceSecurityGroupD2B46A06" + } + ], + "/integ-ec2-machine-image-test/al2022/InstanceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "al2022InstanceRole6711C818" + } + ], + "/integ-ec2-machine-image-test/al2022/InstanceProfile": [ + { + "type": "aws:cdk:logicalId", + "data": "al2022InstanceProfileAA7ED3DD" + } + ], + "/integ-ec2-machine-image-test/al2022/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "al20225AC492C0" + } + ], + "/integ-ec2-machine-image-test/SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2022-ami-kernel-5.15-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": [ + { + "type": "aws:cdk:logicalId", + "data": "SsmParameterValueawsserviceamiamazonlinuxlatestal2022amikernel515x8664C96584B6F00A464EAD1953AFF4B05118Parameter" + } + ], + "/integ-ec2-machine-image-test/al2023/InstanceSecurityGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "al2023InstanceSecurityGroupB018A9BC" + } + ], + "/integ-ec2-machine-image-test/al2023/InstanceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "al2023InstanceRoleECC2D6DD" + } + ], + "/integ-ec2-machine-image-test/al2023/InstanceProfile": [ + { + "type": "aws:cdk:logicalId", + "data": "al2023InstanceProfileAB8077E0" + } + ], + "/integ-ec2-machine-image-test/al2023/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "al20231AC01FE4" + } + ], + "/integ-ec2-machine-image-test/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" + } + ], + "/integ-ec2-machine-image-test/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integ-ec2-machine-image-test/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integ-ec2-machine-image-test" + }, + "integtestDefaultTestDeployAssert24D5C536.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "integtestDefaultTestDeployAssert24D5C536.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "integtestDefaultTestDeployAssert24D5C536": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "integtestDefaultTestDeployAssert24D5C536.template.json", + "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}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "integtestDefaultTestDeployAssert24D5C536.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "integtestDefaultTestDeployAssert24D5C536.assets" + ], + "metadata": { + "/integ-test/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integ-test/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integ-test/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/tree.json new file mode 100644 index 0000000000000..de0c9ba0e7bc9 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.js.snapshot/tree.json @@ -0,0 +1,1510 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "integ-ec2-machine-image-test": { + "id": "integ-ec2-machine-image-test", + "path": "integ-ec2-machine-image-test", + "children": { + "Vpc": { + "id": "Vpc", + "path": "integ-ec2-machine-image-test/Vpc", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-ec2-machine-image-test/Vpc/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPC", + "aws:cdk:cloudformation:props": { + "cidrBlock": "10.0.0.0/16", + "enableDnsHostnames": true, + "enableDnsSupport": true, + "instanceTenancy": "default", + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPC", + "version": "0.0.0" + } + }, + "PublicSubnet1": { + "id": "PublicSubnet1", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": "test-region-1a", + "cidrBlock": "10.0.0.0/19", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "subnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet1/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet1/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "subnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + "allocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet1EIPD7E02669", + "AllocationId" + ] + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PublicSubnet2": { + "id": "PublicSubnet2", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": "test-region-1b", + "cidrBlock": "10.0.32.0/19", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "subnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet2/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet2/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "subnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + }, + "allocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet2EIP3C605A87", + "AllocationId" + ] + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PublicSubnet3": { + "id": "PublicSubnet3", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet3", + "children": { + "Subnet": { + "id": "Subnet", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet3/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": "test-region-1c", + "cidrBlock": "10.0.64.0/19", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PublicSubnet3" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet3/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet3/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PublicSubnet3" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet3/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet3RouteTable93458DBB" + }, + "subnetId": { + "Ref": "VpcPublicSubnet3SubnetBE12F0B6" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet3/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet3RouteTable93458DBB" + }, + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet3/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PublicSubnet3" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "integ-ec2-machine-image-test/Vpc/PublicSubnet3/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "subnetId": { + "Ref": "VpcPublicSubnet3SubnetBE12F0B6" + }, + "allocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet3EIP3A666A23", + "AllocationId" + ] + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PublicSubnet3" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet1": { + "id": "PrivateSubnet1", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": "test-region-1a", + "cidrBlock": "10.0.96.0/19", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PrivateSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PrivateSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "subnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VpcPublicSubnet1NATGateway4D7517AA" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet2": { + "id": "PrivateSubnet2", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": "test-region-1b", + "cidrBlock": "10.0.128.0/19", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PrivateSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PrivateSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "subnetId": { + "Ref": "VpcPrivateSubnet2Subnet3788AAA1" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VpcPublicSubnet2NATGateway9182C01D" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet3": { + "id": "PrivateSubnet3", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet3", + "children": { + "Subnet": { + "id": "Subnet", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet3/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": "test-region-1c", + "cidrBlock": "10.0.160.0/19", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PrivateSubnet3" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet3/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet3/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc/PrivateSubnet3" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet3/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet3RouteTableD98824C7" + }, + "subnetId": { + "Ref": "VpcPrivateSubnet3SubnetF258B56E" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "integ-ec2-machine-image-test/Vpc/PrivateSubnet3/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet3RouteTableD98824C7" + }, + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VpcPublicSubnet3NATGateway7640CD1D" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "IGW": { + "id": "IGW", + "path": "integ-ec2-machine-image-test/Vpc/IGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::InternetGateway", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/Vpc" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInternetGateway", + "version": "0.0.0" + } + }, + "VPCGW": { + "id": "VPCGW", + "path": "integ-ec2-machine-image-test/Vpc/VPCGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCGatewayAttachment", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "internetGatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCGatewayAttachment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.Vpc", + "version": "0.0.0" + } + }, + "amzn2": { + "id": "amzn2", + "path": "integ-ec2-machine-image-test/amzn2", + "children": { + "InstanceSecurityGroup": { + "id": "InstanceSecurityGroup", + "path": "integ-ec2-machine-image-test/amzn2/InstanceSecurityGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-ec2-machine-image-test/amzn2/InstanceSecurityGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "integ-ec2-machine-image-test/amzn2/InstanceSecurityGroup", + "securityGroupEgress": [ + { + "cidrIp": "0.0.0.0/0", + "description": "Allow all outbound traffic by default", + "ipProtocol": "-1" + } + ], + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/amzn2" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "0.0.0" + } + }, + "InstanceRole": { + "id": "InstanceRole", + "path": "integ-ec2-machine-image-test/amzn2/InstanceRole", + "children": { + "ImportInstanceRole": { + "id": "ImportInstanceRole", + "path": "integ-ec2-machine-image-test/amzn2/InstanceRole/ImportInstanceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-ec2-machine-image-test/amzn2/InstanceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ec2.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/amzn2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "InstanceProfile": { + "id": "InstanceProfile", + "path": "integ-ec2-machine-image-test/amzn2/InstanceProfile", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::InstanceProfile", + "aws:cdk:cloudformation:props": { + "roles": [ + { + "Ref": "amzn2InstanceRole3F1DBBD2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnInstanceProfile", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-ec2-machine-image-test/amzn2/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Instance", + "aws:cdk:cloudformation:props": { + "availabilityZone": "test-region-1a", + "iamInstanceProfile": { + "Ref": "amzn2InstanceProfileC501DBD1" + }, + "imageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amikernel510hvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "instanceType": "t3.nano", + "securityGroupIds": [ + { + "Fn::GetAtt": [ + "amzn2InstanceSecurityGroup63173C03", + "GroupId" + ] + } + ], + "subnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/amzn2" + } + ], + "userData": { + "Fn::Base64": "#!/bin/bash" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInstance", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.Instance", + "version": "0.0.0" + } + }, + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "path": "integ-ec2-machine-image-test/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118", + "path": "integ-ec2-machine-image-test/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-kernel-5.10-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "al2022": { + "id": "al2022", + "path": "integ-ec2-machine-image-test/al2022", + "children": { + "InstanceSecurityGroup": { + "id": "InstanceSecurityGroup", + "path": "integ-ec2-machine-image-test/al2022/InstanceSecurityGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-ec2-machine-image-test/al2022/InstanceSecurityGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "integ-ec2-machine-image-test/al2022/InstanceSecurityGroup", + "securityGroupEgress": [ + { + "cidrIp": "0.0.0.0/0", + "description": "Allow all outbound traffic by default", + "ipProtocol": "-1" + } + ], + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/al2022" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "0.0.0" + } + }, + "InstanceRole": { + "id": "InstanceRole", + "path": "integ-ec2-machine-image-test/al2022/InstanceRole", + "children": { + "ImportInstanceRole": { + "id": "ImportInstanceRole", + "path": "integ-ec2-machine-image-test/al2022/InstanceRole/ImportInstanceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-ec2-machine-image-test/al2022/InstanceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ec2.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/al2022" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "InstanceProfile": { + "id": "InstanceProfile", + "path": "integ-ec2-machine-image-test/al2022/InstanceProfile", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::InstanceProfile", + "aws:cdk:cloudformation:props": { + "roles": [ + { + "Ref": "al2022InstanceRole6711C818" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnInstanceProfile", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-ec2-machine-image-test/al2022/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Instance", + "aws:cdk:cloudformation:props": { + "availabilityZone": "test-region-1a", + "iamInstanceProfile": { + "Ref": "al2022InstanceProfileAA7ED3DD" + }, + "imageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestal2022amikernel515x8664C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "instanceType": "t3.nano", + "securityGroupIds": [ + { + "Fn::GetAtt": [ + "al2022InstanceSecurityGroupD2B46A06", + "GroupId" + ] + } + ], + "subnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/al2022" + } + ], + "userData": { + "Fn::Base64": "#!/bin/bash" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInstance", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.Instance", + "version": "0.0.0" + } + }, + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2022-ami-kernel-5.15-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2022-ami-kernel-5.15-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "path": "integ-ec2-machine-image-test/SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2022-ami-kernel-5.15-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--al2022-ami-kernel-5.15-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2022-ami-kernel-5.15-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118", + "path": "integ-ec2-machine-image-test/SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2022-ami-kernel-5.15-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "al2023": { + "id": "al2023", + "path": "integ-ec2-machine-image-test/al2023", + "children": { + "InstanceSecurityGroup": { + "id": "InstanceSecurityGroup", + "path": "integ-ec2-machine-image-test/al2023/InstanceSecurityGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-ec2-machine-image-test/al2023/InstanceSecurityGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "integ-ec2-machine-image-test/al2023/InstanceSecurityGroup", + "securityGroupEgress": [ + { + "cidrIp": "0.0.0.0/0", + "description": "Allow all outbound traffic by default", + "ipProtocol": "-1" + } + ], + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/al2023" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "0.0.0" + } + }, + "InstanceRole": { + "id": "InstanceRole", + "path": "integ-ec2-machine-image-test/al2023/InstanceRole", + "children": { + "ImportInstanceRole": { + "id": "ImportInstanceRole", + "path": "integ-ec2-machine-image-test/al2023/InstanceRole/ImportInstanceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-ec2-machine-image-test/al2023/InstanceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ec2.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/al2023" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "InstanceProfile": { + "id": "InstanceProfile", + "path": "integ-ec2-machine-image-test/al2023/InstanceProfile", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::InstanceProfile", + "aws:cdk:cloudformation:props": { + "roles": [ + { + "Ref": "al2023InstanceRoleECC2D6DD" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnInstanceProfile", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-ec2-machine-image-test/al2023/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Instance", + "aws:cdk:cloudformation:props": { + "availabilityZone": "test-region-1a", + "iamInstanceProfile": { + "Ref": "al2023InstanceProfileAB8077E0" + }, + "imageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "instanceType": "t3.nano", + "securityGroupIds": [ + { + "Fn::GetAtt": [ + "al2023InstanceSecurityGroupB018A9BC", + "GroupId" + ] + } + ], + "subnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + }, + "tags": [ + { + "key": "Name", + "value": "integ-ec2-machine-image-test/al2023" + } + ], + "userData": { + "Fn::Base64": "#!/bin/bash" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInstance", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.Instance", + "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": "integ-ec2-machine-image-test/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": "integ-ec2-machine-image-test/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": "integ-ec2-machine-image-test/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "integ-ec2-machine-image-test/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "integ-test": { + "id": "integ-test", + "path": "integ-test", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "integ-test/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "integ-test/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.270" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "integ-test/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "integ-test/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "integ-test/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.270" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.ts new file mode 100644 index 0000000000000..b82e0f21617a9 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image.ts @@ -0,0 +1,38 @@ +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import { + Stack, + StackProps, + App, + aws_ec2 as ec2, +} from 'aws-cdk-lib'; +import { Construct } from 'constructs'; + + +export class TestCase extends Stack { + constructor(scope: Construct, id: string, props?: StackProps) { + super(scope, id, props); + const vpc = new ec2.Vpc(this, 'Vpc'); + new ec2.Instance(this, 'amzn2', { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.NANO), + machineImage: ec2.MachineImage.latestAmazonLinux2(), + vpc, + }); + new ec2.Instance(this, 'al2022', { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.NANO), + machineImage: ec2.MachineImage.latestAmazonLinux2022(), + vpc, + }); + new ec2.Instance(this, 'al2023', { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.NANO), + machineImage: ec2.MachineImage.latestAmazonLinux2023(), + vpc, + }); + } +} + + +const app = new App(); +new IntegTest(app, 'integ-test', { + testCases: [new TestCase(app, 'integ-ec2-machine-image-test')], + enableLookups: true, +}); diff --git a/packages/@aws-cdk/aws-batch-alpha/test/managed-compute-environment.test.ts b/packages/@aws-cdk/aws-batch-alpha/test/managed-compute-environment.test.ts index 033a5c7aa3408..4b5b160957648 100644 --- a/packages/@aws-cdk/aws-batch-alpha/test/managed-compute-environment.test.ts +++ b/packages/@aws-cdk/aws-batch-alpha/test/managed-compute-environment.test.ts @@ -199,7 +199,7 @@ describe.each([ManagedEc2EcsComputeEnvironment, ManagedEc2EksComputeEnvironment] vpc, images: [ { - image: ec2.MachineImage.latestAmazonLinux(), + image: ec2.MachineImage.latestAmazonLinux2(), }, ], }); @@ -211,7 +211,7 @@ describe.each([ManagedEc2EcsComputeEnvironment, ManagedEc2EksComputeEnvironment] ...defaultComputeResources, Ec2Configuration: [ { - ImageIdOverride: { Ref: 'SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter' }, + ImageIdOverride: { Ref: 'SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amikernel510hvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter' }, ImageType: expectedImageType, }, ], diff --git a/packages/aws-cdk-lib/aws-ec2/README.md b/packages/aws-cdk-lib/aws-ec2/README.md index 42e22db39107a..f4adb3ff2c77d 100644 --- a/packages/aws-cdk-lib/aws-ec2/README.md +++ b/packages/aws-cdk-lib/aws-ec2/README.md @@ -1029,29 +1029,19 @@ care of restarting your instance if it ever fails. declare const vpc: ec2.Vpc; declare const instanceType: ec2.InstanceType; -// Amazon Linux 1 -new ec2.Instance(this, 'Instance1', { - vpc, - instanceType, - machineImage: ec2.MachineImage.latestAmazonLinux(), -}); - // Amazon Linux 2 new ec2.Instance(this, 'Instance2', { vpc, instanceType, - machineImage: ec2.MachineImage.latestAmazonLinux({ - generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2, - }), + machineImage: ec2.MachineImage.latestAmazonLinux2(), }); // Amazon Linux 2 with kernel 5.x new ec2.Instance(this, 'Instance3', { vpc, instanceType, - machineImage: ec2.MachineImage.latestAmazonLinux({ - generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2, - kernel: ec2.AmazonLinuxKernel.KERNEL5_X, + machineImage: new ec2.AmazonLinux2Image({ + kernel: ec2.AmazonLinux2Kernel.KERNEL_5_10, }), }); @@ -1059,22 +1049,116 @@ new ec2.Instance(this, 'Instance3', { new ec2.Instance(this, 'Instance4', { vpc, instanceType, - machineImage: ec2.MachineImage.latestAmazonLinux({ - generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2022, - }), + machineImage: ec2.MachineImage.latestAmazonLinux2022(), }); // Graviton 3 Processor new ec2.Instance(this, 'Instance5', { vpc, instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE), - machineImage: ec2.MachineImage.latestAmazonLinux({ - generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2, + machineImage: ec2.MachineImage.latestAmazonLinux2022({ cpuType: ec2.AmazonLinuxCpuType.ARM_64, }), }); ``` +### Latest Amazon Linux Images + +Rather than specifying a specific AMI ID to use, it is possible to specify a SSM +Parameter that contains the AMI ID. AWS publishes a set of [public parameters](https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-public-parameters-ami.html) +that contain the latest Amazon Linux AMIs. To make it easier to query a +particular image parameter, the CDK provides a couple of constructs `AmazonLinux2ImageSsmParameter`, +`AmazonLinux2022ImageSsmParameter`, & `AmazonLinux2023SsmParameter`. For example +to use the latest `al2023` image: + +```ts +new ec2.Instance(this, 'LatestAl2023', { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE), + machineImage: ec2.MachineImage.latestAmazonLinux2023(), +}); +``` + +> **Warning** +> Since this retrieves the value from an SSM parameter at deployment time, the +> value will be resolved each time the stack is deployed. This means that if +> the parameter contains a different value on your next deployment, the instance +> will be replaced. + +It is also possible to perform the lookup once at synthesis time and then cache +the value in CDK context. This way the value will not change on future +deployments unless you manually refresh the context. + +```ts +new ec2.Instance(this, 'LatestAl2023', { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE), + machineImage: ec2.MachineImage.latestAmazonLinux2023({ + cachedInContext: true, // default is false + }), +}); + +// or +new ec2.Instance(this, 'LatestAl2023', { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE), + // context cache is turned on by default + machineImage: new ec2.AmazonLinux2023ImageSsmParameter(), +}); +``` + +#### Kernel Versions + +Each Amazon Linux AMI uses a specific kernel version. Most Amazon Linux +generations come with an AMI using the "default" kernel and then 1 or more +AMIs using a specific kernel version, which may or may not be different from the +default kernel version. + +For example, Amazon Linux 2 has two different AMIs available from the SSM +parameters. + +- `/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs` + - This is the "default" kernel which uses `kernel-4.14` +- `/aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.10-hvm-x86_64-ebs` + +If a new Amazon Linux generation AMI is published with a new kernel version, +then a new SSM parameter will be created with the new version +(e.g. `/aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.15-hvm-x86_64-ebs`), +but the "default" AMI may or may not be updated. + +If you would like to make sure you always have the latest kernel version, then +either specify the specific latest kernel version or opt-in to using the CDK +latest kernel version. + +```ts +new ec2.Instance(this, 'LatestAl2023', { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE), + // context cache is turned on by default + machineImage: new ec2.AmazonLinux2023ImageSsmParameter({ + kernel: ec2.AmazonLinux2023Kernel.KERNEL_6_1, + }), +}); +``` +_CDK managed latest_ + +```ts +new ec2.Instance(this, 'LatestAl2023', { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE), + // context cache is turned on by default + machineImage: new ec2.AmazonLinux2023ImageSsmParameter({ + kernel: ec2.AmazonLinux2023Kernel.CDK_LATEST, + }), +}); + +// or + +new ec2.Instance(this, 'LatestAl2023', { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE), + machineImage: ec2.MachineImage.latestAmazonLinux2023(), // always uses latest kernel version +}); +``` + +When using the CDK managed latest version, when a new kernel version is made +available the `LATEST` will be updated to point to the new kernel version. You +then would be required to update the newest CDK version for it to take effect. + ### Configuring Instances using CloudFormation Init (cfn-init) CloudFormation Init allows you to configure your instances by writing files to them, installing software @@ -1162,10 +1246,7 @@ declare const instanceType: ec2.InstanceType; new ec2.Instance(this, 'Instance', { vpc, instanceType, - machineImage: ec2.MachineImage.latestAmazonLinux({ - // Amazon Linux 2 uses SystemD - generation: ec2.AmazonLinuxGeneration: AMAZON_LINUX_2, - }), + machineImage: ec2.MachineImage.latestAmazonLinux2022(), init: ec2.CloudFormationInit.fromElements([ // Create a simple config file that runs a Python web server @@ -1701,9 +1782,7 @@ The following demonstrates how to create a launch template with an Amazon Machin declare const vpc: ec2.Vpc; const template = new ec2.LaunchTemplate(this, 'LaunchTemplate', { - machineImage: ec2.MachineImage.latestAmazonLinux({ - generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2, - }), + machineImage: ec2.MachineImage.latestAmazonLinux2022(), securityGroup: new ec2.SecurityGroup(this, 'LaunchTemplateSG', { vpc: vpc, }), @@ -1733,7 +1812,7 @@ declare const instanceType: ec2.InstanceType; new ec2.Instance(this, 'Instance1', { vpc, instanceType, - machineImage: ec2.MachineImage.latestAmazonLinux(), + machineImage: ec2.MachineImage.latestAmazonLinux2022(), detailedMonitoring: true, }); ``` @@ -1764,9 +1843,7 @@ new ec2.Instance(this, 'Instance1', { instanceType, // Amazon Linux 2 comes with SSM Agent by default - machineImage: ec2.MachineImage.latestAmazonLinux({ - generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2, - }), + machineImage: ec2.MachineImage.latestAmazonLinux2022(), // Turn on SSM ssmSessionPermissions: true, diff --git a/packages/aws-cdk-lib/aws-ec2/lib/index.ts b/packages/aws-cdk-lib/aws-ec2/lib/index.ts index 952b1a3f2a1c4..54c43091cc8cc 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/index.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/index.ts @@ -28,6 +28,7 @@ export * from './client-vpn-endpoint'; export * from './client-vpn-authorization-rule'; export * from './client-vpn-route'; export * from './ip-addresses'; +export * from './machine-image'; export * from './placement-group'; // AWS::EC2 CloudFormation Resources: diff --git a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/amazon-linux-2022.ts b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/amazon-linux-2022.ts new file mode 100644 index 0000000000000..06f40de63bae0 --- /dev/null +++ b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/amazon-linux-2022.ts @@ -0,0 +1,91 @@ +import { AmazonLinuxCpuType, AmazonLinuxEdition, AmazonLinuxGeneration, AmazonLinuxImageSsmParameterCommonOptions, AmazonLinuxImageSsmParameterBase } from './common'; + +/** + * Amazon Linux 2022 kernel versions + */ +export class AmazonLinux2022Kernel { + /** + * The latest kernel version currently available in a published AMI. + * + * When a new kernel version is available for an al2022 AMI this will be + * updated to contain the latest kernel version and will cause your instances + * to be replaced. Do not store stateful information on the instance if you are + * using this version. + */ + public static readonly CDK_LATEST = new AmazonLinux2022Kernel('5.15'); + + /** + * The default kernel version for Amazon Linux 2022 is 5.15 and + * the SSM parameter does not include it in the name + * (i.e. /aws/service/ami-amazon-linux-latest/amzn2022-ami-kernel-default-x86_64) + */ + public static readonly DEFAULT = new AmazonLinux2022Kernel('default'); + + /** + * Kernel version 5.15 + */ + public static readonly KERNEL_5_15 = new AmazonLinux2022Kernel('5.15'); + + constructor(private readonly version: string) { } + + /** + * Generate a string representation of the kernel + */ + public toString(): string { + return `kernel-${this.version}`; + } +} + +/** + * Properties specific to al2022 images + */ +export interface AmazonLinux2022ImageSsmParameterProps extends AmazonLinuxImageSsmParameterCommonOptions { + /** + * What kernel version of Amazon Linux to use + * + * @default AmazonLinux2022Kernel.DEFAULT + */ + readonly kernel?: AmazonLinux2022Kernel; +} + +/** + * A SSM Parameter that contains the AMI ID for Amazon Linux 2023 + */ +export class AmazonLinux2022ImageSsmParameter extends AmazonLinuxImageSsmParameterBase { + /** + * Generates a SSM Parameter name for a specific amazon linux 2022 AMI + * + * Example values: + * + * "/aws/service/ami-amazon-linux-latest/al2022-ami-kernel-5.15-x86_64", + * "/aws/service/ami-amazon-linux-latest/al2022-ami-kernel-default-x86_64", + * "/aws/service/ami-amazon-linux-latest/al2022-ami-minimal-kernel-5.15-arm64", + * "/aws/service/ami-amazon-linux-latest/al2022-ami-minimal-kernel-5.15-x86_64", + * "/aws/service/ami-amazon-linux-latest/al2022-ami-kernel-5.15-arm64", + * "/aws/service/ami-amazon-linux-latest/al2022-ami-minimal-kernel-default-arm64", + * "/aws/service/ami-amazon-linux-latest/al2022-ami-minimal-kernel-default-x86_64", + * "/aws/service/ami-amazon-linux-latest/al2022-ami-kernel-default-arm64", + */ + public static ssmParameterName(props: AmazonLinux2022ImageSsmParameterProps): string { + const edition = (props && props.edition) || AmazonLinuxEdition.STANDARD; + + const parts: Array = [ + AmazonLinuxGeneration.AMAZON_LINUX_2022, + 'ami', + edition !== AmazonLinuxEdition.STANDARD ? edition : undefined, + props.kernel?.toString(), + props.cpuType ?? AmazonLinuxCpuType.X86_64, + ].filter(x => !!x); + + return '/aws/service/ami-amazon-linux-latest/' + parts.join('-'); + } + + constructor(props: AmazonLinux2022ImageSsmParameterProps) { + super({ + parameterName: AmazonLinux2022ImageSsmParameter.ssmParameterName(props), + cachedInContext: props.cachedInContext, + userData: props.userData, + }); + } + +} diff --git a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/amazon-linux-2023.ts b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/amazon-linux-2023.ts new file mode 100644 index 0000000000000..3ea5863201ef1 --- /dev/null +++ b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/amazon-linux-2023.ts @@ -0,0 +1,90 @@ +import { AmazonLinuxCpuType, AmazonLinuxEdition, AmazonLinuxGeneration, AmazonLinuxImageSsmParameterCommonOptions, AmazonLinuxImageSsmParameterBase } from './common'; + +/** + * Amazon Linux 2023 kernel versions + */ +export class AmazonLinux2023Kernel { + /** + * The latest kernel version currently available in a published AMI. + * + * When a new kernel version is available for an al2023 AMI this will be + * updated to contain the latest kernel version and will cause your instances + * to be replaced. Do not store stateful information on the instance if you are + * using this version. + */ + public static readonly CDK_LATEST = new AmazonLinux2023Kernel('6.1'); + + /** + * The default kernel version for Amazon Linux 2023 is 6.1 and + * the SSM parameter does not include it in the name + * (i.e. /aws/service/ami-amazon-linux-latest/amzn2023-ami-kernel-default-x86_64) + */ + public static readonly DEFAULT = new AmazonLinux2023Kernel('default'); + + /** + * Kernel version 6.1 + */ + public static readonly KERNEL_6_1 = new AmazonLinux2023Kernel('6.1'); + constructor(private readonly version: string) { } + + /** + * Generate a string representation of the kernel + */ + public toString(): string { + return `kernel-${this.version}`; + } +} + +/** + * Properties specific to al2023 images + */ +export interface AmazonLinux2023ImageSsmParameterProps extends AmazonLinuxImageSsmParameterCommonOptions { + /** + * What kernel version of Amazon Linux to use + * + * @default AmazonLinux2023Kernel.DEFAULT + */ + readonly kernel?: AmazonLinux2023Kernel; +} + + +/** + * A SSM Parameter that contains the AMI ID for Amazon Linux 2023 + */ +export class AmazonLinux2023ImageSsmParameter extends AmazonLinuxImageSsmParameterBase { + /** + * Generates a SSM Parameter name for a specific amazon linux 2022 AMI + * + * Example values: + * + * "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-arm64", + * "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64", + * "/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-6.1-arm64", + * "/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-6.1-x86_64", + * "/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-arm64", + * "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64", + * "/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64", + * "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-arm64", + */ + public static ssmParameterName(props: AmazonLinux2023ImageSsmParameterProps): string { + const edition = (props && props.edition) || AmazonLinuxEdition.STANDARD; + + const parts: Array = [ + AmazonLinuxGeneration.AMAZON_LINUX_2023, + 'ami', + edition !== AmazonLinuxEdition.STANDARD ? edition : undefined, + (props.kernel ?? AmazonLinux2023Kernel.DEFAULT)?.toString(), + props.cpuType ?? AmazonLinuxCpuType.X86_64, + ].filter(x => !!x); + + return '/aws/service/ami-amazon-linux-latest/' + parts.join('-'); + } + + constructor(props: AmazonLinux2023ImageSsmParameterProps) { + super({ + parameterName: AmazonLinux2023ImageSsmParameter.ssmParameterName(props), + cachedInContext: props.cachedInContext, + userData: props.userData, + }); + } +} diff --git a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/amazon-linux2.ts b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/amazon-linux2.ts new file mode 100644 index 0000000000000..a037a61a80851 --- /dev/null +++ b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/amazon-linux2.ts @@ -0,0 +1,109 @@ +import { AmazonLinuxCpuType, AmazonLinuxEdition, AmazonLinuxGeneration, AmazonLinuxImageSsmParameterBase, AmazonLinuxImageSsmParameterCommonOptions, AmazonLinuxStorage, AmazonLinuxVirt } from './common'; + +/** + * Amazon Linux 2 kernel versions + */ +export class AmazonLinux2Kernel { + /** + * The latest kernel version currently available in a published AMI. + * + * When a new kernel version is available for an amzn2 AMI this will be + * updated to contain the latest kernel version and will cause your instances + * to be replaced. Do not store stateful information on the instance if you are + * using this version. + */ + public static readonly CDK_LATEST = new AmazonLinux2Kernel('5.10'); + + /** + * The default kernel version for Amazon Linux 2 is 4.14 and + * Linux 4.14.311-233.529.amzn2.x86_64 + * the SSM parameter does not include it in the name + * (i.e. /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2) + */ + public static readonly DEFAULT = new AmazonLinux2Kernel('default'); + + /** + * Kernel version 5.10 + */ + public static readonly KERNEL_5_10 = new AmazonLinux2Kernel('5.10'); + + constructor(private readonly version: string) { } + + /** + * Generate a string representation of the kernel + */ + public toString(): string | undefined { + return this.version === 'default' + ? undefined + : `kernel-${this.version}`; + } +} + +/** + * Properties specific to amzn2 images + */ +export interface AmazonLinux2ImageSsmParameterProps extends AmazonLinuxImageSsmParameterCommonOptions { + /** + * What storage backed image to use + * + * @default GeneralPurpose + */ + readonly storage?: AmazonLinuxStorage; + + /** + * What kernel version of Amazon Linux to use + * + * @default - + */ + readonly kernel?: AmazonLinux2Kernel; + + /** + * Virtualization type + * + * @default HVM + */ + readonly virtualization?: AmazonLinuxVirt; +} + +/** + * A SSM Parameter that contains the AMI ID for Amazon Linux 2 + */ +export class AmazonLinux2ImageSsmParameter extends AmazonLinuxImageSsmParameterBase { + /** + * Generates a SSM Parameter name for a specific amazon linux 2 AMI + * + * Example values: + * + * "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs", + * "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2", + * "/aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.10-hvm-x86_64-ebs", + * "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-arm64-gp2", + * "/aws/service/ami-amazon-linux-latest/amzn2-ami-minimal-hvm-arm64-ebs", + * "/aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.10-hvm-arm64-gp2", + * "/aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.10-hvm-x86_64-gp2", + * "/aws/service/ami-amazon-linux-latest/amzn2-ami-minimal-hvm-x86_64-ebs" + */ + public static ssmParameterName(props: AmazonLinux2ImageSsmParameterProps): string { + const edition = (props && props.edition) || AmazonLinuxEdition.STANDARD; + + const parts: Array = [ + AmazonLinuxGeneration.AMAZON_LINUX_2, + 'ami', + edition !== AmazonLinuxEdition.STANDARD ? edition : undefined, + props.kernel?.toString(), + props.virtualization ?? AmazonLinuxVirt.HVM, + props.cpuType ?? AmazonLinuxCpuType.X86_64, + props.storage ?? AmazonLinuxStorage.GENERAL_PURPOSE, + ].filter(x => !!x); + + return '/aws/service/ami-amazon-linux-latest/' + parts.join('-'); + } + + constructor(props: AmazonLinux2ImageSsmParameterProps) { + super({ + parameterName: AmazonLinux2ImageSsmParameter.ssmParameterName(props), + cachedInContext: props.cachedInContext, + userData: props.userData, + }); + } +} diff --git a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/common.ts b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/common.ts new file mode 100644 index 0000000000000..a598c2c3a6d5b --- /dev/null +++ b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/common.ts @@ -0,0 +1,218 @@ +import { Construct } from 'constructs'; +import { lookupImage } from './utils'; +import { UserData } from '../user-data'; + +/** + * Common options across all generations. + */ +export interface AmazonLinuxImageSsmParameterCommonOptions extends AmazonLinuxImageSsmParameterBaseOptions { + /** + * What edition of Amazon Linux to use + * + * @default AmazonLinuxEdition.Standard + */ + readonly edition?: AmazonLinuxEdition; + + /** + * CPU Type + * + * @default AmazonLinuxCpuType.X86_64 + */ + readonly cpuType?: AmazonLinuxCpuType; +} + +/** + * Base options for amazon linux ssm parameters + */ +export interface AmazonLinuxImageSsmParameterBaseOptions { + /** + * Whether the AMI ID is cached to be stable between deployments + * + * By default, the newest image is used on each deployment. This will cause + * instances to be replaced whenever a new version is released, and may cause + * downtime if there aren't enough running instances in the AutoScalingGroup + * to reschedule the tasks on. + * + * If set to true, the AMI ID will be cached in `cdk.context.json` and the + * same value will be used on future runs. Your instances will not be replaced + * but your AMI version will grow old over time. To refresh the AMI lookup, + * you will have to evict the value from the cache using the `cdk context` + * command. See https://docs.aws.amazon.com/cdk/latest/guide/context.html for + * more information. + * + * Can not be set to `true` in environment-agnostic stacks. + * + * @default false + */ + readonly cachedInContext?: boolean; + + /** + * Initial user data + * + * @default - Empty UserData for Linux machines + */ + readonly userData?: UserData; +} + +/** + * Base properties for an Amazon Linux SSM Parameter + */ +export interface AmazonLinuxImageSsmParameterBaseProps extends AmazonLinuxImageSsmParameterBaseOptions { + /** + * The name of the SSM parameter that contains the AMI value + */ + readonly parameterName: string; +} + +export abstract class AmazonLinuxImageSsmParameterBase implements IMachineImage { + private readonly cachedInContext: boolean; + constructor(private readonly props: AmazonLinuxImageSsmParameterBaseProps) { + this.cachedInContext = this.props.cachedInContext ?? true; + } + + getImage(scope: Construct): MachineImageConfig { + const imageId = lookupImage(scope, this.cachedInContext, this.props.parameterName); + + const osType = OperatingSystemType.LINUX; + return { + imageId, + osType, + userData: this.props.userData ?? UserData.forLinux(), + }; + } + +} + +/** + * What generation of Amazon Linux to use + */ +export enum AmazonLinuxGeneration { + /** + * Amazon Linux + */ + AMAZON_LINUX = 'amzn', + + /** + * Amazon Linux 2 + */ + AMAZON_LINUX_2 = 'amzn2', + + /** + * Amazon Linux 2022 + */ + AMAZON_LINUX_2022 = 'al2022', + + /** + * Amazon Linux 2023 + */ + AMAZON_LINUX_2023 = 'al2023', +} + +/** + * Interface for classes that can select an appropriate machine image to use + */ +export interface IMachineImage { + /** + * Return the image to use in the given context + */ + getImage(scope: Construct): MachineImageConfig; +} + +/** + * Configuration for a machine image + */ +export interface MachineImageConfig { + /** + * The AMI ID of the image to use + */ + readonly imageId: string; + + /** + * Operating system type for this image + */ + readonly osType: OperatingSystemType; + + /** + * Initial UserData for this image + */ + readonly userData: UserData; +} + +/** + * The OS type of a particular image + */ +export enum OperatingSystemType { + LINUX, + WINDOWS, + /** + * Used when the type of the operating system is not known + * (for example, for imported Auto-Scaling Groups). + */ + UNKNOWN, +} + +/** + * CPU type + */ +export enum AmazonLinuxCpuType { + /** + * arm64 CPU type + */ + ARM_64 = 'arm64', + + /** + * x86_64 CPU type + */ + X86_64 = 'x86_64', +} + +/** + * Amazon Linux edition + */ +export enum AmazonLinuxEdition { + /** + * Standard edition + */ + STANDARD = 'standard', + + /** + * Minimal edition + */ + MINIMAL = 'minimal', +} + +/** + * Virtualization type for Amazon Linux + */ +export enum AmazonLinuxVirt { + /** + * HVM virtualization (recommended) + */ + HVM = 'hvm', + + /** + * PV virtualization + */ + PV = 'pv', +} + +/** + * Available storage options for Amazon Linux images + * Only applies to Amazon Linux & Amazon Linux 2 + */ +export enum AmazonLinuxStorage { + /** + * EBS-backed storage + */ + EBS = 'ebs', + + /** + * S3-backed storage + */ + S3 = 's3', + + /** + * General Purpose-based storage (recommended) + */ + GENERAL_PURPOSE = 'gp2', +} diff --git a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/index.ts b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/index.ts new file mode 100644 index 0000000000000..ad5829128310e --- /dev/null +++ b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/index.ts @@ -0,0 +1,5 @@ +export * from './common'; +export * from './amazon-linux2'; +export * from './machine-image'; +export * from './amazon-linux-2022'; +export * from './amazon-linux-2023'; diff --git a/packages/aws-cdk-lib/aws-ec2/lib/machine-image.ts b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts similarity index 88% rename from packages/aws-cdk-lib/aws-ec2/lib/machine-image.ts rename to packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts index 12c41894e5936..c5064c4dbd10b 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/machine-image.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts @@ -1,20 +1,16 @@ -import * as ssm from '../../aws-ssm'; -import * as cxschema from '../../cloud-assembly-schema'; -import { ContextProvider, CfnMapping, Aws, Stack, Token } from '../../core'; -import * as cxapi from '../../cx-api'; import { Construct } from 'constructs'; -import { UserData } from './user-data'; -import { WindowsVersion } from './windows-versions'; +import { AmazonLinux2022ImageSsmParameter, AmazonLinux2022ImageSsmParameterProps, AmazonLinux2022Kernel } from './amazon-linux-2022'; +import { AmazonLinux2023ImageSsmParameter, AmazonLinux2023ImageSsmParameterProps, AmazonLinux2023Kernel } from './amazon-linux-2023'; +import { AmazonLinux2ImageSsmParameter, AmazonLinux2ImageSsmParameterProps, AmazonLinux2Kernel } from './amazon-linux2'; +import { AmazonLinuxCpuType, AmazonLinuxEdition, AmazonLinuxGeneration, AmazonLinuxStorage, AmazonLinuxVirt, IMachineImage, MachineImageConfig, OperatingSystemType } from './common'; +import { lookupImage } from './utils'; +import * as ssm from '../../../aws-ssm'; +import * as cxschema from '../../../cloud-assembly-schema'; +import { ContextProvider, CfnMapping, Aws, Stack, Token } from '../../../core'; +import * as cxapi from '../../../cx-api'; +import { UserData } from '../user-data'; +import { WindowsVersion } from '../windows-versions'; -/** - * Interface for classes that can select an appropriate machine image to use - */ -export interface IMachineImage { - /** - * Return the image to use in the given context - */ - getImage(scope: Construct): MachineImageConfig; -} /** * Factory functions for standard Amazon Machine Image objects. @@ -32,6 +28,54 @@ export abstract class MachineImage { return new WindowsImage(version, props); } + /** + * An Amazon Linux 2 image that is automatically kept up-to-date + * + * This Machine Image automatically updates to the latest version on every + * deployment. Be aware this will cause your instances to be replaced when a + * new version of the image becomes available. Do not store stateful information + * on the instance if you are using this image. + */ + public static latestAmazonLinux2(props?: AmazonLinux2ImageSsmParameterProps): IMachineImage { + return new AmazonLinux2ImageSsmParameter({ + cachedInContext: false, + ...props, + kernel: AmazonLinux2Kernel.CDK_LATEST, + }); + } + + /** + * An Amazon Linux 2022 image that is automatically kept up-to-date + * + * This Machine Image automatically updates to the latest version on every + * deployment. Be aware this will cause your instances to be replaced when a + * new version of the image becomes available. Do not store stateful information + * on the instance if you are using this image. + */ + public static latestAmazonLinux2022(props?: AmazonLinux2022ImageSsmParameterProps): IMachineImage { + return new AmazonLinux2022ImageSsmParameter({ + cachedInContext: false, + ...props, + kernel: AmazonLinux2022Kernel.CDK_LATEST, + }); + } + + /** + * An Amazon Linux 2023 image that is automatically kept up-to-date + * + * This Machine Image automatically updates to the latest version on every + * deployment. Be aware this will cause your instances to be replaced when a + * new version of the image becomes available. Do not store stateful information + * on the instance if you are using this image. + */ + public static latestAmazonLinux2023(props?: AmazonLinux2023ImageSsmParameterProps): IMachineImage { + return new AmazonLinux2023ImageSsmParameter({ + cachedInContext: false, + ...props, + kernel: AmazonLinux2023Kernel.CDK_LATEST, + }); + } + /** * An Amazon Linux image that is automatically kept up-to-date * @@ -53,6 +97,7 @@ export abstract class MachineImage { * generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2, * }) * ``` + * @deprecated use MachineImage.latestAmazonLinux2 instead */ public static latestAmazonLinux(props?: AmazonLinuxImageProps): IMachineImage { return new AmazonLinuxImage(props); @@ -131,26 +176,6 @@ export abstract class MachineImage { } } -/** - * Configuration for a machine image - */ -export interface MachineImageConfig { - /** - * The AMI ID of the image to use - */ - readonly imageId: string; - - /** - * Operating system type for this image - */ - readonly osType: OperatingSystemType; - - /** - * Initial UserData for this image - */ - readonly userData: UserData; -} - /** * Select the image based on a given SSM parameter * @@ -304,20 +329,6 @@ export class WindowsImage extends GenericSSMParameterImage { } } -/** - * CPU type - */ -export enum AmazonLinuxCpuType { - /** - * arm64 CPU type - */ - ARM_64 = 'arm64', - - /** - * x86_64 CPU type - */ - X86_64 = 'x86_64', -} /** * Amazon Linux image properties @@ -344,13 +355,6 @@ export interface AmazonLinuxImageProps { */ readonly kernel?: AmazonLinuxKernel; - /** - * Virtualization type - * - * @default HVM - */ - readonly virtualization?: AmazonLinuxVirt; - /** * What storage backed image to use * @@ -372,6 +376,13 @@ export interface AmazonLinuxImageProps { */ readonly cpuType?: AmazonLinuxCpuType; + /** + * Virtualization type + * + * @default HVM + */ + readonly virtualization?: AmazonLinuxVirt; + /** * Whether the AMI ID is cached to be stable between deployments * @@ -465,25 +476,6 @@ export class AmazonLinuxImage extends GenericSSMParameterImage { } } -/** - * What generation of Amazon Linux to use - */ -export enum AmazonLinuxGeneration { - /** - * Amazon Linux - */ - AMAZON_LINUX = 'amzn', - - /** - * Amazon Linux 2 - */ - AMAZON_LINUX_2 = 'amzn2', - - /** - * Amazon Linux 2022 - */ - AMAZON_LINUX_2022 = 'al2022', -} /** * Amazon Linux Kernel @@ -495,53 +487,6 @@ export enum AmazonLinuxKernel { KERNEL5_X = 'kernel-5.10', } -/** - * Amazon Linux edition - */ -export enum AmazonLinuxEdition { - /** - * Standard edition - */ - STANDARD = 'standard', - - /** - * Minimal edition - */ - MINIMAL = 'minimal', -} - -/** - * Virtualization type for Amazon Linux - */ -export enum AmazonLinuxVirt { - /** - * HVM virtualization (recommended) - */ - HVM = 'hvm', - - /** - * PV virtualization - */ - PV = 'pv', -} - -export enum AmazonLinuxStorage { - /** - * EBS-backed storage - */ - EBS = 'ebs', - - /** - * S3-backed storage - */ - S3 = 's3', - - /** - * General Purpose-based storage (recommended) - */ - GENERAL_PURPOSE = 'gp2', -} - /** * Configuration options for GenericLinuxImage */ @@ -641,19 +586,6 @@ export class GenericWindowsImage implements IMachineImage { } } -/** - * The OS type of a particular image - */ -export enum OperatingSystemType { - LINUX, - WINDOWS, - /** - * Used when the type of the operating system is not known - * (for example, for imported Auto-Scaling Groups). - */ - UNKNOWN, -} - /** * A machine image whose AMI ID will be searched using DescribeImages. * @@ -743,8 +675,3 @@ export interface LookupMachineImageProps { readonly userData?: UserData; } -function lookupImage(scope: Construct, cachedInContext: boolean | undefined, parameterName: string) { - return cachedInContext - ? ssm.StringParameter.valueFromLookup(scope, parameterName) - : ssm.StringParameter.valueForTypedStringParameterV2(scope, parameterName, ssm.ParameterValueType.AWS_EC2_IMAGE_ID); -} diff --git a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/utils.ts b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/utils.ts new file mode 100644 index 0000000000000..a2da997c80e63 --- /dev/null +++ b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/utils.ts @@ -0,0 +1,9 @@ +import { Construct } from 'constructs'; +import * as ssm from '../../../aws-ssm'; + +export function lookupImage(scope: Construct, cachedInContext: boolean | undefined, parameterName: string) { + return cachedInContext + ? ssm.StringParameter.valueFromLookup(scope, parameterName) + : ssm.StringParameter.valueForTypedStringParameterV2(scope, parameterName, ssm.ParameterValueType.AWS_EC2_IMAGE_ID); +} + diff --git a/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts b/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts index f4f4fcedf8271..3375f1736f9be 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts @@ -269,6 +269,115 @@ test('cached lookups of Amazon Linux 2022 with kernel 5.x', () => { ]); }); +describe('latest amazon linux', () => { + test('latestAmazonLinux2', () => { + // WHEN + ec2.MachineImage.latestAmazonLinux2().getImage(stack); + + // THEN + Template.fromStack(stack).hasParameter('*', { + Type: 'AWS::SSM::Parameter::Value', + Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.10-hvm-x86_64-gp2', + }); + }); + + test('AmazonLinux2ImageSsmParameter', () => { + // WHEN + const ami = new ec2.AmazonLinux2ImageSsmParameter({ + cpuType: ec2.AmazonLinuxCpuType.ARM_64, + edition: ec2.AmazonLinuxEdition.MINIMAL, + virtualization: ec2.AmazonLinuxVirt.PV, + storage: ec2.AmazonLinuxStorage.EBS, + kernel: ec2.AmazonLinux2Kernel.DEFAULT, + }).getImage(stack).imageId; + + // THEN + expect(ami).toEqual('dummy-value-for-/aws/service/ami-amazon-linux-latest/amzn2-ami-minimal-pv-arm64-ebs'); + expect(app.synth().manifest.missing).toEqual([ + { + key: 'ssm:account=1234:parameterName=/aws/service/ami-amazon-linux-latest/amzn2-ami-minimal-pv-arm64-ebs:region=testregion', + props: { + account: '1234', + lookupRoleArn: 'arn:${AWS::Partition}:iam::1234:role/cdk-hnb659fds-lookup-role-1234-testregion', + region: 'testregion', + parameterName: '/aws/service/ami-amazon-linux-latest/amzn2-ami-minimal-pv-arm64-ebs', + }, + provider: 'ssm', + }, + ]); + }); + + test('latestAmazonLinux2022', () => { + // WHEN + ec2.MachineImage.latestAmazonLinux2022().getImage(stack); + + // THEN + Template.fromStack(stack).hasParameter('*', { + Type: 'AWS::SSM::Parameter::Value', + Default: '/aws/service/ami-amazon-linux-latest/al2022-ami-kernel-5.15-x86_64', + }); + }); + + test('AmazonLinux2022ImageSsmParameter', () => { + // WHEN + const ami = new ec2.AmazonLinux2022ImageSsmParameter({ + cpuType: ec2.AmazonLinuxCpuType.ARM_64, + edition: ec2.AmazonLinuxEdition.MINIMAL, + kernel: ec2.AmazonLinux2022Kernel.DEFAULT, + }).getImage(stack).imageId; + + // THEN + expect(ami).toEqual('dummy-value-for-/aws/service/ami-amazon-linux-latest/al2022-ami-minimal-kernel-default-arm64'); + expect(app.synth().manifest.missing).toEqual([ + { + key: 'ssm:account=1234:parameterName=/aws/service/ami-amazon-linux-latest/al2022-ami-minimal-kernel-default-arm64:region=testregion', + props: { + account: '1234', + lookupRoleArn: 'arn:${AWS::Partition}:iam::1234:role/cdk-hnb659fds-lookup-role-1234-testregion', + region: 'testregion', + parameterName: '/aws/service/ami-amazon-linux-latest/al2022-ami-minimal-kernel-default-arm64', + }, + provider: 'ssm', + }, + ]); + }); + + test('latestAmazonLinux2023', () => { + // WHEN + ec2.MachineImage.latestAmazonLinux2023().getImage(stack); + + // THEN + Template.fromStack(stack).hasParameter('*', { + Type: 'AWS::SSM::Parameter::Value', + Default: '/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64', + }); + }); + + test('AmazonLinux2023ImageSsmParameter', () => { + // WHEN + const ami = new ec2.AmazonLinux2023ImageSsmParameter({ + cpuType: ec2.AmazonLinuxCpuType.ARM_64, + edition: ec2.AmazonLinuxEdition.MINIMAL, + kernel: ec2.AmazonLinux2023Kernel.DEFAULT, + }).getImage(stack).imageId; + + // THEN + expect(ami).toEqual('dummy-value-for-/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-arm64'); + expect(app.synth().manifest.missing).toEqual([ + { + key: 'ssm:account=1234:parameterName=/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-arm64:region=testregion', + props: { + account: '1234', + lookupRoleArn: 'arn:${AWS::Partition}:iam::1234:role/cdk-hnb659fds-lookup-role-1234-testregion', + region: 'testregion', + parameterName: '/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-arm64', + }, + provider: 'ssm', + }, + ]); + }); +}); + function isWindowsUserData(ud: ec2.UserData) { return ud.render().indexOf('powershell') > -1; }