pre-command 1.1 KB

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env bash
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. set -euo pipefail
  11. . misc/shlib/shlib.bash
  12. ci_unimportant_heading "Assuming scratch AWS role"
  13. creds=$(aws sts assume-role --role-arn "$AWS_SCRATCH_ROLE_ARN" --duration-seconds 43200 --role-session-name ci)
  14. AWS_ACCESS_KEY_ID=$(jq -r '.Credentials.AccessKeyId' <<< "$creds")
  15. AWS_SECRET_ACCESS_KEY=$(jq -r '.Credentials.SecretAccessKey' <<< "$creds")
  16. AWS_SESSION_TOKEN=$(jq -r '.Credentials.SessionToken' <<< "$creds")
  17. export AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AWS_DEFAULT_REGION
  18. echo "Role ARN: $AWS_SCRATCH_ROLE_ARN"
  19. echo "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID"
  20. echo "AWS_SECRET_ACCESS_KEY=(${#AWS_SECRET_ACCESS_KEY} chars)"
  21. echo "AWS_SESSION_TOKEN=(${#AWS_SESSION_TOKEN} chars)"