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 24fb39b3605c0..7d40760fc56a6 100644 --- a/packages/aws-cdk-lib/aws-ec2/README.md +++ b/packages/aws-cdk-lib/aws-ec2/README.md @@ -571,6 +571,10 @@ 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` parameter. +This can be useful if you want to scope the context variable to a construct +(eg, using `additionalCacheKey: this.node.path`). + Here's how `Vpc.fromLookup()` can be used: [importing existing VPCs](test/integ.import-default-vpc.lit.ts) @@ -810,7 +814,13 @@ 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. + +To customize the cache key use the `additionalCacheKey` parameter. +This can be useful if you want to scope the context variable to a construct (eg, using `additionalCacheKey: this.node.path`). ### Cross Stack Connections @@ -897,6 +907,10 @@ 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 can be useful if you want to scope the context variable to a construct +> (eg, using `additionalCacheKey: this.node.path`). > > `MachineImage.genericLinux()`, `MachineImage.genericWindows()` will use `CfnMapping` in > an agnostic stack. @@ -1237,6 +1251,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 06f40de63bae0..fb55c06cb0ed1 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 a598c2c3a6d5b..8043c6923a48c 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 df99fea0afbee..faf45d3d6496a 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. @@ -687,6 +706,7 @@ export class LookupMachineImage implements IMachineImage { props: { owners: this.props.owners, filters, + additionalCacheKey: this.props.additionalCacheKey, } as cxschema.AmiContextQuery, dummyValue: 'ami-1234', }).value as cxapi.AmiContextResponse; @@ -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..34c96d3ebbc93 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, additionalCacheKey) : ssm.StringParameter.valueForTypedStringParameterV2(scope, parameterName, ssm.ParameterValueType.AWS_EC2_IMAGE_ID); } diff --git a/packages/aws-cdk-lib/aws-ec2/lib/security-group.ts b/packages/aws-cdk-lib/aws-ec2/lib/security-group.ts index e774c1f9de3af..10a11c706e887 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/security-group.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/security-group.ts @@ -369,22 +369,22 @@ export class SecurityGroup extends SecurityGroupBase { * * @deprecated Use `fromLookupById()` instead */ - public static fromLookup(scope: Construct, id: string, securityGroupId: string) { - return this.fromLookupAttributes(scope, id, { securityGroupId }); + public static fromLookup(scope: Construct, id: string, securityGroupId: string, additionalCacheKey?: string) { + return this.fromLookupAttributes(scope, id, { securityGroupId, additionalCacheKey }); } /** * Look up a security group by id. */ - public static fromLookupById(scope: Construct, id: string, securityGroupId: string) { - return this.fromLookupAttributes(scope, id, { securityGroupId }); + public static fromLookupById(scope: Construct, id: string, securityGroupId: string, additionalCacheKey?: string) { + return this.fromLookupAttributes(scope, id, { securityGroupId, additionalCacheKey }); } /** * Look up a security group by name. */ - public static fromLookupByName(scope: Construct, id: string, securityGroupName: string, vpc: IVpc) { - return this.fromLookupAttributes(scope, id, { securityGroupName, vpc }); + public static fromLookupByName(scope: Construct, id: string, securityGroupName: string, vpc: IVpc, additionalCacheKey?: string) { + return this.fromLookupAttributes(scope, id, { securityGroupName, vpc, additionalCacheKey }); } /** @@ -444,6 +444,7 @@ export class SecurityGroup extends SecurityGroupBase { securityGroupId: options.securityGroupId, securityGroupName: options.securityGroupName, vpcId: options.vpc?.vpcId, + additionalCacheKey: options.additionalCacheKey, }, dummyValue: { securityGroupId: 'sg-12345678', @@ -843,4 +844,11 @@ interface SecurityGroupLookupOptions { * @default Don't filter on VPC */ readonly vpc?: IVpc; + + /** + * 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/vpc-lookup.ts b/packages/aws-cdk-lib/aws-ec2/lib/vpc-lookup.ts index 42ee55969d97f..5344d888e3305 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/vpc-lookup.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/vpc-lookup.ts @@ -75,4 +75,11 @@ export interface VpcLookupOptions { * @default the account id of the parent stack */ readonly ownerAccountId?: string; + + /** + * 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/vpc.ts b/packages/aws-cdk-lib/aws-ec2/lib/vpc.ts index f466af74ce9d0..c0d0a314694f1 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/vpc.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/vpc.ts @@ -1351,6 +1351,7 @@ export class Vpc extends VpcBase { returnAsymmetricSubnets: true, returnVpnGateways: options.returnVpnGateways, subnetGroupNameTag: options.subnetGroupNameTag, + additionalCacheKey: options.additionalCacheKey, } as cxschema.VpcContextQuery, dummyValue: undefined, }).value; 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 ac2eef24611c9..3728a1ae3df53 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 @@ -207,6 +207,27 @@ 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', + }, + 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 43ac276abe91c..88397ac3db53f 100644 --- a/packages/aws-cdk-lib/aws-ecs/README.md +++ b/packages/aws-cdk-lib/aws-ecs/README.md @@ -156,6 +156,19 @@ const autoScalingGroup = new autoscaling.AutoScalingGroup(this, 'ASG', { }); ``` +To customize the cache key use the `additionalCacheKey` parameter. +This can be useful if you want to scope the context variable to a construct +(eg, using `additionalCacheKey: this.node.path`). + +```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 d655daa020aa2..cdfa45dc2ae4a 100644 --- a/packages/aws-cdk-lib/aws-ecs/lib/amis.ts +++ b/packages/aws-cdk-lib/aws-ecs/lib/amis.ts @@ -97,6 +97,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; } /* @@ -114,6 +121,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. @@ -152,13 +160,14 @@ export class EcsOptimizedAmi implements ec2.IMachineImage { + (this.windowsVersion ? 'image_id' : 'recommended/image_id'); this.cachedInContext = props?.cachedInContext ?? false; + this.additionalCacheKey = props?.additionalCacheKey; } /** * 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 { @@ -193,6 +202,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; } /** @@ -253,6 +269,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. @@ -280,14 +297,15 @@ 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; } /** * 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 { @@ -358,6 +376,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; } /** @@ -384,6 +409,8 @@ export class BottleRocketImage implements ec2.IMachineImage { private readonly cachedInContext: boolean; + private readonly additionalCacheKey?: string; + /** * Constructs a new instance of the BottleRocketImage class. */ @@ -395,13 +422,14 @@ 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; } /** * 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, @@ -417,8 +445,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, additionalCacheKey) : ssm.StringParameter.valueForTypedStringParameterV2(scope, parameterName, ssm.ParameterValueType.AWS_EC2_IMAGE_ID); } diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md index d5b3673bbe8ea..d431c2577f519 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md @@ -591,6 +591,15 @@ following lookup methods: - `NetworkListener.fromLookup(options)` - Look up a network load balancer listener. +The result of a `fromLookup()` 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` parameter. +This can be useful if you want to scope the context variable to a construct +(eg, using `additionalCacheKey: this.node.path`). + ### Load Balancer lookup options You may look up a load balancer by ARN or by associated tags. When you look a @@ -620,7 +629,18 @@ const loadBalancer = elbv2.ApplicationLoadBalancer.fromLookup(this, 'ALB', { }); ``` -## Load Balancer Listener lookup options +**Look up a Application Load Balancer by ARN, customizing the cache key** + +```ts +const loadBalancer = elbv2.ApplicationLoadBalancer.fromLookup(this, 'ALB', { + loadBalancerArn: 'arn:aws:elasticloadbalancing:us-east-2:123456789012:loadbalancer/app/my-load-balancer/1234567890123456', + additionalCacheKey: this.node.path, +}); +``` + +** + +### Load Balancer Listener lookup options You may look up a load balancer listener by the following criteria: @@ -668,6 +688,17 @@ const listener = elbv2.NetworkListener.fromLookup(this, 'ALBListener', { }); ``` +**Look up a Listener by associated Load Balancer, Port, and Protocol** + +```ts +const listener = elbv2.ApplicationListener.fromLookup(this, 'ALBListener', { + loadBalancerArn: 'arn:aws:elasticloadbalancing:us-east-2:123456789012:loadbalancer/app/my-load-balancer/1234567890123456', + listenerProtocol: elbv2.ApplicationProtocol.HTTPS, + listenerPort: 443, + additionalCacheKey: this.node.path, +}); +``` + ## Metrics You may create metrics for Load Balancers and Target Groups through the `metrics` attribute: diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-listener.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-listener.ts index bbb7d02f34214..44a5eaf5ecb65 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-listener.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-listener.ts @@ -134,7 +134,11 @@ export class ApplicationListener extends BaseListener implements IApplicationLis /** * Look up an ApplicationListener. */ - public static fromLookup(scope: Construct, id: string, options: ApplicationListenerLookupOptions): IApplicationListener { + public static fromLookup( + scope: Construct, + id: string, + options: ApplicationListenerLookupOptions, + ): IApplicationListener { if (Token.isUnresolved(options.listenerArn)) { throw new Error('All arguments to look up a load balancer listener must be concrete (no Tokens)'); } diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-load-balancer.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-load-balancer.ts index 4ddb300b9b92f..ffdfb0408a736 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-load-balancer.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-load-balancer.ts @@ -75,7 +75,11 @@ export class ApplicationLoadBalancer extends BaseLoadBalancer implements IApplic /** * Look up an application load balancer. */ - public static fromLookup(scope: Construct, id: string, options: ApplicationLoadBalancerLookupOptions): IApplicationLoadBalancer { + public static fromLookup( + scope: Construct, + id: string, + options: ApplicationLoadBalancerLookupOptions, + ): IApplicationLoadBalancer { const props = BaseLoadBalancer._queryContextProvider(scope, { userOptions: options, loadBalancerType: cxschema.LoadBalancerType.APPLICATION, diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts index 7f07aecd9f935..a879c64987d2b 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts @@ -176,7 +176,11 @@ export class NetworkLoadBalancer extends BaseLoadBalancer implements INetworkLoa /** * Looks up the network load balancer. */ - public static fromLookup(scope: Construct, id: string, options: NetworkLoadBalancerLookupOptions): INetworkLoadBalancer { + public static fromLookup( + scope: Construct, + id: string, + options: NetworkLoadBalancerLookupOptions, + ): INetworkLoadBalancer { const props = BaseLoadBalancer._queryContextProvider(scope, { userOptions: options, loadBalancerType: cxschema.LoadBalancerType.NETWORK, diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/base-listener.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/base-listener.ts index 72dad641eb2d7..40aedb0be887a 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/base-listener.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/base-listener.ts @@ -27,6 +27,13 @@ export interface BaseListenerLookupOptions { * @default - does not filter by listener port */ readonly listenerPort?: number; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } /** @@ -97,6 +104,7 @@ export abstract class BaseListener extends Resource implements IListener { loadBalancerArn: options.userOptions.loadBalancerArn, loadBalancerTags: cxschemaTags, loadBalancerType: options.loadBalancerType, + additionalCacheKey: options.userOptions.additionalCacheKey, } as cxschema.LoadBalancerListenerContextQuery, dummyValue: { // eslint-disable-next-line @aws-cdk/no-literal-partition diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts index 404895225af4d..b024a741ff777 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts @@ -98,6 +98,13 @@ export interface BaseLoadBalancerLookupOptions { * @default - does not match load balancers by tags */ readonly loadBalancerTags?: Record; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } /** @@ -124,7 +131,10 @@ export abstract class BaseLoadBalancer extends Resource { * Queries the load balancer context provider for load balancer info. * @internal */ - protected static _queryContextProvider(scope: Construct, options: LoadBalancerQueryContextProviderOptions) { + protected static _queryContextProvider( + scope: Construct, + options: LoadBalancerQueryContextProviderOptions, + ) { if (Token.isUnresolved(options.userOptions.loadBalancerArn) || Object.values(options.userOptions.loadBalancerTags ?? {}).some(Token.isUnresolved)) { throw new Error('All arguments to look up a load balancer must be concrete (no Tokens)'); @@ -141,6 +151,7 @@ export abstract class BaseLoadBalancer extends Resource { loadBalancerArn: options.userOptions.loadBalancerArn, loadBalancerTags: cxschemaTags, loadBalancerType: options.loadBalancerType, + additionalCacheKey: options.userOptions.additionalCacheKey, } as cxschema.LoadBalancerContextQuery, dummyValue: { ipAddressType: cxapi.LoadBalancerIpAddressType.DUAL_STACK, diff --git a/packages/aws-cdk-lib/aws-kms/README.md b/packages/aws-cdk-lib/aws-kms/README.md index a039288e468eb..9644970824d3e 100644 --- a/packages/aws-cdk-lib/aws-kms/README.md +++ b/packages/aws-cdk-lib/aws-kms/README.md @@ -96,6 +96,10 @@ 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` parameter. +This can be useful if you want to scope the context variable to a construct +(eg, using `additionalCacheKey: this.node.path`). + Here's how `Key.fromLookup()` can be used: ```ts diff --git a/packages/aws-cdk-lib/aws-kms/lib/key-lookup.ts b/packages/aws-cdk-lib/aws-kms/lib/key-lookup.ts index 0ac02b2185d49..ab79fe2bcd645 100644 --- a/packages/aws-cdk-lib/aws-kms/lib/key-lookup.ts +++ b/packages/aws-cdk-lib/aws-kms/lib/key-lookup.ts @@ -8,4 +8,11 @@ export interface KeyLookupOptions { * Must be in the format `alias/`. */ readonly aliasName: string; + + /** + * 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-kms/lib/key.ts b/packages/aws-cdk-lib/aws-kms/lib/key.ts index ba5d33c2988e9..3b0638d36f725 100644 --- a/packages/aws-cdk-lib/aws-kms/lib/key.ts +++ b/packages/aws-cdk-lib/aws-kms/lib/key.ts @@ -660,6 +660,7 @@ export class Key extends KeyBase { provider: cxschema.ContextProvider.KEY_PROVIDER, props: { aliasName: options.aliasName, + additionalCacheKey: options.additionalCacheKey, } as cxschema.KeyContextQuery, dummyValue: { keyId: '1234abcd-12ab-34cd-56ef-1234567890ab', diff --git a/packages/aws-cdk-lib/aws-route53/README.md b/packages/aws-cdk-lib/aws-route53/README.md index 2f7737d65a3b5..396d9488e8596 100644 --- a/packages/aws-cdk-lib/aws-route53/README.md +++ b/packages/aws-cdk-lib/aws-route53/README.md @@ -327,6 +327,22 @@ route53.HostedZone.fromLookup(this, 'MyZone', { }); ``` +The result of the `HostedZone.fromLookup()` 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` parameter. +This can be useful if you want to scope the context variable to a construct +(eg, using `additionalCacheKey: this.node.path`). + +```ts +route53.HostedZone.fromLookup(this, 'MyZone', { + domainName: 'example.com', + additionalCacheKey: this.node.path, +}); +``` + `HostedZone.fromLookup` requires an environment to be configured. Check out the [documentation](https://docs.aws.amazon.com/cdk/latest/guide/environments.html) for more documentation and examples. CDK automatically looks into your `~/.aws/config` file for the `[default]` profile. diff --git a/packages/aws-cdk-lib/aws-route53/lib/hosted-zone-provider.ts b/packages/aws-cdk-lib/aws-route53/lib/hosted-zone-provider.ts index 99f7132112e07..4e9fcefff9373 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/hosted-zone-provider.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/hosted-zone-provider.ts @@ -23,4 +23,11 @@ export interface HostedZoneProviderProps { * @default - No VPC ID */ readonly vpcId?: string; + + /** + * 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-route53/test/hosted-zone-provider.test.ts b/packages/aws-cdk-lib/aws-route53/test/hosted-zone-provider.test.ts index 94a42bdf85920..a0b355a15b322 100644 --- a/packages/aws-cdk-lib/aws-route53/test/hosted-zone-provider.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/hosted-zone-provider.test.ts @@ -41,7 +41,7 @@ describe('hosted zone provider', () => { expect(zoneRef.hostedZoneId).toEqual(fakeZoneId); }); - test('HostedZoneProvider will return context values if available when using plain hosted zone id', () => { + test('HostedZoneProvider will return context values if available', () => { // GIVEN const app = new cdk.App(); const stack = new cdk.Stack(app, 'TestStack', { @@ -81,5 +81,43 @@ describe('hosted zone provider', () => { expect(fakeZoneId).toEqual(zoneId); }); + + test('HostedZoneProvider will return context values if available with additional cache key', () => { + // GIVEN + const app = new cdk.App(); + const stack = new cdk.Stack(app, 'TestStack', { + env: { account: '12345', region: 'us-east-1' }, + }); + const filter = { domainName: 'test.com', additionalCacheKey: 'cacheKey' }; + + HostedZone.fromLookup(stack, 'Ref', filter); + + const assembly = app.synth().getStackArtifact(stack.artifactId); + const missing = assembly.assembly.manifest.missing!; + expect(missing && missing.length === 1).toEqual(true); + + const fakeZoneId = '11111111111111'; + const fakeZone = { + Id: `/hostedzone/${fakeZoneId}`, + Name: 'example.com.', + CallerReference: 'TestLates-PublicZo-OESZPDFV7G6A', + Config: { + Comment: 'CDK created', + PrivateZone: false, + }, + ResourceRecordSetCount: 3, + }; + + const stack2 = new cdk.Stack(undefined, 'TestStack', { + env: { account: '12345', region: 'us-east-1' }, + }); + stack2.node.setContext(missing[0].key, fakeZone); + + // WHEN + const zoneRef = HostedZone.fromLookup(stack2, 'MyZoneProvider', filter); + + // THEN + expect(zoneRef.hostedZoneId).toEqual(fakeZoneId); + }); }); }); diff --git a/packages/aws-cdk-lib/aws-ssm/README.md b/packages/aws-cdk-lib/aws-ssm/README.md index e70e424f0573b..cc421dcd90a02 100644 --- a/packages/aws-cdk-lib/aws-ssm/README.md +++ b/packages/aws-cdk-lib/aws-ssm/README.md @@ -58,6 +58,19 @@ 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` parameter. +This can be useful if you want to scope the context variable to a construct +(eg, using `additionalCacheKey: this.node.path`). + +```ts +const stringValue = ssm.StringParameter.valueFromLookup(this, '/My/Public/Parameter', 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 1972b605665fc..b188091139902 100644 --- a/packages/aws-cdk-lib/aws-ssm/lib/parameter.ts +++ b/packages/aws-cdk-lib/aws-ssm/lib/parameter.ts @@ -532,10 +532,13 @@ export class StringParameter extends ParameterBase implements IStringParameter { * Requires that the stack this scope is defined in will have explicit * account/region information. Otherwise, it will fail during synthesis. */ - public static valueFromLookup(scope: Construct, parameterName: string): string { + public static valueFromLookup(scope: Construct, parameterName: string, additionalCacheKey?: string): string { const value = ContextProvider.getValue(scope, { provider: cxschema.ContextProvider.SSM_PARAMETER_PROVIDER, - props: { parameterName }, + props: { + parameterName, + additionalCacheKey, + }, dummyValue: `dummy-value-for-${parameterName}`, }).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 8e0c20abd426d..c712b2b797ba7 100644 --- a/packages/aws-cdk-lib/aws-ssm/test/parameter.test.ts +++ b/packages/aws-cdk-lib/aws-ssm/test/parameter.test.ts @@ -652,6 +652,30 @@ test('fromLookup will use the SSM context provider to read value during synthesi ]); }); +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', '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', + additionalCacheKey: 'extraKey', + }, + provider: 'ssm', + }, + ]); +}); + describe('from string list parameter', () => { testDeprecated('valueForTypedStringParameter list type throws error', () => { // GIVEN diff --git a/packages/aws-cdk-lib/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts b/packages/aws-cdk-lib/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts index bd35d023dfe69..b1975064dc755 100644 --- a/packages/aws-cdk-lib/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts +++ b/packages/aws-cdk-lib/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts @@ -92,6 +92,13 @@ export interface AmiContextQuery { * Filters to DescribeImages call */ readonly filters: {[key: string]: string[]}; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } /** @@ -245,6 +252,13 @@ export interface VpcContextQuery { * @default true */ readonly returnVpnGateways?: boolean; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } /** @@ -331,6 +345,13 @@ export interface LoadBalancerContextQuery extends LoadBalancerFilter { * @default - None */ readonly lookupRoleArn?: string; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } /** @@ -406,6 +427,13 @@ export interface LoadBalancerListenerContextQuery extends LoadBalancerFilter { * @default - does not filter by a listener port */ readonly listenerPort?: number; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } /** @@ -449,6 +477,13 @@ export interface SecurityGroupContextQuery { * @default - None */ readonly vpcId?: string; + + /** + * Adds an additional discriminator to the `cdk.context.json` cache key. + * + * @default - no additional cache key + */ + readonly additionalCacheKey?: string; } /** @@ -476,6 +511,13 @@ export interface KeyContextQuery { * Alias name used to search the Key */ readonly aliasName: string; + + /** + * 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/cloud-assembly-schema/schema/cloud-assembly.schema.json b/packages/aws-cdk-lib/cloud-assembly-schema/schema/cloud-assembly.schema.json index 279dfbe369073..cf3436205fc97 100644 --- a/packages/aws-cdk-lib/cloud-assembly-schema/schema/cloud-assembly.schema.json +++ b/packages/aws-cdk-lib/cloud-assembly-schema/schema/cloud-assembly.schema.json @@ -576,6 +576,10 @@ "type": "string" } } + }, + "additionalCacheKey": { + "description": "Adds an additional discriminator to the `cdk.context.json` cache key. (Default - no additional cache key)", + "type": "string" } }, "required": [ @@ -704,6 +708,10 @@ "returnVpnGateways": { "description": "Whether to populate the `vpnGatewayId` field of the `VpcContextResponse`,\nwhich contains the VPN Gateway ID, if one exists. You can explicitly\ndisable this in order to avoid the lookup if you know the VPC does not have\na VPN Gatway attached. (Default true)", "type": "boolean" + }, + "additionalCacheKey": { + "description": "Adds an additional discriminator to the `cdk.context.json` cache key. (Default - no additional cache key)", + "type": "string" } }, "required": [ @@ -755,6 +763,10 @@ "description": "The ARN of the role that should be used to look up the missing values (Default - None)", "type": "string" }, + "additionalCacheKey": { + "description": "Adds an additional discriminator to the `cdk.context.json` cache key. (Default - no additional cache key)", + "type": "string" + }, "loadBalancerType": { "$ref": "#/definitions/LoadBalancerType", "description": "Filter load balancers by their type" @@ -821,6 +833,10 @@ "description": "Filter listeners by listener port (Default - does not filter by a listener port)", "type": "number" }, + "additionalCacheKey": { + "description": "Adds an additional discriminator to the `cdk.context.json` cache key. (Default - no additional cache key)", + "type": "string" + }, "loadBalancerType": { "$ref": "#/definitions/LoadBalancerType", "description": "Filter load balancers by their type" @@ -870,6 +886,10 @@ "vpcId": { "description": "VPC ID (Default - None)", "type": "string" + }, + "additionalCacheKey": { + "description": "Adds an additional discriminator to the `cdk.context.json` cache key. (Default - no additional cache key)", + "type": "string" } }, "required": [ @@ -896,6 +916,10 @@ "aliasName": { "description": "Alias name used to search the Key", "type": "string" + }, + "additionalCacheKey": { + "description": "Adds an additional discriminator to the `cdk.context.json` cache key. (Default - no additional cache key)", + "type": "string" } }, "required": [ diff --git a/packages/aws-cdk-lib/cloud-assembly-schema/schema/cloud-assembly.version.json b/packages/aws-cdk-lib/cloud-assembly-schema/schema/cloud-assembly.version.json index 1f0068d32659a..079dd58c72d69 100644 --- a/packages/aws-cdk-lib/cloud-assembly-schema/schema/cloud-assembly.version.json +++ b/packages/aws-cdk-lib/cloud-assembly-schema/schema/cloud-assembly.version.json @@ -1 +1 @@ -{"version":"36.0.0"} \ No newline at end of file +{"version":"37.0.0"} \ No newline at end of file