Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

aws_ec2: Parameter cpu_type ignored when calling ec2.MachineImage.latest_amazon_linux2023() #28201

Closed
jedreky opened this issue Nov 30, 2023 · 4 comments
Assignees
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@jedreky
Copy link

jedreky commented Nov 30, 2023

Describe the bug

I am using AWS CDK in Python. I want to get the latest Amazon Linux AMI for either x86 or arm architecture, to do this I call:

ec2.MachineImage.latest_amazon_linux2023(cpu_type=ec2.AmazonLinuxCpuType.X86_64).ssm_parameter_name()
ec2.MachineImage.latest_amazon_linux2023(cpu_type=ec2.AmazonLinuxCpuType.ARM_64).ssm_parameter_name()

Expected Behavior

I would expect to get two different outputs.

Current Behavior

In both cases I get:

'/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64'

Reproduction Steps

import aws_cdk.aws_ec2 as ec2
print(ec2.MachineImage.latest_amazon_linux2023(cpu_type=ec2.AmazonLinuxCpuType.X86_64).ssm_parameter_name())
print(ec2.MachineImage.latest_amazon_linux2023(cpu_type=ec2.AmazonLinuxCpuType.ARM_64).ssm_parameter_name())

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.109.0 (build 941dc16)

Framework Version

No response

Node.js Version

v20.5.1

OS

Linux

Language

Python

Language Version

3.11.1

Other information

No response

@jedreky jedreky added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 30, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Nov 30, 2023
@khushail khushail self-assigned this Nov 30, 2023
@khushail khushail added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 30, 2023
@khushail
Copy link
Contributor

Hi @jedreky, thanks for reporting this

@lpizzinidev
Copy link
Contributor

lpizzinidev commented Dec 2, 2023

@jedreky
ssm_parameter_name is a static method and does not inherit the properties from the AmazonLinux2023ImageSsmParameter instantiated by latest_amazon_linux2023.

You should be able to retrieve the correct image with:

ec2.MachineImage.latest_amazon_linux2023(cpu_type=ec2.AmazonLinuxCpuType.ARM_64).get_image(scope).image_id

Or, if you want to use the static method:

ec2.AmazonLinux2023ImageSsmParameter.ssm_parameter_name(kernel=ec2.AmazonLinux2023Kernel.CDK_LATEST, cpu_type=ec2.AmazonLinuxCpuType.ARM_64)

@jedreky
Copy link
Author

jedreky commented Dec 4, 2023

hey Luca, the first method works, thanks a lot :)

@jedreky jedreky closed this as completed Dec 4, 2023
Copy link

github-actions bot commented Dec 4, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

No branches or pull requests

3 participants