diff --git a/al2.pkr.hcl b/al2.pkr.hcl index 225661d..a8438e9 100644 --- a/al2.pkr.hcl +++ b/al2.pkr.hcl @@ -137,6 +137,16 @@ build { ] } + provisioner "shell" { + script = "scripts/install-managed-daemons.sh" + environment_vars = [ + "REGION=${var.region}", + "AGENT_VERSION=${var.ecs_agent_version}", + "AIR_GAPPED=${var.air_gapped}", + "MANAGED_DAEMON_BASE_URL=${var.managed_daemon_base_url}" + ] + } + provisioner "shell" { script = "scripts/install-additional-packages.sh" } diff --git a/al2023.pkr.hcl b/al2023.pkr.hcl index 3dfb6cc..9e48262 100644 --- a/al2023.pkr.hcl +++ b/al2023.pkr.hcl @@ -105,6 +105,16 @@ build { ] } + provisioner "shell" { + script = "scripts/install-managed-daemons.sh" + environment_vars = [ + "REGION=${var.region}", + "AGENT_VERSION=${var.ecs_agent_version}", + "AIR_GAPPED=${var.air_gapped}", + "MANAGED_DAEMON_BASE_URL=${var.managed_daemon_base_url}" + ] + } + provisioner "shell" { script = "scripts/append-efs-client-info.sh" } diff --git a/scripts/install-managed-daemons.sh b/scripts/install-managed-daemons.sh new file mode 100644 index 0000000..d4f77d2 --- /dev/null +++ b/scripts/install-managed-daemons.sh @@ -0,0 +1,179 @@ +#!/usr/bin/env bash +set -ex + +if [ -n "$AIR_GAPPED" ]; then + echo "Air-gapped region, assuming ecs-init and dependencies will be in additional-packages/ directory" + exit 0 +fi + +WORK_DIR="$(mktemp -d)" +trap "rm -rf ${WORK_DIR}" EXIT + +# gpg key is taken from https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-install.html +cat >"$WORK_DIR/amazon-ecs-agent.gpg" <