diff --git a/features/src/utils/devcontainer-feature.json b/features/src/utils/devcontainer-feature.json index ab51b661..c75173e4 100644 --- a/features/src/utils/devcontainer-feature.json +++ b/features/src/utils/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "devcontainer-utils", "id": "utils", - "version": "23.12.0", + "version": "23.12.1", "description": "A feature to install RAPIDS devcontainer utility scripts", "containerEnv": { "BASH_ENV": "/etc/bash.bash_env" diff --git a/features/src/utils/opt/devcontainer/bin/vault/s3/creds/generate.sh b/features/src/utils/opt/devcontainer/bin/vault/s3/creds/generate.sh index 0294c471..cf503d71 100755 --- a/features/src/utils/opt/devcontainer/bin/vault/s3/creds/generate.sh +++ b/features/src/utils/opt/devcontainer/bin/vault/s3/creds/generate.sh @@ -8,7 +8,7 @@ generate_s3_creds() { if test -z "${VAULT_HOST:-}" \ || test -z "${SCCACHE_BUCKET:-}"; then - return; + exit 1; fi SCCACHE_REGION="${SCCACHE_REGION:-${AWS_DEFAULT_REGION:-}}"; @@ -25,7 +25,7 @@ generate_s3_creds() { source devcontainer-utils-init-github-cli; if test -z "${GITHUB_USER:-}"; then - return; + exit 1; fi # Check whether the user is in one of the allowed GitHub orgs @@ -41,7 +41,7 @@ generate_s3_creds() { )"; if test -z "${user_orgs:-}"; then - return; + exit 1; fi echo "" @@ -56,7 +56,7 @@ generate_s3_creds() { if [ "${vault_token:-null}" = "null" ]; then echo "Your GitHub user was not recognized by vault. Skipping." >&2; - return; + exit 1; fi echo "Successfully authenticated with vault!"; @@ -84,12 +84,12 @@ generate_s3_creds() { if grep -qE "^null$" <<< "${aws_access_key_id:-null}"; then echo "Failed to retrieve AWS S3 credentials. Skipping." >&2; - return; + exit 1; fi if grep -qE "^null$" <<< "${aws_secret_access_key:-null}"; then echo "Failed to retrieve AWS S3 credentials. Skipping." >&2; - return; + exit 1; fi echo "Successfully generated temporary AWS S3 credentials!"; @@ -115,6 +115,6 @@ if test -n "${devcontainer_utils_debug:-}"; then PS4="+ ${BASH_SOURCE[0]}:\${LINENO} "; set -x; fi -(generate_s3_creds "$@"); +generate_s3_creds "$@"; . /etc/profile.d/*-devcontainer-utils.sh; diff --git a/features/src/utils/opt/devcontainer/bin/vault/s3/init.sh b/features/src/utils/opt/devcontainer/bin/vault/s3/init.sh index f08364dc..bcabe313 100755 --- a/features/src/utils/opt/devcontainer/bin/vault/s3/init.sh +++ b/features/src/utils/opt/devcontainer/bin/vault/s3/init.sh @@ -25,16 +25,18 @@ init_vault_s3_creds() { && grep -qE "^$" <<< "${AWS_SECRET_ACCESS_KEY:-}" ; then if test -n "${VAULT_HOST:-}" ; then # Generate S3 creds if they don't exist (or are expired) - if ! devcontainer-utils-vault-s3-creds-test 2>&1 >/dev/null; then - devcontainer-utils-vault-s3-creds-generate; + if devcontainer-utils-vault-s3-creds-test 2>&1 >/dev/null\ + || devcontainer-utils-vault-s3-creds-generate; then + # Persist creds in ~/.aws dir + devcontainer-utils-vault-s3-creds-persist <<< " + $(s3_bucket_args) + $(s3_bucket_auth) + "; + # Install a crontab to refresh the credentials + devcontainer-utils-vault-s3-creds-schedule; + else + devcontainer-utils-vault-s3-creds-persist <<< "--no_bucket --no_region"; fi - # Persist creds in ~/.aws dir - devcontainer-utils-vault-s3-creds-persist <<< " - $(s3_bucket_args) - $(s3_bucket_auth) - "; - # Install a crontab to refresh the credentials - devcontainer-utils-vault-s3-creds-schedule; else # If credentials have been mounted in, ensure they're used case $(devcontainer-utils-vault-s3-creds-test; echo $?) in