Last active
May 12, 2023 11:36
-
-
Save guitarrapc/7dab82a3dcffc2921f9f756e7a7f549a to your computer and use it in GitHub Desktop.
Get ARM64 Amazon EC2 Images via awscli, pulumi, terraform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Amazon Linux 2023 | |
# need filter to latest | |
$ aws ec2 describe-images --owners amazon amazon --filters "Name=name,Values=al2023-ami-2023*-arm64" "Name=virtualization-type,Values=hvm" "Name=architecture,Values=arm64" --query 'reverse(sort_by(Images, &CreationDate))[:5].Name' --output text | |
# list of amis | |
$ aws ssm get-parameters-by-path --path "/aws/service/ami-amazon-linux-latest" | |
# only latest returns (same image id) | |
$ aws ssm get-parameters --name /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-arm64 --output text | |
$ aws ssm get-parameters --name /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-arm64 --output text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Amazon Linux 2 | |
# need filter to latest | |
$ aws ec2 describe-images --owners amazon amazon --filters "Name=name,Values=amzn2-ami-kernel-5.10-hvm-*-arm64-gp2" "Name=virtualization-type,Values=hvm" "Name=architecture,Values=arm64" --query 'reverse(sort_by(Images, &CreationDate))[:5].Name' --output text | |
# list of amis | |
$ aws ssm get-parameters-by-path --path "/aws/service/ami-amazon-linux-latest" | |
# only latest returns | |
$ aws ssm get-parameters --name /aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.10-hvm-arm64-gp2 --output text | |
# kernel 4.1 | |
$ aws ssm get-parameters --name /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-arm64-gp2 --output text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Amazon Linux 2 | |
var amzn2Latest = Pulumi.Aws.Ssm.GetParameter.Invoke(new Pulumi.Aws.Ssm.GetParameterInvokeArgs | |
{ | |
Name = "/aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.10-hvm-arm64-gp2", | |
}); | |
// Amazon Linux 2023 | |
var amzn2023Latest = Pulumi.Aws.Ssm.GetParameter.Invoke(new Pulumi.Aws.Ssm.GetParameterInvokeArgs | |
{ | |
Name = "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-arm64", | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "aws_ssm_parameter" "amzn2_latest" { | |
name = "/aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.10-hvm-arm64-gp2" | |
} | |
data "aws_ssm_parameter" "amzn2023_latest" { | |
name = "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-arm64" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment