Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ci/plugins/scratch-aws-access/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ set -euo pipefail

ci_unimportant_heading "Assuming scratch AWS role"

creds=$(aws sts assume-role --role-arn "$AWS_SCRATCH_ROLE_ARN" --duration-seconds 43200 --role-session-name ci)
# Tag the session with the Buildkite job ID so CloudTrail attributes the
# session to a specific build step. Falls back to a stable "unknown" so
# the call still succeeds outside Buildkite (local dev). AWS source-identity
# regex: [a-zA-Z0-9+=,.@_/-]+, max 64 chars; BUILDKITE_JOB_ID is a UUID.
source_identity="${BUILDKITE_JOB_ID:-unknown}"

creds=$(aws sts assume-role --role-arn "$AWS_SCRATCH_ROLE_ARN" --duration-seconds 43200 --role-session-name ci --source-identity "$source_identity")

AWS_ACCESS_KEY_ID=$(jq -r '.Credentials.AccessKeyId' <<< "$creds")
AWS_SECRET_ACCESS_KEY=$(jq -r '.Credentials.SecretAccessKey' <<< "$creds")
Expand Down
Loading