From 3c729be3c5c3e8847ce9b7fa28aa477e02d36fc4 Mon Sep 17 00:00:00 2001 From: sanne Date: Mon, 10 Jan 2022 16:56:12 +0100 Subject: [PATCH] tools/appsre-build-worker-packer: Add image_users variable packer will share the ami with those users. --- templates/packer/composer.pkr.hcl | 3 +++ templates/packer/variables.pkr.hcl | 5 +++++ tools/appsre-build-worker-packer.sh | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/templates/packer/composer.pkr.hcl b/templates/packer/composer.pkr.hcl index 8ca9fbbff..9233008e1 100644 --- a/templates/packer/composer.pkr.hcl +++ b/templates/packer/composer.pkr.hcl @@ -37,6 +37,9 @@ source "amazon-ebs" "image_builder" { # Set a name for the resulting AMI. ami_name = "${var.image_name}" + # Share the resulting AMI with accounts + ami_users = "${var.image_users}" + # Network configuration for the instance building our image. associate_public_ip_address = true ssh_interface = "public_ip" diff --git a/templates/packer/variables.pkr.hcl b/templates/packer/variables.pkr.hcl index 2f2f2237f..4e01a2580 100644 --- a/templates/packer/variables.pkr.hcl +++ b/templates/packer/variables.pkr.hcl @@ -15,6 +15,11 @@ variable "osbuild_commit" { type = string } # The name of the resulting AMI and the underlying EBS snapshot variable "image_name" { type = string } +# A list of users to share the AMI with +variable "image_users" { + type = list(string) + default = [] +} # Skip ansible tags variable "ansible_skip_tags" { diff --git a/tools/appsre-build-worker-packer.sh b/tools/appsre-build-worker-packer.sh index bb8d1262c..2549ba8db 100755 --- a/tools/appsre-build-worker-packer.sh +++ b/tools/appsre-build-worker-packer.sh @@ -143,6 +143,13 @@ else SKIP_TAGS="rpmrepo" fi +# Format: PACKER_IMAGE_USERS="\"000000000000\",\"000000000001\"" +if [ -n "$PACKER_IMAGE_USERS" ]; then + cat > templates/packer/share.auto.pkrvars.hcl <