From 9e421e5b25c43cb9f49ebfb29751a42d73b87e6a Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Wed, 21 Apr 2021 18:29:24 +0200 Subject: [PATCH] chore(ssm): latest parameter value with dynamic reference (#14205) CloudFormation now allows referencing the latest Systems Manager parameter values in templates without specifying parameter versions using dynamic references. Remove the "trick" with the `Parameter` using a default value. See https://aws.amazon.com/about-aws/whats-new/2021/04/now-reference-latest-aws-systems-manager-parameter-values-in-aws-cloudformation-templates-without-specifying-parameter-versions/ ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../integ.all-service-addons.expected.json | 18 +- .../test/test.firelens.ts | 6 +- .../test/auto-scaling-group.test.ts | 8 +- .../test/integ.amazonlinux2.expected.json | 10 +- ...nteg.asg-metrics-collections.expected.json | 661 ------------------ ...g.asg-w-classic-loadbalancer.expected.json | 10 +- .../test/integ.asg-w-elbv2.expected.json | 10 +- .../test/integ.custom-scaling.expected.json | 10 +- .../test/integ.external-role.expected.json | 10 +- .../test/integ.spot-instances.expected.json | 10 +- .../test/scheduled-action.test.ts | 6 - .../test/compute-environment.test.ts | 4 +- .../integ.deployment-group.expected.json | 10 +- .../aws-ec2/test/bastion-host.test.ts | 8 +- ...teg.bastion-host-arm-support.expected.json | 10 +- .../test/integ.bastion-host.expected.json | 10 +- .../test/integ.instance-init.expected.json | 10 +- ....instance-multipart-userdata.expected.json | 10 +- .../aws-ec2/test/integ.instance.expected.json | 10 +- .../aws-ec2/test/launch-template.test.ts | 9 +- ...on-load-balanced-ecs-service.expected.json | 10 +- ...integ.scheduled-ecs-task.lit.expected.json | 10 +- .../integ.app-mesh-proxy-config.expected.json | 10 +- .../test/ec2/integ.bottlerocket.expected.json | 10 +- .../test/ec2/integ.clb-host-nw.expected.json | 10 +- ...nteg.cloudmap-container-port.expected.json | 10 +- .../ec2/integ.environment-file.expected.json | 10 +- .../integ.firelens-s3-config.expected.json | 16 +- .../test/ec2/integ.lb-awsvpc-nw.expected.json | 10 +- .../test/ec2/integ.lb-bridge-nw.expected.json | 10 +- .../test/ec2/integ.sd-awsvpc-nw.expected.json | 10 +- .../test/ec2/integ.sd-bridge-nw.expected.json | 10 +- .../test/ec2/integ.spot-drain.expected.json | 14 +- .../@aws-cdk/aws-ecs/test/ecs-cluster.test.ts | 118 +--- .../integ.firelens-cloudwatch.expected.json | 10 +- .../integ.eks-cluster.defaults.expected.json | 16 +- ...eks-cluster.kubectl-disabled.expected.json | 10 +- .../test/integ.eks-cluster.lit.expected.json | 16 +- .../test/integ.eks-helm.lit.expected.json | 20 +- .../test/integ.eks-kubectl.lit.expected.json | 16 +- .../test/integ.eks-spot.expected.json | 20 +- .../aws-eks-legacy/test/test.cluster.ts | 10 +- .../test/integ.eks-cluster.expected.json | 40 +- .../@aws-cdk/aws-eks/test/test.cluster.ts | 76 +- .../integ.event-ec2-task.lit.expected.json | 10 +- .../integ.lustre-file-system.expected.json | 10 +- .../integ.globalaccelerator.expected.json | 12 +- packages/@aws-cdk/aws-ssm/lib/parameter.ts | 13 +- ...g.parameter-store-string.lit.expected.json | 10 +- .../test/test.parameter-store-string.ts | 12 +- .../@aws-cdk/aws-ssm/test/test.parameter.ts | 46 +- .../test/ecs/integ.ec2-run-task.expected.json | 10 +- .../test/ecs/integ.ec2-task.expected.json | 10 +- packages/aws-cdk/lib/api/deploy-stack.ts | 8 +- .../aws-cdk/test/api/deploy-stack.test.ts | 28 +- 55 files changed, 175 insertions(+), 1326 deletions(-) delete mode 100644 packages/@aws-cdk/aws-autoscaling/test/integ.asg-metrics-collections.expected.json diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.all-service-addons.expected.json b/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.all-service-addons.expected.json index 47ba97c3ee10d..a3ca1613f58a7 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.all-service-addons.expected.json +++ b/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.all-service-addons.expected.json @@ -765,9 +765,7 @@ "FirelensConfiguration": { "Type": "fluentbit" }, - "Image": { - "Ref": "SsmParameterValueawsserviceawsforfluentbitlatestC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "Image": "{{resolve:ssm:/aws/service/aws-for-fluent-bit/latest}}", "LogConfiguration": { "LogDriver": "awslogs", "Options": { @@ -1634,9 +1632,7 @@ "FirelensConfiguration": { "Type": "fluentbit" }, - "Image": { - "Ref": "SsmParameterValueawsserviceawsforfluentbitlatestC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "Image": "{{resolve:ssm:/aws/service/aws-for-fluent-bit/latest}}", "LogConfiguration": { "LogDriver": "awslogs", "Options": { @@ -2622,9 +2618,7 @@ "FirelensConfiguration": { "Type": "fluentbit" }, - "Image": { - "Ref": "SsmParameterValueawsserviceawsforfluentbitlatestC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "Image": "{{resolve:ssm:/aws/service/aws-for-fluent-bit/latest}}", "LogConfiguration": { "LogDriver": "awslogs", "Options": { @@ -3484,12 +3478,6 @@ } } }, - "Parameters": { - "SsmParameterValueawsserviceawsforfluentbitlatestC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/aws-for-fluent-bit/latest" - } - }, "Outputs": { "greeterloadbalancerdnsoutput": { "Value": { diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/test/test.firelens.ts b/packages/@aws-cdk-containers/ecs-service-extensions/test/test.firelens.ts index a6011a2caabf6..897cc7e9eb892 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/test/test.firelens.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/test/test.firelens.ts @@ -80,9 +80,7 @@ export = { FirelensConfiguration: { Type: 'fluentbit', }, - Image: { - Ref: 'SsmParameterValueawsserviceawsforfluentbitlatestC96584B6F00A464EAD1953AFF4B05118Parameter', - }, + Image: '{{resolve:ssm:/aws/service/aws-for-fluent-bit/latest}}', LogConfiguration: { LogDriver: 'awslogs', Options: { @@ -119,4 +117,4 @@ export = { test.done(); }, -}; \ No newline at end of file +}; diff --git a/packages/@aws-cdk/aws-autoscaling/test/auto-scaling-group.test.ts b/packages/@aws-cdk/aws-autoscaling/test/auto-scaling-group.test.ts index 8e97792860e8f..9e7b31b6ff59f 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/auto-scaling-group.test.ts +++ b/packages/@aws-cdk/aws-autoscaling/test/auto-scaling-group.test.ts @@ -22,12 +22,6 @@ nodeunitShim({ }); expect(stack).toMatch({ - 'Parameters': { - 'SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter': { - 'Type': 'AWS::SSM::Parameter::Value', - 'Default': '/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2', - }, - }, 'Resources': { 'MyFleetInstanceSecurityGroup774E8234': { 'Type': 'AWS::EC2::SecurityGroup', @@ -89,7 +83,7 @@ nodeunitShim({ 'IamInstanceProfile': { 'Ref': 'MyFleetInstanceProfile70A58496', }, - 'ImageId': { 'Ref': 'SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter' }, + 'ImageId': '{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2}}', 'InstanceType': 'm4.micro', 'SecurityGroups': [ { diff --git a/packages/@aws-cdk/aws-autoscaling/test/integ.amazonlinux2.expected.json b/packages/@aws-cdk/aws-autoscaling/test/integ.amazonlinux2.expected.json index af9c16803e320..36f25fecba0a8 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/integ.amazonlinux2.expected.json +++ b/packages/@aws-cdk/aws-autoscaling/test/integ.amazonlinux2.expected.json @@ -423,9 +423,7 @@ "FleetLaunchConfig59F79D36": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "FleetInstanceProfileC6192A66" @@ -477,11 +475,5 @@ } } } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling/test/integ.asg-metrics-collections.expected.json b/packages/@aws-cdk/aws-autoscaling/test/integ.asg-metrics-collections.expected.json deleted file mode 100644 index ba27663a60ccd..0000000000000 --- a/packages/@aws-cdk/aws-autoscaling/test/integ.asg-metrics-collections.expected.json +++ /dev/null @@ -1,661 +0,0 @@ -{ - "Resources": { - "VPCB9E5F0B4": { - "Type": "AWS::EC2::VPC", - "Properties": { - "CidrBlock": "10.0.0.0/16", - "EnableDnsHostnames": true, - "EnableDnsSupport": true, - "InstanceTenancy": "default", - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC" - } - ] - } - }, - "VPCPublicSubnet1SubnetB4246D30": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "CidrBlock": "10.0.0.0/19", - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "AvailabilityZone": "test-region-1a", - "MapPublicIpOnLaunch": true, - "Tags": [ - { - "Key": "aws-cdk:subnet-name", - "Value": "Public" - }, - { - "Key": "aws-cdk:subnet-type", - "Value": "Public" - }, - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PublicSubnet1" - } - ] - } - }, - "VPCPublicSubnet1RouteTableFEE4B781": { - "Type": "AWS::EC2::RouteTable", - "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PublicSubnet1" - } - ] - } - }, - "VPCPublicSubnet1RouteTableAssociation0B0896DC": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "Properties": { - "RouteTableId": { - "Ref": "VPCPublicSubnet1RouteTableFEE4B781" - }, - "SubnetId": { - "Ref": "VPCPublicSubnet1SubnetB4246D30" - } - } - }, - "VPCPublicSubnet1DefaultRoute91CEF279": { - "Type": "AWS::EC2::Route", - "Properties": { - "RouteTableId": { - "Ref": "VPCPublicSubnet1RouteTableFEE4B781" - }, - "DestinationCidrBlock": "0.0.0.0/0", - "GatewayId": { - "Ref": "VPCIGWB7E252D3" - } - }, - "DependsOn": [ - "VPCVPCGW99B986DC" - ] - }, - "VPCPublicSubnet1EIP6AD938E8": { - "Type": "AWS::EC2::EIP", - "Properties": { - "Domain": "vpc", - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PublicSubnet1" - } - ] - } - }, - "VPCPublicSubnet1NATGatewayE0556630": { - "Type": "AWS::EC2::NatGateway", - "Properties": { - "AllocationId": { - "Fn::GetAtt": [ - "VPCPublicSubnet1EIP6AD938E8", - "AllocationId" - ] - }, - "SubnetId": { - "Ref": "VPCPublicSubnet1SubnetB4246D30" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PublicSubnet1" - } - ] - } - }, - "VPCPublicSubnet2Subnet74179F39": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "CidrBlock": "10.0.32.0/19", - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "AvailabilityZone": "test-region-1b", - "MapPublicIpOnLaunch": true, - "Tags": [ - { - "Key": "aws-cdk:subnet-name", - "Value": "Public" - }, - { - "Key": "aws-cdk:subnet-type", - "Value": "Public" - }, - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PublicSubnet2" - } - ] - } - }, - "VPCPublicSubnet2RouteTable6F1A15F1": { - "Type": "AWS::EC2::RouteTable", - "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PublicSubnet2" - } - ] - } - }, - "VPCPublicSubnet2RouteTableAssociation5A808732": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "Properties": { - "RouteTableId": { - "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" - }, - "SubnetId": { - "Ref": "VPCPublicSubnet2Subnet74179F39" - } - } - }, - "VPCPublicSubnet2DefaultRouteB7481BBA": { - "Type": "AWS::EC2::Route", - "Properties": { - "RouteTableId": { - "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" - }, - "DestinationCidrBlock": "0.0.0.0/0", - "GatewayId": { - "Ref": "VPCIGWB7E252D3" - } - }, - "DependsOn": [ - "VPCVPCGW99B986DC" - ] - }, - "VPCPublicSubnet2EIP4947BC00": { - "Type": "AWS::EC2::EIP", - "Properties": { - "Domain": "vpc", - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PublicSubnet2" - } - ] - } - }, - "VPCPublicSubnet2NATGateway3C070193": { - "Type": "AWS::EC2::NatGateway", - "Properties": { - "AllocationId": { - "Fn::GetAtt": [ - "VPCPublicSubnet2EIP4947BC00", - "AllocationId" - ] - }, - "SubnetId": { - "Ref": "VPCPublicSubnet2Subnet74179F39" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PublicSubnet2" - } - ] - } - }, - "VPCPublicSubnet3Subnet631C5E25": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "CidrBlock": "10.0.64.0/19", - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "AvailabilityZone": "test-region-1c", - "MapPublicIpOnLaunch": true, - "Tags": [ - { - "Key": "aws-cdk:subnet-name", - "Value": "Public" - }, - { - "Key": "aws-cdk:subnet-type", - "Value": "Public" - }, - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PublicSubnet3" - } - ] - } - }, - "VPCPublicSubnet3RouteTable98AE0E14": { - "Type": "AWS::EC2::RouteTable", - "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PublicSubnet3" - } - ] - } - }, - "VPCPublicSubnet3RouteTableAssociation427FE0C6": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "Properties": { - "RouteTableId": { - "Ref": "VPCPublicSubnet3RouteTable98AE0E14" - }, - "SubnetId": { - "Ref": "VPCPublicSubnet3Subnet631C5E25" - } - } - }, - "VPCPublicSubnet3DefaultRouteA0D29D46": { - "Type": "AWS::EC2::Route", - "Properties": { - "RouteTableId": { - "Ref": "VPCPublicSubnet3RouteTable98AE0E14" - }, - "DestinationCidrBlock": "0.0.0.0/0", - "GatewayId": { - "Ref": "VPCIGWB7E252D3" - } - }, - "DependsOn": [ - "VPCVPCGW99B986DC" - ] - }, - "VPCPublicSubnet3EIPAD4BC883": { - "Type": "AWS::EC2::EIP", - "Properties": { - "Domain": "vpc", - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PublicSubnet3" - } - ] - } - }, - "VPCPublicSubnet3NATGatewayD3048F5C": { - "Type": "AWS::EC2::NatGateway", - "Properties": { - "AllocationId": { - "Fn::GetAtt": [ - "VPCPublicSubnet3EIPAD4BC883", - "AllocationId" - ] - }, - "SubnetId": { - "Ref": "VPCPublicSubnet3Subnet631C5E25" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PublicSubnet3" - } - ] - } - }, - "VPCPrivateSubnet1Subnet8BCA10E0": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "CidrBlock": "10.0.96.0/19", - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "AvailabilityZone": "test-region-1a", - "MapPublicIpOnLaunch": false, - "Tags": [ - { - "Key": "aws-cdk:subnet-name", - "Value": "Private" - }, - { - "Key": "aws-cdk:subnet-type", - "Value": "Private" - }, - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PrivateSubnet1" - } - ] - } - }, - "VPCPrivateSubnet1RouteTableBE8A6027": { - "Type": "AWS::EC2::RouteTable", - "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PrivateSubnet1" - } - ] - } - }, - "VPCPrivateSubnet1RouteTableAssociation347902D1": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "Properties": { - "RouteTableId": { - "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" - }, - "SubnetId": { - "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" - } - } - }, - "VPCPrivateSubnet1DefaultRouteAE1D6490": { - "Type": "AWS::EC2::Route", - "Properties": { - "RouteTableId": { - "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" - }, - "DestinationCidrBlock": "0.0.0.0/0", - "NatGatewayId": { - "Ref": "VPCPublicSubnet1NATGatewayE0556630" - } - } - }, - "VPCPrivateSubnet2SubnetCFCDAA7A": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "CidrBlock": "10.0.128.0/19", - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "AvailabilityZone": "test-region-1b", - "MapPublicIpOnLaunch": false, - "Tags": [ - { - "Key": "aws-cdk:subnet-name", - "Value": "Private" - }, - { - "Key": "aws-cdk:subnet-type", - "Value": "Private" - }, - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PrivateSubnet2" - } - ] - } - }, - "VPCPrivateSubnet2RouteTable0A19E10E": { - "Type": "AWS::EC2::RouteTable", - "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PrivateSubnet2" - } - ] - } - }, - "VPCPrivateSubnet2RouteTableAssociation0C73D413": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "Properties": { - "RouteTableId": { - "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" - }, - "SubnetId": { - "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" - } - } - }, - "VPCPrivateSubnet2DefaultRouteF4F5CFD2": { - "Type": "AWS::EC2::Route", - "Properties": { - "RouteTableId": { - "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" - }, - "DestinationCidrBlock": "0.0.0.0/0", - "NatGatewayId": { - "Ref": "VPCPublicSubnet2NATGateway3C070193" - } - } - }, - "VPCPrivateSubnet3Subnet3EDCD457": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "CidrBlock": "10.0.160.0/19", - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "AvailabilityZone": "test-region-1c", - "MapPublicIpOnLaunch": false, - "Tags": [ - { - "Key": "aws-cdk:subnet-name", - "Value": "Private" - }, - { - "Key": "aws-cdk:subnet-type", - "Value": "Private" - }, - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PrivateSubnet3" - } - ] - } - }, - "VPCPrivateSubnet3RouteTable192186F8": { - "Type": "AWS::EC2::RouteTable", - "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC/PrivateSubnet3" - } - ] - } - }, - "VPCPrivateSubnet3RouteTableAssociationC28D144E": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "Properties": { - "RouteTableId": { - "Ref": "VPCPrivateSubnet3RouteTable192186F8" - }, - "SubnetId": { - "Ref": "VPCPrivateSubnet3Subnet3EDCD457" - } - } - }, - "VPCPrivateSubnet3DefaultRoute27F311AE": { - "Type": "AWS::EC2::Route", - "Properties": { - "RouteTableId": { - "Ref": "VPCPrivateSubnet3RouteTable192186F8" - }, - "DestinationCidrBlock": "0.0.0.0/0", - "NatGatewayId": { - "Ref": "VPCPublicSubnet3NATGatewayD3048F5C" - } - } - }, - "VPCIGWB7E252D3": { - "Type": "AWS::EC2::InternetGateway", - "Properties": { - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/VPC" - } - ] - } - }, - "VPCVPCGW99B986DC": { - "Type": "AWS::EC2::VPCGatewayAttachment", - "Properties": { - "VpcId": { - "Ref": "VPCB9E5F0B4" - }, - "InternetGatewayId": { - "Ref": "VPCIGWB7E252D3" - } - } - }, - "ASGInstanceSecurityGroup0525485D": { - "Type": "AWS::EC2::SecurityGroup", - "Properties": { - "GroupDescription": "aws-cdk-asg-integ/ASG/InstanceSecurityGroup", - "SecurityGroupEgress": [ - { - "CidrIp": "0.0.0.0/0", - "Description": "Allow all outbound traffic by default", - "IpProtocol": "-1" - } - ], - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/ASG" - } - ], - "VpcId": { - "Ref": "VPCB9E5F0B4" - } - } - }, - "ASGInstanceRoleE263A41B": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": { - "Fn::Join": [ - "", - [ - "ec2.", - { - "Ref": "AWS::URLSuffix" - } - ] - ] - } - } - } - ], - "Version": "2012-10-17" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-asg-integ/ASG" - } - ] - } - }, - "ASGInstanceProfile0A2834D7": { - "Type": "AWS::IAM::InstanceProfile", - "Properties": { - "Roles": [ - { - "Ref": "ASGInstanceRoleE263A41B" - } - ] - } - }, - "ASGLaunchConfigC00AF12B": { - "Type": "AWS::AutoScaling::LaunchConfiguration", - "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, - "InstanceType": "t2.micro", - "IamInstanceProfile": { - "Ref": "ASGInstanceProfile0A2834D7" - }, - "SecurityGroups": [ - { - "Fn::GetAtt": [ - "ASGInstanceSecurityGroup0525485D", - "GroupId" - ] - } - ], - "UserData": { - "Fn::Base64": "#!/bin/bash" - } - }, - "DependsOn": [ - "ASGInstanceRoleE263A41B" - ] - }, - "ASG46ED3070": { - "Type": "AWS::AutoScaling::AutoScalingGroup", - "Properties": { - "MaxSize": "1", - "MinSize": "1", - "LaunchConfigurationName": { - "Ref": "ASGLaunchConfigC00AF12B" - }, - "MetricsCollection": [ - { - "Granularity": "1Minute" - }, - { - "Granularity": "1Minute", - "Metrics": [ - "GroupPendingInstances", - "GroupStandbyInstances", - "GroupTotalInstances" - ] - } - ], - "Tags": [ - { - "Key": "Name", - "PropagateAtLaunch": true, - "Value": "aws-cdk-asg-integ/ASG" - } - ], - "VPCZoneIdentifier": [ - { - "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" - }, - { - "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" - }, - { - "Ref": "VPCPrivateSubnet3Subnet3EDCD457" - } - ] - }, - "UpdatePolicy": { - "AutoScalingScheduledAction": { - "IgnoreUnmodifiedGroupSizeProperties": true - } - } - } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2" - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling/test/integ.asg-w-classic-loadbalancer.expected.json b/packages/@aws-cdk/aws-autoscaling/test/integ.asg-w-classic-loadbalancer.expected.json index 5882016a8f8b2..8bcafeca92ca7 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/integ.asg-w-classic-loadbalancer.expected.json +++ b/packages/@aws-cdk/aws-autoscaling/test/integ.asg-w-classic-loadbalancer.expected.json @@ -603,9 +603,7 @@ "FleetLaunchConfig59F79D36": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "FleetInstanceProfileC6192A66" @@ -749,11 +747,5 @@ "VPCPublicSubnet3DefaultRouteA0D29D46" ] } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling/test/integ.asg-w-elbv2.expected.json b/packages/@aws-cdk/aws-autoscaling/test/integ.asg-w-elbv2.expected.json index 34f240a76559d..9dcd5257d05ef 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/integ.asg-w-elbv2.expected.json +++ b/packages/@aws-cdk/aws-autoscaling/test/integ.asg-w-elbv2.expected.json @@ -444,9 +444,7 @@ "FleetLaunchConfig59F79D36": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "FleetInstanceProfileC6192A66" @@ -677,11 +675,5 @@ } } } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling/test/integ.custom-scaling.expected.json b/packages/@aws-cdk/aws-autoscaling/test/integ.custom-scaling.expected.json index 21457d1ea78e6..bcc87632a5c29 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/integ.custom-scaling.expected.json +++ b/packages/@aws-cdk/aws-autoscaling/test/integ.custom-scaling.expected.json @@ -423,9 +423,7 @@ "FleetLaunchConfig59F79D36": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "FleetInstanceProfileC6192A66" @@ -511,11 +509,5 @@ } } } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling/test/integ.external-role.expected.json b/packages/@aws-cdk/aws-autoscaling/test/integ.external-role.expected.json index 49196dcc8ba93..8a810d98515fe 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/integ.external-role.expected.json +++ b/packages/@aws-cdk/aws-autoscaling/test/integ.external-role.expected.json @@ -576,9 +576,7 @@ "ASGLaunchConfigC00AF12B": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "ASGInstanceProfile0A2834D7" @@ -632,11 +630,5 @@ } } } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling/test/integ.spot-instances.expected.json b/packages/@aws-cdk/aws-autoscaling/test/integ.spot-instances.expected.json index 709737be069fe..bc7b8de6da282 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/integ.spot-instances.expected.json +++ b/packages/@aws-cdk/aws-autoscaling/test/integ.spot-instances.expected.json @@ -423,9 +423,7 @@ "FleetLaunchConfig59F79D36": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "FleetInstanceProfileC6192A66" @@ -477,11 +475,5 @@ } } } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts b/packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts index e5044af33543e..b1043837a4bd4 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts +++ b/packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts @@ -96,12 +96,6 @@ nodeunitShim({ }, }, }, - Parameters: { - SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter: { - Type: 'AWS::SSM::Parameter::Value', - Default: '/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2', - }, - }, }, MatchStyle.SUPERSET); test.done(); diff --git a/packages/@aws-cdk/aws-batch/test/compute-environment.test.ts b/packages/@aws-cdk/aws-batch/test/compute-environment.test.ts index dd18be3f1496c..244b323981002 100644 --- a/packages/@aws-cdk/aws-batch/test/compute-environment.test.ts +++ b/packages/@aws-cdk/aws-batch/test/compute-environment.test.ts @@ -214,9 +214,7 @@ describe('Batch Compute Evironment', () => { AllocationStrategy: batch.AllocationStrategy.BEST_FIT, DesiredvCpus: props.computeResources.desiredvCpus, Ec2KeyPair: props.computeResources.ec2KeyPair, - ImageId: { - Ref: 'SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter', - }, + ImageId: '{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}', InstanceRole: { 'Fn::GetAtt': [ props.computeResources.instanceRole ? 'InstanceProfile' : '', diff --git a/packages/@aws-cdk/aws-codedeploy/test/server/integ.deployment-group.expected.json b/packages/@aws-cdk/aws-codedeploy/test/server/integ.deployment-group.expected.json index c5ae20b9ac145..189c58b36eec0 100644 --- a/packages/@aws-cdk/aws-codedeploy/test/server/integ.deployment-group.expected.json +++ b/packages/@aws-cdk/aws-codedeploy/test/server/integ.deployment-group.expected.json @@ -639,9 +639,7 @@ "ASGLaunchConfigC00AF12B": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2}}", "InstanceType": "m5.large", "IamInstanceProfile": { "Ref": "ASGInstanceProfile0A2834D7" @@ -877,11 +875,5 @@ } } } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2/test/bastion-host.test.ts b/packages/@aws-cdk/aws-ec2/test/bastion-host.test.ts index f774cf9aaa3d8..8d080b37bc442 100644 --- a/packages/@aws-cdk/aws-ec2/test/bastion-host.test.ts +++ b/packages/@aws-cdk/aws-ec2/test/bastion-host.test.ts @@ -97,9 +97,7 @@ nodeunitShim({ // THEN expect(stack).to(haveResource('AWS::EC2::Instance', { - ImageId: { - Ref: 'SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter', - }, + ImageId: '{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2}}', })); test.done(); @@ -117,9 +115,7 @@ nodeunitShim({ // THEN expect(stack).to(haveResource('AWS::EC2::Instance', { - ImageId: { - Ref: 'SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter', - }, + ImageId: '{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-arm64-gp2}}', })); test.done(); diff --git a/packages/@aws-cdk/aws-ec2/test/integ.bastion-host-arm-support.expected.json b/packages/@aws-cdk/aws-ec2/test/integ.bastion-host-arm-support.expected.json index 81f4ae3377d40..d9ed4091ca53a 100644 --- a/packages/@aws-cdk/aws-ec2/test/integ.bastion-host-arm-support.expected.json +++ b/packages/@aws-cdk/aws-ec2/test/integ.bastion-host-arm-support.expected.json @@ -611,9 +611,7 @@ "IamInstanceProfile": { "Ref": "BastionHostInstanceProfile770FCA07" }, - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-arm64-gp2}}", "InstanceType": "t4g.nano", "SecurityGroupIds": [ { @@ -649,11 +647,5 @@ "Ref": "BastionHost30F9ED05" } } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmarm64gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-arm64-gp2" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2/test/integ.bastion-host.expected.json b/packages/@aws-cdk/aws-ec2/test/integ.bastion-host.expected.json index 4943873897e75..cd3d2bc2e705b 100644 --- a/packages/@aws-cdk/aws-ec2/test/integ.bastion-host.expected.json +++ b/packages/@aws-cdk/aws-ec2/test/integ.bastion-host.expected.json @@ -611,9 +611,7 @@ "IamInstanceProfile": { "Ref": "BastionHostInstanceProfile770FCA07" }, - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2}}", "InstanceType": "t3.nano", "SecurityGroupIds": [ { @@ -649,11 +647,5 @@ "Ref": "BastionHost30F9ED05" } } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2/test/integ.instance-init.expected.json b/packages/@aws-cdk/aws-ec2/test/integ.instance-init.expected.json index 2b736d3961b4c..f99bfc4a6b96b 100644 --- a/packages/@aws-cdk/aws-ec2/test/integ.instance-init.expected.json +++ b/packages/@aws-cdk/aws-ec2/test/integ.instance-init.expected.json @@ -137,9 +137,7 @@ "IamInstanceProfile": { "Ref": "Instance2InstanceProfile582F915C" }, - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2}}", "InstanceType": "t2.micro", "SecurityGroupIds": [ { @@ -302,10 +300,6 @@ } }, "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2" - }, "AssetParametersf8a1af398dac2fad92eeea4fb7620be1c4f504e23e3bfcd859fbb5744187930bS3Bucket597083AB": { "Type": "String", "Description": "S3 bucket for asset \"f8a1af398dac2fad92eeea4fb7620be1c4f504e23e3bfcd859fbb5744187930b\"" @@ -319,4 +313,4 @@ "Description": "Artifact hash for asset \"f8a1af398dac2fad92eeea4fb7620be1c4f504e23e3bfcd859fbb5744187930b\"" } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2/test/integ.instance-multipart-userdata.expected.json b/packages/@aws-cdk/aws-ec2/test/integ.instance-multipart-userdata.expected.json index 371a30e7456f6..c5a08cce4530a 100644 --- a/packages/@aws-cdk/aws-ec2/test/integ.instance-multipart-userdata.expected.json +++ b/packages/@aws-cdk/aws-ec2/test/integ.instance-multipart-userdata.expected.json @@ -620,9 +620,7 @@ "IamInstanceProfile": { "Ref": "InstanceInstanceProfileAB5AEF02" }, - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2}}", "InstanceType": "t3.nano", "SecurityGroupIds": [ { @@ -684,11 +682,5 @@ "InstanceInstanceRoleE9785DE5" ] } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2/test/integ.instance.expected.json b/packages/@aws-cdk/aws-ec2/test/integ.instance.expected.json index 957af9c0f453e..e433b190ade9a 100644 --- a/packages/@aws-cdk/aws-ec2/test/integ.instance.expected.json +++ b/packages/@aws-cdk/aws-ec2/test/integ.instance.expected.json @@ -616,9 +616,7 @@ "IamInstanceProfile": { "Ref": "InstanceInstanceProfileAB5AEF02" }, - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2}}", "InstanceType": "t3.nano", "SecurityGroupIds": [ { @@ -646,11 +644,5 @@ "InstanceInstanceRoleE9785DE5" ] } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2/test/launch-template.test.ts b/packages/@aws-cdk/aws-ec2/test/launch-template.test.ts index 4d033a0cad78c..389d5ef55155c 100644 --- a/packages/@aws-cdk/aws-ec2/test/launch-template.test.ts +++ b/packages/@aws-cdk/aws-ec2/test/launch-template.test.ts @@ -3,7 +3,6 @@ import { expect as expectCDK, haveResource, haveResourceLike, - stringLike, } from '@aws-cdk/assert-internal'; import { CfnInstanceProfile, @@ -158,9 +157,7 @@ describe('LaunchTemplate', () => { // THEN expectCDK(stack).to(haveResourceLike('AWS::EC2::LaunchTemplate', { LaunchTemplateData: { - ImageId: { - Ref: stringLike('SsmParameterValueawsserviceamiamazonlinuxlatestamznami*Parameter'), - }, + ImageId: '{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2}}', }, })); expect(template.osType).toBe(OperatingSystemType.LINUX); @@ -176,9 +173,7 @@ describe('LaunchTemplate', () => { // THEN expectCDK(stack).to(haveResourceLike('AWS::EC2::LaunchTemplate', { LaunchTemplateData: { - ImageId: { - Ref: stringLike('SsmParameterValueawsserviceamiwindowslatestWindowsServer2019EnglishFullBase*Parameter'), - }, + ImageId: '{{resolve:ssm:/aws/service/ami-windows-latest/Windows_Server-2019-English-Full-Base}}', }, })); expect(template.osType).toBe(OperatingSystemType.WINDOWS); diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service.expected.json b/packages/@aws-cdk/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service.expected.json index 0412778adb2e8..83100fb8404f1 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service.expected.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service.expected.json @@ -505,9 +505,7 @@ "ClusterDefaultAutoScalingGroupLaunchConfig81EA5466": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "ClusterDefaultAutoScalingGroupInstanceProfile2BB4FE55" @@ -1160,12 +1158,6 @@ ] } }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } - }, "Outputs": { "myServiceLoadBalancerDNS3A083E9F": { "Value": { diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/ec2/integ.scheduled-ecs-task.lit.expected.json b/packages/@aws-cdk/aws-ecs-patterns/test/ec2/integ.scheduled-ecs-task.lit.expected.json index e3afaddbeb7c6..cb276afd853f3 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/ec2/integ.scheduled-ecs-task.lit.expected.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/ec2/integ.scheduled-ecs-task.lit.expected.json @@ -325,9 +325,7 @@ "EcsClusterDefaultAutoScalingGroupLaunchConfigB7E376C1": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3" @@ -884,11 +882,5 @@ ] } } - }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.app-mesh-proxy-config.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.app-mesh-proxy-config.expected.json index 2e5eed7f911c6..5931bfbe6125d 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.app-mesh-proxy-config.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.app-mesh-proxy-config.expected.json @@ -484,9 +484,7 @@ "EcsClusterDefaultAutoScalingGroupLaunchConfigB7E376C1": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3" @@ -968,11 +966,5 @@ } } } - }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.bottlerocket.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.bottlerocket.expected.json index 616a80172092e..68ecfe2a87661 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.bottlerocket.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.bottlerocket.expected.json @@ -478,9 +478,7 @@ "EcsClusterbottlerocketasgLaunchConfig644AD24C": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsservicebottlerocketawsecs1x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/bottlerocket/aws-ecs-1/x86_64/latest/image_id}}", "InstanceType": "c5.large", "IamInstanceProfile": { "Ref": "EcsClusterbottlerocketasgInstanceProfile22A89B9D" @@ -832,11 +830,5 @@ "EcsClusterbottlerocketasgLifecycleHookDrainHookRoleDE4D94EB" ] } - }, - "Parameters": { - "SsmParameterValueawsservicebottlerocketawsecs1x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/bottlerocket/aws-ecs-1/x86_64/latest/image_id" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.clb-host-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.clb-host-nw.expected.json index 77ccc9c6c36c6..51ec3e18fb52f 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.clb-host-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.clb-host-nw.expected.json @@ -505,9 +505,7 @@ "EcsClusterDefaultAutoScalingGroupLaunchConfigB7E376C1": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3" @@ -1007,12 +1005,6 @@ } } }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } - }, "Outputs": { "LoadBalancerDNS": { "Value": { diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.cloudmap-container-port.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.cloudmap-container-port.expected.json index da866432d8539..6808def866ea1 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.cloudmap-container-port.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.cloudmap-container-port.expected.json @@ -305,9 +305,7 @@ "FargateClustercapacityLaunchConfig9B95CCB7": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t3.micro", "IamInstanceProfile": { "Ref": "FargateClustercapacityInstanceProfile8294296C" @@ -798,11 +796,5 @@ } } } - }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.environment-file.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.environment-file.expected.json index c309c8a70f249..406021932bd02 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.environment-file.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.environment-file.expected.json @@ -497,9 +497,7 @@ "EcsClusterDefaultAutoScalingGroupLaunchConfigB7E376C1": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3" @@ -1332,10 +1330,6 @@ } }, "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - }, "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3BucketAEADE8C7": { "Type": "String", "Description": "S3 bucket for asset \"e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68\"" @@ -1385,4 +1379,4 @@ "Description": "Artifact hash for asset \"872561bf078edd1685d50c9ff821cdd60d2b2ddfb0013c4087e79bf2bb50724d\"" } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.firelens-s3-config.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.firelens-s3-config.expected.json index e863d75fa16fb..358ccdcee2969 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.firelens-s3-config.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.firelens-s3-config.expected.json @@ -484,9 +484,7 @@ "EcsClusterDefaultAutoScalingGroupLaunchConfigB7E376C1": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3" @@ -910,9 +908,7 @@ }, "Type": "fluentbit" }, - "Image": { - "Ref": "SsmParameterValueawsserviceawsforfluentbit210C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "Image": "{{resolve:ssm:/aws/service/aws-for-fluent-bit/2.1.0}}", "LogConfiguration": { "LogDriver": "awslogs", "Options": { @@ -1164,10 +1160,6 @@ } }, "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - }, "AssetParameters2ca891b3a73a4a36630bba20580e3390a104d2ac9ff1f22a6bcadf575f8a5a61S3Bucket4E939944": { "Type": "String", "Description": "S3 bucket for asset \"2ca891b3a73a4a36630bba20580e3390a104d2ac9ff1f22a6bcadf575f8a5a61\"" @@ -1179,10 +1171,6 @@ "AssetParameters2ca891b3a73a4a36630bba20580e3390a104d2ac9ff1f22a6bcadf575f8a5a61ArtifactHashB4EEDAF3": { "Type": "String", "Description": "Artifact hash for asset \"2ca891b3a73a4a36630bba20580e3390a104d2ac9ff1f22a6bcadf575f8a5a61\"" - }, - "SsmParameterValueawsserviceawsforfluentbit210C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/aws-for-fluent-bit/2.1.0" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.expected.json index 1fef2d83e2784..252359bbea4ee 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.expected.json @@ -484,9 +484,7 @@ "EcsClusterDefaultAutoScalingGroupLaunchConfigB7E376C1": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3" @@ -1077,12 +1075,6 @@ } } }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } - }, "Outputs": { "LoadBalancerDNS": { "Value": { diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.expected.json index 1bcb9d34f8dbd..cd5d383c8d5a8 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.expected.json @@ -505,9 +505,7 @@ "EcsClusterDefaultAutoScalingGroupLaunchConfigB7E376C1": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3" @@ -1041,12 +1039,6 @@ } } }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } - }, "Outputs": { "LoadBalancerDNS": { "Value": { diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-awsvpc-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-awsvpc-nw.expected.json index 353debc6de544..5ee8ceb825f7b 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-awsvpc-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-awsvpc-nw.expected.json @@ -484,9 +484,7 @@ "EcsClusterDefaultAutoScalingGroupLaunchConfigB7E376C1": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3" @@ -990,11 +988,5 @@ } } } - }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-bridge-nw.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-bridge-nw.expected.json index 4722ee003bef2..6295444de267b 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-bridge-nw.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.sd-bridge-nw.expected.json @@ -484,9 +484,7 @@ "EcsClusterDefaultAutoScalingGroupLaunchConfigB7E376C1": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3" @@ -955,11 +953,5 @@ } } } - }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.spot-drain.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.spot-drain.expected.json index 20ba3cf89516e..a290b4b72a020 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.spot-drain.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.spot-drain.expected.json @@ -484,9 +484,7 @@ "EcsClusterasgSpotLaunchConfig75BCA823": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "c5.xlarge", "IamInstanceProfile": { "Ref": "EcsClusterasgSpotInstanceProfile0D6DD08D" @@ -966,9 +964,7 @@ "EcsClusterasgOdLaunchConfigD3B9E271": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t3.large", "IamInstanceProfile": { "Ref": "EcsClusterasgOdInstanceProfileE5B88756" @@ -1387,11 +1383,5 @@ } } } - }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/test/ecs-cluster.test.ts b/packages/@aws-cdk/aws-ecs/test/ecs-cluster.test.ts index aa1e57c8e55f7..8b4af8a955e58 100644 --- a/packages/@aws-cdk/aws-ecs/test/ecs-cluster.test.ts +++ b/packages/@aws-cdk/aws-ecs/test/ecs-cluster.test.ts @@ -39,9 +39,7 @@ nodeunitShim({ })); expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { - ImageId: { - Ref: 'SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter', - }, + ImageId: '{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}', InstanceType: 't2.micro', IamInstanceProfile: { Ref: 'EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3', @@ -210,9 +208,7 @@ nodeunitShim({ })); expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { - ImageId: { - Ref: 'SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter', - }, + ImageId: '{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}', InstanceType: 't2.micro', IamInstanceProfile: { Ref: 'EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3', @@ -574,9 +570,7 @@ nodeunitShim({ })); expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { - ImageId: { - Ref: 'SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter', - }, + ImageId: '{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}', InstanceType: 't2.micro', IamInstanceProfile: { Ref: 'EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3', @@ -770,9 +764,7 @@ nodeunitShim({ // THEN expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { - ImageId: { - Ref: 'SsmParameterValueawsserviceecsoptimizedamiwindowsserver2019englishfullrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter', - }, + ImageId: '{{resolve:ssm:/aws/service/ecs/optimized-ami/windows_server/2019/english/full/recommended/image_id}}', InstanceType: 't2.micro', IamInstanceProfile: { Ref: 'EcsClusterWindowsAutoScalingGroupInstanceProfile65DFA6BB', @@ -826,21 +818,10 @@ nodeunitShim({ }); // THEN - const assembly = app.synth(); - const template = assembly.getStackByName(stack.stackName).template; expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { - ImageId: { - Ref: 'SsmParameterValueawsserviceecsoptimizedamiamazonlinux2gpurecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter', - }, + ImageId: '{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/gpu/recommended/image_id}}', })); - test.deepEqual(template.Parameters, { - SsmParameterValueawsserviceecsoptimizedamiamazonlinux2gpurecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter: { - Type: 'AWS::SSM::Parameter::Value', - Default: '/aws/service/ecs/optimized-ami/amazon-linux-2/gpu/recommended/image_id', - }, - }); - test.done(); }, @@ -867,8 +848,7 @@ nodeunitShim({ 'allows specifying windows image'(test: Test) { // GIVEN - const app = new cdk.App(); - const stack = new cdk.Stack(app, 'test'); + const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'MyVpc', {}); const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc }); @@ -880,14 +860,9 @@ nodeunitShim({ }); // THEN - const assembly = app.synth(); - const template = assembly.getStackByName(stack.stackName).template; - test.deepEqual(template.Parameters, { - SsmParameterValueawsserviceecsoptimizedamiwindowsserver2019englishfullrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter: { - Type: 'AWS::SSM::Parameter::Value', - Default: '/aws/service/ecs/optimized-ami/windows_server/2019/english/full/recommended/image_id', - }, - }); + expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { + ImageId: '{{resolve:ssm:/aws/service/ecs/optimized-ami/windows_server/2019/english/full/recommended/image_id}}', + })); test.done(); }, @@ -1006,8 +981,7 @@ nodeunitShim({ 'allows specifying special HW AMI Type v2'(test: Test) { // GIVEN - const app = new cdk.App(); - const stack = new cdk.Stack(app, 'test'); + const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'MyVpc', {}); const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc }); @@ -1017,28 +991,16 @@ nodeunitShim({ }); // THEN - const assembly = app.synth(); - const template = assembly.getStackByName(stack.stackName).template; expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { - ImageId: { - Ref: 'SsmParameterValueawsserviceecsoptimizedamiamazonlinux2gpurecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter', - }, + ImageId: '{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/gpu/recommended/image_id}}', })); - test.deepEqual(template.Parameters, { - SsmParameterValueawsserviceecsoptimizedamiamazonlinux2gpurecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter: { - Type: 'AWS::SSM::Parameter::Value', - Default: '/aws/service/ecs/optimized-ami/amazon-linux-2/gpu/recommended/image_id', - }, - }); - test.done(); }, 'allows specifying Amazon Linux v1 AMI'(test: Test) { // GIVEN - const app = new cdk.App(); - const stack = new cdk.Stack(app, 'test'); + const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'MyVpc', {}); const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc }); @@ -1048,28 +1010,16 @@ nodeunitShim({ }); // THEN - const assembly = app.synth(); - const template = assembly.getStackByName(stack.stackName).template; expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { - ImageId: { - Ref: 'SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter', - }, + ImageId: '{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux/recommended/image_id}}', })); - test.deepEqual(template.Parameters, { - SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter: { - Type: 'AWS::SSM::Parameter::Value', - Default: '/aws/service/ecs/optimized-ami/amazon-linux/recommended/image_id', - }, - }); - test.done(); }, 'allows specifying windows image v2'(test: Test) { // GIVEN - const app = new cdk.App(); - const stack = new cdk.Stack(app, 'test'); + const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'MyVpc', {}); const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc }); @@ -1079,14 +1029,9 @@ nodeunitShim({ }); // THEN - const assembly = app.synth(); - const template = assembly.getStackByName(stack.stackName).template; - test.deepEqual(template.Parameters, { - SsmParameterValueawsserviceecsoptimizedamiwindowsserver2019englishfullrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter: { - Type: 'AWS::SSM::Parameter::Value', - Default: '/aws/service/ecs/optimized-ami/windows_server/2019/english/full/recommended/image_id', - }, - }); + expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { + ImageId: '{{resolve:ssm:/aws/service/ecs/optimized-ami/windows_server/2019/english/full/recommended/image_id}}', + })); test.done(); }, @@ -1410,9 +1355,7 @@ nodeunitShim({ })); expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { - ImageId: { - Ref: 'SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter', - }, + ImageId: '{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}', InstanceType: 't2.micro', AssociatePublicIpAddress: true, IamInstanceProfile: { @@ -1554,30 +1497,19 @@ nodeunitShim({ 'BottleRocketImage() returns correct AMI'(test: Test) { // GIVEN - const app = new cdk.App(); - const stack = new cdk.Stack(app, 'test'); + const stack = new cdk.Stack(); // WHEN - new ecs.BottleRocketImage().getImage(stack); + const machineImageConfig = new ecs.BottleRocketImage().getImage(stack); // THEN - const assembly = app.synth(); - const parameters = assembly.getStackByName(stack.stackName).template.Parameters; - test.ok(Object.entries(parameters).some( - ([k, v]) => k.startsWith('SsmParameterValueawsservicebottlerocketawsecs') && - (v as any).Default.includes('/bottlerocket/'), - ), 'Bottlerocket AMI should be in ssm parameters'); - test.ok(Object.entries(parameters).some( - ([k, v]) => k.startsWith('SsmParameterValueawsservicebottlerocketawsecs') && - (v as any).Default.includes('/aws-ecs-1/'), - ), 'ecs variant should be in ssm parameters'); + test.equal(stack.resolve(machineImageConfig.imageId), '{{resolve:ssm:/aws/service/bottlerocket/aws-ecs-1/x86_64/latest/image_id}}'); test.done(); }, 'cluster capacity with bottlerocket AMI'(test: Test) { // GIVEN - const app = new cdk.App(); - const stack = new cdk.Stack(app, 'test'); + const stack = new cdk.Stack(); const cluster = new ecs.Cluster(stack, 'EcsCluster'); cluster.addCapacity('bottlerocket-asg', { @@ -1589,9 +1521,7 @@ nodeunitShim({ expect(stack).to(haveResource('AWS::ECS::Cluster')); expect(stack).to(haveResource('AWS::AutoScaling::AutoScalingGroup')); expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { - ImageId: { - Ref: 'SsmParameterValueawsservicebottlerocketawsecs1x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter', - }, + ImageId: '{{resolve:ssm:/aws/service/bottlerocket/aws-ecs-1/x86_64/latest/image_id}}', UserData: { 'Fn::Base64': { 'Fn::Join': [ @@ -1659,7 +1589,7 @@ nodeunitShim({ Tags: [ { Key: 'Name', - Value: 'test/EcsCluster/bottlerocket-asg', + Value: 'Default/EcsCluster/bottlerocket-asg', }, ], }), diff --git a/packages/@aws-cdk/aws-ecs/test/fargate/integ.firelens-cloudwatch.expected.json b/packages/@aws-cdk/aws-ecs/test/fargate/integ.firelens-cloudwatch.expected.json index c6efbdee23f66..4380259788434 100644 --- a/packages/@aws-cdk/aws-ecs/test/fargate/integ.firelens-cloudwatch.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/fargate/integ.firelens-cloudwatch.expected.json @@ -433,9 +433,7 @@ "FirelensConfiguration": { "Type": "fluentbit" }, - "Image": { - "Ref": "SsmParameterValueawsserviceawsforfluentbitlatestC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "Image": "{{resolve:ssm:/aws/service/aws-for-fluent-bit/latest}}", "LogConfiguration": { "LogDriver": "awslogs", "Options": { @@ -597,11 +595,5 @@ } } } - }, - "Parameters": { - "SsmParameterValueawsserviceawsforfluentbitlatestC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/aws-for-fluent-bit/latest" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-cluster.defaults.expected.json b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-cluster.defaults.expected.json index f98225e84b35e..eb937ac5b7f25 100644 --- a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-cluster.defaults.expected.json +++ b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-cluster.defaults.expected.json @@ -775,14 +775,13 @@ ] } }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "ClusterResourceHandlerServiceRole7FB16465", "Arn" ] }, - "Runtime": "python3.7", + "Handler": "index.handler", "Layers": [ { "Fn::GetAtt": [ @@ -792,6 +791,7 @@ } ], "MemorySize": 512, + "Runtime": "python3.7", "Timeout": 900 }, "DependsOn": [ @@ -891,14 +891,12 @@ ] } }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "ClusterResourceHandlerServiceRole7FB16465", "Arn" ] }, - "Runtime": "python3.7", "Environment": { "Variables": { "CLUSTER_NAME": { @@ -906,6 +904,7 @@ } } }, + "Handler": "index.handler", "Layers": [ { "Fn::GetAtt": [ @@ -915,6 +914,7 @@ } ], "MemorySize": 256, + "Runtime": "python3.7", "Timeout": 900 }, "DependsOn": [ @@ -1117,9 +1117,7 @@ "ClusterDefaultCapacityLaunchConfig72790CF7": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id}}", "InstanceType": "m5.large", "IamInstanceProfile": { "Ref": "ClusterDefaultCapacityInstanceProfile70387741" @@ -1306,10 +1304,6 @@ "AssetParameters640847533c8a00b3133aeb128edcac41fb7b60349c9e18764fcf7ea4af14d444ArtifactHash606C8127": { "Type": "String", "Description": "Artifact hash for asset \"640847533c8a00b3133aeb128edcac41fb7b60349c9e18764fcf7ea4af14d444\"" - }, - "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-cluster.kubectl-disabled.expected.json b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-cluster.kubectl-disabled.expected.json index 66e63cb1a7497..8dd0f5e3967e1 100644 --- a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-cluster.kubectl-disabled.expected.json +++ b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-cluster.kubectl-disabled.expected.json @@ -902,9 +902,7 @@ "EKSClusterNodesLaunchConfig921F1106": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.medium", "IamInstanceProfile": { "Ref": "EKSClusterNodesInstanceProfile0F2DB3B9" @@ -1034,11 +1032,5 @@ ] } } - }, - "Parameters": { - "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-cluster.lit.expected.json b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-cluster.lit.expected.json index 254e46a33dfd5..11cf4d6615d56 100644 --- a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-cluster.lit.expected.json +++ b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-cluster.lit.expected.json @@ -775,14 +775,13 @@ ] } }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "EKSClusterResourceHandlerServiceRoleFD631254", "Arn" ] }, - "Runtime": "python3.7", + "Handler": "index.handler", "Layers": [ { "Fn::GetAtt": [ @@ -792,6 +791,7 @@ } ], "MemorySize": 512, + "Runtime": "python3.7", "Timeout": 900 }, "DependsOn": [ @@ -891,14 +891,12 @@ ] } }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "EKSClusterResourceHandlerServiceRoleFD631254", "Arn" ] }, - "Runtime": "python3.7", "Environment": { "Variables": { "CLUSTER_NAME": { @@ -906,6 +904,7 @@ } } }, + "Handler": "index.handler", "Layers": [ { "Fn::GetAtt": [ @@ -915,6 +914,7 @@ } ], "MemorySize": 256, + "Runtime": "python3.7", "Timeout": 900 }, "DependsOn": [ @@ -1117,9 +1117,7 @@ "EKSClusterNodesLaunchConfig921F1106": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.medium", "IamInstanceProfile": { "Ref": "EKSClusterNodesInstanceProfile0F2DB3B9" @@ -1306,10 +1304,6 @@ "AssetParameters640847533c8a00b3133aeb128edcac41fb7b60349c9e18764fcf7ea4af14d444ArtifactHash606C8127": { "Type": "String", "Description": "Artifact hash for asset \"640847533c8a00b3133aeb128edcac41fb7b60349c9e18764fcf7ea4af14d444\"" - }, - "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-helm.lit.expected.json b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-helm.lit.expected.json index ba37ddbe77d70..1fce7bbf583bd 100644 --- a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-helm.lit.expected.json +++ b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-helm.lit.expected.json @@ -639,14 +639,13 @@ ] } }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "cluster22ResourceHandlerServiceRoleC2E4F327", "Arn" ] }, - "Runtime": "python3.7", + "Handler": "index.handler", "Layers": [ { "Fn::GetAtt": [ @@ -656,6 +655,7 @@ } ], "MemorySize": 512, + "Runtime": "python3.7", "Timeout": 900 }, "DependsOn": [ @@ -749,14 +749,12 @@ ] } }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "cluster22ResourceHandlerServiceRoleC2E4F327", "Arn" ] }, - "Runtime": "python3.7", "Environment": { "Variables": { "CLUSTER_NAME": { @@ -764,6 +762,7 @@ } } }, + "Handler": "index.handler", "Layers": [ { "Fn::GetAtt": [ @@ -773,6 +772,7 @@ } ], "MemorySize": 256, + "Runtime": "python3.7", "Timeout": 900 }, "DependsOn": [ @@ -1010,9 +1010,7 @@ "cluster22NodesLaunchConfig184BF3BA": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.medium", "IamInstanceProfile": { "Ref": "cluster22NodesInstanceProfile3D4963ED" @@ -1159,14 +1157,12 @@ ] } }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "cluster22ResourceHandlerServiceRoleC2E4F327", "Arn" ] }, - "Runtime": "python3.7", "Environment": { "Variables": { "CLUSTER_NAME": { @@ -1174,6 +1170,7 @@ } } }, + "Handler": "index.handler", "Layers": [ { "Fn::GetAtt": [ @@ -1183,6 +1180,7 @@ } ], "MemorySize": 256, + "Runtime": "python3.7", "Timeout": 900 }, "DependsOn": [ @@ -1326,10 +1324,6 @@ "AssetParameters8e2989bd32b411eba804b201a0f3984c984893c7fe6daa0b572fdd59c63e3653ArtifactHash77099D9F": { "Type": "String", "Description": "Artifact hash for asset \"8e2989bd32b411eba804b201a0f3984c984893c7fe6daa0b572fdd59c63e3653\"" - }, - "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id" } } } diff --git a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-kubectl.lit.expected.json b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-kubectl.lit.expected.json index fd726b6e62f29..65e207c725e40 100644 --- a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-kubectl.lit.expected.json +++ b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-kubectl.lit.expected.json @@ -639,14 +639,13 @@ ] } }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "cluster22ResourceHandlerServiceRoleC2E4F327", "Arn" ] }, - "Runtime": "python3.7", + "Handler": "index.handler", "Layers": [ { "Fn::GetAtt": [ @@ -656,6 +655,7 @@ } ], "MemorySize": 512, + "Runtime": "python3.7", "Timeout": 900 }, "DependsOn": [ @@ -749,14 +749,12 @@ ] } }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "cluster22ResourceHandlerServiceRoleC2E4F327", "Arn" ] }, - "Runtime": "python3.7", "Environment": { "Variables": { "CLUSTER_NAME": { @@ -764,6 +762,7 @@ } } }, + "Handler": "index.handler", "Layers": [ { "Fn::GetAtt": [ @@ -773,6 +772,7 @@ } ], "MemorySize": 256, + "Runtime": "python3.7", "Timeout": 900 }, "DependsOn": [ @@ -1010,9 +1010,7 @@ "cluster22NodesLaunchConfig184BF3BA": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.medium", "IamInstanceProfile": { "Ref": "cluster22NodesInstanceProfile3D4963ED" @@ -1210,10 +1208,6 @@ "AssetParameters640847533c8a00b3133aeb128edcac41fb7b60349c9e18764fcf7ea4af14d444ArtifactHash606C8127": { "Type": "String", "Description": "Artifact hash for asset \"640847533c8a00b3133aeb128edcac41fb7b60349c9e18764fcf7ea4af14d444\"" - }, - "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id" } } } diff --git a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-spot.expected.json b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-spot.expected.json index 56f7f71864838..b68633208c82a 100644 --- a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-spot.expected.json +++ b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-spot.expected.json @@ -613,14 +613,13 @@ ] } }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "myClusterResourceHandlerServiceRole95F554E2", "Arn" ] }, - "Runtime": "python3.7", + "Handler": "index.handler", "Layers": [ { "Fn::GetAtt": [ @@ -630,6 +629,7 @@ } ], "MemorySize": 512, + "Runtime": "python3.7", "Timeout": 900 }, "DependsOn": [ @@ -723,14 +723,12 @@ ] } }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "myClusterResourceHandlerServiceRole95F554E2", "Arn" ] }, - "Runtime": "python3.7", "Environment": { "Variables": { "CLUSTER_NAME": { @@ -738,6 +736,7 @@ } } }, + "Handler": "index.handler", "Layers": [ { "Fn::GetAtt": [ @@ -747,6 +746,7 @@ } ], "MemorySize": 256, + "Runtime": "python3.7", "Timeout": 900 }, "DependsOn": [ @@ -949,9 +949,7 @@ "myClusterDefaultCapacityLaunchConfigCF6D4B81": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id}}", "InstanceType": "m5.large", "IamInstanceProfile": { "Ref": "myClusterDefaultCapacityInstanceProfileE7E48198" @@ -1270,9 +1268,7 @@ "myClusterspotLaunchConfig6681F311": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id}}", "InstanceType": "t3.large", "IamInstanceProfile": { "Ref": "myClusterspotInstanceProfile93D80EE5" @@ -1442,10 +1438,6 @@ "AssetParameters640847533c8a00b3133aeb128edcac41fb7b60349c9e18764fcf7ea4af14d444ArtifactHash606C8127": { "Type": "String", "Description": "Artifact hash for asset \"640847533c8a00b3133aeb128edcac41fb7b60349c9e18764fcf7ea4af14d444\"" - }, - "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-eks-legacy/test/test.cluster.ts b/packages/@aws-cdk/aws-eks-legacy/test/test.cluster.ts index cfcc21a8ce50e..6f7a3b33b4dc4 100644 --- a/packages/@aws-cdk/aws-eks-legacy/test/test.cluster.ts +++ b/packages/@aws-cdk/aws-eks-legacy/test/test.cluster.ts @@ -564,7 +564,7 @@ export = { 'EKS-Optimized AMI with GPU support'(test: Test) { // GIVEN - const { app, stack } = testFixtureNoVpc(); + const { stack } = testFixtureNoVpc(); // WHEN new eks.Cluster(stack, 'cluster', { @@ -573,11 +573,9 @@ export = { }); // THEN - const assembly = app.synth(); - const parameters = assembly.getStackByName(stack.stackName).template.Parameters; - test.ok(Object.entries(parameters).some( - ([k, v]) => k.startsWith('SsmParameterValueawsserviceeksoptimizedami') && (v as any).Default.includes('amazon-linux2-gpu'), - ), 'EKS AMI with GPU should be in ssm parameters'); + expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { + ImageId: '{{resolve:ssm:/aws/service/eks/optimized-ami/1.14/amazon-linux2-gpu/recommended/image_id}}', + })); test.done(); }, }; diff --git a/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.expected.json b/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.expected.json index de8e6fe0bf8ae..0ff855468f38c 100644 --- a/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.expected.json +++ b/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.expected.json @@ -1652,9 +1652,7 @@ "ClusterNodesLaunchConfig7C420A27": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/eks/optimized-ami/1.19/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.medium", "IamInstanceProfile": { "Ref": "ClusterNodesInstanceProfileF2DD0E21" @@ -1977,9 +1975,7 @@ "ClusterNodesArmLaunchConfigAAF61344": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2arm64recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/eks/optimized-ami/1.19/amazon-linux-2-arm64/recommended/image_id}}", "InstanceType": "m6g.medium", "IamInstanceProfile": { "Ref": "ClusterNodesArmInstanceProfile158C5C9F" @@ -2302,9 +2298,7 @@ "ClusterBottlerocketNodesLaunchConfig76D7BEBE": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsservicebottlerocketawsk8s119x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/bottlerocket/aws-k8s-1.19/x86_64/latest/image_id}}", "InstanceType": "t3.small", "IamInstanceProfile": { "Ref": "ClusterBottlerocketNodesInstanceProfileB6E2F25A" @@ -2627,9 +2621,7 @@ "ClusterspotLaunchConfigCC19F2E6": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/eks/optimized-ami/1.19/amazon-linux-2/recommended/image_id}}", "InstanceType": "t3.large", "IamInstanceProfile": { "Ref": "ClusterspotInstanceProfileAB88D077" @@ -2985,9 +2977,7 @@ "ClusterInferenceInstancesLaunchConfig03BF48FE": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2gpurecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/eks/optimized-ami/1.19/amazon-linux-2-gpu/recommended/image_id}}", "InstanceType": "inf1.2xlarge", "IamInstanceProfile": { "Ref": "ClusterInferenceInstancesInstanceProfile5A1209B4" @@ -4028,9 +4018,7 @@ "Type": "AWS::EC2::LaunchTemplate", "Properties": { "LaunchTemplateData": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/eks/optimized-ami/1.19/amazon-linux-2/recommended/image_id}}", "InstanceType": "t3.small", "UserData": { "Fn::Base64": { @@ -4777,22 +4765,6 @@ "AssetParameterse334ff007b5126b62d66d4baac94004f4281dc2b0b0c4685ec93e330cb59e921ArtifactHash31BE978F": { "Type": "String", "Description": "Artifact hash for asset \"e334ff007b5126b62d66d4baac94004f4281dc2b0b0c4685ec93e330cb59e921\"" - }, - "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/eks/optimized-ami/1.19/amazon-linux-2/recommended/image_id" - }, - "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2arm64recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/eks/optimized-ami/1.19/amazon-linux-2-arm64/recommended/image_id" - }, - "SsmParameterValueawsservicebottlerocketawsk8s119x8664latestimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/bottlerocket/aws-k8s-1.19/x86_64/latest/image_id" - }, - "SsmParameterValueawsserviceeksoptimizedami119amazonlinux2gpurecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/eks/optimized-ami/1.19/amazon-linux-2-gpu/recommended/image_id" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-eks/test/test.cluster.ts b/packages/@aws-cdk/aws-eks/test/test.cluster.ts index 3a1866d6f460b..5db1ced5f0e71 100644 --- a/packages/@aws-cdk/aws-eks/test/test.cluster.ts +++ b/packages/@aws-cdk/aws-eks/test/test.cluster.ts @@ -1437,44 +1437,26 @@ export = { 'EksOptimizedImage() with no nodeType always uses STANDARD with LATEST_KUBERNETES_VERSION'(test: Test) { // GIVEN - const { app, stack } = testFixtureNoVpc(); + const { stack } = testFixtureNoVpc(); const LATEST_KUBERNETES_VERSION = '1.14'; // WHEN - new eks.EksOptimizedImage().getImage(stack); + const machineImageConfig = new eks.EksOptimizedImage().getImage(stack); // THEN - const assembly = app.synth(); - const parameters = assembly.getStackByName(stack.stackName).template.Parameters; - test.ok(Object.entries(parameters).some( - ([k, v]) => k.startsWith('SsmParameterValueawsserviceeksoptimizedami') && - (v as any).Default.includes('/amazon-linux-2/'), - ), 'EKS STANDARD AMI should be in ssm parameters'); - test.ok(Object.entries(parameters).some( - ([k, v]) => k.startsWith('SsmParameterValueawsserviceeksoptimizedami') && - (v as any).Default.includes(LATEST_KUBERNETES_VERSION), - ), 'LATEST_KUBERNETES_VERSION should be in ssm parameters'); + test.equal(stack.resolve(machineImageConfig.imageId), `{{resolve:ssm:/aws/service/eks/optimized-ami/${LATEST_KUBERNETES_VERSION}/amazon-linux-2/recommended/image_id}}`); test.done(); }, 'EksOptimizedImage() with specific kubernetesVersion return correct AMI'(test: Test) { // GIVEN - const { app, stack } = testFixtureNoVpc(); + const { stack } = testFixtureNoVpc(); // WHEN - new eks.EksOptimizedImage({ kubernetesVersion: '1.19' }).getImage(stack); + const machineImageConfig = new eks.EksOptimizedImage({ kubernetesVersion: '1.19' }).getImage(stack); // THEN - const assembly = app.synth(); - const parameters = assembly.getStackByName(stack.stackName).template.Parameters; - test.ok(Object.entries(parameters).some( - ([k, v]) => k.startsWith('SsmParameterValueawsserviceeksoptimizedami') && - (v as any).Default.includes('/amazon-linux-2/'), - ), 'EKS STANDARD AMI should be in ssm parameters'); - test.ok(Object.entries(parameters).some( - ([k, v]) => k.startsWith('SsmParameterValueawsserviceeksoptimizedami') && - (v as any).Default.includes('/1.19/'), - ), 'kubernetesVersion should be in ssm parameters'); + test.equal(stack.resolve(machineImageConfig.imageId), '{{resolve:ssm:/aws/service/eks/optimized-ami/1.19/amazon-linux-2/recommended/image_id}}'); test.done(); }, @@ -1541,7 +1523,7 @@ export = { 'addAutoScalingGroupCapacity with T4g instance type comes with nodegroup with correct AmiType'(test: Test) { // GIVEN - const { app, stack } = testFixtureNoVpc(); + const { stack } = testFixtureNoVpc(); // WHEN new eks.Cluster(stack, 'cluster', { @@ -1553,18 +1535,15 @@ export = { }); // THEN - const assembly = app.synth(); - const parameters = assembly.getStackByName(stack.stackName).template.Parameters; - test.ok(Object.entries(parameters).some( - ([k, v]) => k.startsWith('SsmParameterValueawsserviceeksoptimizedami') && - (v as any).Default.includes('amazon-linux-2-arm64/'), - ), 'Amazon Linux 2 AMI for ARM64 should be in ssm parameters'); + expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { + ImageId: '{{resolve:ssm:/aws/service/eks/optimized-ami/1.19/amazon-linux-2-arm64/recommended/image_id}}', + })); test.done(); }, 'EKS-Optimized AMI with GPU support when addAutoScalingGroupCapacity'(test: Test) { // GIVEN - const { app, stack } = testFixtureNoVpc(); + const { stack } = testFixtureNoVpc(); // WHEN new eks.Cluster(stack, 'cluster', { @@ -1576,17 +1555,15 @@ export = { }); // THEN - const assembly = app.synth(); - const parameters = assembly.getStackByName(stack.stackName).template.Parameters; - test.ok(Object.entries(parameters).some( - ([k, v]) => k.startsWith('SsmParameterValueawsserviceeksoptimizedami') && (v as any).Default.includes('amazon-linux-2-gpu'), - ), 'EKS AMI with GPU should be in ssm parameters'); + expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { + ImageId: '{{resolve:ssm:/aws/service/eks/optimized-ami/1.19/amazon-linux-2-gpu/recommended/image_id}}', + })); test.done(); }, 'EKS-Optimized AMI with ARM64 when addAutoScalingGroupCapacity'(test: Test) { // GIVEN - const { app, stack } = testFixtureNoVpc(); + const { stack } = testFixtureNoVpc(); // WHEN new eks.Cluster(stack, 'cluster', { @@ -1598,32 +1575,21 @@ export = { }); // THEN - const assembly = app.synth(); - const parameters = assembly.getStackByName(stack.stackName).template.Parameters; - test.ok(Object.entries(parameters).some( - ([k, v]) => k.startsWith('SsmParameterValueawsserviceeksoptimizedami') && (v as any).Default.includes('/amazon-linux-2-arm64/'), - ), 'EKS AMI with GPU should be in ssm parameters'); + expect(stack).to(haveResource('AWS::AutoScaling::LaunchConfiguration', { + ImageId: '{{resolve:ssm:/aws/service/eks/optimized-ami/1.19/amazon-linux-2-arm64/recommended/image_id}}', + })); test.done(); }, 'BottleRocketImage() with specific kubernetesVersion return correct AMI'(test: Test) { // GIVEN - const { app, stack } = testFixtureNoVpc(); + const { stack } = testFixtureNoVpc(); // WHEN - new BottleRocketImage({ kubernetesVersion: '1.19' }).getImage(stack); + const machineImageConfig = new BottleRocketImage({ kubernetesVersion: '1.19' }).getImage(stack); // THEN - const assembly = app.synth(); - const parameters = assembly.getStackByName(stack.stackName).template.Parameters; - test.ok(Object.entries(parameters).some( - ([k, v]) => k.startsWith('SsmParameterValueawsservicebottlerocketaws') && - (v as any).Default.includes('/bottlerocket/'), - ), 'BottleRocket AMI should be in ssm parameters'); - test.ok(Object.entries(parameters).some( - ([k, v]) => k.startsWith('SsmParameterValueawsservicebottlerocketaws') && - (v as any).Default.includes('/aws-k8s-1.19/'), - ), 'kubernetesVersion should be in ssm parameters'); + test.equal(stack.resolve(machineImageConfig).imageId, '{{resolve:ssm:/aws/service/bottlerocket/aws-k8s-1.19/x86_64/latest/image_id}}'); test.done(); }, diff --git a/packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-ec2-task.lit.expected.json b/packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-ec2-task.lit.expected.json index dbdb415e57e63..715521127e6f2 100644 --- a/packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-ec2-task.lit.expected.json +++ b/packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-ec2-task.lit.expected.json @@ -325,9 +325,7 @@ "EcsClusterDefaultAutoScalingGroupLaunchConfigB7E376C1": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "EcsClusterDefaultAutoScalingGroupInstanceProfile2CE606B3" @@ -928,11 +926,5 @@ ] } } - }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-fsx/test/integ.lustre-file-system.expected.json b/packages/@aws-cdk/aws-fsx/test/integ.lustre-file-system.expected.json index c5826b996a6bf..263e4f374715f 100644 --- a/packages/@aws-cdk/aws-fsx/test/integ.lustre-file-system.expected.json +++ b/packages/@aws-cdk/aws-fsx/test/integ.lustre-file-system.expected.json @@ -669,9 +669,7 @@ "IamInstanceProfile": { "Ref": "instInstanceProfile59FAEED2" }, - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2}}", "InstanceType": "t2.large", "SecurityGroupIds": [ { @@ -698,11 +696,5 @@ "instInstanceRoleFE783FB1" ] } - }, - "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamzn2amihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-globalaccelerator-endpoints/test/integ.globalaccelerator.expected.json b/packages/@aws-cdk/aws-globalaccelerator-endpoints/test/integ.globalaccelerator.expected.json index 36f2af987a0e2..a7e7939cb5e0c 100644 --- a/packages/@aws-cdk/aws-globalaccelerator-endpoints/test/integ.globalaccelerator.expected.json +++ b/packages/@aws-cdk/aws-globalaccelerator-endpoints/test/integ.globalaccelerator.expected.json @@ -656,9 +656,7 @@ "IamInstanceProfile": { "Ref": "Instance0InstanceProfile3A61DE71" }, - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2}}", "InstanceType": "t3.small", "SecurityGroupIds": [ { @@ -757,9 +755,7 @@ "IamInstanceProfile": { "Ref": "Instance1InstanceProfileC04770B7" }, - "ImageId": { - "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2}}", "InstanceType": "t3.small", "SecurityGroupIds": [ { @@ -972,10 +968,6 @@ } }, "Parameters": { - "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2" - }, "AssetParameters0625b1566df06e0ffd948f0f65f97a3d22d48242e66196d3f72b480f5309b343S3Bucket65227904": { "Type": "String", "Description": "S3 bucket for asset \"0625b1566df06e0ffd948f0f65f97a3d22d48242e66196d3f72b480f5309b343\"" diff --git a/packages/@aws-cdk/aws-ssm/lib/parameter.ts b/packages/@aws-cdk/aws-ssm/lib/parameter.ts index 416454c1ef8cc..cf627584e74c1 100644 --- a/packages/@aws-cdk/aws-ssm/lib/parameter.ts +++ b/packages/@aws-cdk/aws-ssm/lib/parameter.ts @@ -2,7 +2,7 @@ import * as iam from '@aws-cdk/aws-iam'; import * as kms from '@aws-cdk/aws-kms'; import * as cxschema from '@aws-cdk/cloud-assembly-schema'; import { - CfnDynamicReference, CfnDynamicReferenceService, CfnParameter, + CfnDynamicReference, CfnDynamicReferenceService, Construct as CompatConstruct, ContextProvider, Fn, IResource, Resource, Stack, Token, } from '@aws-cdk/core'; import { Construct } from 'constructs'; @@ -79,14 +79,14 @@ export interface ParameterOptions { * A regular expression used to validate the parameter value. For example, for String types with values restricted to * numbers, you can specify the following: ``^\d+$`` * - * @default no validation is performed + * @default - no validation is performed */ readonly allowedPattern?: string; /** * Information about the parameter that you want to add to the system. * - * @default none + * @default - none */ readonly description?: string; @@ -270,7 +270,7 @@ export interface StringParameterAttributes extends CommonStringParameterAttribut /** * The version number of the value you wish to retrieve. * - * @default The latest version will be retrieved. + * @default - The latest version will be retrieved. */ readonly version?: number; @@ -323,9 +323,8 @@ export class StringParameter extends ParameterBase implements IStringParameter { const type = attrs.type || ParameterType.STRING; - const stringValue = attrs.version - ? new CfnDynamicReference(CfnDynamicReferenceService.SSM, `${attrs.parameterName}:${attrs.version}`).toString() - : new CfnParameter(scope as CompatConstruct, `${id}.Parameter`, { type: `AWS::SSM::Parameter::Value<${type}>`, default: attrs.parameterName }).valueAsString; + const version = attrs.version ? `:${attrs.version}` : ''; + const stringValue = new CfnDynamicReference(CfnDynamicReferenceService.SSM, `${attrs.parameterName}${version}`).toString(); class Import extends ParameterBase { public readonly parameterName = attrs.parameterName; diff --git a/packages/@aws-cdk/aws-ssm/test/integ.parameter-store-string.lit.expected.json b/packages/@aws-cdk/aws-ssm/test/integ.parameter-store-string.lit.expected.json index 1d3d7baba28e0..e1734e3122576 100644 --- a/packages/@aws-cdk/aws-ssm/test/integ.parameter-store-string.lit.expected.json +++ b/packages/@aws-cdk/aws-ssm/test/integ.parameter-store-string.lit.expected.json @@ -12,12 +12,6 @@ } }, { - "Parameters": { - "MyValueParameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/My/Public/Parameter" - } - }, "Resources": { "Dummy": { "Type": "AWS::SNS::Topic" @@ -25,9 +19,7 @@ }, "Outputs": { "TheValue": { - "Value": { - "Ref": "MyValueParameter" - } + "Value": "{{resolve:ssm:/My/Public/Parameter}}" } } } diff --git a/packages/@aws-cdk/aws-ssm/test/test.parameter-store-string.ts b/packages/@aws-cdk/aws-ssm/test/test.parameter-store-string.ts index 215a91090bc5c..7f9660984055d 100644 --- a/packages/@aws-cdk/aws-ssm/test/test.parameter-store-string.ts +++ b/packages/@aws-cdk/aws-ssm/test/test.parameter-store-string.ts @@ -1,4 +1,3 @@ -import { expect } from '@aws-cdk/assert-internal'; import * as cdk from '@aws-cdk/core'; import { Test } from 'nodeunit'; import * as ssm from '../lib'; @@ -30,16 +29,7 @@ export = { }); // THEN - expect(stack).toMatch({ - Parameters: { - RefParameter: { - Type: 'AWS::SSM::Parameter::Value', - Default: '/some/key', - }, - }, - }); - - test.deepEqual(stack.resolve(ref.stringValue), { Ref: 'RefParameter' }); + test.deepEqual(stack.resolve(ref.stringValue), '{{resolve:ssm:/some/key}}'); test.done(); }, diff --git a/packages/@aws-cdk/aws-ssm/test/test.parameter.ts b/packages/@aws-cdk/aws-ssm/test/test.parameter.ts index 8ce26dd03a0c5..7513842e9354c 100644 --- a/packages/@aws-cdk/aws-ssm/test/test.parameter.ts +++ b/packages/@aws-cdk/aws-ssm/test/test.parameter.ts @@ -304,15 +304,7 @@ export = { }); test.deepEqual(stack.resolve(param.parameterName), 'MyParamName'); test.deepEqual(stack.resolve(param.parameterType), 'String'); - test.deepEqual(stack.resolve(param.stringValue), { Ref: 'MyParamNameParameter' }); - expect(stack).toMatch({ - Parameters: { - MyParamNameParameter: { - Type: 'AWS::SSM::Parameter::Value', - Default: 'MyParamName', - }, - }, - }); + test.deepEqual(stack.resolve(param.stringValue), '{{resolve:ssm:MyParamName}}'); test.done(); }, @@ -554,41 +546,7 @@ export = { const value = ssm.StringParameter.valueForStringParameter(stack, 'my-param-name'); // THEN - expect(stack).toMatch({ - Parameters: { - SsmParameterValuemyparamnameC96584B6F00A464EAD1953AFF4B05118Parameter: { - Type: 'AWS::SSM::Parameter::Value', - Default: 'my-param-name', - }, - }, - }); - test.deepEqual(stack.resolve(value), { Ref: 'SsmParameterValuemyparamnameC96584B6F00A464EAD1953AFF4B05118Parameter' }); - test.done(); - }, - - 'de-dup based on parameter name'(test: Test) { - // GIVEN - const stack = new cdk.Stack(); - - // WHEN - ssm.StringParameter.valueForStringParameter(stack, 'my-param-name'); - ssm.StringParameter.valueForStringParameter(stack, 'my-param-name'); - ssm.StringParameter.valueForStringParameter(stack, 'my-param-name-2'); - ssm.StringParameter.valueForStringParameter(stack, 'my-param-name'); - - // THEN - expect(stack).toMatch({ - Parameters: { - SsmParameterValuemyparamnameC96584B6F00A464EAD1953AFF4B05118Parameter: { - Type: 'AWS::SSM::Parameter::Value', - Default: 'my-param-name', - }, - SsmParameterValuemyparamname2C96584B6F00A464EAD1953AFF4B05118Parameter: { - Type: 'AWS::SSM::Parameter::Value', - Default: 'my-param-name-2', - }, - }, - }); + test.deepEqual(stack.resolve(value), '{{resolve:ssm:my-param-name}}'); test.done(); }, diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-run-task.expected.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-run-task.expected.json index c67a1adcd7dd7..f9c1c240d5959 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-run-task.expected.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-run-task.expected.json @@ -127,9 +127,7 @@ "Ec2ClusterDefaultAutoScalingGroupLaunchConfig7B2FED3A": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "Ec2ClusterDefaultAutoScalingGroupInstanceProfileDB232471" @@ -843,12 +841,6 @@ ] } }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } - }, "Outputs": { "stateMachineArn": { "Value": { diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-task.expected.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-task.expected.json index 891777171b73c..71ede5b22edbc 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-task.expected.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-task.expected.json @@ -127,9 +127,7 @@ "FargateClusterDefaultAutoScalingGroupLaunchConfig57306899": { "Type": "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId": { - "Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter" - }, + "ImageId": "{{resolve:ssm:/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id}}", "InstanceType": "t2.micro", "IamInstanceProfile": { "Ref": "FargateClusterDefaultAutoScalingGroupInstanceProfile2C0FEF3B" @@ -738,11 +736,5 @@ "StateMachineRoleB840431D" ] } - }, - "Parameters": { - "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - } } } \ No newline at end of file diff --git a/packages/aws-cdk/lib/api/deploy-stack.ts b/packages/aws-cdk/lib/api/deploy-stack.ts index df811e39587be..5735ddf28332c 100644 --- a/packages/aws-cdk/lib/api/deploy-stack.ts +++ b/packages/aws-cdk/lib/api/deploy-stack.ts @@ -461,6 +461,12 @@ async function canSkipDeploy( return false; } + // Stack retrieves latest version of SSM parameters with dynamic reference + if (/{{resolve:ssm:[a-zA-Z0-9_.-/]+}}/.test(JSON.stringify(deployStackOptions.stack.template))) { + debug(`${deployName}: stack retrieves latest version of SSM parameters with dynamic reference`); + return false; + } + // We can skip deploy return true; } @@ -516,4 +522,4 @@ function restUrlFromManifest(url: string, environment: cxapi.Environment): strin const urlSuffix: string = regionUtil.getEndpointSuffix(environment.region); return `https://s3.${environment.region}.${urlSuffix}/${bucketName}/${objectKey}`; -} \ No newline at end of file +} diff --git a/packages/aws-cdk/test/api/deploy-stack.test.ts b/packages/aws-cdk/test/api/deploy-stack.test.ts index 8fffb321ef995..c89e1095363bf 100644 --- a/packages/aws-cdk/test/api/deploy-stack.test.ts +++ b/packages/aws-cdk/test/api/deploy-stack.test.ts @@ -23,6 +23,17 @@ const FAKE_STACK_TERMINATION_PROTECTION = testStack({ terminationProtection: true, }); +const FAKE_STACK_SSM = testStack({ + stackName: 'ssm', + template: { + Outputs: { + MyOutput: { + Value: '{{resolve:ssm:/my/ssm/param}}', + }, + }, + }, +}); + let sdk: MockSdk; let sdkProvider: MockSdkProvider; let cfnMocks: MockedObject>; @@ -635,6 +646,21 @@ test('updateTerminationProtection called when termination protection is undefine })); }); +test('deploy not skipped if template retrieves latest version of SSM parameters', async () => { + // GIVEN + givenStackExists(); + givenTemplateIs(FAKE_STACK_SSM.template); + + // WHEN + await deployStack({ + ...standardDeployStackArguments(), + stack: FAKE_STACK_SSM, + }); + + // THEN + expect(cfnMocks.executeChangeSet).toHaveBeenCalled(); +}); + /** * Set up the mocks so that it looks like the stack exists to start with * @@ -670,4 +696,4 @@ function givenTemplateIs(template: any) { cfnMocks.getTemplate!.mockReturnValue({ TemplateBody: JSON.stringify(template), }); -} \ No newline at end of file +}