* chore(deps-dev): bump vitest from 3.2.4 to 4.1.5 (#1748) * chore(deps-dev): bump vitest from 3.2.4 to 4.1.5 Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 3.2.4 to 4.1.5. - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Commits](https://github.com/vitest-dev/vitest/commits/v4.1.5/packages/vitest) --- updated-dependencies: - dependency-name: vitest dependency-version: 4.1.5 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): update @vitest/coverage-v8 Bump @vitest/coverage-v8 to ^4.1.5 to match peer dependency, and move vi.mock('node:fs') calls to the top level of test files to reflect actual hoisting semantics required by vitest 4.x. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Keller <kellertk@amazon.com> (cherry picked from commit78f374f6d1) * chore(deps): bump @actions/core from 2.0.3 to 3.0.1 (#1746) * chore(deps): bump @actions/core from 2.0.3 to 3.0.1 Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 2.0.3 to 3.0.1. - [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core) --- updated-dependencies: - dependency-name: "@actions/core" dependency-version: 3.0.1 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * chore: update test mocks for @actions/core ESM @actions/core v3 ships as an ESM module with non-configurable exports, breaking vi.spyOn(). Switch to vi.mock('@actions/core') which intercepts at the module loader level. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Keller <kellertk@amazon.com> (cherry picked from commit64d8e82527) * chore(deps): bump @aws-sdk/client-sts from 3.1043.0 to 3.1044.0 (#1754) Bumps [@aws-sdk/client-sts](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/clients/client-sts) from 3.1043.0 to 3.1044.0. - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/clients/client-sts/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.1044.0/clients/client-sts) --- updated-dependencies: - dependency-name: "@aws-sdk/client-sts" dependency-version: 3.1042.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commit4cfda40a13) * chore: bump unit test node version (#1758) (cherry picked from commit39d1702721) * chore: automatic major version tagging (#1565) * Update release-please.yml to auto-update version tag * chore: configure release-please auto floating tag --------- Co-authored-by: Tom Keller <kellertk@amazon.com> (cherry picked from commitc36525a567) * feat: Allow custom session tags to be passed when assuming a role (#1759) * Add possibility to input custom session tags * Use json for input to custom-tags, add documentation for custom-tags * Add more examples * Simplify example to avoid parse error * Add input validation for custom tags * Fix unit tests for custom-tags * Add debugging message * Skip failing test for now * Build package * Remove some unused validation for custom tags * feat: add validation for custom session tags Harden the custom-tags feature against misuse and misconfiguration: - Validate input is a JSON object (reject arrays, primitives, null) - Enforce STS tag constraints: key length (128), value length (256), allowed characters - Reject nested object/array values that would silently stringify to '[object Object]' - Block overriding default session tags (GitHub, Repository, Workflow, etc.) - Enforce 50-tag session limit - Warn when custom-tags used with OIDC or web identity - Fix missing await on helpers test assertion - Remove unused CUSTOM_TAGS_JSON_INPUTS fixture - Normalize test mocking to vi.mocked() pattern --------- Co-authored-by: Sylvain Verly <sylvain.verly@gmail.com> (cherry picked from commit61f50f630f) * chore: configure codeql to ignore generated code (#1760) (cherry picked from commitdc2353e57a) * feat: support custom STS endpoints (#1762) Closes #1067. This is a advanced option and is not needed for most deployments. (cherry picked from commit8d52d05d7a) * chore: automate README version bumping (#1763) Closes #1420. (cherry picked from commit07ada0fe07) * feat: add more retry logic and better logging (#1764) Wraps exportAccountId and validateCredentials calls in retryAndBackoff. Closes #1681. Adds a label parameter to retryAndBackoff for better info-level log messages. (cherry picked from commit540d0c13ae) * feat: add regex validation to role-session-name (#1765) Previously invalid role session names would get errors from the STS API instead of this action rejecting them, causing unnecessary retries. Now we check them and fail early. Closes #1656. That FR recommended that we sanitize the name before sending to STS, but instead we error to not silently change the user's selected session name (avoiding the potential security sharp edge) (cherry picked from commite35449909c) * chore: update documentation for environment workflows (#1766) Closes #1238. (cherry picked from commit3f7e1b63d7) * chore(deps): bump @aws-sdk/client-sts from 3.1044.0 to 3.1045.0 (#1767) Bumps [@aws-sdk/client-sts](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/clients/client-sts) from 3.1044.0 to 3.1045.0. - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/clients/client-sts/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.1045.0/clients/client-sts) --- updated-dependencies: - dependency-name: "@aws-sdk/client-sts" dependency-version: 3.1045.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commita388f23f7d) * chore(deps-dev): bump @vitest/coverage-v8 from 4.1.5 to 4.1.6 (#1768) Bumps [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8) from 4.1.5 to 4.1.6. - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Commits](https://github.com/vitest-dev/vitest/commits/v4.1.6/packages/coverage-v8) --- updated-dependencies: - dependency-name: "@vitest/coverage-v8" dependency-version: 4.1.6 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commit1fb495c4b2) * chore(deps-dev): bump @smithy/property-provider from 4.2.14 to 4.3.1 (#1771) Bumps [@smithy/property-provider](https://github.com/smithy-lang/smithy-typescript/tree/HEAD/packages/property-provider) from 4.2.14 to 4.3.1. - [Release notes](https://github.com/smithy-lang/smithy-typescript/releases) - [Changelog](https://github.com/smithy-lang/smithy-typescript/blob/main/packages/property-provider/CHANGELOG.md) - [Commits](https://github.com/smithy-lang/smithy-typescript/commits/@smithy/property-provider@4.3.1/packages/property-provider) --- updated-dependencies: - dependency-name: "@smithy/property-provider" dependency-version: 4.3.1 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commit1ab31502aa) * chore(deps): bump @smithy/node-http-handler from 4.6.1 to 4.7.1 (#1770) Bumps [@smithy/node-http-handler](https://github.com/smithy-lang/smithy-typescript/tree/HEAD/packages/node-http-handler) from 4.6.1 to 4.7.1. - [Release notes](https://github.com/smithy-lang/smithy-typescript/releases) - [Changelog](https://github.com/smithy-lang/smithy-typescript/blob/main/packages/node-http-handler/CHANGELOG.md) - [Commits](https://github.com/smithy-lang/smithy-typescript/commits/@smithy/node-http-handler@4.7.1/packages/node-http-handler) --- updated-dependencies: - dependency-name: "@smithy/node-http-handler" dependency-version: 4.7.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commitdbd503f368) * chore(deps-dev): bump @biomejs/biome from 2.4.14 to 2.4.15 (#1772) Bumps [@biomejs/biome](https://github.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome) from 2.4.14 to 2.4.15. - [Release notes](https://github.com/biomejs/biome/releases) - [Changelog](https://github.com/biomejs/biome/blob/main/packages/@biomejs/biome/CHANGELOG.md) - [Commits](https://github.com/biomejs/biome/commits/@biomejs/biome@2.4.15/packages/@biomejs/biome) --- updated-dependencies: - dependency-name: "@biomejs/biome" dependency-version: 2.4.15 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commit7521c55910) * chore(deps-dev): bump @types/node from 25.6.0 to 25.7.0 (#1773) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 25.6.0 to 25.7.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-version: 25.7.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commitef734cca81) * feat: expose run id in STS client user-agent (#1774) * feat: expose run id in STS client user-agent Closes #483. This commit modifies the user-agent string so that it includes the GITHUB_RUN_ID and the GITHUB_RUN_ATTEMPT, in the format typically used by the SDK. User agent strings are logged to CloudTrail, allowing users to correlate CloudTrail events with GHA runs. We took this approach instead of logging the ACCESS_KEY_ID as suggested in the issue to avoid logging sensitive information. * feat: add github_action to ua string (cherry picked from commit29d1be3027) * feat: add additional session tags by default (#1775) Closes #390. Note that 50 session tags are the AWS default, and this commit changes our default set from 7 tags to 15 tags. This commit includes logic to split the tags into "required" vs "overridable". Required tags are this action's previous defaults and could never be overridden. Overridable tags are the new set and can be overridden by custom-tags. The action will not add tags if the addition plus the required plus the user's custom tags exceed the AWS limit of 50 total tags. This ensures backwards compat for the tag additions. (cherry picked from commite0ba768507) * chore: document forgejo compatibility (#1776) * chore: document forgejo compatibility * chore: linting fixes (cherry picked from commitf35a7d7d7e) * fix: skip credential check on output-env-credentials: false (#1778) Closes #1554. (cherry picked from commit58e7c47adf) * chore: update README for additional claim support (#1779) * chore: update README for additional claim support * chore: lint fix (whitespace) (cherry picked from commit713aaabfec) * chore(deps): bump @smithy/node-http-handler from 4.7.1 to 4.7.3 (#1781) Bumps [@smithy/node-http-handler](https://github.com/smithy-lang/smithy-typescript/tree/HEAD/packages/node-http-handler) from 4.7.1 to 4.7.3. - [Release notes](https://github.com/smithy-lang/smithy-typescript/releases) - [Changelog](https://github.com/smithy-lang/smithy-typescript/blob/main/packages/node-http-handler/CHANGELOG.md) - [Commits](https://github.com/smithy-lang/smithy-typescript/commits/@smithy/node-http-handler@4.7.3/packages/node-http-handler) --- updated-dependencies: - dependency-name: "@smithy/node-http-handler" dependency-version: 4.7.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commita7c33ae483) * chore(deps-dev): bump @types/node from 25.7.0 to 25.9.0 (#1785) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 25.7.0 to 25.9.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-version: 25.9.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commitffde832a1d) * chore(deps-dev): bump @aws-sdk/credential-provider-env (#1784) Bumps [@aws-sdk/credential-provider-env](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/packages-internal/credential-provider-env) from 3.972.34 to 3.972.38. - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/packages-internal/credential-provider-env/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/HEAD/packages-internal/credential-provider-env) --- updated-dependencies: - dependency-name: "@aws-sdk/credential-provider-env" dependency-version: 3.972.38 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commitbc1093db1d) * chore(deps-dev): bump @smithy/property-provider from 4.3.1 to 4.3.3 (#1783) Bumps [@smithy/property-provider](https://github.com/smithy-lang/smithy-typescript/tree/HEAD/packages/property-provider) from 4.3.1 to 4.3.3. - [Release notes](https://github.com/smithy-lang/smithy-typescript/releases) - [Changelog](https://github.com/smithy-lang/smithy-typescript/blob/main/packages/property-provider/CHANGELOG.md) - [Commits](https://github.com/smithy-lang/smithy-typescript/commits/@smithy/property-provider@4.3.3/packages/property-provider) --- updated-dependencies: - dependency-name: "@smithy/property-provider" dependency-version: 4.3.3 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commitfe6ad3af19) * chore(deps): bump @aws-sdk/client-sts from 3.1045.0 to 3.1049.0 (#1782) Bumps [@aws-sdk/client-sts](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/clients/client-sts) from 3.1045.0 to 3.1049.0. - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/clients/client-sts/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.1049.0/clients/client-sts) --- updated-dependencies: - dependency-name: "@aws-sdk/client-sts" dependency-version: 3.1049.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commit4684f47f89) * chore: reconcile lockfile and test formatting * chore: Update dist --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Michael Lehmann <lehmanmj@amazon.com> Co-authored-by: Sylvain Verly <sylvain.verly@gmail.com>
805 lines
43 KiB
Markdown
805 lines
43 KiB
Markdown
# Configure AWS Credentials
|
|
|
|
Authenticate to AWS in GitHub Actions (and others)! Works especially well with
|
|
[AWS Secrets Manager][secretsmanager].
|
|
|
|
[secretsmanager]: https://github.com/aws-actions/aws-secretsmanager-get-secrets
|
|
|
|
## Quick Start (OIDC, recommended)
|
|
|
|
1. Create an IAM Identity Provider in your AWS account for GitHub OIDC. (See
|
|
[OIDC configuration](#oidc-configuration-details) below for details.)
|
|
2. Create an IAM Role in your AWS account with a trust policy that allows GitHub
|
|
Actions to assume it. (Expand the sections below) <details>
|
|
<summary>GitHub OIDC Trust Policy</summary>
|
|
|
|
```json
|
|
{
|
|
"Version": "2012-10-17",
|
|
"Statement": [
|
|
{
|
|
"Effect": "Allow",
|
|
"Principal": {
|
|
"Federated": "arn:aws:iam::<AWS_ACCOUNT_ID>:oidc-provider/token.actions.githubusercontent.com"
|
|
},
|
|
"Action": "sts:AssumeRoleWithWebIdentity",
|
|
"Condition": {
|
|
"StringEquals": {
|
|
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
|
|
"token.actions.githubusercontent.com:sub": "repo:<GITHUB_ORG>/<GITHUB_REPOSITORY>:ref:refs/heads/<GITHUB_BRANCH>"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
</details>
|
|
|
|
Note: if you are running in a GitHub environment based workflow, the value
|
|
for the Sub claim will be different, in the form of
|
|
`repo:<GITHUB_ORG>/<GITHUB_REPOSITORY>:environment:<ENVIRONMENT_NAME>`.
|
|
Adjust the trust policy accordingly if you are using environment-based
|
|
workflows.
|
|
|
|
3. Attach permissions to the IAM Role that allow it to access the AWS resources
|
|
you need.
|
|
4. Add the following to your GitHub Actions workflow: <details>
|
|
<summary>Example Workflow</summary>
|
|
|
|
```yaml
|
|
# Need ID token write permission to use OIDC
|
|
permissions:
|
|
id-token: write
|
|
jobs:
|
|
run_job_with_aws:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Configure AWS Credentials
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
role-to-assume: <Role ARN you created in step 2>
|
|
aws-region: <AWS Region you want to use>
|
|
- name: Additional steps
|
|
run: |
|
|
# Your commands that require AWS credentials
|
|
aws sts get-caller-identity
|
|
```
|
|
|
|
</details>
|
|
|
|
That's it! Your GitHub Actions workflow can now access AWS resources using the
|
|
IAM Role you created. Other authentication scenarios are also supported (see
|
|
below).
|
|
|
|
## Security Recommendations
|
|
|
|
- Use temporary credentials when possible. OIDC is recommended because it
|
|
provides temporary credentials and it's easy to set up.
|
|
- Do not store credentials in your repository's code. Consider using
|
|
[git-secrets](https://github.com/awslabs/git-secrets) to prevent committing
|
|
secrets to your repository.
|
|
- [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege)
|
|
to your workflows. Grant only those permissions that are necessary for the
|
|
workflow to run.
|
|
- [Monitor the activity](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#keep-a-log)
|
|
of the credentials used in workflows.
|
|
- Periodically rotate any long-lived credentials that you use.
|
|
- Store sensitive information in a secure way, such as using
|
|
[AWS Secrets Manager](https://aws.amazon.com/secrets-manager/) or [GitHub
|
|
Secrets][gh-secrets].
|
|
- Be especially careful about running Actions in non-ephemeral environments, or
|
|
[triggering workflows on `pull_request_target`](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request_target)
|
|
events.
|
|
|
|
[gh-secrets]:
|
|
https://docs.github.com/en/actions/security-guides/encrypted-secrets
|
|
|
|
## Non-OIDC Authentication Options
|
|
|
|
This action supports five different authentication methods that are configured
|
|
by specifying different inputs.
|
|
|
|
1. Use a `core.getIDToken()` call to authenticate via OIDC.
|
|
2. Re-export existing long-lived IAM credentials (access key ID and secret
|
|
access key) as environment variables.
|
|
3. Use static credentials stored in GitHub Secrets to fetch temporary
|
|
credentials via STS AssumeRole.
|
|
4. Use a Web Identity Token to fetch temporary credentials via STS
|
|
AssumeRoleWithWebIdentity.
|
|
5. Use credentials stored in the Action environment to fetch temporary
|
|
credentials via STS AssumeRole.
|
|
|
|
Because we use the AWS JavaScript SDK, we always will use the [credential
|
|
resolution flow for Node.js][cred-resolution].
|
|
|
|
[cred-resolution]:
|
|
https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html
|
|
|
|
Depending on your inputs, the action might override parts of this flow.
|
|
|
|
<details>
|
|
<summary>Inputs and their effects on the credential resolution flow</summary>
|
|
|
|
| **Identity Used** | `aws-access-key-id` | `role-to-assume` | `web-identity-token-file` | `role-chaining` |
|
|
| --------------------------------------- | ------------------- | ---------------- | ------------------------- | --------------- |
|
|
| [✅ Recommended] GitHub OIDC | | ✔ | | |
|
|
| IAM User (no AssumeRole) | ✔ | | | |
|
|
| AssumeRole using static IAM credentials | ✔ | ✔ | | |
|
|
| AssumeWithWebIdentity use a token file | | ✔ | ✔ | |
|
|
| AssumeRole using existing credentials | | ✔ | | ✔ |
|
|
|
|
_Note: `role-chaining` is not always necessary to use existing credentials. If
|
|
you're getting a "Credentials loaded by the SDK do not match" error, try
|
|
enabling this option._
|
|
|
|
</details>
|
|
|
|
Additionally, **`aws-region`** is always required.
|
|
|
|
_Note: If you use GitHub Enterprise Server, you may need to adjust examples here
|
|
to match your environment._
|
|
|
|
## Additional Options
|
|
|
|
### Options
|
|
|
|
The options list can be expanded below. See [action.yml](./action.yml) for more
|
|
detail.
|
|
|
|
<details>
|
|
<summary>Options list and descriptions</summary>
|
|
|
|
| Option | Description | Required |
|
|
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
|
|
| aws-region | Which AWS region to use | Yes |
|
|
| aws-profile | Name of the AWS profile to configure. When provided, credentials are written to `~/.aws/credentials` and `~/.aws/config` files. This enables configuring multiple profiles in a single workflow. Name cannot contain whitespace, square brackets, or slashes. When set, credentials will not be exported as environment variables unless `output-env-credentials` is manually set to true. | No |
|
|
| overwrite-aws-profile | Overwrite the given AWS profile if it already exists. When set to false or not set, an error will be thrown if the profile already exists. | No |
|
|
| role-to-assume | Role for which to fetch credentials. Only required for some authentication types. | No |
|
|
| aws-access-key-id | AWS access key to use. Only required for some authentication types. | No |
|
|
| aws-secret-access-key | AWS secret key to use. Only required for some authentication types. | No |
|
|
| aws-session-token | AWS session token to use. Used in uncommon authentication scenarios. | No |
|
|
| role-chaining | Use existing credentials from the environment to assume a new role. | No |
|
|
| audience | The JWT audience when using OIDC. Used in non-default AWS partitions, like China regions. | No |
|
|
| http-proxy | An HTTP proxy to use for API calls. | No |
|
|
| mask-aws-account-id | AWS account IDs are not considered secret. Setting this will hide account IDs from output anyway. | No |
|
|
| role-duration-seconds | The assumed role duration in seconds, if assuming a role. Defaults to 1 hour (3600 seconds). Acceptable values range from 15 minutes (900 seconds) to 12 hours (43200 seconds). | No |
|
|
| role-external-id | The external ID of the role to assume. Only needed if your role requires it. | No |
|
|
| role-session-name | Defaults to "GitHubActions", but may be changed if required. | No |
|
|
| role-skip-session-tagging | Skips session tagging if set. | No |
|
|
| transitive-tag-keys | Define a list of transitive tag keys to pass when assuming a role. | No |
|
|
| inline-session-policy | You may further restrict the assumed role policy by defining an inline policy here. | No |
|
|
| managed-session-policies | You may further restrict the assumed role policy by specifying a managed policy here. | No |
|
|
| output-credentials | When set, outputs fetched credentials as action step output. (Outputs aws-access-key-id, aws-secret-access-key, aws-session-token, aws-account-id, authenticated-arn, and aws-expiration). Defaults to false. | No |
|
|
| output-env-credentials | When set, outputs fetched credentials as environment variables (AWS_REGION, AWS_DEFAULT_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, and AWS_PROFILE (if profile option is used)). Defaults to true when `aws-profile` is not set, and false when `aws-profile` is set. Set to false to avoid setting env variables. (NOTE: Setting to false will prevent aws-account-id from being exported as a step output). | No |
|
|
| unset-current-credentials | When set, attempts to unset any existing credentials in your action runner. | No |
|
|
| disable-retry | Disabled retry/backoff logic for assume role calls. By default, retries are enabled. | No |
|
|
| retry-max-attempts | Limits the number of retry attempts before giving up. Defaults to 12. | No |
|
|
| special-characters-workaround | Uncommonly, some environments cannot tolerate special characters in a secret key. This option will retry fetching credentials until the secret access key does not contain special characters. This option overrides disable-retry and retry-max-attempts. | No |
|
|
| use-existing-credentials | When set, the action will check if existing credentials are valid and exit if they are. Defaults to false. | No |
|
|
| allowed-account-ids | A comma-delimited list of expected AWS account IDs. The action will fail if we receive credentials for the wrong account. | No |
|
|
| force-skip-oidc | When set, the action will skip using GitHub OIDC provider even if the id-token permission is set. | No |
|
|
| action-timeout-s | Global timeout for the action in seconds. If set to a value greater than 0, the action will fail if it takes longer than this time to complete. | No |
|
|
|
|
</details>
|
|
|
|
#### Adjust the retry mechanism
|
|
|
|
You can configure retry settings for if the STS call fails. By default, we retry
|
|
with exponential backoff `12` times. You can disable this behavior altogether by
|
|
setting the `disable-retry` input to `true`, or you can configure the number of
|
|
times it retries with the `retry-max-attempts` input.
|
|
|
|
#### Mask account ID
|
|
|
|
Your account ID is not masked by default in workflow logs. You can set the
|
|
`mask-aws-account-id` input to `true` to mask your account ID in workflow logs
|
|
if desired.
|
|
|
|
#### Unset current credentials
|
|
|
|
Sometimes, existing credentials in your runner can get in the way of the
|
|
intended outcome. You can set the `unset-current-credentials` input to `true` to
|
|
work around this issue.
|
|
|
|
#### Configure named AWS profiles
|
|
|
|
By default, this action exports credentials as environment variables
|
|
(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc.). However, you can use the
|
|
`aws-profile` input to configure named AWS profiles. When `aws-profile` is
|
|
provided, credentials are written to `~/.aws/credentials` and `~/.aws/config`
|
|
files (which are created if they don't already exist). The default locations of
|
|
these files will be overridden if the `AWS_SHARED_CREDENTIALS_FILE` and
|
|
`AWS_CONFIG_FILE` environment variables are present.
|
|
|
|
Profile names may not contain whitespace, square brackets, or forward or
|
|
backslashes.
|
|
|
|
Writing to a profile will prevent credentials being written to the environment
|
|
by default. Use `output-env-credentials: true` if you would like the credentials
|
|
to also be exported as environment variables.
|
|
|
|
By default, the action will not overwrite existing profiles. If you would like
|
|
to overwrite a profile, set the `overwrite-aws-profile` input to `true`.
|
|
|
|
_Note: When writing profiles, the action will preserve existing profile sections
|
|
in the credentials and config files. However, comments in these files will not
|
|
be preserved._
|
|
|
|
_Caution: Writing to the AWS configuration file means that credentials will
|
|
persist in the execution environment even after the action cleanup step. Use
|
|
extreme care to ensure that this is safe in your environment and you do not leak
|
|
valid credentials unintentionally. Writing to configuration files is intended
|
|
for unusual authentication scenarios._
|
|
|
|
For using profiles with static IAM User Credentials or when using one role to
|
|
assume another, role chaining is needed:
|
|
|
|
<details>
|
|
|
|
If using static credentials, it's necessary to set `role-chaining: true` and
|
|
specify the profile name as an environment variable in the job step:
|
|
|
|
```yaml
|
|
- name: Configure AWS Credentials
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
aws-region: us-east-1
|
|
role-to-assume: arn:aws:iam::123456789100:role/my-role
|
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
aws-profile: MyProfile1
|
|
role-chaining: true
|
|
env:
|
|
AWS_PROFILE: MyProfile1
|
|
```
|
|
|
|
If you are using one role to assume another while using profiles, the subsequent
|
|
steps must set `role-chaining: true` and specify the prior profile's name as
|
|
step environment variables:
|
|
|
|
```yaml
|
|
- name: Configure AWS credentials
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
aws-region: us-east-1
|
|
role-to-assume: arn:aws:iam::123456789100:role/my-first-role
|
|
aws-profile: firstRoleInChain
|
|
|
|
- name: assume second role
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
aws-region: us-east-2
|
|
role-to-assume: arn:aws:iam::987654321000:role/my-second-role
|
|
role-chaining: true
|
|
aws-profile: secondRoleInChain
|
|
env:
|
|
AWS_PROFILE: firstRoleInChain
|
|
```
|
|
|
|
</details>
|
|
|
|
See the [Examples](#examples) section for more usage examples.
|
|
|
|
#### Skip the cleanup
|
|
|
|
By default, this action runs a post-job cleanup step that removes credentials
|
|
from the environment. To skip this step, set the `AWS_SKIP_CLEANUP_STEP`
|
|
environment variable to `true`:
|
|
|
|
```yaml
|
|
env:
|
|
AWS_SKIP_CLEANUP_STEP: "true"
|
|
```
|
|
|
|
#### Use an HTTP proxy
|
|
|
|
If need use an HTTP proxy you can set it in the action manually. Additionally
|
|
this action will always consider the `HTTP_PROXY` environment variable.
|
|
|
|
<details>
|
|
<summary>Proxy configuration</summary>
|
|
|
|
Manually configured proxy:
|
|
|
|
```yaml
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
aws-region: us-east-2
|
|
role-to-assume: my-github-actions-role
|
|
http-proxy: "http://companydomain.com:3128"
|
|
```
|
|
|
|
Proxy configured in the environment variable:
|
|
|
|
```bash
|
|
# Your environment configuration
|
|
HTTP_PROXY="http://companydomain.com:3128"
|
|
```
|
|
|
|
</details>
|
|
|
|
#### Special characters in AWS_SECRET_ACCESS_KEY
|
|
|
|
Some edge cases are unable to properly parse an `AWS_SECRET_ACCESS_KEY` if it
|
|
contains special characters. For more information, please see the [AWS CLI
|
|
documentation][aws-cli-troubleshooting].
|
|
|
|
[aws-cli-troubleshooting]:
|
|
https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-troubleshooting.html#tshoot-signature-does-not-match
|
|
|
|
If you set the `special-characters-workaround` option, this action will
|
|
continually retry fetching credentials until we get one that does not have
|
|
special characters. This option overrides the `disable-retry` and
|
|
`retry-max-attempts` options. We recommend that you do not enable this option
|
|
unless required, because retrying APIs infinitely until they succeed is not best
|
|
practice.
|
|
|
|
## Session Naming and Policies
|
|
|
|
The default session name is "GitHubActions", and you can modify it by specifying
|
|
the desired name in `role-session-name`.
|
|
|
|
_Note: you might find it helpful to set the `role-session-name` to
|
|
`${{ github.run_id }}` so as to clarify in audit logs which AWS actions were
|
|
performed by which workflow run._
|
|
|
|
The session will be tagged with the following tags: (Refer to [GitHub's
|
|
documentation for `GITHUB_` environment variable definitions][gh-env-vars])
|
|
|
|
[gh-env-vars]:
|
|
https://docs.github.com/en/actions/reference/workflows-and-actions/variables#default-environment-variables
|
|
|
|
**Protected tags** are always emitted when session tags are used, and cannot be
|
|
overridden via `custom-tags`:
|
|
|
|
| Key | Value |
|
|
| ---------- | ----------------- |
|
|
| GitHub | "Actions" |
|
|
| Repository | GITHUB_REPOSITORY |
|
|
| Workflow | GITHUB_WORKFLOW |
|
|
| Action | GITHUB_ACTION |
|
|
| Actor | GITHUB_ACTOR |
|
|
| Commit | GITHUB_SHA |
|
|
| Branch | GITHUB_REF |
|
|
|
|
**Overrideable tags** are automatically added to the set of default session tags
|
|
but may be overridden via `custom-tags`. AWS has a maximum limit of 50 session
|
|
tags; tags from this list are dropped in reverse priority order if your
|
|
`custom-tags` set plus the protected set exceeds this limit.
|
|
|
|
| Key | Value | Priority |
|
|
| --------------- | ----------------------- | -------- |
|
|
| EventName | GITHUB_EVENT_NAME | 1 |
|
|
| BaseRef | GITHUB_BASE_REF | 2 |
|
|
| HeadRef | GITHUB_HEAD_REF | 3 |
|
|
| RefName | GITHUB_REF_NAME | 4 |
|
|
| RunId | GITHUB_RUN_ID | 5 |
|
|
| RefType | GITHUB_REF_TYPE | 6 |
|
|
| Job | GITHUB_JOB | 7 |
|
|
| TriggeringActor | GITHUB_TRIGGERING_ACTOR | 8 |
|
|
|
|
Tags whose source environment variable is unset are omitted (e.g., `BaseRef` and
|
|
`HeadRef` are only set on `pull_request` events).
|
|
|
|
_Note: all tag values must conform to
|
|
[the tag requirements][sts-tag-requirements].
|
|
Values longer than 256 characters will be truncated, and characters outside the
|
|
allowed set will be replaced with an underscore (`_`).\_
|
|
|
|
[sts-tag-requirements]:
|
|
https://docs.aws.amazon.com/STS/latest/APIReference/API_Tag.html
|
|
|
|
The action will use session tagging by default unless you are using OIDC.
|
|
|
|
To [forward session tags to subsequent sessions in a role
|
|
chain][session-tag-chaining], you can use
|
|
|
|
[session-tag-chaining]:
|
|
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_role-chaining
|
|
|
|
the `transitive-tag-keys` input to specify the keys of the tags to be passed.
|
|
|
|
_Note that all subsequent roles in the chain must have
|
|
`role-skip-session-tagging` set to `true`_
|
|
|
|
```yaml
|
|
uses: aws-actions/configure-aws-credentials@v6
|
|
with:
|
|
transitive-tag-keys: |
|
|
Repository
|
|
Workflow
|
|
Action
|
|
Actor
|
|
```
|
|
|
|
### Custom session tags
|
|
|
|
You can add custom session tags using the `custom-tags` input, which accepts a
|
|
JSON object. Custom tags cannot override protected tags, but they can override
|
|
overrideable tags (in which case the overrideable tag's slot is freed for the
|
|
next overrideable tag in the priority list, if any).
|
|
|
|
```yaml
|
|
uses: aws-actions/configure-aws-credentials@v6
|
|
with:
|
|
custom-tags: '{"Environment": "Production", "Team": "Platform"}'
|
|
```
|
|
|
|
_Note: custom tags are not supported when using OIDC or web identity token
|
|
authentication. In those flows, session tags are controlled by the identity
|
|
provider's token claims._
|
|
|
|
### Session policies
|
|
|
|
Session policies are not required, but they allow you to limit the scope of the
|
|
fetched credentials without making changes to IAM roles. You can specify inline
|
|
session policies right in your workflow file, or refer to an existing managed
|
|
session policy by its ARN.
|
|
|
|
#### Inline session policies
|
|
|
|
An IAM policy in stringified JSON format that you want to use as an inline
|
|
session policy. Depending on preferences, the JSON could be written on a single
|
|
line.
|
|
|
|
<details>
|
|
<summary>Inline session policy examples</summary>
|
|
|
|
```yaml
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
inline-session-policy: '{"Version":"2012-10-17","Statement":[{"Sid":"Stmt1","Effect":"Allow","Action":"s3:List*","Resource":"*"}]}'
|
|
```
|
|
|
|
Or we can have a nicely formatted JSON as well:
|
|
|
|
```yaml
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
inline-session-policy: >-
|
|
{
|
|
"Version": "2012-10-17",
|
|
"Statement": [
|
|
{
|
|
"Sid":"Stmt1",
|
|
"Effect":"Allow",
|
|
"Action":"s3:List*",
|
|
"Resource":"*"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
</details>
|
|
|
|
#### Managed session policies
|
|
|
|
The Amazon Resource Names (ARNs) of the IAM managed policies that you want to
|
|
use as managed session policies. The policies must exist in the same account as
|
|
the role.
|
|
|
|
<details>
|
|
<summary>Managed session policy examples</summary>
|
|
|
|
```yaml
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
managed-session-policies: arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
|
|
```
|
|
|
|
And we can pass multiple managed policies likes this:
|
|
|
|
```yaml
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
managed-session-policies: |
|
|
arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
|
|
arn:aws:iam::aws:policy/AmazonS3OutpostsReadOnlyAccess
|
|
```
|
|
|
|
</details>
|
|
|
|
### Custom STS endpoint
|
|
|
|
Use the `sts-endpoint` input to override the AWS STS endpoint URL. Most users
|
|
should not set this option and instead let the SDK derive the correct endpoint
|
|
from the specified region.
|
|
|
|
## OIDC Configuration Details
|
|
|
|
We recommend using
|
|
[GitHub's OIDC provider](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services)
|
|
to get short-lived AWS credentials needed for your actions. When using OIDC, you
|
|
configure IAM to accept JWTs from GitHub's OIDC endpoint. This action will then
|
|
create a JWT unique to the workflow run using the OIDC endpoint, and it will use
|
|
the JWT to assume the specified role with short-term credentials.
|
|
|
|
To get this to work
|
|
|
|
1. Configure your workflow to use the `id-token: write` permission.
|
|
2. Configure your audience, if required.
|
|
3. In your AWS account, configure IAM to trust GitHub's OIDC identity provider.
|
|
4. Configure an IAM role with appropriate claim limits and permission scope.
|
|
|
|
_Note_: Naming your role "GitHubActions" has been reported to not work. See
|
|
[#953](https://github.com/aws-actions/configure-aws-credentials/issues/953).
|
|
|
|
5. Specify that role's ARN when setting up this action.
|
|
|
|
### OIDC Audience
|
|
|
|
When the JWT is created, an audience needs to be specified. Normally, you would
|
|
use `sts.amazonaws.com`, and this action uses this by default if you don't
|
|
specify one. This will work for most cases. Changing the default audience may be
|
|
necessary when using non-default AWS partitions, such as China regions. You can
|
|
specify the audience through the `audience` input:
|
|
|
|
```yaml
|
|
- name: Configure AWS Credentials for China region audience
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
audience: sts.amazonaws.com.cn
|
|
aws-region: cn-northwest-1
|
|
role-to-assume: arn:aws-cn:iam::123456789100:role/my-github-actions-role
|
|
```
|
|
|
|
### Configuring IAM to trust GitHub
|
|
|
|
To use GitHub's OIDC provider, you must first set up federation in your AWS
|
|
account. This involves creating an IAM Identity Provider that trusts GitHub's
|
|
OIDC endpoint. You can create an IAM Identity Provider in the AWS Management
|
|
Console by specifying the following details:
|
|
|
|
- **Provider Type**: OIDC
|
|
- **Provider URL**: `https://token.actions.githubusercontent.com`
|
|
- **Audience**: `sts.amazonaws.com` (or your custom audience if you specified
|
|
one in the `audience` input)
|
|
|
|
Prior versions of this documentation gave instructions for specifying the
|
|
certificate fingerprint, but this is no longer necessary. The thumbprint, if
|
|
specified, will be ignored.
|
|
|
|
You can also create the IAM Identity Provider using the AWS CLI:
|
|
|
|
```bash
|
|
aws iam create-open-id-connect-provider \
|
|
--url https://token.actions.githubusercontent.com \
|
|
--client-id-list sts.amazonaws.com
|
|
```
|
|
|
|
### Claims and scoping permissions
|
|
|
|
To align with the Amazon IAM best practice of [granting least
|
|
privilege][least-privilege], the assume role policy document should contain a
|
|
[`Condition`](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html)
|
|
that restricts which workflows can assume the role. Without any condition, any
|
|
GitHub user or repository could potentially assume the role.
|
|
|
|
GitHub provides a number of additional claims in the OIDC token that you can use
|
|
in your IAM policies to scope down permissions. Early versions of this action
|
|
only supported the `sub` and `aud` claims, but AWS IAM and GitHub have since
|
|
added support for `sub` claim customization and a variety of additional
|
|
claims ([1][gh-blog-oidc], [2][sub-claim-custom]).
|
|
|
|
> **Warning:** Avoid `ForAllValues:` in `Allow` statements. These operators
|
|
> return true when the claim is absent or misspelled, which can lead to
|
|
> uninended access. Instead, use `StringEquals` or `StringLike` operators to
|
|
> check for specific claim values.
|
|
|
|
[least-privilege]:
|
|
https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege
|
|
[gh-blog-oidc]:
|
|
https://aws.amazon.com/about-aws/whats-new/2026/01/aws-sts-supports-validation-identity-provider-claims/
|
|
[sub-claim-custom]:
|
|
https://docs.github.com/en/rest/actions/oidc?apiVersion=2026-03-10
|
|
|
|
#### Inspecting the token
|
|
|
|
If you aren't sure what claim values your workflow is producing, the
|
|
[`actions-oidc-debugger`](https://github.com/github/actions-oidc-debugger)
|
|
action will print the decoded JWT payload. Run it in a private repository
|
|
only — the token itself is short-lived but the claim values may be sensitive.
|
|
|
|
See the GitHub [security-hardening guide][gh-oidc-hardening] for further
|
|
discussion of trust conditions and threat modeling.
|
|
|
|
[gh-oidc-hardening]:
|
|
https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect
|
|
|
|
### Further information about OIDC
|
|
|
|
For further information on OIDC and GitHub Actions, please see:
|
|
|
|
- [AWS docs: Creating OpenID Connect (OIDC) identity providers](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html)
|
|
- [AWS docs: IAM JSON policy elements: Condition](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html)
|
|
- [GitHub docs: About security hardening with OpenID Connect](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
- [GitHub docs: Configuring OpenID Connect in Amazon Web Services](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services)
|
|
- [GitHub changelog: GitHub Actions: Secure cloud deployments with OpenID Connect](https://github.blog/changelog/2021-10-27-github-actions-secure-cloud-deployments-with-openid-connect/)
|
|
|
|
## Compatibility with non-GitHub Actions environments
|
|
|
|
This action has been sucessfully tested with
|
|
Codeberg/[Forgejo Actions](https://forgejo.org/docs/next/user/actions/overview/)
|
|
and should be generally compatible with any CI/CD environment that sets the
|
|
correct `GITHUB_` environment variables. For use with Foregejo, please review
|
|
the
|
|
[runner differences with GitHub's action runners][forgejo-gh-differences].
|
|
|
|
[forgejo-gh-differences]:
|
|
https://forgejo.org/docs/next/user/actions/github-actions/#known-list-of-differences
|
|
The main difference to be aware of is that Forgejo uses the
|
|
`enable-openid-connect` flag to enable OIDC instad of GitHub's `id-token: write`
|
|
permission. Forgejo also uses a slightly different syntax for the workflow
|
|
definition file, omitting some subkeys.
|
|
|
|
For OIDC use, the issuer name for the IAM IdP for GitHub Actions is
|
|
`token.actions.githubusercontent.com`. For Forgejo Actions it is
|
|
`[foregejo instance url]/api/actions`. As an example, Codeberg would use
|
|
`codeberg.org/api/actions` as the issuer URL when configuring the IAM Identity
|
|
Provider. The audience would still be `sts.amazonaws.com` by default.
|
|
|
|
## Examples
|
|
|
|
### AssumeRoleWithWebIdentity
|
|
|
|
```yaml
|
|
- name: Configure AWS Credentials
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
aws-region: us-east-2
|
|
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
|
|
role-session-name: MySessionName
|
|
```
|
|
|
|
In this example, the Action will load the OIDC token from the GitHub-provided
|
|
environment variable and use it to assume the role
|
|
`arn:aws:iam::123456789100:role/my-github-actions-role` with the session name
|
|
`MySessionName`.
|
|
|
|
### AssumeRole with role previously assumed by action in same workflow
|
|
|
|
```yaml
|
|
- name: Configure AWS Credentials
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
aws-region: us-east-2
|
|
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
|
|
role-session-name: MySessionName
|
|
- name: Configure other AWS Credentials
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
aws-region: us-east-2
|
|
role-to-assume: arn:aws:iam::987654321000:role/my-second-role
|
|
role-session-name: MySessionName
|
|
role-chaining: true
|
|
```
|
|
|
|
In this two-step example, the first step will use OIDC to assume the role
|
|
`arn:aws:iam::123456789100:role/my-github-actions-role` just as in the prior
|
|
example. Following that, a second step will use this role to assume a different
|
|
role, `arn:aws:iam::987654321000:role/my-second-role`.
|
|
|
|
Note that the trust relationship/trust policy of the second role must grant the
|
|
permissions `sts:AssumeRole` and `sts:TagSession` to the first role. (Or,
|
|
alternatively, the `TagSession` permission can be omitted if you are using the
|
|
`role-skip-session-tagging: true` flag for the second step.)
|
|
|
|
### AssumeRole with static IAM credentials in repository secrets
|
|
|
|
```yaml
|
|
- name: Configure AWS Credentials
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
aws-region: us-east-2
|
|
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
|
|
role-external-id: ${{ secrets.AWS_ROLE_EXTERNAL_ID }}
|
|
role-duration-seconds: 1200
|
|
role-session-name: MySessionName
|
|
```
|
|
|
|
In this example, the secret `AWS_ROLE_TO_ASSUME` contains a string like
|
|
`arn:aws:iam::123456789100:role/my-github-actions-role`. To assume a role in the
|
|
same account as the static credentials, you can simply specify the role name,
|
|
like `role-to-assume: my-github-actions-role`.
|
|
|
|
### Retrieving credentials from step output
|
|
|
|
```yaml
|
|
- name: Configure AWS Credentials 1
|
|
id: creds
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
aws-region: us-east-2
|
|
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
|
|
output-credentials: true
|
|
- name: get caller identity 1
|
|
run: |
|
|
aws sts get-caller-identity
|
|
- name: Configure AWS Credentials 2
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
aws-region: us-east-2
|
|
aws-access-key-id: ${{ steps.creds.outputs.aws-access-key-id }}
|
|
aws-secret-access-key: ${{ steps.creds.outputs.aws-secret-access-key }}
|
|
aws-session-token: ${{ steps.creds.outputs.aws-session-token }}
|
|
role-to-assume: arn:aws:iam::123456789100:role/my-other-github-actions-role
|
|
- name: get caller identity2
|
|
run: |
|
|
aws sts get-caller-identity
|
|
```
|
|
|
|
This example shows that you can reference the fetched credentials as outputs if
|
|
`output-credentials` is set to true. This example also shows that you can use
|
|
the `aws-session-token` input in a situation where session tokens are fetched
|
|
and passed to this action.
|
|
|
|
If you only want the credentials available as _step outputs_ and not exported to
|
|
the environment (for example, on a self-hosted runner where you do not want the
|
|
assumed-role credentials to shadow an existing EC2 instance profile), pair
|
|
`output-credentials: true` with `output-env-credentials: false`. In that mode,
|
|
the action does not run its post-credential SDK-pickup validation step, since
|
|
the credentials were never written to the environment.
|
|
|
|
### Configure multiple AWS profiles in a single workflow
|
|
|
|
```yaml
|
|
- name: Configure AWS Credentials for Dev
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
aws-region: us-east-1
|
|
role-to-assume: arn:aws:iam::111111111111:role/dev-role
|
|
aws-profile: dev
|
|
|
|
- name: Configure AWS Credentials for Prod
|
|
uses: aws-actions/configure-aws-credentials@v6.1.0
|
|
with:
|
|
aws-region: us-west-2
|
|
role-to-assume: arn:aws:iam::222222222222:role/prod-role
|
|
aws-profile: prod
|
|
|
|
- name: Use multiple profiles
|
|
run: |
|
|
# Check caller identity for dev account
|
|
aws sts get-caller-identity --profile dev
|
|
|
|
# Check caller identity for prod account
|
|
aws sts get-caller-identity --profile prod
|
|
|
|
# Deploy to dev using CDK
|
|
cdk deploy --profile dev
|
|
```
|
|
|
|
This example shows how to configure multiple named AWS profiles in a single
|
|
workflow. When using the `aws-profile` input, credentials are written to
|
|
`~/.aws/credentials` and `~/.aws/config` files, allowing you to reference
|
|
different profiles using the `--profile` flag with AWS CLI, SDKs, CDK, and other
|
|
tools.
|
|
|
|
Each profile is independent and can authenticate to different AWS accounts or
|
|
use different roles. This is particularly useful for multi-account deployments
|
|
or when you need to interact with multiple AWS environments in a single job.
|
|
|
|
## Versioning
|
|
|
|
Starting with version 5.0.0, this action uses semantic-style release tags and
|
|
[immutable releases][immutable-releases].
|
|
|
|
[immutable-releases]:
|
|
https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/immutable-releases
|
|
|
|
A floating version tag (vN) is also provided for convenience: this tag will move
|
|
to the latest major version (vN -> vN.2.1, vM -> vM.0.0, etc.).
|
|
|
|
## License
|
|
|
|
This code is made available under the MIT license.
|
|
|
|
## Security Disclosures
|
|
|
|
If you would like to report a potential security issue in this project, please
|
|
do not create a GitHub issue. Instead, please follow the instructions
|
|
[on the vulnerability reporting page](https://aws.amazon.com/security/vulnerability-reporting/)
|
|
or [email AWS security](mailto:aws-security@amazon.com) directly.
|