Publish AMI artifact IDs to SSM

This commit is contained in:
Timothy J. Aveni
2026-06-28 17:41:21 -07:00
parent 70797543e4
commit 30d6ba2332
3 changed files with 109 additions and 6 deletions
+18 -1
View File
@@ -271,6 +271,20 @@ aws ec2 create-tags \
"Key=RootSnapshotId,Value=${root_snapshot_id}" \
"Key=NixSnapshotId,Value=${nix_snapshot_id}"
ssm_ami_prefix="/quixos/amis/${name}/${architecture}"
for ssm_ami_parameter_name in \
"${ssm_ami_prefix}/recommended" \
"${ssm_ami_prefix}/by-builder-rev/${builder_git_rev}" \
"${ssm_ami_prefix}/by-input-hash/${input_hash}"
do
aws ssm put-parameter \
--region "$aws_region" \
--name "$ssm_ami_parameter_name" \
--type String \
--value "$image_id" \
--overwrite >/dev/null
done
aws ec2 deregister-image --region "$aws_region" --image-id "$capture_image_id" >/dev/null
jq -n \
@@ -285,6 +299,7 @@ jq -n \
--arg rootDeviceName "$root_device_name" \
--arg nixDeviceName "$nix_device_name" \
--arg nixPool "$nix_pool" \
--arg ssmRecommendedParameter "${ssm_ami_prefix}/recommended" \
'{
architecture: $architecture,
system: $system,
@@ -296,7 +311,8 @@ jq -n \
nixSnapshotId: $nixSnapshotId,
rootDeviceName: $rootDeviceName,
nixDeviceName: $nixDeviceName,
nixPool: $nixPool
nixPool: $nixPool,
ssmRecommendedParameter: $ssmRecommendedParameter
}' > artifact.json
if [ "$keep_builder" = false ]; then
@@ -313,3 +329,4 @@ if [ "$keep_builder" = false ]; then
fi
echo "Published AMI: $image_id"
echo "Published SSM parameter: ${ssm_ami_prefix}/recommended"