Skip to content

Commit

Permalink
feat(ecs): change the default Amazon Linux generation to v2 (#3009)
Browse files Browse the repository at this point in the history
This change make CDK consistent with the recommendataion we give customers: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI.html. This closes #3005.

BREAKING CHANGE: Previously, the default generation is conditionally set to Amazon Linux v1 if `hardwareType` was `STANDARD`. Now it always defaults to Amazon Linux v2.
  • Loading branch information
hencrice authored and Elad Ben-Israel committed Jun 24, 2019
1 parent 573e585 commit 32e3421
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t2.micro",
"IamInstanceProfile": {
Expand Down Expand Up @@ -863,9 +863,9 @@
}
},
"Parameters": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/ecs/optimized-ami/amazon-linux/recommended/image_id"
"Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id"
}
}
}
9 changes: 3 additions & 6 deletions packages/@aws-cdk/aws-ecs/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export interface EcsOptimizedAmiProps {
/**
* What generation of Amazon Linux to use
*
* @default AmazonLinuxGeneration.AmazonLinux if hardwareType equal to AmiHardwareType.Standard else AmazonLinuxGeneration.AmazonLinux2
* @default AmazonLinuxGeneration.AmazonLinux2
*/
readonly generation?: ec2.AmazonLinuxGeneration;

Expand Down Expand Up @@ -261,11 +261,8 @@ export class EcsOptimizedAmi implements ec2.IMachineImage {
this.generation = props.generation;
}
} else { // generation not defined in props object
if (this.hwType === AmiHardwareType.STANDARD) { // default to Amazon Linux v1 if no HW is standard
this.generation = ec2.AmazonLinuxGeneration.AMAZON_LINUX;
} else { // default to Amazon Linux v2 if special HW
this.generation = ec2.AmazonLinuxGeneration.AMAZON_LINUX_2;
}
// always default to Amazon Linux v2 regardless of HW
this.generation = ec2.AmazonLinuxGeneration.AMAZON_LINUX_2;
}

// set the SSM parameter name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"Parameters": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/ecs/optimized-ami/amazon-linux/recommended/image_id"
"Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id"
}
},
"Resources": {
Expand Down Expand Up @@ -448,7 +448,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t2.micro",
"IamInstanceProfile": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"Parameters": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/ecs/optimized-ami/amazon-linux/recommended/image_id"
"Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id"
}
},
"Resources": {
Expand Down Expand Up @@ -469,7 +469,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t2.micro",
"IamInstanceProfile": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"Parameters": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/ecs/optimized-ami/amazon-linux/recommended/image_id"
"Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id"
}
},
"Resources": {
Expand Down Expand Up @@ -448,7 +448,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t2.micro",
"IamInstanceProfile": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"Parameters": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/ecs/optimized-ami/amazon-linux/recommended/image_id"
"Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id"
}
},
"Resources": {
Expand Down Expand Up @@ -448,7 +448,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t2.micro",
"IamInstanceProfile": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/test/test.ecs-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export = {

expect(stack).to(haveResource("AWS::AutoScaling::LaunchConfiguration", {
ImageId: {
Ref: "SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
Ref: "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
InstanceType: "t2.micro",
IamInstanceProfile: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t2.micro",
"IamInstanceProfile": {
Expand Down Expand Up @@ -1176,9 +1176,9 @@
}
},
"Parameters": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/ecs/optimized-ami/amazon-linux/recommended/image_id"
"Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id"
},
"TaskDefTheContainerAssetImageImageName92ECAC22": {
"Type": "String",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": {
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
"Ref": "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter"
},
"InstanceType": "t2.micro",
"IamInstanceProfile": {
Expand Down Expand Up @@ -957,9 +957,9 @@
}
},
"Parameters": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinuxrecommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/aws/service/ecs/optimized-ami/amazon-linux/recommended/image_id"
"Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id"
},
"TaskDefTheContainerAssetImageImageName92ECAC22": {
"Type": "String",
Expand Down

0 comments on commit 32e3421

Please sign in to comment.