Skip to content

Conversation

ykethan
Copy link
Contributor

@ykethan ykethan commented Apr 27, 2025

Issue # (if applicable)

Closes #.

Reason for this change

ECS packages currently does not have all the AMI's from the documentation:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI.html
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_windows_AMI.html

Description of changes

adds

For Windows Server Core variants:

Windows Server 2022 Core: /aws/service/ami-windows-latest/Windows_Server-2022-English-Core-ECS_Optimized
Windows Server 2019 Core: /aws/service/ami-windows-latest/Windows_Server-2019-English-Core-ECS_Optimized

For kernel-specific Amazon Linux 2 variants:

Amazon Linux 2 kernel 5.10: /aws/service/ecs/optimized-ami/amazon-linux-2/kernel-5.10/recommended
Amazon Linux 2 kernel 5.10 (arm64): /aws/service/ecs/optimized-ami/amazon-linux-2/kernel-5.10/arm64/recommended
Amazon Linux 2 kernel 5.10 (GPU): /aws/service/ecs/optimized-ami/amazon-linux-2/kernel-5.10/gpu/recommended
Amazon Linux 2 kernel 5.10 (Neuron): /aws/service/ecs/optimized-ami/amazon-linux-2/kernel-5.10/inf/recommended

Describe any new or updated permissions being added

Description of how you validated changes

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 labels Apr 27, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team April 27, 2025 21:04
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter fails with the following errors:

❌ The title scope of the pull request should omit 'aws-' from the name of modified packages. Use 'ecs' instead of 'aws-ecs'.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Apr 30, 2025
@shikha372 shikha372 self-assigned this Apr 30, 2025
Copy link
Contributor

@shikha372 shikha372 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ykethan for submitting this request, left few comments to address

@ykethan ykethan requested a review from shikha372 May 1, 2025 19:09
this.amiParameterName = constructSsmParameterPath({
windowsVersion: this.windowsVersion,
generation: this.generation,
hwType: this.hwType || AmiHardwareType.STANDARD,
Copy link
Contributor

@shikha372 shikha372 May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we were setting a default value for this.hwtype before, is my understanding correct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, we only set this on EcsOptimizedAmi class

/**
* Constructs a new instance of the EcsOptimizedAmi class.
*/
constructor(props?: EcsOptimizedAmiProps) {
this.hwType = (props && props.hardwareType) || AmiHardwareType.STANDARD;

But in EcsOptimizedImage class dont set a default value during initialization

/**
* Constructs a new instance of the EcsOptimizedAmi class.
*/
private constructor(props: EcsOptimizedAmiProps) {
this.hwType = props && props.hardwareType;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay a little bit confused, can we remove this default that we're adding here or its needed ?

hwType: this.hwType ?? AmiHardwareType.STANDARD,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is needed in this case. Let me explain:

In the original code, we didn't have an explicit default for this.hwType in the EcsOptimizedImage class constructor - it simply assigns this.hwType = props && props.hardwareType which could leave it as undefined.

When we previously constructed the SSM parameter path, we had a series of conditionals:

+ (this.hwType === AmiHardwareType.GPU ? 'gpu/' : '')
+ (this.hwType === AmiHardwareType.ARM ? 'arm64/' : '')
+ (this.hwType === AmiHardwareType.NEURON ? 'inf/' : '')

With these conditionals, if this.hwType was undefined, none of these would match, which functionally behaves like using STANDARD (since no hardware-specific path segment would be added).

Now with the new shared utility function constructSsmParameterPath(), we need to provide an explicit hwType value. Using this.hwType ?? AmiHardwareType.STANDARD ensures we maintain the same behavior as before - if this.hwType is undefined, we default to STANDARD.

So while we're adding an explicit default here, it's not changing the actual behavior - it's just making the implicit default from the original code explicit for the utility function.

Let me know if this makes sense or if you'd prefer to handle it differently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay got it, if I understand correctly, the AmiHardwaretype check was to add specific suffix like 'gpu/' or 'arm64', since there is no special case handling for this.hwType === AmiHardwareType.STANDARD its same as being undefined.

@ykethan ykethan requested a review from shikha372 May 9, 2025 01:51
shikha372
shikha372 previously approved these changes May 22, 2025
@shikha372 shikha372 dismissed their stale review May 22, 2025 22:23

failing build

@shikha372 shikha372 changed the title feat(aws-ecs) :add windows core and kernel optimized ecs amis feat(aws-ecs): add windows core and kernel optimized ecs amis May 27, 2025
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 022da8d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@ykethan ykethan closed this by deleting the head repository Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK contribution/core This is a PR that came from AWS. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants