diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/cdk-ec2-machine-image-cached.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/cdk-ec2-machine-image-cached.assets.json new file mode 100644 index 0000000000000..d71428145dbd8 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/cdk-ec2-machine-image-cached.assets.json @@ -0,0 +1,20 @@ +{ + "version": "34.0.0", + "files": { + "18035a5c59b3c622a6f952b627e53ba58bcfc4f09c0ba6b55886e25644395ce6": { + "source": { + "path": "cdk-ec2-machine-image-cached.template.json", + "packaging": "file" + }, + "destinations": { + "12345678-test-region": { + "bucketName": "cdk-hnb659fds-assets-12345678-test-region", + "objectKey": "18035a5c59b3c622a6f952b627e53ba58bcfc4f09c0ba6b55886e25644395ce6.json", + "region": "test-region", + "assumeRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-file-publishing-role-12345678-test-region" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/cdk-ec2-machine-image-cached.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/cdk-ec2-machine-image-cached.template.json new file mode 100644 index 0000000000000..df901543822cc --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/cdk-ec2-machine-image-cached.template.json @@ -0,0 +1,742 @@ +{ + "Resources": { + "Vpc8378EB38": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc" + } + ] + } + }, + "VpcPublicSubnet1Subnet5C2D37C4": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "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": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "VpcPublicSubnet1RouteTable6C95E38E": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "VpcPublicSubnet1RouteTableAssociation97140677": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + } + } + }, + "VpcPublicSubnet1DefaultRoute3DA9E72A": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ] + }, + "VpcPublicSubnet1EIPD7E02669": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1NATGateway4D7517AA": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet1EIPD7E02669", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1" + } + ] + }, + "DependsOn": [ + "VpcPublicSubnet1DefaultRoute3DA9E72A", + "VpcPublicSubnet1RouteTableAssociation97140677" + ] + }, + "VpcPublicSubnet2Subnet691E08A3": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "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": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "VpcPublicSubnet2RouteTable94F7E489": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "VpcPublicSubnet2RouteTableAssociationDD5762D8": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + } + }, + "VpcPublicSubnet2DefaultRoute97F91067": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ] + }, + "VpcPublicSubnet2EIP3C605A87": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPublicSubnet2NATGateway9182C01D": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet2EIP3C605A87", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2" + } + ] + }, + "DependsOn": [ + "VpcPublicSubnet2DefaultRoute97F91067", + "VpcPublicSubnet2RouteTableAssociationDD5762D8" + ] + }, + "VpcPublicSubnet3SubnetBE12F0B6": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "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": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "VpcPublicSubnet3RouteTable93458DBB": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "VpcPublicSubnet3RouteTableAssociation1F1EDF02": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet3RouteTable93458DBB" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet3SubnetBE12F0B6" + } + } + }, + "VpcPublicSubnet3DefaultRoute4697774F": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "RouteTableId": { + "Ref": "VpcPublicSubnet3RouteTable93458DBB" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ] + }, + "VpcPublicSubnet3EIP3A666A23": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3" + } + ] + } + }, + "VpcPublicSubnet3NATGateway7640CD1D": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet3EIP3A666A23", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "VpcPublicSubnet3SubnetBE12F0B6" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3" + } + ] + }, + "DependsOn": [ + "VpcPublicSubnet3DefaultRoute4697774F", + "VpcPublicSubnet3RouteTableAssociation1F1EDF02" + ] + }, + "VpcPrivateSubnet1Subnet536B997A": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "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": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "VpcPrivateSubnet1RouteTableB2C5B500": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "VpcPrivateSubnet1RouteTableAssociation70C59FA6": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + } + } + }, + "VpcPrivateSubnet1DefaultRouteBE02A9ED": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet1NATGateway4D7517AA" + }, + "RouteTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + } + } + }, + "VpcPrivateSubnet2Subnet3788AAA1": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "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": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "VpcPrivateSubnet2RouteTableA678073B": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "VpcPrivateSubnet2RouteTableAssociationA89CAD56": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet2Subnet3788AAA1" + } + } + }, + "VpcPrivateSubnet2DefaultRoute060D2087": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet2NATGateway9182C01D" + }, + "RouteTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + } + } + }, + "VpcPrivateSubnet3SubnetF258B56E": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "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": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "VpcPrivateSubnet3RouteTableD98824C7": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "VpcPrivateSubnet3RouteTableAssociation16BDDC43": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet3RouteTableD98824C7" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet3SubnetF258B56E" + } + } + }, + "VpcPrivateSubnet3DefaultRoute94B74F0D": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet3NATGateway7640CD1D" + }, + "RouteTableId": { + "Ref": "VpcPrivateSubnet3RouteTableD98824C7" + } + } + }, + "VpcIGWD7BA715C": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/Vpc" + } + ] + } + }, + "VpcVPCGWBF912B6E": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "InternetGatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "al2023CachedInstanceSecurityGroup2719C9BA": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "cdk-ec2-machine-image-cached/al2023Cached/InstanceSecurityGroup", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1" + } + ], + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/al2023Cached" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "al2023CachedInstanceRoleD76E1DF5": { + "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": "cdk-ec2-machine-image-cached/al2023Cached" + } + ] + } + }, + "al2023CachedInstanceProfileD264357E": { + "Type": "AWS::IAM::InstanceProfile", + "Properties": { + "Roles": [ + { + "Ref": "al2023CachedInstanceRoleD76E1DF5" + } + ] + } + }, + "al2023Cached1FFF710B": { + "Type": "AWS::EC2::Instance", + "Properties": { + "AvailabilityZone": "test-region-1a", + "IamInstanceProfile": { + "Ref": "al2023CachedInstanceProfileD264357E" + }, + "ImageId": "dummy-value-for-/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64", + "InstanceType": "t2.nano", + "SecurityGroupIds": [ + { + "Fn::GetAtt": [ + "al2023CachedInstanceSecurityGroup2719C9BA", + "GroupId" + ] + } + ], + "SubnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/al2023Cached" + } + ], + "UserData": { + "Fn::Base64": "#!/bin/bash" + } + }, + "DependsOn": [ + "al2023CachedInstanceRoleD76E1DF5" + ] + }, + "al2023CachedScopeInstanceSecurityGroupADC3C195": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "cdk-ec2-machine-image-cached/al2023CachedScope/InstanceSecurityGroup", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1" + } + ], + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/al2023CachedScope" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "al2023CachedScopeInstanceRoleB7C63F12": { + "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": "cdk-ec2-machine-image-cached/al2023CachedScope" + } + ] + } + }, + "al2023CachedScopeInstanceProfileD8064966": { + "Type": "AWS::IAM::InstanceProfile", + "Properties": { + "Roles": [ + { + "Ref": "al2023CachedScopeInstanceRoleB7C63F12" + } + ] + } + }, + "al2023CachedScopeF8E30E37": { + "Type": "AWS::EC2::Instance", + "Properties": { + "AvailabilityZone": "test-region-1a", + "IamInstanceProfile": { + "Ref": "al2023CachedScopeInstanceProfileD8064966" + }, + "ImageId": "dummy-value-for-/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64", + "InstanceType": "t2.nano", + "SecurityGroupIds": [ + { + "Fn::GetAtt": [ + "al2023CachedScopeInstanceSecurityGroupADC3C195", + "GroupId" + ] + } + ], + "SubnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cdk-ec2-machine-image-cached/al2023CachedScope" + } + ], + "UserData": { + "Fn::Base64": "#!/bin/bash" + } + }, + "DependsOn": [ + "al2023CachedScopeInstanceRoleB7C63F12" + ] + } + }, + "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-cached.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/cdk.out new file mode 100644 index 0000000000000..2313ab5436501 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"34.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/integ.json new file mode 100644 index 0000000000000..90c551c143d47 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/integ.json @@ -0,0 +1,13 @@ +{ + "enableLookups": true, + "version": "34.0.0", + "testCases": { + "integ-ec2-machine-image-cached/DefaultTest": { + "stacks": [ + "cdk-ec2-machine-image-cached" + ], + "assertionStack": "integ-ec2-machine-image-cached/DefaultTest/DeployAssert", + "assertionStackName": "integec2machineimagecachedDefaultTestDeployAssert24B647BE" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/integec2machineimagecachedDefaultTestDeployAssert24B647BE.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/integec2machineimagecachedDefaultTestDeployAssert24B647BE.assets.json new file mode 100644 index 0000000000000..e729a7bb8fce7 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/integec2machineimagecachedDefaultTestDeployAssert24B647BE.assets.json @@ -0,0 +1,19 @@ +{ + "version": "34.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "integec2machineimagecachedDefaultTestDeployAssert24B647BE.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-cached.js.snapshot/integec2machineimagecachedDefaultTestDeployAssert24B647BE.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/integec2machineimagecachedDefaultTestDeployAssert24B647BE.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-cached.js.snapshot/integec2machineimagecachedDefaultTestDeployAssert24B647BE.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-cached.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/manifest.json new file mode 100644 index 0000000000000..38dd0484a013d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/manifest.json @@ -0,0 +1,374 @@ +{ + "version": "34.0.0", + "artifacts": { + "cdk-ec2-machine-image-cached.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "cdk-ec2-machine-image-cached.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "cdk-ec2-machine-image-cached": { + "type": "aws:cloudformation:stack", + "environment": "aws://12345678/test-region", + "properties": { + "templateFile": "cdk-ec2-machine-image-cached.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-deploy-role-12345678-test-region", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-cfn-exec-role-12345678-test-region", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-12345678-test-region/18035a5c59b3c622a6f952b627e53ba58bcfc4f09c0ba6b55886e25644395ce6.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "cdk-ec2-machine-image-cached.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-lookup-role-12345678-test-region", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "cdk-ec2-machine-image-cached.assets" + ], + "metadata": { + "/cdk-ec2-machine-image-cached/Vpc/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Vpc8378EB38" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1Subnet5C2D37C4" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1RouteTable6C95E38E" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1RouteTableAssociation97140677" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1DefaultRoute3DA9E72A" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet1/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1EIPD7E02669" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet1/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1NATGateway4D7517AA" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2Subnet691E08A3" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2RouteTable94F7E489" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2RouteTableAssociationDD5762D8" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2DefaultRoute97F91067" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet2/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2EIP3C605A87" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet2/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2NATGateway9182C01D" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet3/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet3SubnetBE12F0B6" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet3/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet3RouteTable93458DBB" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet3/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet3RouteTableAssociation1F1EDF02" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet3/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet3DefaultRoute4697774F" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet3/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet3EIP3A666A23" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PublicSubnet3/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet3NATGateway7640CD1D" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1Subnet536B997A" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1RouteTableB2C5B500" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1RouteTableAssociation70C59FA6" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1DefaultRouteBE02A9ED" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2Subnet3788AAA1" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2RouteTableA678073B" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2RouteTableAssociationA89CAD56" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2DefaultRoute060D2087" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet3SubnetF258B56E" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet3RouteTableD98824C7" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet3RouteTableAssociation16BDDC43" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet3DefaultRoute94B74F0D" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/IGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcIGWD7BA715C" + } + ], + "/cdk-ec2-machine-image-cached/Vpc/VPCGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcVPCGWBF912B6E" + } + ], + "/cdk-ec2-machine-image-cached/al2023Cached/InstanceSecurityGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "al2023CachedInstanceSecurityGroup2719C9BA" + } + ], + "/cdk-ec2-machine-image-cached/al2023Cached/InstanceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "al2023CachedInstanceRoleD76E1DF5" + } + ], + "/cdk-ec2-machine-image-cached/al2023Cached/InstanceProfile": [ + { + "type": "aws:cdk:logicalId", + "data": "al2023CachedInstanceProfileD264357E" + } + ], + "/cdk-ec2-machine-image-cached/al2023Cached/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "al2023Cached1FFF710B" + } + ], + "/cdk-ec2-machine-image-cached/al2023CachedScope/InstanceSecurityGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "al2023CachedScopeInstanceSecurityGroupADC3C195" + } + ], + "/cdk-ec2-machine-image-cached/al2023CachedScope/InstanceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "al2023CachedScopeInstanceRoleB7C63F12" + } + ], + "/cdk-ec2-machine-image-cached/al2023CachedScope/InstanceProfile": [ + { + "type": "aws:cdk:logicalId", + "data": "al2023CachedScopeInstanceProfileD8064966" + } + ], + "/cdk-ec2-machine-image-cached/al2023CachedScope/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "al2023CachedScopeF8E30E37" + } + ], + "/cdk-ec2-machine-image-cached/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/cdk-ec2-machine-image-cached/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "cdk-ec2-machine-image-cached" + }, + "integec2machineimagecachedDefaultTestDeployAssert24B647BE.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "integec2machineimagecachedDefaultTestDeployAssert24B647BE.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "integec2machineimagecachedDefaultTestDeployAssert24B647BE": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "integec2machineimagecachedDefaultTestDeployAssert24B647BE.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": [ + "integec2machineimagecachedDefaultTestDeployAssert24B647BE.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": [ + "integec2machineimagecachedDefaultTestDeployAssert24B647BE.assets" + ], + "metadata": { + "/integ-ec2-machine-image-cached/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integ-ec2-machine-image-cached/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integ-ec2-machine-image-cached/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + }, + "missing": [ + { + "key": "ssm:account=12345678:parameterName=/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64:region=test-region", + "provider": "ssm", + "props": { + "account": "12345678", + "region": "test-region", + "parameterName": "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64", + "lookupRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-lookup-role-12345678-test-region" + } + }, + { + "key": "ssm:account=12345678:additionalCacheKey=extraKey:parameterName=/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64:region=test-region", + "provider": "ssm", + "props": { + "account": "12345678", + "region": "test-region", + "parameterName": "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64", + "additionalCacheKey": "extraKey", + "lookupRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-lookup-role-12345678-test-region" + } + } + ] +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/tree.json new file mode 100644 index 0000000000000..ec51bfe019314 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.js.snapshot/tree.json @@ -0,0 +1,1300 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "cdk-ec2-machine-image-cached": { + "id": "cdk-ec2-machine-image-cached", + "path": "cdk-ec2-machine-image-cached", + "children": { + "Vpc": { + "id": "Vpc", + "path": "cdk-ec2-machine-image-cached/Vpc", + "children": { + "Resource": { + "id": "Resource", + "path": "cdk-ec2-machine-image-cached/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": "cdk-ec2-machine-image-cached/Vpc" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPC", + "version": "0.0.0" + } + }, + "PublicSubnet1": { + "id": "PublicSubnet1", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "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": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "cdk-ec2-machine-image-cached/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": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "routeTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet1/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet1EIPD7E02669", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/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": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "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": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "cdk-ec2-machine-image-cached/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": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "routeTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet2/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet2EIP3C605A87", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + }, + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/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": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3", + "children": { + "Subnet": { + "id": "Subnet", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "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": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "cdk-ec2-machine-image-cached/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": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "routeTableId": { + "Ref": "VpcPublicSubnet3RouteTable93458DBB" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "cdk-ec2-machine-image-cached/Vpc/PublicSubnet3/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet3EIP3A666A23", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "VpcPublicSubnet3SubnetBE12F0B6" + }, + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/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": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "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": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "cdk-ec2-machine-image-cached/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": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VpcPublicSubnet1NATGateway4D7517AA" + }, + "routeTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + } + } + }, + "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": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "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": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "cdk-ec2-machine-image-cached/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": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VpcPublicSubnet2NATGateway9182C01D" + }, + "routeTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + } + } + }, + "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": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3", + "children": { + "Subnet": { + "id": "Subnet", + "path": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "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": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "cdk-ec2-machine-image-cached/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": "cdk-ec2-machine-image-cached/Vpc/PrivateSubnet3/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VpcPublicSubnet3NATGateway7640CD1D" + }, + "routeTableId": { + "Ref": "VpcPrivateSubnet3RouteTableD98824C7" + } + } + }, + "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": "cdk-ec2-machine-image-cached/Vpc/IGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::InternetGateway", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/Vpc" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInternetGateway", + "version": "0.0.0" + } + }, + "VPCGW": { + "id": "VPCGW", + "path": "cdk-ec2-machine-image-cached/Vpc/VPCGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCGatewayAttachment", + "aws:cdk:cloudformation:props": { + "internetGatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCGatewayAttachment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.Vpc", + "version": "0.0.0" + } + }, + "al2023Cached": { + "id": "al2023Cached", + "path": "cdk-ec2-machine-image-cached/al2023Cached", + "children": { + "InstanceSecurityGroup": { + "id": "InstanceSecurityGroup", + "path": "cdk-ec2-machine-image-cached/al2023Cached/InstanceSecurityGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "cdk-ec2-machine-image-cached/al2023Cached/InstanceSecurityGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "cdk-ec2-machine-image-cached/al2023Cached/InstanceSecurityGroup", + "securityGroupEgress": [ + { + "cidrIp": "0.0.0.0/0", + "description": "Allow all outbound traffic by default", + "ipProtocol": "-1" + } + ], + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/al2023Cached" + } + ], + "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": "cdk-ec2-machine-image-cached/al2023Cached/InstanceRole", + "children": { + "ImportInstanceRole": { + "id": "ImportInstanceRole", + "path": "cdk-ec2-machine-image-cached/al2023Cached/InstanceRole/ImportInstanceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "cdk-ec2-machine-image-cached/al2023Cached/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": "cdk-ec2-machine-image-cached/al2023Cached" + } + ] + } + }, + "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": "cdk-ec2-machine-image-cached/al2023Cached/InstanceProfile", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::InstanceProfile", + "aws:cdk:cloudformation:props": { + "roles": [ + { + "Ref": "al2023CachedInstanceRoleD76E1DF5" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnInstanceProfile", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "cdk-ec2-machine-image-cached/al2023Cached/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Instance", + "aws:cdk:cloudformation:props": { + "availabilityZone": "test-region-1a", + "iamInstanceProfile": { + "Ref": "al2023CachedInstanceProfileD264357E" + }, + "imageId": "dummy-value-for-/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64", + "instanceType": "t2.nano", + "securityGroupIds": [ + { + "Fn::GetAtt": [ + "al2023CachedInstanceSecurityGroup2719C9BA", + "GroupId" + ] + } + ], + "subnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + }, + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/al2023Cached" + } + ], + "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" + } + }, + "al2023CachedScope": { + "id": "al2023CachedScope", + "path": "cdk-ec2-machine-image-cached/al2023CachedScope", + "children": { + "InstanceSecurityGroup": { + "id": "InstanceSecurityGroup", + "path": "cdk-ec2-machine-image-cached/al2023CachedScope/InstanceSecurityGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "cdk-ec2-machine-image-cached/al2023CachedScope/InstanceSecurityGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "cdk-ec2-machine-image-cached/al2023CachedScope/InstanceSecurityGroup", + "securityGroupEgress": [ + { + "cidrIp": "0.0.0.0/0", + "description": "Allow all outbound traffic by default", + "ipProtocol": "-1" + } + ], + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/al2023CachedScope" + } + ], + "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": "cdk-ec2-machine-image-cached/al2023CachedScope/InstanceRole", + "children": { + "ImportInstanceRole": { + "id": "ImportInstanceRole", + "path": "cdk-ec2-machine-image-cached/al2023CachedScope/InstanceRole/ImportInstanceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "cdk-ec2-machine-image-cached/al2023CachedScope/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": "cdk-ec2-machine-image-cached/al2023CachedScope" + } + ] + } + }, + "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": "cdk-ec2-machine-image-cached/al2023CachedScope/InstanceProfile", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::InstanceProfile", + "aws:cdk:cloudformation:props": { + "roles": [ + { + "Ref": "al2023CachedScopeInstanceRoleB7C63F12" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnInstanceProfile", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "cdk-ec2-machine-image-cached/al2023CachedScope/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Instance", + "aws:cdk:cloudformation:props": { + "availabilityZone": "test-region-1a", + "iamInstanceProfile": { + "Ref": "al2023CachedScopeInstanceProfileD8064966" + }, + "imageId": "dummy-value-for-/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64", + "instanceType": "t2.nano", + "securityGroupIds": [ + { + "Fn::GetAtt": [ + "al2023CachedScopeInstanceSecurityGroupADC3C195", + "GroupId" + ] + } + ], + "subnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + }, + "tags": [ + { + "key": "Name", + "value": "cdk-ec2-machine-image-cached/al2023CachedScope" + } + ], + "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" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "cdk-ec2-machine-image-cached/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "cdk-ec2-machine-image-cached/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "integ-ec2-machine-image-cached": { + "id": "integ-ec2-machine-image-cached", + "path": "integ-ec2-machine-image-cached", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "integ-ec2-machine-image-cached/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "integ-ec2-machine-image-cached/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "integ-ec2-machine-image-cached/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "integ-ec2-machine-image-cached/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "integ-ec2-machine-image-cached/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.2.70" + } + } + }, + "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-cached.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.ts new file mode 100644 index 0000000000000..0439c1f11f40a --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.machine-image-cached.ts @@ -0,0 +1,53 @@ +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import { + Stack, + StackProps, + App, + aws_ec2 as ec2, +} from 'aws-cdk-lib'; +import { Construct } from 'constructs'; +import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api'; + +// we associate this stack with an explicit environment since this is required by the +// environmental context provider used with `cachedInContext`. CDK_INTEG_XXX are set +// when producing the .expected file and CDK_DEFAULT_XXX is passed in through from +// the CLI in actual deployment. +const env = { + account: process.env.CDK_INTEG_ACCOUNT || process.env.CDK_DEFAULT_ACCOUNT, + region: process.env.CDK_INTEG_REGION || process.env.CDK_DEFAULT_REGION, +}; + +export class TestCase extends Stack { + constructor(scope: Construct, id: string, props?: StackProps) { + super(scope, id, props); + this.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false); + const vpc = new ec2.Vpc(this, 'Vpc'); + + const instanceType = ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.NANO); + + new ec2.Instance(this, 'al2023Cached', { + instanceType, + machineImage: ec2.MachineImage.latestAmazonLinux2023({ + cachedInContext: true, + }), + vpc, + }); + + new ec2.Instance(this, 'al2023CachedScope', { + instanceType, + machineImage: ec2.MachineImage.latestAmazonLinux2023({ + cachedInContext: true, + additionalCacheKey: 'extraKey', + }), + vpc, + }); + } +} + +const app = new App(); +const stack = new TestCase(app, 'cdk-ec2-machine-image-cached', { env }); +new IntegTest(app, 'integ-ec2-machine-image-cached', { + testCases: [stack], + enableLookups: true, +}); +app.synth(); diff --git a/packages/aws-cdk-lib/aws-ec2/README.md b/packages/aws-cdk-lib/aws-ec2/README.md index 870af1a2ad993..6cc5316e02dac 100644 --- a/packages/aws-cdk-lib/aws-ec2/README.md +++ b/packages/aws-cdk-lib/aws-ec2/README.md @@ -882,7 +882,10 @@ If the security group ID is known and configuration details are unknown, use met const sg = ec2.SecurityGroup.fromLookupById(this, 'SecurityGroupLookup', 'sg-1234'); ``` -The result of `SecurityGroup.fromLookupByName` and `SecurityGroup.fromLookupById` operations will be written to a file called `cdk.context.json`. You must commit this file to source control so that the lookup values are available in non-privileged environments such as CI build steps, and to ensure your template builds are repeatable. +The result of `SecurityGroup.fromLookupByName` and `SecurityGroup.fromLookupById` operations will be +written to a file called `cdk.context.json`. +You must commit this file to source control so that the lookup values are available in non-privileged +environments such as CI build steps, and to ensure your template builds are repeatable. ### Cross Stack Connections @@ -969,6 +972,13 @@ examples of images you might want to use: > `cdk.context.json`, or use the `cdk context` command. For more information, see > [Runtime Context](https://docs.aws.amazon.com/cdk/latest/guide/context.html) in the CDK > developer guide. +> +> To customize the cache key, use the `additionalCacheKey` parameter. +> This allows you to have multiple lookups with the same parameters +> cache their values separately. This can be useful if you want to +> scope the context variable to a construct (ie, using `additionalCacheKey: this.node.path`), +> so that if the value in the cache needs to be updated, it does not need to be updated +> for all constructs at the same time. > > `MachineImage.genericLinux()`, `MachineImage.genericWindows()` will use `CfnMapping` in > an agnostic stack. @@ -1361,6 +1371,31 @@ new ec2.Instance(this, 'LatestAl2023', { // context cache is turned on by default machineImage: new ec2.AmazonLinux2023ImageSsmParameter(), }); + +// or +new ec2.Instance(this, 'LatestAl2023', { + vpc, + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE), + machineImage: ec2.MachineImage.latestAmazonLinux2023({ + cachedInContext: true, + // creates a distinct context variable for this image, instead of resolving to the same + // value anywhere this lookup is done in your app + additionalCacheKey: this.node.path, + }), +}); + +// or +new ec2.Instance(this, 'LatestAl2023', { + vpc, + instanceType: ec2.InstanceType.of(ec2.InstanceClass.C7G, ec2.InstanceSize.LARGE), + // context cache is turned on by default + machineImage: new ec2.AmazonLinux2023ImageSsmParameter({ + // creates a distinct context variable for this image, instead of resolving to the same + // value anywhere this lookup is done in your app + additionalCacheKey: this.node.path, + }), +}); + ``` #### Kernel Versions 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 index 640ea8d4b0052..b1b64815e5c00 100644 --- 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 @@ -84,6 +84,7 @@ export class AmazonLinux2022ImageSsmParameter extends AmazonLinuxImageSsmParamet super({ parameterName: AmazonLinux2022ImageSsmParameter.ssmParameterName(props), cachedInContext: props.cachedInContext, + additionalCacheKey: props.additionalCacheKey, 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 index 2983bbaee3cc6..99a1ef71d8795 100644 --- 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 @@ -83,6 +83,7 @@ export class AmazonLinux2023ImageSsmParameter extends AmazonLinuxImageSsmParamet super({ parameterName: AmazonLinux2023ImageSsmParameter.ssmParameterName(props), cachedInContext: props.cachedInContext, + additionalCacheKey: props.additionalCacheKey, 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 index a037a61a80851..b1bf191157c50 100644 --- 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 @@ -103,6 +103,7 @@ export class AmazonLinux2ImageSsmParameter extends AmazonLinuxImageSsmParameterB super({ parameterName: AmazonLinux2ImageSsmParameter.ssmParameterName(props), cachedInContext: props.cachedInContext, + additionalCacheKey: props.additionalCacheKey, 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 index 8404c541aeb1e..77248e35b869a 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/common.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/common.ts @@ -46,6 +46,13 @@ export interface AmazonLinuxImageSsmParameterBaseOptions { */ readonly cachedInContext?: boolean; + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; + /** * Initial user data * @@ -71,7 +78,7 @@ export abstract class AmazonLinuxImageSsmParameterBase implements IMachineImage } getImage(scope: Construct): MachineImageConfig { - const imageId = lookupImage(scope, this.cachedInContext, this.props.parameterName); + const imageId = lookupImage(scope, this.cachedInContext, this.props.parameterName, this.props.additionalCacheKey); const osType = OperatingSystemType.LINUX; return { diff --git a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts index 3119db5dadcdc..61ab74b056633 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts @@ -302,6 +302,13 @@ export interface SsmParameterImageOptions { */ readonly cachedInContext?: boolean; + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; + /** * The version of the SSM parameter. * @@ -328,7 +335,7 @@ class GenericSsmParameterImage implements IMachineImage { * Return the image to use in the given context */ public getImage(scope: Construct): MachineImageConfig { - const imageId = lookupImage(scope, this.props.cachedInContext, this.parameterName); + const imageId = lookupImage(scope, this.props.cachedInContext ?? false, this.parameterName, this.props.additionalCacheKey); const osType = this.props.os ?? OperatingSystemType.LINUX; return { @@ -459,6 +466,13 @@ export interface AmazonLinuxImageProps { * @default false */ readonly cachedInContext?: boolean; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } /** @@ -529,7 +543,7 @@ export class AmazonLinuxImage extends GenericSSMParameterImage { * Return the image to use in the given context */ public getImage(scope: Construct): MachineImageConfig { - const imageId = lookupImage(scope, this.cachedInContext, this.parameterName); + const imageId = lookupImage(scope, this.cachedInContext, this.parameterName, this.props.additionalCacheKey); const osType = OperatingSystemType.LINUX; return { @@ -666,11 +680,16 @@ export class GenericWindowsImage implements IMachineImage { * will be used on future runs. 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. + * If `props.additionalCacheKey` is set, the context key uses that value as a discriminator + * rather than the cached value being global across all lookups. */ export class LookupMachineImage implements IMachineImage { constructor(private readonly props: LookupMachineImageProps) { } + /** + * Return the correct image + */ public getImage(scope: Construct): MachineImageConfig { // Need to know 'windows' or not before doing the query to return the right // osType for the dummy value, so might as well add it to the filter. @@ -689,6 +708,7 @@ export class LookupMachineImage implements IMachineImage { filters, } as cxschema.AmiContextQuery, dummyValue: 'ami-1234', + additionalCacheKey: this.props.additionalCacheKey, }).value as cxapi.AmiContextResponse; if (typeof value !== 'string') { @@ -742,5 +762,12 @@ export interface LookupMachineImageProps { * @default - Empty user data appropriate for the platform type */ readonly userData?: UserData; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } 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 index a2da997c80e63..fbe6c7ab4c9c7 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/utils.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/utils.ts @@ -1,9 +1,9 @@ import { Construct } from 'constructs'; import * as ssm from '../../../aws-ssm'; -export function lookupImage(scope: Construct, cachedInContext: boolean | undefined, parameterName: string) { +export function lookupImage(scope: Construct, cachedInContext: boolean | undefined, parameterName: string, additionalCacheKey?: string) { return cachedInContext - ? ssm.StringParameter.valueFromLookup(scope, parameterName) + ? ssm.StringParameter.valueFromLookup(scope, parameterName, undefined, { additionalCacheKey }) : 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 0744fd735d6ec..f44adc088ab9b 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 @@ -210,6 +210,29 @@ test('cached lookups of Amazon Linux', () => { ]); }); +test('cached lookups of Amazon Linux linked to scope', () => { + // WHEN + const ami = ec2.MachineImage.latestAmazonLinux({ cachedInContext: true, additionalCacheKey: 'extraKey' }).getImage(stack).imageId; + + // THEN + expect(ami).toEqual('dummy-value-for-/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2'); + expect(app.synth().manifest.missing).toEqual([ + { + key: 'ssm:account=1234:additionalCacheKey=extraKey:parameterName=/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2: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/amzn-ami-hvm-x86_64-gp2', + additionalCacheKey: 'extraKey', + dummyValue: 'dummy-value-for-/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2', + ignoreErrorOnMissingContext: false, + }, + provider: 'ssm', + }, + ]); +}); + test('cached lookups of Amazon Linux 2', () => { // WHEN const ami = ec2.MachineImage.latestAmazonLinux({ diff --git a/packages/aws-cdk-lib/aws-ecs/README.md b/packages/aws-cdk-lib/aws-ecs/README.md index 20aa257b443a6..6c2e012066316 100644 --- a/packages/aws-cdk-lib/aws-ecs/README.md +++ b/packages/aws-cdk-lib/aws-ecs/README.md @@ -169,6 +169,22 @@ const autoScalingGroup = new autoscaling.AutoScalingGroup(this, 'ASG', { }); ``` +To customize the cache key, use the `additionalCacheKey` parameter. +This allows you to have multiple lookups with the same parameters +cache their values separately. This can be useful if you want to +scope the context variable to a construct (ie, using `additionalCacheKey: this.node.path`), +so that if the value in the cache needs to be updated, it does not need to be updated +for all constructs at the same time. + +```ts +declare const vpc: ec2.Vpc; +const autoScalingGroup = new autoscaling.AutoScalingGroup(this, 'ASG', { + machineImage: ecs.EcsOptimizedImage.amazonLinux({ cachedInContext: true, additionalCacheKey: this.node.path }), + vpc, + instanceType: new ec2.InstanceType('t2.micro'), +}); +``` + To use `LaunchTemplate` with `AsgCapacityProvider`, make sure to specify the `userData` in the `LaunchTemplate`: ```ts diff --git a/packages/aws-cdk-lib/aws-ecs/lib/amis.ts b/packages/aws-cdk-lib/aws-ecs/lib/amis.ts index 57812212db28c..7b82d7dcb5017 100644 --- a/packages/aws-cdk-lib/aws-ecs/lib/amis.ts +++ b/packages/aws-cdk-lib/aws-ecs/lib/amis.ts @@ -98,6 +98,13 @@ export interface EcsOptimizedAmiProps { * @default false */ readonly cachedInContext?: boolean; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } /* @@ -115,6 +122,7 @@ export class EcsOptimizedAmi implements ec2.IMachineImage { private readonly amiParameterName: string; private readonly cachedInContext: boolean; + private readonly additionalCacheKey?: string; /** * Constructs a new instance of the EcsOptimizedAmi class. @@ -153,13 +161,18 @@ export class EcsOptimizedAmi implements ec2.IMachineImage { + (this.windowsVersion ? 'image_id' : 'recommended/image_id'); this.cachedInContext = props?.cachedInContext ?? false; + this.additionalCacheKey = props?.additionalCacheKey; + + if (this.additionalCacheKey !== undefined && !this.cachedInContext) { + throw new UnscopedValidationError('"additionalCacheKey" was set but "cachedInContext" is false, so it will have no effect'); + } } /** * Return the correct image */ public getImage(scope: Construct): ec2.MachineImageConfig { - const ami = lookupImage(scope, this.cachedInContext, this.amiParameterName); + const ami = lookupImage(scope, this.cachedInContext, this.amiParameterName, this.additionalCacheKey); const osType = this.windowsVersion ? ec2.OperatingSystemType.WINDOWS : ec2.OperatingSystemType.LINUX; return { @@ -194,6 +207,13 @@ export interface EcsOptimizedImageOptions { * @default false */ readonly cachedInContext?: boolean; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } /** @@ -254,6 +274,7 @@ export class EcsOptimizedImage implements ec2.IMachineImage { private readonly amiParameterName: string; private readonly cachedInContext: boolean; + private readonly additionalCacheKey?: string; /** * Constructs a new instance of the EcsOptimizedAmi class. @@ -281,14 +302,19 @@ export class EcsOptimizedImage implements ec2.IMachineImage { + (this.hwType === AmiHardwareType.NEURON ? 'inf/' : '') + (this.windowsVersion ? 'image_id' : 'recommended/image_id'); - this.cachedInContext = props?.cachedInContext ?? false; + this.cachedInContext = props.cachedInContext ?? false; + this.additionalCacheKey = props.additionalCacheKey; + + if (this.additionalCacheKey !== undefined && !this.cachedInContext) { + throw new UnscopedValidationError('"additionalCacheKey" was set but "cachedInContext" is false, so it will have no effect'); + } } /** * Return the correct image */ public getImage(scope: Construct): ec2.MachineImageConfig { - const ami = lookupImage(scope, this.cachedInContext, this.amiParameterName); + const ami = lookupImage(scope, this.cachedInContext, this.amiParameterName, this.additionalCacheKey); const osType = this.windowsVersion ? ec2.OperatingSystemType.WINDOWS : ec2.OperatingSystemType.LINUX; return { @@ -359,6 +385,13 @@ export interface BottleRocketImageProps { * @default false */ readonly cachedInContext?: boolean; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } /** @@ -385,6 +418,8 @@ export class BottleRocketImage implements ec2.IMachineImage { private readonly cachedInContext: boolean; + private readonly additionalCacheKey?: string; + /** * Constructs a new instance of the BottleRocketImage class. */ @@ -396,13 +431,18 @@ export class BottleRocketImage implements ec2.IMachineImage { this.amiParameterName = `/aws/service/bottlerocket/${this.variant}/${this.architecture}/latest/image_id`; this.cachedInContext = props.cachedInContext ?? false; + this.additionalCacheKey = props.additionalCacheKey; + + if (this.additionalCacheKey !== undefined && !this.cachedInContext) { + throw new UnscopedValidationError('"additionalCacheKey" was set but "cachedInContext" is false, so it will have no effect'); + } } /** * Return the correct image */ public getImage(scope: Construct): ec2.MachineImageConfig { - const ami = lookupImage(scope, this.cachedInContext, this.amiParameterName); + const ami = lookupImage(scope, this.cachedInContext, this.amiParameterName, this.additionalCacheKey); return { imageId: ami, @@ -418,8 +458,8 @@ Object.defineProperty(BottleRocketImage.prototype, BR_IMAGE_SYMBOL, { writable: false, }); -function lookupImage(scope: Construct, cachedInContext: boolean | undefined, parameterName: string) { +function lookupImage(scope: Construct, cachedInContext: boolean | undefined, parameterName: string, additionalCacheKey?: string) { return cachedInContext - ? ssm.StringParameter.valueFromLookup(scope, parameterName) + ? ssm.StringParameter.valueFromLookup(scope, parameterName, undefined, { additionalCacheKey }) : ssm.StringParameter.valueForTypedStringParameterV2(scope, parameterName, ssm.ParameterValueType.AWS_EC2_IMAGE_ID); } diff --git a/packages/aws-cdk-lib/aws-ssm/README.md b/packages/aws-cdk-lib/aws-ssm/README.md index 9083df8353699..1672787a628c7 100644 --- a/packages/aws-cdk-lib/aws-ssm/README.md +++ b/packages/aws-cdk-lib/aws-ssm/README.md @@ -57,6 +57,22 @@ This method uses AWS API calls to lookup the value from SSM during synthesis. const stringValue = ssm.StringParameter.valueFromLookup(this, '/My/Public/Parameter'); ``` +The result of the `StringParameter.valueFromLookup()` operation will be written to a file +called `cdk.context.json`. You must commit this file to source control so +that the lookup values are available in non-privileged environments such +as CI build steps, and to ensure your template builds are repeatable. + +To customize the cache key, use the `additionalCacheKey` property of the `options` parameter. +This allows you to have multiple lookups with the same parameters +cache their values separately. This can be useful if you want to +scope the context variable to a construct (ie, using `additionalCacheKey: this.node.path`), +so that if the value in the cache needs to be updated, it does not need to be updated +for all constructs at the same time. + +```ts +const stringValue = ssm.StringParameter.valueFromLookup(this, '/My/Public/Parameter', undefined, { additionalCacheKey: this.node.path }); +``` + When using `valueFromLookup` an initial value of 'dummy-value-for-${parameterName}' (`dummy-value-for-/My/Public/Parameter` in the above example) is returned prior to the lookup being performed. This can lead to errors if you are using this diff --git a/packages/aws-cdk-lib/aws-ssm/lib/parameter.ts b/packages/aws-cdk-lib/aws-ssm/lib/parameter.ts index 21bdc3a0fe993..c620f669a78c6 100644 --- a/packages/aws-cdk-lib/aws-ssm/lib/parameter.ts +++ b/packages/aws-cdk-lib/aws-ssm/lib/parameter.ts @@ -458,6 +458,18 @@ export interface SecureStringParameterAttributes extends CommonStringParameterAt } +/** + * Additional properties for looking up an existing StringParameter + */ +export interface StringParameterLookupOptions { + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; +} + /** * Creates a new String SSM Parameter. * @resource AWS::SSM::Parameter @@ -585,12 +597,16 @@ export class StringParameter extends ParameterBase implements IStringParameter { * and the ContextProvider will be told NOT to raise an error on synthesis * if the SSM Parameter is not found in the account at synth time. */ - public static valueFromLookup(scope: Construct, parameterName: string, defaultValue?: string): string { + + public static valueFromLookup(scope: Construct, parameterName: string, defaultValue?: string, options?: StringParameterLookupOptions): string { const value = ContextProvider.getValue(scope, { provider: cxschema.ContextProvider.SSM_PARAMETER_PROVIDER, - props: { parameterName }, + props: { + parameterName, + }, dummyValue: defaultValue || `dummy-value-for-${parameterName}`, mustExist: defaultValue === undefined, + additionalCacheKey: options?.additionalCacheKey, }).value; return value; diff --git a/packages/aws-cdk-lib/aws-ssm/test/parameter.test.ts b/packages/aws-cdk-lib/aws-ssm/test/parameter.test.ts index 5440521fb52de..422961806ad79 100644 --- a/packages/aws-cdk-lib/aws-ssm/test/parameter.test.ts +++ b/packages/aws-cdk-lib/aws-ssm/test/parameter.test.ts @@ -760,6 +760,32 @@ test('fromLookup will return defaultValue when it is provided', () => { ]); }); +test('fromLookup will use the SSM context provider to read value during synthesis when linked to scope', () => { + // GIVEN + const app = new cdk.App({ context: { [cxapi.NEW_STYLE_STACK_SYNTHESIS_CONTEXT]: false } }); + const stack = new cdk.Stack(app, 'my-staq', { env: { region: 'us-east-1', account: '12344' } }); + + // WHEN + const value = ssm.StringParameter.valueFromLookup(stack, 'my-param-name', undefined, { additionalCacheKey: 'extraKey' }); + + // THEN + expect(value).toEqual('dummy-value-for-my-param-name'); + expect(app.synth().manifest.missing).toEqual([ + { + key: 'ssm:account=12344:additionalCacheKey=extraKey:parameterName=my-param-name:region=us-east-1', + props: { + account: '12344', + region: 'us-east-1', + parameterName: 'my-param-name', + dummyValue: 'dummy-value-for-my-param-name', + ignoreErrorOnMissingContext: false, + additionalCacheKey: 'extraKey', + }, + provider: 'ssm', + }, + ]); +}); + describe('from string list parameter', () => { testDeprecated('valueForTypedStringParameter list type throws error', () => { // GIVEN diff --git a/packages/aws-cdk-lib/core/lib/context-provider.ts b/packages/aws-cdk-lib/core/lib/context-provider.ts index 474737d6f2aac..c3bc0b528e1f9 100644 --- a/packages/aws-cdk-lib/core/lib/context-provider.ts +++ b/packages/aws-cdk-lib/core/lib/context-provider.ts @@ -25,6 +25,13 @@ export interface GetContextKeyOptions { * @default true */ readonly includeEnvironment?: boolean; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } /** @@ -129,9 +136,11 @@ export class ContextProvider { public static getKey(scope: Construct, options: GetContextKeyOptions): GetContextKeyResult { const stack = Stack.of(scope); - const props = options.includeEnvironment ?? true - ? { account: stack.account, region: stack.region, ...options.props } - : (options.props ?? {}); + const props = { + ...(options.includeEnvironment ?? true ? { account: stack.account, region: stack.region } : {}), + ...(options.additionalCacheKey ? { additionalCacheKey: options.additionalCacheKey } : {}), + ...options.props, + }; if (Object.values(props).find(x => Token.isUnresolved(x))) { throw new ValidationError( @@ -180,6 +189,7 @@ export class ContextProvider { // cloud assembly still has the original name, which is somewhat wrong // because it's not about missing context. ignoreErrorOnMissingContext, + ...(options.additionalCacheKey ? { additionalCacheKey: options.additionalCacheKey } : {}), ...props, };