diff --git a/al2022.pkr.hcl b/al2022.pkr.hcl index 33cc12f..d7bb8e7 100644 --- a/al2022.pkr.hcl +++ b/al2022.pkr.hcl @@ -1,5 +1,5 @@ locals { - ami_name_al2022 = "${var.ami_name_prefix_al2022}-hvm-2022.0.${var.ami_version}-x86_64-ebs" + ami_name_al2022 = "${var.ami_name_prefix_al2022}-hvm-2022.0.${var.ami_version}${var.kernel_version_al2022}-x86_64" } source "amazon-ebs" "al2022" { diff --git a/al2022arm.pkr.hcl b/al2022arm.pkr.hcl index 441c450..70898ee 100644 --- a/al2022arm.pkr.hcl +++ b/al2022arm.pkr.hcl @@ -1,5 +1,5 @@ locals { - ami_name_al2022arm = "${var.ami_name_prefix_al2022}-hvm-2022.0.${var.ami_version}-arm64-ebs" + ami_name_al2022arm = "${var.ami_name_prefix_al2022}-hvm-2022.0.${var.ami_version}${var.kernel_version_al2022arm}-arm64" } source "amazon-ebs" "al2022arm" { diff --git a/al2022neu.pkr.hcl b/al2022neu.pkr.hcl index f0cc009..fbfbcd5 100644 --- a/al2022neu.pkr.hcl +++ b/al2022neu.pkr.hcl @@ -1,5 +1,5 @@ locals { - ami_name_al2022neu = "${var.ami_name_prefix_al2022}-neuron-hvm-2022.0.${var.ami_version}-x86_64-ebs" + ami_name_al2022neu = "${var.ami_name_prefix_al2022}-neuron-hvm-2022.0.${var.ami_version}${var.kernel_version_al2022}-x86_64" } source "amazon-ebs" "al2022neu" { diff --git a/generate-release-vars.sh b/generate-release-vars.sh index 4309f21..84f36aa 100755 --- a/generate-release-vars.sh +++ b/generate-release-vars.sh @@ -53,10 +53,12 @@ ami_name_al2_arm=$(aws ec2 describe-images --region "$region" --owner amazon --i # AL2022 ami_id_al2022_x86=$(aws ssm get-parameters --region "$region" --names /aws/service/ami-amazon-linux-latest/al2022-ami-minimal-kernel-default-x86_64 --query 'Parameters[0].[Value]' --output text) ami_name_al2022_x86=$(aws ec2 describe-images --region "$region" --owner amazon --image-id "$ami_id_al2022_x86" --query 'Images[0].Name' --output text) +kernel_version_al2022_x86=$(grep -o -e "-kernel-[1-9.]*" <<<"$ami_name_al2022_x86") # AL2022 ARM (use describe-images for now until al2022 ARM SSM parameters are ready) ami_id_al2022_arm=$(aws ec2 describe-images --region "$region" --owners amazon --filters "Name=name,Values=al2022-ami-minimal-2022.0.*" "Name=architecture,Values=arm64" --query "reverse(sort_by(Images, &CreationDate))[0].ImageId" --output text) ami_name_al2022_arm=$(aws ec2 describe-images --region "$region" --owner amazon --image-id "$ami_id_al2022_arm" --query 'Images[0].Name' --output text) +kernel_version_al2022_arm=$(grep -o -e "-kernel-[1-9.]*" <<<"$ami_name_al2022_arm") # Get the latest AL2022 distribution release # xmllint is required to find the latest distribution release from releasemd.xml in us-west-2 @@ -75,5 +77,7 @@ source_ami_al2 = "$ami_name_al2_x86" source_ami_al2arm = "$ami_name_al2_arm" source_ami_al2022 = "$ami_name_al2022_x86" source_ami_al2022arm = "$ami_name_al2022_arm" +kernel_version_al2022 = "$kernel_version_al2022_x86" +kernel_version_al2022arm = "$kernel_version_al2022_arm" distribution_release_al2022 = "$distribution_release_al2022" EOF diff --git a/release.auto.pkrvars.hcl b/release.auto.pkrvars.hcl index e4c20d1..16cbabb 100644 --- a/release.auto.pkrvars.hcl +++ b/release.auto.pkrvars.hcl @@ -9,3 +9,5 @@ source_ami_al2arm = "amzn2-ami-minimal-hvm-2.0.20220912.1-arm64-ebs" source_ami_al2022 = "al2022-ami-minimal-2022.0.20220928.0-kernel-5.15-x86_64" source_ami_al2022arm = "al2022-ami-minimal-2022.0.20220928.0-kernel-5.15-arm64" distribution_release_al2022 = "2022.0.20220928" +kernel_version_al2022 = "-kernel-5.15" +kernel_version_al2022arm = "-kernel-5.15" diff --git a/variables.pkr.hcl b/variables.pkr.hcl index 626a3ed..cd1d069 100644 --- a/variables.pkr.hcl +++ b/variables.pkr.hcl @@ -104,6 +104,16 @@ variable "distribution_release_al2022" { description = "Amazon Linux 2022 distribution release." } +variable "kernel_version_al2022" { + type = string + description = "Amazon Linux 2022 kernel version." +} + +variable "kernel_version_al2022arm" { + type = string + description = "Amazon Linux 2022 ARM kernel version." +} + variable "ami_name_prefix_al1" { type = string description = "Outputted AMI name prefix."