Fix variable names in Vault JWT module scripts

- Correct the variable name in `main.tf` and `run.sh` to ensure they are consistent and match expected inputs for Vault CLI interactions.
pull/297/head
Muhammad Atif Ali 10 months ago
parent bf24358b89
commit d3a796e91d

@ -46,9 +46,9 @@ resource "coder_script" "vault" {
display_name = "Vault (GitHub)" display_name = "Vault (GitHub)"
icon = "/icon/vault.svg" icon = "/icon/vault.svg"
script = templatefile("${path.module}/run.sh", { script = templatefile("${path.module}/run.sh", {
CODER_OIDC_ACCESS_TOKEN : data.coder_workspace_owner.me.oidc_token, CODER_OIDC_ACCESS_TOKEN : data.coder_workspace_owner.me.oidc_access_token,
VAULT_JWT_AUTH_PATH : var.vault_jwt_auth_path, VAULT_JWT_AUTH_PATH : var.vault_jwt_auth_path,
VAULT_ROLE : var.vault_jwt_role, VAULT_JWT_ROLE : var.vault_jwt_role,
VAULT_CLI_VERSION : var.vault_cli_version, VAULT_CLI_VERSION : var.vault_cli_version,
}) })
run_on_start = true run_on_start = true

@ -43,22 +43,22 @@ install() {
printf "Unsupported architecture: $${ARCH}\n" printf "Unsupported architecture: $${ARCH}\n"
return 1 return 1
fi fi
# Fetch the latest version of Vault if INSTALL_VERSION is 'latest' # Fetch the latest version of Vault if VAULT_CLI_VERSION is 'latest'
if [ "$${INSTALL_VERSION}" = "latest" ]; then if [ "$${VAULT_CLI_VERSION}" = "latest" ]; then
LATEST_VERSION=$(curl -s https://releases.hashicorp.com/vault/ | grep -v 'rc' | grep -oE 'vault/[0-9]+\.[0-9]+\.[0-9]+' | sed 's/vault\///' | sort -V | tail -n 1) LATEST_VERSION=$(curl -s https://releases.hashicorp.com/vault/ | grep -v 'rc' | grep -oE 'vault/[0-9]+\.[0-9]+\.[0-9]+' | sed 's/vault\///' | sort -V | tail -n 1)
printf "Latest version of Vault is %s.\n\n" "$${LATEST_VERSION}" printf "Latest version of Vault is %s.\n\n" "$${LATEST_VERSION}"
if [ -z "$${LATEST_VERSION}" ]; then if [ -z "$${LATEST_VERSION}" ]; then
printf "Failed to determine the latest Vault version.\n" printf "Failed to determine the latest Vault version.\n"
return 1 return 1
fi fi
INSTALL_VERSION=$${LATEST_VERSION} VAULT_CLI_VERSION=$${VAULT_CLI_VERSION}
fi fi
# Check if the vault CLI is installed and has the correct version # Check if the vault CLI is installed and has the correct version
installation_needed=1 installation_needed=1
if command -v vault > /dev/null 2>&1; then if command -v vault > /dev/null 2>&1; then
CURRENT_VERSION=$(vault version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') CURRENT_VERSION=$(vault version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
if [ "$${CURRENT_VERSION}" = "$${INSTALL_VERSION}" ]; then if [ "$${CURRENT_VERSION}" = "$${VAULT_CLI_VERSION}" ]; then
printf "Vault version %s is already installed and up-to-date.\n\n" "$${CURRENT_VERSION}" printf "Vault version %s is already installed and up-to-date.\n\n" "$${CURRENT_VERSION}"
installation_needed=0 installation_needed=0
fi fi
@ -69,9 +69,9 @@ install() {
if [ -z "$${CURRENT_VERSION}" ]; then if [ -z "$${CURRENT_VERSION}" ]; then
printf "Installing Vault CLI ...\n\n" printf "Installing Vault CLI ...\n\n"
else else
printf "Upgrading Vault CLI from version %s to %s ...\n\n" "$${CURRENT_VERSION}" "${INSTALL_VERSION}" printf "Upgrading Vault CLI from version %s to %s ...\n\n" "$${CURRENT_VERSION}" "${VAULT_CLI_VERSION}"
fi fi
fetch vault.zip "https://releases.hashicorp.com/vault/$${INSTALL_VERSION}/vault_$${INSTALL_VERSION}_linux_$${ARCH}.zip" fetch vault.zip "https://releases.hashicorp.com/vault/$${VAULT_CLI_VERSION}/vault_$${VAULT_CLI_VERSION}_linux_$${ARCH}.zip"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
printf "Failed to download Vault.\n" printf "Failed to download Vault.\n"
return 1 return 1

Loading…
Cancel
Save