name: setup_profile description: Use the AWS credentials GH action and the AWS CLI to set up an AWS profile on the worker inputs: profile-name: description: 'The name of the AWS profile that credentials should be placed in' required: true role-to-assume: description: 'The role whose credentials will be placed in the given profile' required: true aws-region: description: 'The region that will be configured for the profile' required: true runs: using: composite steps: - name: Fetch credentials id: credentials uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2 with: role-to-assume: ${{ inputs.role-to-assume }} aws-region: ${{ inputs.aws-region }} # NOTE: session lifetime is capped at the e2e roles' MaxSessionDuration # (currently 1h). We intentionally do NOT set role-duration-seconds # higher here — STS rejects it with "requested DurationSeconds exceeds # the MaxSessionDuration set for this role". The durable fix for # long-running retrying e2e jobs (iam_access_drift / # amplify_outputs_backwards_compatibility) is either (a) raising those # roles' MaxSessionDuration in the e2e account, or (b) re-assuming the # role inside the retry loop — both account/infra-owned, tracked # separately. # Credentials with special characters are not handled correctly on Windows # when put into profile files. This forces action to retry until credentials without special characters # are retrieved # See: https://github.com/aws-actions/configure-aws-credentials/issues/599 # and https://github.com/aws-actions/configure-aws-credentials/issues/528 special-characters-workaround: ${{ contains(runner.os, 'Windows') }} # places the credentials in the GH context object rather than setting env vars # the AWS credentials action does not have an option to configure a profile, so this manually configures one output-credentials: true - shell: bash run: | aws configure set aws_access_key_id ${{ steps.credentials.outputs.aws-access-key-id }} --profile ${{ inputs.profile-name }} aws configure set aws_secret_access_key ${{ steps.credentials.outputs.aws-secret-access-key }} --profile ${{ inputs.profile-name }} aws configure set aws_session_token ${{ steps.credentials.outputs.aws-session-token }} --profile ${{ inputs.profile-name }} aws configure set region ${{ inputs.aws-region }} --profile ${{ inputs.profile-name }}