Conversation
| generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX, | ||
| const amznLinux2 = ec2.MachineImage.latestAmazonLinux2({ | ||
| edition: ec2.AmazonLinuxEdition.STANDARD, | ||
| virtualization: ec2.AmazonLinuxVirt.HVM, | ||
| storage: ec2.AmazonLinuxStorage.GENERAL_PURPOSE, | ||
| cpuType: ec2.AmazonLinuxCpuType.X86_64, | ||
| kernel: ec2.AmazonLinux2Kernel.KERNEL_5_10, | ||
| }); | ||
|
|
||
| const amznLinux2023 = ec2.MachineImage.latestAmazonLinux2023({ | ||
| edition: ec2.AmazonLinuxEdition.STANDARD, | ||
| cpuType: ec2.AmazonLinuxCpuType.X86_64, | ||
| kernel: ec2.AmazonLinux2023Kernel.KERNEL_6_1, |
There was a problem hiding this comment.
This can be moved to another PR, just noticed the deprecated method usage when updating the Windows example below
There was a problem hiding this comment.
Not thrilled about adding a ton of noise to the breaking changes list, but I don't think it would safe to not list them
all individually and use something like removed:aws-cdk-lib.aws_ec2.WindowsVersion.*
There was a problem hiding this comment.
Might not be required, I'm trying to have WindowsVersion become a union of two new enums instead, WindowsLatest and WindowsSpecific. Will see if JSII doesn't complain too much
There was a problem hiding this comment.
Aborting this idea, it would be even messier:
/**
* @deprecated use {@link WindowsLatestVersion} or {@link WindowsSpecificVersion} instead
*/
export const WindowsVersion = { ...WindowsLatestVersion, ...WindowsSpecificVersion };
export type WindowsVersion = typeof WindowsVersion[keyof typeof WindowsVersion];API elements with incompatible changes:
err - ENUM aws-cdk-lib.aws_ec2.WindowsVersion: has been removed [removed:aws-cdk-lib.aws_ec2.WindowsVersion]
err - METHOD aws-cdk-lib.aws_ec2.MachineImage.latestWindows: argument version, takes aws-cdk-lib.aws_ec2.WindowsLatestVersion (formerly aws-cdk-lib.aws_ec2.WindowsVersion): could not find type aws-cdk-lib.aws_ec2.WindowsVersion [incompatible-argument:aws-cdk-lib.aws_ec2.MachineImage.latestWindows]
err - INITIALIZER aws-cdk-lib.aws_ec2.WindowsImage.<initializer>: argument version, takes aws-cdk-lib.aws_ec2.WindowsLatestVersion | aws-cdk-lib.aws_ec2.WindowsSpecificVersion (formerly aws-cdk-lib.aws_ec2.WindowsVersion): none of aws-cdk-lib.aws_ec2.WindowsVersion are assignable to aws-cdk-lib.aws_ec2.WindowsLatestVersion | aws-cdk-lib.aws_ec2.WindowsSpecificVersion, could not find type aws-cdk-lib.aws_ec2.WindowsVersion, could not find type aws-cdk-lib.aws_ec2.WindowsVersion [incompatible-argument:aws-cdk-lib.aws_ec2.WindowsImage.<initializer>]Unsurprisingly, the enum appears as being deleted, even though it retains its values and typing. The bigger issue is that I would need to introduce another breaking change by changing the type of MachineImage.latestWindows.
Removing the unusable enum values added to WindowsVersion is not really an issue for users, but requiring them to change their existing stacks would be a huge pain for basically no gain.
So we're back to the original plan of removing the newly added datestamped WindowsVersion values
This reverts commit 195a484.
| /** | ||
| * Specific, datestamped Windows version name. | ||
| */ | ||
| export enum WindowsSpecificVersion { |
There was a problem hiding this comment.
Will this break folks currently using a timestamped version?
There was a problem hiding this comment.
The datestamped versions never worked with WindowsVersion, since the constructor uses ssm:GetParameter, looking for the /aws/service/ami-windows-latest/<version> key. Only non-datestamped versions keys are listed, and their corresponding value points to the latest AMI version, as shown here:
$ aws ssm get-parameters --names /aws/service/ami-windows-latest/Windows_Server-2022-English-Full-Base | jq '.Parameters[] | .Value'
"ami-03cd80cfebcbb4481"
$ aws ec2 describe-images --image-ids ami-03cd80cfebcbb4481 | jq '.Images[] | .Name'
"Windows_Server-2022-English-Full-Base-2024.03.13"| ec2.WindowsSpecificVersion.WINDOWS_SERVER_2016_ENGLISH_FULL_BASE_2023_11_15, | ||
| ec2.WindowsSpecificVersion.WINDOWS_SERVER_2019_ENGLISH_FULL_BASE_2023_12_13, | ||
| ec2.WindowsSpecificVersion.WINDOWS_SERVER_2022_ENGLISH_CORE_ECS_OPTIMIZED_2024_01_10, | ||
| ]; |
packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.windows-machine-image.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.windows-machine-image.ts
Outdated
Show resolved
Hide resolved
msambol
left a comment
There was a problem hiding this comment.
I like the direction you took this. This LGTM.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
TheRealAmazonKendra
left a comment
There was a problem hiding this comment.
A couple of things here before I start looking at specifics:
- I see the addition of deprecated versions. We shouldn't be adding anything that's deprecated.
- What's the actual value add of all these hyper specific versions? If we are going to need to maintain a hyper specific and extremely long list like this, we need a pretty compelling reason for it.
|
Main use case I see for this PR is giving users an easier access to stable versions so their instances don't get replaced on deploy when there's a new latest version. I don't think this is a good enough reason to continue down this path, reverting the previous change with #29737 should be enough 👍 |
What I'd suggest here is rather than us keeping an exhaustive list in an enum, is having a function where they can provide the date themselves. If no date is provided, yolo, we choose one for you and it gets replaced on deploy, if one is provided, we always use that. |
|
Good call. For now, I'm going to close this PR. I'll open another one to re-update |
Issue # (if applicable)
Closes #29736
Reason for this change
Oversight on my part when #29435 was created. I'd assumed that Windows versions and their datestamped counterparts (e.g.
Windows_Server-2022-English-Full-BaseandWindows_Server-2022-English-Full-Base-2024.02.14) could be retrieved in the same manner, and that the non-datestamped versions had just been removed since they were not being listed byec2:DescribeImages.The non datestamped versions are actually SSM parameter name suffixes used to retrieve the latest AMI image ID for a given region:
Description of changes
WindowsVersioninto a second enum,WindowsSpecificVersionWindowsSpecificVersioncorresponds to a "datestampless" value inWindowsVersion, e.g.WindowsSpecificVersion.WINDOWS_SERVER_2022_ENGLISH_FULL_BASE_2024_02_14andWindowsVersion.WINDOWS_SERVER_2022_ENGLISH_FULL_BASE@deprecatedtags forWindowsVersionsMachineImage.specificWindowsstatic method to lookupWindowsSpecificVersionsDescription of how you validated changes
I've added unit and integration tests to validate both
MachineImage.specificWindowsandMachineImage.latestWindows.The
WindowsSpecificVersionvalues were compared to the SDK results ofec2:DescribeImageswith the following params:{ "Owners": ["amazon"], "Filters": [{ "Name": "name", "Values": ["Windows_Server*"] }] }The
WindowsVersionvalues were compared to the SDK results ofssm:GetParametersByPathwith the following params:{ "Path": "/aws/service/ami-windows-latest", }The parameters that did not start with
/aws/service/ami-windows-latest/Windows_Serverwere ignored. Some are Amazon Linux images:amzn2-ami-hvm-2.0.*amzn2-x86_64-SQL_2019_*Others are either EC2LaunchV2 or NitroTPM Windows images, neither currently supported by the CDK:
EC2LaunchV2-Windows_Server-2016-English-*TPM-Windows_Server-2016-English-*TPM-Windows_Server-2019-English-*TPM-Windows_Server-2022-English-*Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license