Skip to content

Commit

Permalink
Add install-managed-daemons.sh script to al2 and al2023
Browse files Browse the repository at this point in the history
Currently this only installs the ebs-csi-driver managed daemon, but it
will likely be expanded to add more in future.
  • Loading branch information
sparrc committed Oct 27, 2023
1 parent 69366c1 commit 53b84a0
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 0 deletions.
10 changes: 10 additions & 0 deletions al2.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
10 changes: 10 additions & 0 deletions al2023.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
179 changes: 179 additions & 0 deletions scripts/install-managed-daemons.sh
Original file line number Diff line number Diff line change
@@ -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" <<EOF
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2
mQINBFq1SasBEADliGcT1NVJ1ydfN8DqebYYe9ne3dt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xt9r0MiLgcLyspWxSdmoYGZ6nQP
RO5Nm/ZVS+u2imPCRzNUZEMa+dlE6kHx0rS0dPiuJ4O7NtPeYDKkoQtNagspsDvh
cK7CSqAiKMq06UBTxqlTSRkm62eOCtcs3p3OeHu5GRZF1uzTET0ZxYkaPgdrQknx
ozjP5mC7X+45lcCfmcVt94TFNL5HwEUVJpmOgmzILCI8yoDTWzloo+i+fPFsXX4f
kynhE83mSEcr5VHFYrTY3mQXGmNJ3bCLuc/jq7ysGq69xiKmTlUeXFm+aojcRO5i
zyShIRJZ0GZfuzDYFDbMV9amA/YQGygLw//zP5ju5SW26dNxlf3MdFQE5JJ86rn9
MgZ4gcpazHEVUsbZsgkLizRp9imUiH8ymLqAXnfRGlU/LpNSefnvDFTtEIRcpOHc
bhayG0bk51Bd4mioOXnIsKy4j63nJXA27x5EVVHQ1sYRN8Ny4Fdr2tMAmj2O+X+J
qX2yy/UX5nSPU492e2CdZ1UhoU0SRFY3bxKHKB7SDbVeav+K5g==
=Gi5D
-----END PGP PUBLIC KEY BLOCK-----
EOF

if [ -z "$MANAGED_DAEMON_BASE_URL" ]; then
host_suffix=""
if grep -q "^cn-" <<<"$REGION"; then
host_suffix=".cn"
fi
MANAGED_DAEMON_BASE_URL="https://s3.$REGION.amazonaws.com${host_suffix}/amazon-ecs-agent-$REGION/"
fi

ARCH=$(uname -m)
case "$ARCH" in
"aarch64")
ARCH_MOD="-arm64"
;;
"arm64")
ARCH_MOD="-arm64"
;;
*)
ARCH_MOD=""
;;
esac

# Install CSI driver managed daemon
CSI_DRIVER_FILENAME="ebs-csi-driver${ARCH_MOD}-v$AGENT_VERSION.tar"
CSI_DRIVER_FULL_URL="${MANAGED_DAEMON_BASE_URL}${CSI_DRIVER_FILENAME}"

curl -fLSs -o "$WORK_DIR/${CSI_DRIVER_FILENAME}" "$CSI_DRIVER_FULL_URL"
curl -fLSs -o "$WORK_DIR/${CSI_DRIVER_FILENAME}.asc" "${CSI_DRIVER_FULL_URL}.asc"
# bypass gpg check until gpg util is available in minimal AMI
# we've added a gpg check to our manual release steps until then
gpg --import "$WORK_DIR/amazon-ecs-agent.gpg" || true
gpg --verify "$WORK_DIR/${CSI_DRIVER_FILENAME}.asc" "$WORK_DIR/${CSI_DRIVER_FILENAME}" || true

sudo mkdir -p "/var/lib/ecs/deps/daemons/ebs-csi-driver/"
sudo mv "$WORK_DIR/${CSI_DRIVER_FILENAME}" "/var/lib/ecs/deps/daemons/ebs-csi-driver/ebs-csi-driver.tar"
6 changes: 6 additions & 0 deletions variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,9 @@ variable "neu_instance_types" {
description = "List of available in-region instance types for NEU platform"
default = ["inf1.xlarge"]
}

variable "managed_daemon_base_url" {
type = string
description = "Base URL (minus file name) to download managed daemons from."
default = ""
}

0 comments on commit 53b84a0

Please sign in to comment.