From eb08906bc71226590e807e09e350c43076a777e0 Mon Sep 17 00:00:00 2001 From: Chien Han Lin Date: Tue, 28 Nov 2023 21:50:24 +0000 Subject: [PATCH] Make EBS CSI driver version overridable --- al2.pkr.hcl | 1 + al2023.pkr.hcl | 1 + scripts/install-managed-daemons.sh | 6 +++++- variables.pkr.hcl | 6 ++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/al2.pkr.hcl b/al2.pkr.hcl index a8438e9..0ad2ad5 100644 --- a/al2.pkr.hcl +++ b/al2.pkr.hcl @@ -142,6 +142,7 @@ build { environment_vars = [ "REGION=${var.region}", "AGENT_VERSION=${var.ecs_agent_version}", + "EBS_CSI_DRIVER_VERSION=${var.ebs_csi_driver_version}", "AIR_GAPPED=${var.air_gapped}", "MANAGED_DAEMON_BASE_URL=${var.managed_daemon_base_url}" ] diff --git a/al2023.pkr.hcl b/al2023.pkr.hcl index 9e48262..7816516 100644 --- a/al2023.pkr.hcl +++ b/al2023.pkr.hcl @@ -110,6 +110,7 @@ build { environment_vars = [ "REGION=${var.region}", "AGENT_VERSION=${var.ecs_agent_version}", + "EBS_CSI_DRIVER_VERSION=${var.ebs_csi_driver_version}", "AIR_GAPPED=${var.air_gapped}", "MANAGED_DAEMON_BASE_URL=${var.managed_daemon_base_url}" ] diff --git a/scripts/install-managed-daemons.sh b/scripts/install-managed-daemons.sh index d4f77d2..9b22390 100644 --- a/scripts/install-managed-daemons.sh +++ b/scripts/install-managed-daemons.sh @@ -151,6 +151,10 @@ if [ -z "$MANAGED_DAEMON_BASE_URL" ]; then MANAGED_DAEMON_BASE_URL="https://s3.$REGION.amazonaws.com${host_suffix}/amazon-ecs-agent-$REGION/" fi +if [ -z "$EBS_CSI_DRIVER_VERSION" ]; then + EBS_CSI_DRIVER_VERSION="v${AGENT_VERSION}" +fi + ARCH=$(uname -m) case "$ARCH" in "aarch64") @@ -165,7 +169,7 @@ case "$ARCH" in esac # Install CSI driver managed daemon -CSI_DRIVER_FILENAME="ebs-csi-driver${ARCH_MOD}-v$AGENT_VERSION.tar" +CSI_DRIVER_FILENAME="ebs-csi-driver${ARCH_MOD}-${EBS_CSI_DRIVER_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" diff --git a/variables.pkr.hcl b/variables.pkr.hcl index 7e7f650..d78ab85 100644 --- a/variables.pkr.hcl +++ b/variables.pkr.hcl @@ -210,3 +210,9 @@ variable "managed_daemon_base_url" { description = "Base URL (minus file name) to download managed daemons from." default = "" } + +variable "ebs_csi_driver_version" { + type = string + description = "EBS CSI driver version to build AMI with." + default = "" +} \ No newline at end of file