mirror of
https://github.com/aws-actions/configure-aws-credentials.git
synced 2026-08-24 04:25:05 +09:00
Compare commits
158 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4fc4975a85 | |||
| 47ce154311 | |||
| d700acbb22 | |||
| ca00fd4d38 | |||
| 0f88004d9c | |||
| f171d5c895 | |||
| 2c187c9a63 | |||
| 97834a484a | |||
| 16ffc4e9d9 | |||
| b47a85173f | |||
| 7ec02fdd4f | |||
| bfd218503e | |||
| 83b5a56547 | |||
| ccbdafa425 | |||
| d90c1f89e1 | |||
| 8ce5662dcb | |||
| 132df1605a | |||
| c3eecb10dc | |||
| b06d1612cc | |||
| 3610e7477c | |||
| 2cefa29f87 | |||
| a70163716a | |||
| 074f3e3ed6 | |||
| cfdc9e618a | |||
| f0b286ee81 | |||
| 978afc099f | |||
| 73daff1b20 | |||
| a9a462e707 | |||
| c02032282e | |||
| 050bf7aae9 | |||
| 1ff999ed11 | |||
| cf0a0ec4cc | |||
| f9195c8403 | |||
| da5122d981 | |||
| aab03b4eeb | |||
| 909c963c25 | |||
| 35f8f79dc2 | |||
| e402f5e2c3 | |||
| 45d446aaa3 | |||
| 835806a903 | |||
| bd1354327e | |||
| 1ceaabc2d4 | |||
| 2ecdac5a31 | |||
| 21013c6ea2 | |||
| 1c492975ae | |||
| e46110bca8 | |||
| 17842ca385 | |||
| e26e190428 | |||
| 0fc95ed935 | |||
| d23081dda5 | |||
| 3ce4859d07 | |||
| 779816abba | |||
| ead1e6af28 | |||
| 55f725fcb5 | |||
| 39228ca2bf | |||
| 8179d389e2 | |||
| 9edadd368f | |||
| e57d9b2db1 | |||
| 3802ea987a | |||
| 12e3392609 | |||
| 46b3b9326a | |||
| c6bba96e8b | |||
| ca8fe1c3f8 | |||
| 6116f2b953 | |||
| 02217eeb8c | |||
| 1ef78072ef | |||
| 1dc2e06aed | |||
| 96589f5dfc | |||
| 66cc13c21a | |||
| 89b4925657 | |||
| b6cea2df1f | |||
| febab93d02 | |||
| 556dab0aae | |||
| 884bdab0d8 | |||
| 6c6ac55798 | |||
| af7e7d4f5c | |||
| a5e454b255 | |||
| 9fc3c1681a | |||
| b4ffe2aa11 | |||
| 1b9c66a165 | |||
| 7e510d6542 | |||
| 61a110527d | |||
| 826aaf0064 | |||
| 294a79b668 | |||
| 994ed19d9f | |||
| 2e63828dd3 | |||
| c7680c3252 | |||
| c03b90f3c2 | |||
| cf3f053829 | |||
| bd07581024 | |||
| bb85fe0f29 | |||
| 29d24b9c2f | |||
| 7bcde6a7fc | |||
| e79c24214a | |||
| 43c891271e | |||
| db27a042ea | |||
| fff2104678 | |||
| b7b582623b | |||
| 045613fde5 | |||
| 1a40b8cd5a | |||
| 09f4416695 | |||
| ffc9011218 | |||
| a78e788c51 | |||
| f36b88236d | |||
| 6f06e4dfb7 | |||
| f2e29018a3 | |||
| c458ab2cb0 | |||
| aca3ce3e45 | |||
| e9cf1db62a | |||
| ad2daec542 | |||
| 4397372e5c | |||
| 0f2f0dac6a | |||
| 587276aa2b | |||
| dd3458040d | |||
| db5bf1fe97 | |||
| a955e86dca | |||
| f2e859a9be | |||
| cb66b82ec8 | |||
| 9a9e6b7961 | |||
| 4fe8125b4f | |||
| 18f29abc49 | |||
| 69786f15ae | |||
| d234546a96 | |||
| 773f9c2d3f | |||
| d0421aed0f | |||
| 304d8d7e94 | |||
| e0fc2428cc | |||
| 1b1cca71d5 | |||
| 3f2fb6dc54 | |||
| a3cf0463b1 | |||
| d29f260a27 | |||
| 5c47d180b4 | |||
| 7f3226aee9 | |||
| 3bd0e77022 | |||
| 2ec0c7d68f | |||
| 858acd4186 | |||
| a206705a9c | |||
| 8a3c6172d2 | |||
| b140ab7b24 | |||
| 16efdbdbee | |||
| ce974c0f53 | |||
| 75ac214068 | |||
| 859ce83a76 | |||
| e821ee1878 | |||
| c754bf3531 | |||
| 0a785df9d6 | |||
| 5393920a08 | |||
| 72072f2ea6 | |||
| dc381ded38 | |||
| 8b493da9a6 | |||
| 03de6e7db9 | |||
| 75a5a83a24 | |||
| 2e34541e3b | |||
| a5dceb9b44 | |||
| f6445e06fc | |||
| 40c1389cab | |||
| 01c96af67c | |||
| 486457dc46 |
@@ -1,2 +0,0 @@
|
||||
build
|
||||
dist
|
||||
-168
@@ -1,168 +0,0 @@
|
||||
env:
|
||||
jest: true
|
||||
node: true
|
||||
root: true
|
||||
plugins:
|
||||
- import
|
||||
- prettier
|
||||
parserOptions:
|
||||
ecmaVersion: 2021
|
||||
sourceType: module
|
||||
extends:
|
||||
- plugin:prettier/recommended
|
||||
- prettier
|
||||
rules:
|
||||
prettier/prettier: [error]
|
||||
import/no-extraneous-dependencies:
|
||||
- error
|
||||
- devDependencies:
|
||||
- "**/test/**"
|
||||
- "**/build-tools/**"
|
||||
optionalDependencies: false
|
||||
peerDependencies: true
|
||||
import/no-unresolved: [error]
|
||||
import/order:
|
||||
- warn
|
||||
- groups:
|
||||
- builtin
|
||||
- external
|
||||
alphabetize:
|
||||
order: asc
|
||||
caseInsensitive: true
|
||||
array-callback-return: [warn]
|
||||
no-await-in-loop: [warn]
|
||||
no-constant-binary-expression: [error]
|
||||
no-constructor-return: [error]
|
||||
no-duplicate-imports: [error]
|
||||
no-self-compare: [warn]
|
||||
no-template-curly-in-string: [error]
|
||||
no-unmodified-loop-condition: [error]
|
||||
no-unreachable-loop: [error]
|
||||
no-unused-private-class-members: [error]
|
||||
no-use-before-define: [error]
|
||||
require-atomic-updates: [error]
|
||||
block-scoped-var: [warn]
|
||||
camelcase: [warn]
|
||||
class-methods-use-this: [error]
|
||||
consistent-return: [warn]
|
||||
consistent-this: [warn]
|
||||
default-case-last: [warn]
|
||||
default-param-last: [warn]
|
||||
dot-notation: [error]
|
||||
eqeqeq: [error]
|
||||
guard-for-in: [warn]
|
||||
logical-assignment-operators:
|
||||
- error
|
||||
- always
|
||||
- enforceForIfStatements: false
|
||||
no-array-constructor: [error]
|
||||
no-bitwise: [error]
|
||||
no-console: [warn]
|
||||
no-empty-function: [warn]
|
||||
no-eval: [error]
|
||||
no-extra-bind: [error]
|
||||
no-labels: [error]
|
||||
no-implicit-globals: [error]
|
||||
no-invalid-this: [error]
|
||||
key-spacing: [error]
|
||||
no-multiple-empty-lines: [error]
|
||||
no-return-await: [warn]
|
||||
no-trailing-spaces: [error]
|
||||
no-lonely-if: [error]
|
||||
no-nested-ternary: [warn]
|
||||
no-mixed-operators: [warn]
|
||||
no-proto: [error]
|
||||
no-sequences: [error]
|
||||
no-throw-literal: [error]
|
||||
no-useless-call: [error]
|
||||
no-useless-concat: [warn]
|
||||
no-var: [error]
|
||||
one-var-declaration-per-line: [error]
|
||||
prefer-const: [warn]
|
||||
prefer-arrow-callback: [warn]
|
||||
prefer-regex-literals: [warn]
|
||||
prefer-promise-reject-errors: [warn]
|
||||
prefer-spread: [warn]
|
||||
prefer-template: [warn]
|
||||
require-await: [error]
|
||||
overrides:
|
||||
- files:
|
||||
- '**/*.ts'
|
||||
parser: '@typescript-eslint/parser'
|
||||
parserOptions:
|
||||
ecmaVersion: 2021
|
||||
sourceType: module
|
||||
project: ./tsconfig.json
|
||||
extends:
|
||||
- plugin:@typescript-eslint/recommended
|
||||
- plugin:@typescript-eslint/recommended-requiring-type-checking
|
||||
- plugin:import/typescript
|
||||
rules:
|
||||
'@typescript-eslint/array-type':
|
||||
- warn
|
||||
- default: array-simple
|
||||
'@typescript-eslint/ban-tslint-comment': [error]
|
||||
'@typescript-eslint/consistent-indexed-object-style': [warn]
|
||||
'@typescript-eslint/consistent-type-assertions': [warn]
|
||||
'@typescript-eslint/prefer-includes': [warn]
|
||||
dot-notation: [off]
|
||||
'@typescript-eslint/dot-notation': [error]
|
||||
'@typescript-eslint/no-explicit-any': [off]
|
||||
'@typescript-eslint/consistent-type-exports': [warn]
|
||||
'@typescript-eslint/consistent-type-imports': [warn]
|
||||
'@typescript-eslint/no-base-to-string': [error]
|
||||
'@typescript-eslint/no-confusing-non-null-assertion': [warn]
|
||||
'@typescript-eslint/no-invalid-void-type': [error]
|
||||
'@typescript-eslint/no-meaningless-void-operator': [warn]
|
||||
'@typescript-eslint/no-redundant-type-constituents': [warn]
|
||||
'@typescript-eslint/no-unnecessary-boolean-literal-compare': [warn]
|
||||
'@typescript-eslint/no-unnecessary-condition': [warn]
|
||||
'@typescript-eslint/no-unnecessary-qualifier': [warn]
|
||||
'@typescript-eslint/no-unnecessary-type-arguments': [warn]
|
||||
'@typescript-eslint/non-nullable-type-assertion-style': [warn]
|
||||
'@typescript-eslint/prefer-for-of': [error]
|
||||
'@typescript-eslint/prefer-literal-enum-member': [warn]
|
||||
'@typescript-eslint/prefer-optional-chain': [warn]
|
||||
'@typescript-eslint/prefer-readonly': [warn]
|
||||
'@typescript-eslint/prefer-regexp-exec': [warn]
|
||||
'@typescript-eslint/prefer-string-starts-ends-with': [warn]
|
||||
'@typescript-eslint/prefer-ts-expect-error': [error]
|
||||
'@typescript-eslint/promise-function-async': [warn]
|
||||
'@typescript-eslint/require-array-sort-compare': [error]
|
||||
default-param-last: [off]
|
||||
'@typescript-eslint/default-param-last': [warn]
|
||||
no-array-constructor: [off]
|
||||
'@typescript-eslint/no-array-constructor': [error]
|
||||
no-dupe-class-members: [off]
|
||||
'@typescript-eslint/no-dupe-class-members': [warn]
|
||||
no-invalid-this: [off]
|
||||
'@typescript-eslint/no-invalid-this': [warn]
|
||||
no-unused-vars: [off]
|
||||
'@typescript-eslint/no-unused-vars':
|
||||
- error
|
||||
- varsIgnorePattern: '^_'
|
||||
argsIgnorePattern: '^_'
|
||||
caughtErrorsIgnorePattern: '^_'
|
||||
'@typescript-eslint/no-non-null-assertion': [off]
|
||||
'@typescript-eslint/no-require-imports':
|
||||
- error
|
||||
no-return-await: [off]
|
||||
'@typescript-eslint/return-await': [error]
|
||||
no-shadow: [off]
|
||||
'@typescript-eslint/no-shadow': [error]
|
||||
'@typescript-eslint/no-floating-promises': [error]
|
||||
"@typescript-eslint/member-ordering":
|
||||
- error
|
||||
- default:
|
||||
- public-static-field
|
||||
- public-static-method
|
||||
- protected-static-field
|
||||
- protected-static-method
|
||||
- private-static-field
|
||||
- private-static-method
|
||||
- field
|
||||
- constructor
|
||||
- method
|
||||
no-use-before-define: [off]
|
||||
'@typescript-eslint/no-use-before-define': [error]
|
||||
no-duplicate-imports: [off]
|
||||
@@ -12,6 +12,14 @@ body:
|
||||
description: What is the problem? A clear and concise description of the bug.
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: regression
|
||||
attributes:
|
||||
label: Regression Issue
|
||||
description: What is a regression? If it worked in a previous version but doesn't in the latest version, it's considered a regression. In this case, please provide specific version number in the report.
|
||||
options:
|
||||
- label: Select this option if this issue appears to be a regression.
|
||||
required: false
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
on:
|
||||
pull_request_review:
|
||||
types: submitted
|
||||
|
||||
jobs:
|
||||
approved_pr:
|
||||
name: Automerge approved PRs
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
id-token: write
|
||||
if: >-
|
||||
github.event.review.state == 'approved' &&
|
||||
github.event.repository == 'aws/configure-aws-credentials' &&
|
||||
(github.event.review.author_association == 'OWNER' || github.event.review.user.login == 'aws-sdk-osds')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Configure AWS credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-region: us-west-2
|
||||
role-to-assume: ${{ secrets.SECRETS_AWS_PACKAGING_ROLE_TO_ASSUME }}
|
||||
role-duration-seconds: 900
|
||||
role-session-name: SecretsManagerFetch
|
||||
- name: Get bot user token
|
||||
uses: aws-actions/aws-secretsmanager-get-secrets@v2
|
||||
with:
|
||||
parse-json-secrets: true
|
||||
secret-ids: |
|
||||
OSDS,arn:aws:secretsmanager:us-west-2:206735643321:secret:github-aws-sdk-osds-automation-gebs9n
|
||||
- name: Enable PR automerge
|
||||
run: gh pr merge --auto --squash "$PR_URL"
|
||||
env:
|
||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||
GITHUB_TOKEN: ${{ env.OSDS_ACCESS_TOKEN }}
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Stale issue job
|
||||
steps:
|
||||
- uses: aws-actions/stale-issue-cleanup@v5
|
||||
- uses: aws-actions/stale-issue-cleanup@v6
|
||||
with:
|
||||
# Setting messages to an empty string will cause the automation to skip
|
||||
# that category
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
name: Dependabot auto-approve
|
||||
on: pull_request
|
||||
permissions:
|
||||
pull-requests: write
|
||||
jobs:
|
||||
dependabot:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'aws/configure-aws-credentials'
|
||||
steps:
|
||||
- name: Get Metadata
|
||||
id: dependabot-metadata
|
||||
uses: dependabot/fetch-metadata@v2
|
||||
- uses: actions/checkout@v4
|
||||
name: Clone repo
|
||||
- name: Configure AWS credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-region: us-west-2
|
||||
role-to-assume: ${{ secrets.SECRETS_AWS_PACKAGING_ROLE_TO_ASSUME }}
|
||||
role-duration-seconds: 900
|
||||
role-session-name: SecretsManagerFetch
|
||||
- name: Get bot user token
|
||||
uses: aws-actions/aws-secretsmanager-get-secrets@v2
|
||||
with:
|
||||
parse-json-secrets: true
|
||||
secret-ids: |
|
||||
OSDS,arn:aws:secretsmanager:us-west-2:206735643321:secret:github-aws-sdk-osds-automation-gebs9n
|
||||
- name: Approve PR if not already approved
|
||||
run: |
|
||||
gh pr checkout "$PR_URL"
|
||||
if [ "$(gh pr status --json reviewDecision - q .currentBranch.reviewDecision)" != "APPROVED" ]; then
|
||||
gh pr review "$PR_URL" --approve
|
||||
else echo "PR already approved"
|
||||
fi
|
||||
env:
|
||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||
GITHUB_TOKEN: ${{ env.OSDS_ACCESS_TOKEN }}
|
||||
@@ -0,0 +1,32 @@
|
||||
# Apply potential regression label on issues
|
||||
name: issue-regression-label
|
||||
on:
|
||||
issues:
|
||||
types: [opened, edited]
|
||||
jobs:
|
||||
add-regression-label:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- name: Fetch template body
|
||||
id: check_regression
|
||||
uses: actions/github-script@v7
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
TEMPLATE_BODY: ${{ github.event.issue.body }}
|
||||
with:
|
||||
script: |
|
||||
const regressionPattern = /\[x\] Select this option if this issue appears to be a regression\./i;
|
||||
const template = `${process.env.TEMPLATE_BODY}`
|
||||
const match = regressionPattern.test(template);
|
||||
core.setOutput('is_regression', match);
|
||||
- name: Manage regression label
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
if [ "${{ steps.check_regression.outputs.is_regression }}" == "true" ]; then
|
||||
gh issue edit ${{ github.event.issue.number }} --add-label "potential-regression" -R ${{ github.repository }}
|
||||
else
|
||||
gh issue edit ${{ github.event.issue.number }} --remove-label "potential-regression" -R ${{ github.repository }}
|
||||
fi
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.ref_name }}
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
role-duration-seconds: 900
|
||||
role-session-name: SecretsManagerFetch
|
||||
- name: Get bot user token
|
||||
uses: aws-actions/aws-secretsmanager-get-secrets@v1
|
||||
uses: aws-actions/aws-secretsmanager-get-secrets@v2
|
||||
with:
|
||||
parse-json-secrets: true
|
||||
secret-ids: |
|
||||
@@ -48,4 +48,4 @@ jobs:
|
||||
git remote set-url origin https://${{ env.OSDS_ACCESS_TOKEN }}@github.com/aws-actions/configure-aws-credentials.git
|
||||
git add dist
|
||||
git commit -m "chore: Update dist" || echo "No changes to commit"
|
||||
git push origin
|
||||
git push --force origin
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: amannn/action-semantic-pull-request@v4.5.0
|
||||
- uses: amannn/action-semantic-pull-request@v5.5.3
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
name: Release Please
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
release-please:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-region: us-west-2
|
||||
role-to-assume: ${{ secrets.SECRETS_AWS_PACKAGING_ROLE_TO_ASSUME }}
|
||||
role-duration-seconds: 900
|
||||
role-session-name: ${{ github.run_id }}
|
||||
|
||||
- name: Get git credentials
|
||||
uses: aws-actions/aws-secretsmanager-get-secrets@v2
|
||||
with:
|
||||
parse-json-secrets: true
|
||||
secret-ids: |
|
||||
OSDS,arn:aws:secretsmanager:us-west-2:206735643321:secret:github-aws-sdk-osds-automation-gebs9n
|
||||
|
||||
- name: Run release-please
|
||||
uses: googleapis/release-please-action@v4
|
||||
with:
|
||||
release-type: node
|
||||
token: ${{ env.OSDS_ACCESS_TOKEN }}
|
||||
config-file: release-please-config.json
|
||||
manifest-file: .release-please-manifest.json
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: "Checkout repository"
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Integ test for OIDC
|
||||
uses: ./
|
||||
with:
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: "Checkout repository"
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Integ test for OIDC
|
||||
uses: ./
|
||||
with:
|
||||
@@ -62,7 +62,7 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: "Checkout repository"
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Integ test for access keys
|
||||
uses: ./
|
||||
with:
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: "Checkout repository"
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Integ test for access keys
|
||||
uses: ./
|
||||
env:
|
||||
@@ -103,7 +103,7 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: "Checkout repository"
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Integ test for IAM user
|
||||
uses: ./
|
||||
with:
|
||||
|
||||
@@ -14,9 +14,9 @@ jobs:
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- name: "Checkout repository"
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: "Setup node"
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
- name: "Install dependencies"
|
||||
@@ -29,9 +29,9 @@ jobs:
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- name: "Checkout repostiory"
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: "Setup node"
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
- name: "Install dependencies"
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
queue_rules:
|
||||
- name: default
|
||||
conditions:
|
||||
# Conditions to merge a queued PR
|
||||
- check-success=Run unit tests (windows-latest)
|
||||
- check-success=Run unit tests (ubuntu-latest)
|
||||
- check-success=Run unit tests (macos-latest)
|
||||
- "#approved-reviews-by>=1"
|
||||
- -approved-reviews-by~=author
|
||||
|
||||
pull_request_rules:
|
||||
- name: Automatically merge on CI success and review approval
|
||||
conditions:
|
||||
- base~=main|integ-tests
|
||||
- "#approved-reviews-by>=1"
|
||||
- -approved-reviews-by~=author
|
||||
- check-success=Run unit tests (windows-latest)
|
||||
- check-success=Run unit tests (ubuntu-latest)
|
||||
- check-success=Run unit tests (macos-latest)
|
||||
- label!=work-in-progress
|
||||
- -title~=(WIP|wip)
|
||||
- -merged
|
||||
- -closed
|
||||
- author!=dependabot[bot]
|
||||
actions:
|
||||
queue:
|
||||
method: squash
|
||||
name: default
|
||||
|
||||
- name: Automatically approve and merge Dependabot PRs
|
||||
conditions:
|
||||
- base~=main
|
||||
- author=dependabot[bot]
|
||||
- check-success=Run unit tests (windows-latest)
|
||||
- check-success=Run unit tests (ubuntu-latest)
|
||||
- check-success=Run unit tests (macos-latest)
|
||||
- -title~=(WIP|wip)
|
||||
- -label~=(blocked|do-not-merge)
|
||||
- -merged
|
||||
- -closed
|
||||
actions:
|
||||
review:
|
||||
type: APPROVE
|
||||
queue:
|
||||
method: squash
|
||||
name: default
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"overrides": []
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
".release-please-manifest.json": "4.0.2",
|
||||
"package.json": "4.0.2",
|
||||
".": "4.0.3"
|
||||
}
|
||||
@@ -2,6 +2,29 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [4.0.3](https://github.com/aws-actions/configure-aws-credentials/compare/v4.0.2...v4.0.3) (2025-01-27)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* added release-please action config ([0f88004](https://github.com/aws-actions/configure-aws-credentials/commit/0f88004d9c27e0bdbbc254b3f7c8053cb38f04d7))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add id-token permission to automerge ([97834a4](https://github.com/aws-actions/configure-aws-credentials/commit/97834a484a5ab3c40fa9e2eb40fcf8041105a573))
|
||||
* cpy syntax on npm package ([#1195](https://github.com/aws-actions/configure-aws-credentials/issues/1195)) ([83b5a56](https://github.com/aws-actions/configure-aws-credentials/commit/83b5a565471214aec459e234bef606339fe07111))
|
||||
* force push packaged files to main ([bfd2185](https://github.com/aws-actions/configure-aws-credentials/commit/bfd218503eb87938c29603a551e19c6b594f5fe5))
|
||||
|
||||
|
||||
### Miscellaneous Chores
|
||||
|
||||
* release 4.0.3 ([ca00fd4](https://github.com/aws-actions/configure-aws-credentials/commit/ca00fd4d3842ad58c3c21ebfe69defa1f0e7bdc4))
|
||||
|
||||
## [4.0.2](https://github.com/aws-actions/configure-aws-credentials/compare/v4.0.1...v4.0.2) (2024-02-09)
|
||||
|
||||
* Revert 4.0.1 to remove warning
|
||||
|
||||
## [4.0.1](https://github.com/aws-actions/configure-aws-credentials/compare/v4.0.0...v4.0.1) (2023-10-03)
|
||||
|
||||
### Documentation
|
||||
|
||||
@@ -1,157 +1,47 @@
|
||||
## Configure AWS Credentials for GitHub Actions
|
||||
Configure your AWS credentials and region environment variables for use in other
|
||||
GitHub Actions. This action implements the AWS SDK credential resolution chain
|
||||
and exports environment variables for your other Actions to use. Environment
|
||||
variable exports are detected by both the AWS SDKs and the AWS CLI for AWS API
|
||||
calls.
|
||||
GitHub Actions.
|
||||
|
||||
---
|
||||
|
||||
### Recent News
|
||||
|
||||
#### Long-term credentials warning (10/3/23)
|
||||
|
||||
We have added a warning when using long-term credentials to access AWS
|
||||
(IAM access keys and secret keys). Using long-term credentials requires you
|
||||
to create IAM users and properly secure the access keys to prevent their disclosure.
|
||||
A better approach is to use [GitHub's support for OpenID Connect](#OIDC) to authenticate
|
||||
using an IAM role to generate temporary security credentials.
|
||||
|
||||
#### v4 Announcement (9/11/23)
|
||||
|
||||
We have just released `v4` of Configure AWS Credentials. The only thing that
|
||||
changed from `v3` is that the action now runs on `node20` instead of `node16`. If using a self-hosted runner, specify [v2.311.0](https://github.com/actions/runner/releases/tag/v2.311.0) or above for `node20` support.
|
||||
You can still see the `v3` announcement below, as it is still recent.
|
||||
|
||||
#### v3 Announcement (8/23/23)
|
||||
|
||||
We have recently released `v3` of Configure AWS Credentials! With this new
|
||||
release we have migrated the code to TypeScript, and have also migrated away
|
||||
from using `v2` of the JavaScript AWS SDK. This should eliminate the warning you
|
||||
have seen in your workflow logs about `v2` deprecation.
|
||||
|
||||
In addition to the refactored codebase, we have also introduced some changes to
|
||||
existing functionality, added some new features, and fixed some bugs. These
|
||||
changes should be backwards compatible with your existing workflows.
|
||||
|
||||
**Notable changes to existing functionality**
|
||||
|
||||
- By default, the assumed role credentials will only be valid for one hour in
|
||||
_all_ use cases. This is changed from 6 hours in `v2`. You can adjust this value
|
||||
with the `role-duration-seconds` input.
|
||||
- By default, your account ID will not be masked in workflow logs. This was
|
||||
changed from being masked by default in the previous version. AWS does not consider
|
||||
account IDs as sensitive information, so this change reflects that stance. You
|
||||
can revert to the old default and mask your account ID in workflow logs by
|
||||
setting the `mask-aws-account-id` input to `true`.
|
||||
|
||||
**New features**
|
||||
|
||||
- You can now configure retry settings in case your STS call fails. By default,
|
||||
we retry with exponential backoff twelve times. You can disable this behavior
|
||||
altogether by setting the `disable-retry` input to `true`, or you can configure
|
||||
the number of times the action will retry with the `retry-max-attempts` input.
|
||||
- You can now set the returned credentials as action step outputs. To do this,
|
||||
you can set the `output-credentials` prop to `true`.
|
||||
- There's now an option to clear the AWS-related environment variables at the
|
||||
start of the action. Clearing these variables is often a workaround for
|
||||
problems, so enabling this can be helpful if existing credentials or environment
|
||||
variables are interfering with the action. You can enable this by setting the
|
||||
`unset-current-credentials` input to `true`.
|
||||
|
||||
**Bug fixes**
|
||||
|
||||
You can find a list of bugs that have been fixed in v3 in the
|
||||
[changelog](./CHANGELOG.md).
|
||||
|
||||
---
|
||||
|
||||
### Table of Contents
|
||||
<!-- toc -->
|
||||
- [Overview](#overview)
|
||||
- [Security recommendations](#security-recommendations)
|
||||
- [Using this action](#using-this-action)
|
||||
+ [Credential Lifetime](#credential-lifetime)
|
||||
+ [External ID](#external-id)
|
||||
+ [Session tagging](#session-tagging-and-name)
|
||||
+ [Sample IAM Role Permissions](#sample-iam-role-cloudformation-template)
|
||||
+ [Misc](#misc)
|
||||
- [OIDC](#OIDC)
|
||||
+ [Audience](#audience)
|
||||
+ [Sample IAM OIDC CloudFormation Template](#sample-iam-oidc-cloudformation-template)
|
||||
+ [Claims and scoping permissions](#claims-and-scoping-permissions)
|
||||
+ [Further info](#further-info)
|
||||
- [Self-Hosted Runners](#self-hosted-runners)
|
||||
+ [Proxy Configuration](#proxy-configuration)
|
||||
+ [Use with the AWS CLI](#use-with-the-aws-cli)
|
||||
- [Examples](#examples)
|
||||
- [License Summary](#license-summary)
|
||||
- [Security Disclosures](#security-disclosures)
|
||||
<!-- tocstop -->
|
||||
This action implements the AWS JavaScript SDK credential resolution chain
|
||||
and exports session environment variables for your other Actions to use.
|
||||
Environment variable exports are detected by both the AWS SDKs and the AWS CLI
|
||||
for AWS API calls.
|
||||
|
||||
## Overview
|
||||
API calls to AWS need to be signed with credential information, so when you use
|
||||
one of the AWS SDKs or an AWS tool, you must provide it with AWS credentials and
|
||||
and AWS region. One way to do that in GitHub Actions is to use a repository
|
||||
secret with IAM credentials, but this doesn't follow [AWS security
|
||||
guidelines](https://docs.aws.amazon.com/IAM/latest/UserGuide/security-creds.html)
|
||||
on using long term credentials. Instead, we recommend that you use a long term
|
||||
credential or JWT to fetch a temporary credential, and use that with your tools
|
||||
instead. This GitHub Action facilitates just that.
|
||||
|
||||
AWS SDKs and Tools look for your credentials in standardized environment
|
||||
variables. In essence, this Action runs through the standard [credential
|
||||
resolution flow](https://docs.aws.amazon.com/sdkref/latest/guide/standardized-credentials.html),
|
||||
and at the end, exports environment variables for you to use later.
|
||||
|
||||
We support five methods for fetching credentials from AWS, but we recommend that
|
||||
you use GitHub's OIDC provider in conjunction with a configured AWS IAM
|
||||
Identity Provider endpoint.
|
||||
|
||||
To do that, you would add the following step to your workflow:
|
||||
|
||||
```yaml
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
|
||||
aws-region: us-east-2
|
||||
```
|
||||
This will cause the action to perform an [`AssumeRoleWithWebIdentity`](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html) call and
|
||||
return temporary security credentials for use by other steps in your workflow. In order for
|
||||
this to work, you'll need to preconfigure the IAM Identity Provider in your AWS account
|
||||
(see the [OIDC](https://github.com/aws-actions/configure-aws-credentials#OIDC) section below for details).
|
||||
|
||||
You can use this action with the AWS CLI available in
|
||||
[GitHub's hosted virtual environments](https://help.github.com/en/actions/reference/software-installed-on-github-hosted-runners) or run this action multiple times
|
||||
to use different AWS accounts, regions, or IAM roles in the same GitHub Actions
|
||||
workflow. As an example, here is a complete workflow file that uploads artifacts
|
||||
to Amazon S3.
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
deploy:
|
||||
name: Upload to Amazon S3
|
||||
runs-on: ubuntu-latest
|
||||
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Configure AWS credentials from Test account
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
role-to-assume: arn:aws:iam::111111111111:role/my-github-actions-role-test
|
||||
aws-region: us-east-1
|
||||
- name: Copy files to the test website with the AWS CLI
|
||||
run: |
|
||||
aws s3 sync . s3://my-s3-test-website-bucket
|
||||
- name: Configure AWS credentials from Production account
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
role-to-assume: arn:aws:iam::222222222222:role/my-github-actions-role-prod
|
||||
aws-region: us-west-2
|
||||
- name: Copy files to the production website with the AWS CLI
|
||||
run: |
|
||||
aws s3 sync . s3://my-s3-prod-website-bucket
|
||||
```
|
||||
|
||||
See [action.yml](action.yml) for the full documentation for this action's inputs
|
||||
and outputs.
|
||||
For more information on how to do that, read on.
|
||||
|
||||
### Note about GHES
|
||||
|
||||
Some of this documentation may be inaccurate if you are using GHES (GitHub Enterprise Servers), please take note to review the GitHub documentation when relevant.
|
||||
Some of this documentation may be inaccurate if you are using GHES (GitHub
|
||||
Enterprise Server), please take note to review the GitHub documentation when
|
||||
relevant.
|
||||
|
||||
For example, the URL that the OIDC JWT is issued from is different than the usual `token.actions.githubusercontent.com`, and will be unique to your enterprise server. As a result, you will need to configure this differently when you create the Identity Provider.
|
||||
For example, the URL that the OIDC JWT is issued from is different than the
|
||||
usual `token.actions.githubusercontent.com`, and will be unique to your
|
||||
enterprise server. As a result, you will need to configure this differently when
|
||||
you create the Identity Provider.
|
||||
|
||||
We do not presently have a GHES testing environment to validate this action. If
|
||||
you are running in GHES and encounter problems, please
|
||||
[let us know](https://github.com/aws-actions/configure-aws-credentials/issues/new/choose).
|
||||
|
||||
## Security recommendations
|
||||
|
||||
@@ -159,10 +49,14 @@ We recommend following
|
||||
[Amazon IAM best practices](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)
|
||||
for the AWS credentials used in GitHub Actions workflows, including:
|
||||
* Do not store credentials in your repository's code.
|
||||
* [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege) to the credentials used in GitHub Actions
|
||||
workflows. Grant only the permissions required to perform the actions in your
|
||||
GitHub Actions workflows.
|
||||
* [Monitor the activity](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#keep-a-log) of the credentials used in GitHub Actions workflows.
|
||||
* [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege)
|
||||
to the credentials used in GitHub Actions workflows. Grant only the
|
||||
permissions required to perform the actions in your GitHub Actions workflows.
|
||||
Do not assume overly permissive roles, even for testing.
|
||||
* [Monitor the activity](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#keep-a-log)
|
||||
of the credentials used in GitHub Actions workflows.
|
||||
* Use temporary credentials when possible.
|
||||
* Periodically rotate any long-term credentials you use.
|
||||
|
||||
## Using this action
|
||||
There are five different supported ways to retrieve credentials:
|
||||
@@ -173,9 +67,17 @@ There are five different supported ways to retrieve credentials:
|
||||
- Using a WebIdentity Token File (`AssumeRoleWithWebIdentity`)
|
||||
- Using existing credentials in your runner (`AssumeRole`)
|
||||
|
||||
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. See [OIDC](#OIDC) for more information on how to setup your AWS account to assume a role with OIDC.
|
||||
Because we use the AWS JavaScript SDK, we always will use the [credential
|
||||
resolution flow for Node.js](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.
|
||||
|
||||
The following table describes which method is used based on which values are supplied to the Action:
|
||||
We recommend using the first option above: [GitHub's OIDC provider](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services).
|
||||
This method uses OIDC to get short-lived credentials needed for your actions.
|
||||
See [OIDC](#OIDC) for more information on how to setup your AWS account to
|
||||
assume a role with OIDC.
|
||||
|
||||
The following table describes which method we'll use to get your credentials
|
||||
based on which values are supplied to the Action:
|
||||
|
||||
| **Identity Used** | `aws-access-key-id` | `role-to-assume` | `web-identity-token-file` | `role-chaining` | `id-token` permission
|
||||
| --------------------------------------------------------------- | ------------------- | ---------------- | ------------------------- | - | - |
|
||||
@@ -185,20 +87,52 @@ The following table describes which method is used based on which values are sup
|
||||
| Assume Role using WebIdentity Token File credentials | | ✔ | ✔ | | |
|
||||
| Assume Role using existing credentials | | ✔ | | ✔ | |
|
||||
|
||||
*Note: `role-chaining` is not necessary to use existing credentials in every use case. If you're getting a "Credentials loaded by the SDK do not match" error, try enabling this prop.
|
||||
*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.*
|
||||
|
||||
### Credential Lifetime
|
||||
### Options
|
||||
See [action.yml](./action.yml) for more detail.
|
||||
|
||||
| Option | Description | Required |
|
||||
|---------------------------|---------------------------------------------------------------------------------------------------|----------|
|
||||
| aws-region | Which AWS region to use | Yes |
|
||||
| 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. | 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 |
|
||||
| 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. Defaults to false. | 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 |
|
||||
|
||||
#### Credential Lifetime
|
||||
The default session duration is **1 hour**.
|
||||
|
||||
If you would like to adjust this you can pass a duration to `role-duration-seconds`, but the duration cannot exceed the maximum that was defined when the IAM Role was created.
|
||||
If you would like to adjust this you can pass a duration to
|
||||
`role-duration-seconds`, but the duration cannot exceed the maximum that was
|
||||
defined when the IAM Role was created.
|
||||
|
||||
### External ID
|
||||
If your role requires an external ID to assume, you can provide the external ID with the `role-external-id` input
|
||||
#### External ID
|
||||
If your role requires an external ID to assume, you can provide the external ID
|
||||
with the `role-external-id` input
|
||||
|
||||
### Session tagging and name
|
||||
The default session name is "GitHubActions", and you can modify it by specifying the desired name in `role-session-name`.
|
||||
The session will be tagged with the following tags: (`GITHUB_` environment variable definitions can be
|
||||
[found here](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables))
|
||||
#### Session tagging and name
|
||||
The default session name is "GitHubActions", and you can modify it by specifying
|
||||
the desired name in `role-session-name`. The session will be tagged with the
|
||||
following tags: (Refer to [GitHub's documentation for `GITHUB_` environment
|
||||
variable definitions](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables))
|
||||
|
||||
| Key | Value |
|
||||
| ---------- | ----------------- |
|
||||
@@ -211,16 +145,18 @@ The session will be tagged with the following tags: (`GITHUB_` environment varia
|
||||
| Commit | GITHUB_SHA |
|
||||
|
||||
_Note: all tag values must conform to
|
||||
[the requirements](https://docs.aws.amazon.com/STS/latest/APIReference/API_Tag.html).
|
||||
[the tag requirements](https://docs.aws.amazon.com/STS/latest/APIReference/API_Tag.html).
|
||||
Particularly, `GITHUB_WORKFLOW` will be truncated if it's too long. If
|
||||
`GITHUB_ACTOR` or `GITHUB_WORKFLOW` contain invalid characters, the characters
|
||||
will be replaced with an '*'._
|
||||
|
||||
The action will use session tagging by default during role assumption, unless you are assuming a role with a WebIdentity.
|
||||
For WebIdentity role assumption, the session tags have to be included
|
||||
in the encoded WebIdentity token. This means that Tags can only be supplied by
|
||||
the OIDC provider, and they cannot set during the AssumeRoleWithWebIdentity API call
|
||||
within the Action. See [issue 419](https://github.com/aws-actions/configure-aws-credentials/issues/419) for more info
|
||||
The action will use session tagging by default during role assumption, unless
|
||||
you follow our recommendation and are assuming a role with a WebIdentity. For
|
||||
WebIdentity role assumption, the session tags have to be included in the encoded
|
||||
WebIdentity token. This means that tags can only be supplied by the OIDC
|
||||
provider, and they cannot set during the AssumeRoleWithWebIdentity API call
|
||||
within the Action. See [#419](https://github.com/aws-actions/configure-aws-credentials/issues/419)
|
||||
for more information.
|
||||
|
||||
You can skip this session tagging by providing
|
||||
`role-skip-session-tagging` as true in the action's inputs:
|
||||
@@ -231,10 +167,15 @@ You can skip this session tagging by providing
|
||||
```
|
||||
|
||||
### 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 like this:
|
||||
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 like this:
|
||||
```yaml
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
@@ -259,8 +200,9 @@ Or we can have a nicely formatted JSON as well:
|
||||
```
|
||||
|
||||
#### 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. You can pass a single managed policy like this:
|
||||
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. You can pass a single managed policy like this:
|
||||
```yaml
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
@@ -278,13 +220,20 @@ And we can pass multiple managed policies likes this:
|
||||
### Misc
|
||||
|
||||
#### Adjust the retry mechanism
|
||||
You can now configure retry settings for when 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.
|
||||
You can now configure retry settings for when 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 since it's not considered sensitive information. However, you can set the `mask-aws-account-id` input to `true` to mask your account ID in workflow logs if desired.
|
||||
Your account ID is not masked by default in workflow logs since it's not
|
||||
considered sensitive information. However, 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, and the recommended solution is to include another step in your workflow which unsets the environment variables set by this action. Now if you set the `unset-current-credentials` input to `true`, the workaround is made eaiser
|
||||
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.
|
||||
|
||||
#### Special characters in AWS_SECRET_ACCESS_KEY
|
||||
Some edge cases are unable to properly parse an `AWS_SECRET_ACCESS_KEY` if it
|
||||
@@ -293,11 +242,32 @@ contains special characters. For more information, please see the
|
||||
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.
|
||||
`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.
|
||||
|
||||
## OIDC
|
||||
|
||||
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, this action will create a JWT unique to the workflow run, and it will use this JWT to assume the role. For this action to create the JWT, it is required for your workflow to have the `id-token: write` permission:
|
||||
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.
|
||||
|
||||
First, in order for this action to create the JWT, your workflow file must have
|
||||
the `id-token: write` permission:
|
||||
|
||||
```yaml
|
||||
permissions:
|
||||
@@ -305,9 +275,13 @@ We recommend using [GitHub's OIDC provider](https://docs.github.com/en/actions/d
|
||||
contents: read
|
||||
```
|
||||
|
||||
### Audience
|
||||
### OIDC Audience
|
||||
|
||||
When the JWT is created, an audience needs to be specified. By default, the audience is `sts.amazonaws.com` and this will work for most cases. Changing the default audience may be necessary when using non-default AWS partitions. You can specify the audience through the `audience` input:
|
||||
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
|
||||
@@ -315,22 +289,23 @@ When the JWT is created, an audience needs to be specified. By default, the audi
|
||||
with:
|
||||
audience: sts.amazonaws.com.cn
|
||||
aws-region: us-east-3
|
||||
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
|
||||
role-to-assume: arn:aws-cn:iam::123456789100:role/my-github-actions-role
|
||||
```
|
||||
|
||||
### Sample IAM OIDC CloudFormation Template
|
||||
### Configuring IAM to trust GitHub
|
||||
To use GitHub's OIDC provider, you must first set up federation
|
||||
with the provider in as an IAM IdP. The GitHub OIDC provider only needs to be
|
||||
with the provider as an IAM IdP. The GitHub OIDC provider only needs to be
|
||||
created once per account (i.e. multiple IAM Roles that can be assumed by the
|
||||
GitHub's OIDC can share a single OIDC Provider).
|
||||
GitHub's OIDC can share a single OIDC Provider). Here is a sample CloudFormation
|
||||
template that will configure this trust for you.
|
||||
|
||||
Note that the thumbprint has been set to all F's because the thumbprint is not
|
||||
used when authenticating `token.actions.githubusercontent.com`. Instead, IAM
|
||||
uses its library of trusted CAs to authenticate. However, this value is still
|
||||
required by the API.
|
||||
Note that the thumbprint below has been set to all F's because the thumbprint is
|
||||
not used when authenticating `token.actions.githubusercontent.com`. This is a
|
||||
special case used *only when GitHub's OIDC is authenticating to IAM*. IAM uses
|
||||
its library of trusted CAs to authenticate. The value is still the API, so it
|
||||
must be specified.
|
||||
|
||||
This CloudFormation template will configure the IdP for you. You can copy the
|
||||
template below, or load it from here:
|
||||
You can copy the template below, or load it from here:
|
||||
https://d38mtn6aq9zhn6.cloudfront.net/configure-aws-credentials-latest.yml
|
||||
|
||||
```yaml
|
||||
@@ -390,13 +365,35 @@ Outputs:
|
||||
```
|
||||
|
||||
### Claims and scoping permissions
|
||||
To align with the Amazon IAM best practice of [granting least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-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 specifies a subject (`sub`) allowed to assume the role. [GitHub also recommends](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#defining-trust-conditions-on-cloud-roles-using-oidc-claims) filtering for the correct audience (`aud`). See [AWS IAM documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_iam-condition-keys.html#condition-keys-wif) on which claims you can filter for in your trust policies.
|
||||
To align with the Amazon IAM best practice of [granting least
|
||||
privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-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 specifies a subject (`sub`) allowed to assume the role. [GitHub also
|
||||
recommends](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#defining-trust-conditions-on-cloud-roles-using-oidc-claims)
|
||||
filtering for the correct audience (`aud`). See [AWS IAM
|
||||
documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_iam-condition-keys.html#condition-keys-wif)
|
||||
on which claims you can filter for in your trust policies.
|
||||
|
||||
Without a subject (`sub`) condition, any GitHub user or repository could potentially assume the role. The subject can be scoped to a GitHub organization and repository as shown in the CloudFormation template. However, scoping it down to your org and repo may cause the role assumption to fail in some cases. See [Example subject claims](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#example-subject-claims) for specific details on what the subject value will be depending on your workflow. You can also [customize your subject claim](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#customizing-the-token-claims) if you want full control over the information you can filter for in your trust policy. If you aren't sure what your subject (`sub`) key is, you can add the [`actions-oidc-debugger`](https://github.com/github/actions-oidc-debugger) action to your workflow to see the value of the subject (`sub`) key, as well as other claims.
|
||||
Without a subject (`sub`) condition, any GitHub user or repository could
|
||||
potentially assume the role. The subject can be scoped to a GitHub organization
|
||||
and repository as shown in the CloudFormation template. However, scoping it down
|
||||
to your org and repo may cause the role assumption to fail in some cases. See
|
||||
[Example subject claims](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#example-subject-claims)
|
||||
for specific details on what the subject value will be depending on your
|
||||
workflow. You can also [customize your subject claim](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#customizing-the-token-claims)
|
||||
if you want full control over the information you can filter for in your trust
|
||||
policy. If you aren't sure what your subject (`sub`) key is, you can add the
|
||||
[`actions-oidc-debugger`](https://github.com/github/actions-oidc-debugger)
|
||||
action to your workflow to see the value of the subject (`sub`) key, as well as
|
||||
other claims.
|
||||
|
||||
Additional claim conditions can be added for higher specificity as explained in the [GitHub documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect). Due to implementation details, not every OIDC claim is presently supported by IAM.
|
||||
Additional claim conditions can be added for higher specificity as explained in
|
||||
the [GitHub documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect).
|
||||
Due to implementation details, not every OIDC claim is presently supported by
|
||||
IAM.
|
||||
|
||||
### Further info
|
||||
### Further information about OIDC
|
||||
|
||||
For further information on OIDC and GitHub Actions, please see:
|
||||
|
||||
@@ -448,11 +445,10 @@ web identity.
|
||||
|
||||
### Proxy Configuration
|
||||
|
||||
If you run in self-hosted environments and in secured environment where you need
|
||||
use a specific proxy you can set it in the action manually.
|
||||
If need use a HTTP proxy you can set it in the action manually.
|
||||
|
||||
Additionally this action will always consider already configured proxy in the
|
||||
environment.
|
||||
Additionally this action will always consider the `HTTP_PROXY` environment
|
||||
variable.
|
||||
|
||||
Manually configured proxy:
|
||||
```yaml
|
||||
@@ -469,9 +465,6 @@ Proxy configured in the environment variable:
|
||||
HTTP_PROXY="http://companydomain.com:3128"
|
||||
```
|
||||
|
||||
The action will read the underlying proxy configuration from the environment and
|
||||
you don't need to configure it in the action.
|
||||
|
||||
### Use with the AWS CLI
|
||||
This workflow does _not_ install the [AWS CLI](https://aws.amazon.com/cli/)
|
||||
into your environment. Self-hosted runners that intend to run this action prior
|
||||
@@ -492,7 +485,10 @@ should include the AWS CLI by default.
|
||||
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`.
|
||||
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
|
||||
@@ -510,7 +506,10 @@ In this example, the Action will load the OIDC token from the GitHub-provided en
|
||||
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`.
|
||||
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`.
|
||||
|
||||
### AssumeRole with static IAM credentials in repository secrets
|
||||
```yaml
|
||||
@@ -525,7 +524,10 @@ In this two-step example, the first step will use OIDC to assume the role `arn:a
|
||||
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`.
|
||||
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, AssumeRole with temporary credentials
|
||||
```yaml
|
||||
@@ -551,10 +553,16 @@ In this example, the secret `AWS_ROLE_TO_ASSUME` contains a string like `arn:aws
|
||||
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.
|
||||
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.
|
||||
|
||||
## License Summary
|
||||
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 [here](https://aws.amazon.com/security/vulnerability-reporting/) or [email AWS security directly](mailto:aws-security@amazon.com).
|
||||
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
|
||||
[here](https://aws.amazon.com/security/vulnerability-reporting/) or [email AWS
|
||||
security directly](mailto:aws-security@amazon.com).
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
const { fs } = require('memfs')
|
||||
module.exports = fs
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"formatter": {
|
||||
"indentStyle": "space",
|
||||
"lineWidth": 120,
|
||||
"indentWidth": 2,
|
||||
"lineEnding": "lf",
|
||||
"enabled": true,
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"performance": {
|
||||
"noDelete": "off",
|
||||
},
|
||||
"complexity": {
|
||||
"noExtraBooleanCast": "off",
|
||||
}
|
||||
},
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"trailingCommas": "all",
|
||||
"jsxQuoteStyle": "double",
|
||||
"quoteStyle": "single",
|
||||
"bracketSpacing": true,
|
||||
"arrowParentheses": "always",
|
||||
},
|
||||
},
|
||||
"json": {
|
||||
"formatter": {
|
||||
"trailingCommas": "all",
|
||||
},
|
||||
},
|
||||
}
|
||||
+12134
-6082
File diff suppressed because one or more lines are too long
+3
-1
@@ -10,6 +10,8 @@ export interface assumeRoleParams {
|
||||
webIdentityTokenFile?: string;
|
||||
webIdentityToken?: string;
|
||||
inlineSessionPolicy?: string;
|
||||
managedSessionPolicies?: any[];
|
||||
managedSessionPolicies?: {
|
||||
arn: string;
|
||||
}[];
|
||||
}
|
||||
export declare function assumeRole(params: assumeRoleParams): Promise<import("@aws-sdk/client-sts").AssumeRoleCommandOutput>;
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
import type * as core from '@actions/core';
|
||||
declare const _default: {
|
||||
readonly outputs: {
|
||||
STS_CREDENTIALS: {
|
||||
Credentials: {
|
||||
AccessKeyId: string;
|
||||
SecretAccessKey: string;
|
||||
SessionToken: string;
|
||||
Expiration: Date;
|
||||
};
|
||||
AssumedRoleUser: {
|
||||
Arn: string;
|
||||
AssumedRoleId: string;
|
||||
};
|
||||
};
|
||||
GET_CALLER_IDENTITY: {
|
||||
Account: string;
|
||||
Arn: string;
|
||||
};
|
||||
FAKE_STS_ACCESS_KEY_ID: string;
|
||||
FAKE_STS_SECRET_ACCESS_KEY: string;
|
||||
FAKE_STS_SESSION_TOKEN: string;
|
||||
ODD_CHARACTER_CREDENTIALS: {
|
||||
Credentials: {
|
||||
AccessKeyId: string;
|
||||
SecretAccessKey: string;
|
||||
SessionToken: string;
|
||||
Expiration: Date;
|
||||
};
|
||||
AssumedRoleUser: {
|
||||
Arn: string;
|
||||
AssumedRoleId: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
readonly envs: {
|
||||
GITHUB_REPOSITORY: string;
|
||||
GITHUB_WORKFLOW: string;
|
||||
GITHUB_ACTION: string;
|
||||
GITHUB_ACTOR: string;
|
||||
GITHUB_SHA: string;
|
||||
GITHUB_WORKSPACE: string;
|
||||
GITHUB_ACTIONS: string;
|
||||
};
|
||||
readonly GH_OIDC_INPUTS: {
|
||||
'role-to-assume': string;
|
||||
'aws-region': string;
|
||||
'special-characters-workaround': string;
|
||||
};
|
||||
readonly IAM_USER_INPUTS: {
|
||||
'aws-access-key-id': string;
|
||||
'aws-secret-access-key': string;
|
||||
'aws-region': string;
|
||||
};
|
||||
readonly IAM_ASSUMEROLE_INPUTS: {
|
||||
'aws-access-key-id': string;
|
||||
'aws-secret-access-key': string;
|
||||
'role-to-assume': string;
|
||||
'aws-region': string;
|
||||
};
|
||||
readonly WEBIDENTITY_TOKEN_FILE_INPUTS: {
|
||||
'web-identity-token-file': string;
|
||||
'role-to-assume': string;
|
||||
'aws-region': string;
|
||||
};
|
||||
readonly EXISTING_ROLE_INPUTS: {
|
||||
'role-to-assume': string;
|
||||
'role-chaining': string;
|
||||
'aws-region': string;
|
||||
};
|
||||
readonly getInput: (fakeEnv: Record<string, string>) => (name: string, options?: core.InputOptions) => string;
|
||||
readonly getMultilineInput: (fakeEnv: Record<string, string[]>) => (name: string, options?: core.InputOptions) => string[];
|
||||
};
|
||||
export default _default;
|
||||
+13045
-5641
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@ jobs:
|
||||
sast-guard:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: grolston/guard-action@main
|
||||
with:
|
||||
data_directory: './cloudformation/' ## change to your template directory
|
||||
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }}
|
||||
role-session-name: myGitHubActions
|
||||
- name: Deploy EC2 Bastion
|
||||
uses: aws-actions/aws-cloudformation-github-deploy@v1.0.3
|
||||
uses: aws-actions/aws-cloudformation-github-deploy@v1.3.0
|
||||
with:
|
||||
name: myEC2bastion
|
||||
## change to path to template in your github repo
|
||||
|
||||
Generated
+4201
-6987
File diff suppressed because it is too large
Load Diff
+21
-31
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "configure-aws-credentials",
|
||||
"description": "A GitHub Action to configure AWS credentials",
|
||||
"version": "4.0.3",
|
||||
"scripts": {
|
||||
"build": "tsc --project tsconfig.build.json",
|
||||
"lint": "eslint .",
|
||||
"package": "npm run build && ncc build --license THIRD-PARTY -o dist && ncc build src/cleanup/index.ts -o dist/cleanup && copyup -E dist/THIRD-PARTY . && del-cli dist/THIRD-PARTY",
|
||||
"test": "npm run lint && jest --verbose"
|
||||
"lint": "biome check --error-on-warnings ./src",
|
||||
"package": "npm run build && ncc build --license THIRD-PARTY -o dist && ncc build src/cleanup/index.ts -o dist/cleanup && cpy dist/THIRD-PARTY . && del-cli dist/THIRD-PARTY",
|
||||
"test": "npm run lint && vitest run"
|
||||
},
|
||||
"author": {
|
||||
"name": "Amazon.com, Inc. or its affiliates",
|
||||
@@ -13,36 +14,26 @@
|
||||
"organization": true
|
||||
},
|
||||
"devDependencies": {
|
||||
"@aws-sdk/credential-provider-env": "^3.186.0",
|
||||
"@smithy/property-provider": "^2.1.1",
|
||||
"@jest/globals": "^29.7.0",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^20",
|
||||
"@typescript-eslint/eslint-plugin": "<=5.62.0",
|
||||
"@typescript-eslint/parser": "<=5.62.0",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"aws-sdk-client-mock": "^3.0.1",
|
||||
"copyfiles": "^2.4.1",
|
||||
"del-cli": "^5.1.0",
|
||||
"eslint": "^8",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-import-resolver-node": "^0.3.6",
|
||||
"eslint-import-resolver-typescript": "^3.6.1",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"jest": "^29.7.0",
|
||||
"jest-junit": "^16",
|
||||
"@aws-sdk/credential-provider-env": "^3.515.0",
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@smithy/property-provider": "^3.1.7",
|
||||
"@types/node": "^22.9.0",
|
||||
"@vercel/ncc": "^0.38.2",
|
||||
"@vitest/coverage-v8": "^2.1.3",
|
||||
"aws-sdk-client-mock": "^4.1.0",
|
||||
"cpy-cli": "^5.0.0",
|
||||
"del-cli": "^6.0.0",
|
||||
"json-schema": "^0.4.0",
|
||||
"prettier": "^3.2.5",
|
||||
"standard-version": "^9",
|
||||
"ts-jest": "^29.1.2",
|
||||
"typescript": "^5.3.3"
|
||||
"memfs": "^4.14.0",
|
||||
"standard-version": "^9.5.0",
|
||||
"typescript": "^5.6.3",
|
||||
"vitest": "^2.1.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.1",
|
||||
"@aws-sdk/client-sts": "^3",
|
||||
"@smithy/node-http-handler": "^2.3.1",
|
||||
"https-proxy-agent": "^5.0.0"
|
||||
"@actions/core": "^1.11.1",
|
||||
"@aws-sdk/client-sts": "^3.675.0",
|
||||
"@smithy/node-http-handler": "^4.0.1",
|
||||
"https-proxy-agent": "^5.0.1"
|
||||
},
|
||||
"keywords": [
|
||||
"aws",
|
||||
@@ -55,7 +46,6 @@
|
||||
"main": "build/index.js",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/aws-actions/configure-aws-credentials",
|
||||
"version": "0.0.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/aws-actions/configure-aws-credentials/issues"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"packages": {
|
||||
".": {
|
||||
"changelog-path": "CHANGELOG.md",
|
||||
"release-type": "node",
|
||||
"bump-minor-pre-major": false,
|
||||
"bump-patch-for-minor-pre-major": false,
|
||||
"draft": false,
|
||||
"prerelease": false
|
||||
}
|
||||
},
|
||||
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { info } from '@actions/core';
|
||||
import { STSClient } from '@aws-sdk/client-sts';
|
||||
import type { AwsCredentialIdentity } from '@aws-sdk/types';
|
||||
import { NodeHttpHandler } from '@smithy/node-http-handler';
|
||||
import { HttpsProxyAgent } from 'https-proxy-agent';
|
||||
import { errorMessage } from './helpers';
|
||||
@@ -40,7 +41,7 @@ export class CredentialsClient {
|
||||
}
|
||||
|
||||
public async validateCredentials(expectedAccessKeyId?: string, roleChaining?: boolean) {
|
||||
let credentials;
|
||||
let credentials: AwsCredentialIdentity;
|
||||
try {
|
||||
credentials = await this.loadCredentials();
|
||||
if (!credentials.accessKeyId) {
|
||||
@@ -55,7 +56,7 @@ export class CredentialsClient {
|
||||
|
||||
if (expectedAccessKeyId && expectedAccessKeyId !== actualAccessKeyId) {
|
||||
throw new Error(
|
||||
'Unexpected failure: Credentials loaded by the SDK do not match the access key ID configured by the action'
|
||||
'Unexpected failure: Credentials loaded by the SDK do not match the access key ID configured by the action',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+19
-15
@@ -1,6 +1,6 @@
|
||||
import assert from 'assert';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import assert from 'node:assert';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import * as core from '@actions/core';
|
||||
import type { AssumeRoleCommandInput, STSClient, Tag } from '@aws-sdk/client-sts';
|
||||
import { AssumeRoleCommand, AssumeRoleWithWebIdentityCommand } from '@aws-sdk/client-sts';
|
||||
@@ -15,7 +15,7 @@ async function assumeRoleWithOIDC(params: AssumeRoleCommandInput, client: STSCli
|
||||
new AssumeRoleWithWebIdentityCommand({
|
||||
...params,
|
||||
WebIdentityToken: webIdentityToken,
|
||||
})
|
||||
}),
|
||||
);
|
||||
return creds;
|
||||
} catch (error) {
|
||||
@@ -27,10 +27,10 @@ async function assumeRoleWithWebIdentityTokenFile(
|
||||
params: AssumeRoleCommandInput,
|
||||
client: STSClient,
|
||||
webIdentityTokenFile: string,
|
||||
workspace: string
|
||||
workspace: string,
|
||||
) {
|
||||
core.debug(
|
||||
'webIdentityTokenFile provided. Will call sts:AssumeRoleWithWebIdentity and take session tags from token contents.'
|
||||
'webIdentityTokenFile provided. Will call sts:AssumeRoleWithWebIdentity and take session tags from token contents.',
|
||||
);
|
||||
const webIdentityTokenFilePath = path.isAbsolute(webIdentityTokenFile)
|
||||
? webIdentityTokenFile
|
||||
@@ -46,7 +46,7 @@ async function assumeRoleWithWebIdentityTokenFile(
|
||||
new AssumeRoleWithWebIdentityCommand({
|
||||
...params,
|
||||
WebIdentityToken: webIdentityToken,
|
||||
})
|
||||
}),
|
||||
);
|
||||
return creds;
|
||||
} catch (error) {
|
||||
@@ -75,7 +75,7 @@ export interface assumeRoleParams {
|
||||
webIdentityTokenFile?: string;
|
||||
webIdentityToken?: string;
|
||||
inlineSessionPolicy?: string;
|
||||
managedSessionPolicies?: any[];
|
||||
managedSessionPolicies?: { arn: string }[];
|
||||
}
|
||||
|
||||
export async function assumeRole(params: assumeRoleParams) {
|
||||
@@ -108,8 +108,11 @@ export async function assumeRole(params: assumeRoleParams) {
|
||||
{ Key: 'Actor', Value: sanitizeGitHubVariables(GITHUB_ACTOR) },
|
||||
{ Key: 'Commit', Value: GITHUB_SHA },
|
||||
];
|
||||
if (process.env['GITHUB_REF']) {
|
||||
tagArray.push({ Key: 'Branch', Value: sanitizeGitHubVariables(process.env['GITHUB_REF']) });
|
||||
if (process.env.GITHUB_REF) {
|
||||
tagArray.push({
|
||||
Key: 'Branch',
|
||||
Value: sanitizeGitHubVariables(process.env.GITHUB_REF),
|
||||
});
|
||||
}
|
||||
const tags = roleSkipSessionTagging ? undefined : tagArray;
|
||||
if (!tags) {
|
||||
@@ -123,7 +126,7 @@ export async function assumeRole(params: assumeRoleParams) {
|
||||
if (!roleArn.startsWith('arn:aws')) {
|
||||
assert(
|
||||
isDefined(sourceAccountId),
|
||||
'Source Account ID is needed if the Role Name is provided and not the Role Arn.'
|
||||
'Source Account ID is needed if the Role Name is provided and not the Role Arn.',
|
||||
);
|
||||
roleArn = `arn:aws:iam::${sourceAccountId}:role/${roleArn}`;
|
||||
}
|
||||
@@ -139,6 +142,7 @@ export async function assumeRole(params: assumeRoleParams) {
|
||||
PolicyArns: managedSessionPolicies?.length ? managedSessionPolicies : undefined,
|
||||
};
|
||||
const keys = Object.keys(commonAssumeRoleParams) as Array<keyof typeof commonAssumeRoleParams>;
|
||||
// biome-ignore lint/complexity/noForEach: Legacy code
|
||||
keys.forEach((k) => commonAssumeRoleParams[k] === undefined && delete commonAssumeRoleParams[k]);
|
||||
|
||||
// Instantiate STS client
|
||||
@@ -147,14 +151,14 @@ export async function assumeRole(params: assumeRoleParams) {
|
||||
// Assume role using one of three methods
|
||||
if (!!webIdentityToken) {
|
||||
return assumeRoleWithOIDC(commonAssumeRoleParams, stsClient, webIdentityToken);
|
||||
} else if (!!webIdentityTokenFile) {
|
||||
}
|
||||
if (!!webIdentityTokenFile) {
|
||||
return assumeRoleWithWebIdentityTokenFile(
|
||||
commonAssumeRoleParams,
|
||||
stsClient,
|
||||
webIdentityTokenFile,
|
||||
GITHUB_WORKSPACE
|
||||
GITHUB_WORKSPACE,
|
||||
);
|
||||
} else {
|
||||
return assumeRoleWithCredentials(commonAssumeRoleParams, stsClient);
|
||||
}
|
||||
return assumeRoleWithCredentials(commonAssumeRoleParams, stsClient);
|
||||
}
|
||||
|
||||
+4
-3
@@ -23,7 +23,7 @@ export function exportCredentials(creds?: Partial<Credentials>, outputCredential
|
||||
if (creds?.SessionToken) {
|
||||
core.setSecret(creds.SessionToken);
|
||||
core.exportVariable('AWS_SESSION_TOKEN', creds.SessionToken);
|
||||
} else if (process.env['AWS_SESSION_TOKEN']) {
|
||||
} else if (process.env.AWS_SESSION_TOKEN) {
|
||||
// clear session token from previous credentials action
|
||||
core.exportVariable('AWS_SESSION_TOKEN', '');
|
||||
}
|
||||
@@ -116,7 +116,7 @@ export async function retryAndBackoff<T>(
|
||||
isRetryable: boolean,
|
||||
maxRetries = 12,
|
||||
retries = 0,
|
||||
base = 50
|
||||
base = 50,
|
||||
): Promise<T> {
|
||||
try {
|
||||
return await fn();
|
||||
@@ -125,7 +125,8 @@ export async function retryAndBackoff<T>(
|
||||
throw err;
|
||||
}
|
||||
// It's retryable, so sleep and retry.
|
||||
await sleep(Math.random() * (Math.pow(2, retries) * base));
|
||||
await sleep(Math.random() * (2 ** retries * base));
|
||||
// biome-ignore lint/style/noParameterAssign: This is a loop variable
|
||||
retries += 1;
|
||||
if (retries >= maxRetries) {
|
||||
throw err;
|
||||
|
||||
+31
-22
@@ -1,13 +1,13 @@
|
||||
import * as core from '@actions/core';
|
||||
import type { AssumeRoleCommandOutput } from '@aws-sdk/client-sts';
|
||||
import { assumeRole } from './assumeRole';
|
||||
import { CredentialsClient } from './CredentialsClient';
|
||||
import { assumeRole } from './assumeRole';
|
||||
import {
|
||||
errorMessage,
|
||||
retryAndBackoff,
|
||||
exportRegion,
|
||||
exportCredentials,
|
||||
exportAccountId,
|
||||
exportCredentials,
|
||||
exportRegion,
|
||||
retryAndBackoff,
|
||||
unsetCredentials,
|
||||
verifyKeys,
|
||||
} from './helpers';
|
||||
@@ -20,24 +20,35 @@ export async function run() {
|
||||
try {
|
||||
// Get inputs
|
||||
const AccessKeyId = core.getInput('aws-access-key-id', { required: false });
|
||||
const SecretAccessKey = core.getInput('aws-secret-access-key', { required: false });
|
||||
const sessionTokenInput = core.getInput('aws-session-token', { required: false });
|
||||
const SecretAccessKey = core.getInput('aws-secret-access-key', {
|
||||
required: false,
|
||||
});
|
||||
const sessionTokenInput = core.getInput('aws-session-token', {
|
||||
required: false,
|
||||
});
|
||||
const SessionToken = sessionTokenInput === '' ? undefined : sessionTokenInput;
|
||||
const region = core.getInput('aws-region', { required: true });
|
||||
const roleToAssume = core.getInput('role-to-assume', { required: false });
|
||||
const audience = core.getInput('audience', { required: false });
|
||||
const maskAccountIdInput = core.getInput('mask-aws-account-id', { required: false }) || 'false';
|
||||
const maskAccountId = maskAccountIdInput.toLowerCase() === 'true';
|
||||
const roleExternalId = core.getInput('role-external-id', { required: false });
|
||||
const webIdentityTokenFile = core.getInput('web-identity-token-file', { required: false });
|
||||
const roleDuration = parseInt(core.getInput('role-duration-seconds', { required: false })) || DEFAULT_ROLE_DURATION;
|
||||
const roleExternalId = core.getInput('role-external-id', {
|
||||
required: false,
|
||||
});
|
||||
const webIdentityTokenFile = core.getInput('web-identity-token-file', {
|
||||
required: false,
|
||||
});
|
||||
const roleDuration =
|
||||
Number.parseInt(core.getInput('role-duration-seconds', { required: false })) || DEFAULT_ROLE_DURATION;
|
||||
const roleSessionName = core.getInput('role-session-name', { required: false }) || ROLE_SESSION_NAME;
|
||||
const roleSkipSessionTaggingInput = core.getInput('role-skip-session-tagging', { required: false }) || 'false';
|
||||
const roleSkipSessionTagging = roleSkipSessionTaggingInput.toLowerCase() === 'true';
|
||||
const proxyServer = core.getInput('http-proxy', { required: false });
|
||||
const inlineSessionPolicy = core.getInput('inline-session-policy', { required: false });
|
||||
const inlineSessionPolicy = core.getInput('inline-session-policy', {
|
||||
required: false,
|
||||
});
|
||||
const managedSessionPoliciesInput = core.getMultilineInput('managed-session-policies', { required: false });
|
||||
const managedSessionPolicies: any[] = [];
|
||||
const managedSessionPolicies: { arn: string }[] = [];
|
||||
const roleChainingInput = core.getInput('role-chaining', { required: false }) || 'false';
|
||||
const roleChaining = roleChainingInput.toLowerCase() === 'true';
|
||||
const outputCredentialsInput = core.getInput('output-credentials', { required: false }) || 'false';
|
||||
@@ -49,7 +60,7 @@ export async function run() {
|
||||
const specialCharacterWorkaroundInput =
|
||||
core.getInput('special-characters-workaround', { required: false }) || 'false';
|
||||
const specialCharacterWorkaround = specialCharacterWorkaroundInput.toLowerCase() === 'true';
|
||||
let maxRetries = parseInt(core.getInput('retry-max-attempts', { required: false })) || 12;
|
||||
let maxRetries = Number.parseInt(core.getInput('retry-max-attempts', { required: false })) || 12;
|
||||
switch (true) {
|
||||
case specialCharacterWorkaround:
|
||||
// 😳
|
||||
@@ -74,17 +85,17 @@ export async function run() {
|
||||
!!roleToAssume &&
|
||||
!webIdentityTokenFile &&
|
||||
!AccessKeyId &&
|
||||
!process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'] &&
|
||||
!process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN &&
|
||||
!roleChaining
|
||||
) {
|
||||
core.info(
|
||||
'It looks like you might be trying to authenticate with OIDC. Did you mean to set the `id-token` permission? ' +
|
||||
'If you are not trying to authenticate with OIDC and the action is working successfully, you can ignore this message.'
|
||||
'If you are not trying to authenticate with OIDC and the action is working successfully, you can ignore this message.',
|
||||
);
|
||||
}
|
||||
return (
|
||||
!!roleToAssume &&
|
||||
!!process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'] &&
|
||||
!!process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN &&
|
||||
!AccessKeyId &&
|
||||
!webIdentityTokenFile &&
|
||||
!roleChaining
|
||||
@@ -114,7 +125,7 @@ export async function run() {
|
||||
return core.getIDToken(audience);
|
||||
},
|
||||
!disableRetry,
|
||||
maxRetries
|
||||
maxRetries,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new Error(`getIDToken call failed: ${errorMessage(error)}`);
|
||||
@@ -146,7 +157,6 @@ export async function run() {
|
||||
if (roleToAssume) {
|
||||
let roleCredentials: AssumeRoleCommandOutput;
|
||||
do {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
roleCredentials = await retryAndBackoff(
|
||||
async () => {
|
||||
return assumeRole({
|
||||
@@ -164,17 +174,16 @@ export async function run() {
|
||||
});
|
||||
},
|
||||
!disableRetry,
|
||||
maxRetries
|
||||
maxRetries,
|
||||
);
|
||||
// eslint-disable-next-line no-unmodified-loop-condition
|
||||
} while (specialCharacterWorkaround && !verifyKeys(roleCredentials.Credentials));
|
||||
core.info(`Authenticated as assumedRoleId ${roleCredentials.AssumedRoleUser!.AssumedRoleId!}`);
|
||||
core.info(`Authenticated as assumedRoleId ${roleCredentials.AssumedRoleUser?.AssumedRoleId}`);
|
||||
exportCredentials(roleCredentials.Credentials, outputCredentials);
|
||||
// We need to validate the credentials in 2 of our use-cases
|
||||
// First: self-hosted runners. If the GITHUB_ACTIONS environment variable
|
||||
// is set to `true` then we are NOT in a self-hosted runner.
|
||||
// Second: Customer provided credentials manually (IAM User keys stored in GH Secrets)
|
||||
if (!process.env['GITHUB_ACTIONS'] || AccessKeyId) {
|
||||
if (!process.env.GITHUB_ACTIONS || AccessKeyId) {
|
||||
await credentialsClient.validateCredentials(roleCredentials.Credentials?.AccessKeyId);
|
||||
}
|
||||
await exportAccountId(credentialsClient, maskAccountId);
|
||||
@@ -184,7 +193,7 @@ export async function run() {
|
||||
} catch (error) {
|
||||
core.setFailed(errorMessage(error));
|
||||
|
||||
const showStackTrace = process.env['SHOW_STACK_TRACE'];
|
||||
const showStackTrace = process.env.SHOW_STACK_TRACE;
|
||||
|
||||
if (showStackTrace === 'true') {
|
||||
throw error;
|
||||
|
||||
+29
-33
@@ -1,35 +1,34 @@
|
||||
import * as core from '@actions/core';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { cleanup } from '../src/cleanup';
|
||||
import * as core from '@actions/core';
|
||||
import { mockClient } from 'aws-sdk-client-mock';
|
||||
import { STSClient } from '@aws-sdk/client-sts';
|
||||
import mocks from './mockinputs.test';
|
||||
|
||||
const FAKE_ACCESS_KEY_ID = 'MY-AWS-ACCESS-KEY-ID';
|
||||
const FAKE_SECRET_ACCESS_KEY = 'MY-AWS-SECRET-ACCESS-KEY';
|
||||
const FAKE_SESSION_TOKEN = 'MY-AWS-SESSION-TOKEN';
|
||||
const FAKE_REGION = 'fake-region-1';
|
||||
const ACTION_ENVIRONMENT_VARIABLES = {
|
||||
AWS_ACCESS_KEY_ID: FAKE_ACCESS_KEY_ID,
|
||||
AWS_SECRET_ACCESS_KEY: FAKE_SECRET_ACCESS_KEY,
|
||||
AWS_SESSION_TOKEN: FAKE_SESSION_TOKEN,
|
||||
AWS_DEFAULT_REGION: FAKE_REGION,
|
||||
AWS_REGION: FAKE_REGION,
|
||||
};
|
||||
|
||||
describe('Configure AWS Credentials', () => {
|
||||
const OLD_ENV = process.env;
|
||||
const mockedSTSClient = mockClient(STSClient);
|
||||
|
||||
describe('Configure AWS Credentials cleanup', {}, () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
jest.spyOn(core, 'exportVariable').mockImplementation();
|
||||
jest.spyOn(core, 'setSecret').mockImplementation();
|
||||
jest.spyOn(core, 'setOutput').mockImplementation();
|
||||
jest.spyOn(core, 'setFailed').mockImplementation();
|
||||
process.env = { ...OLD_ENV, ...ACTION_ENVIRONMENT_VARIABLES };
|
||||
// Reset mock state
|
||||
vi.restoreAllMocks();
|
||||
mockedSTSClient.reset();
|
||||
// Mock GitHub Actions core functions
|
||||
vi.spyOn(core, 'exportVariable').mockImplementation((_n, _v) => {});
|
||||
vi.spyOn(core, 'setSecret').mockImplementation((_s) => {});
|
||||
vi.spyOn(core, 'setFailed').mockImplementation((_m) => {});
|
||||
vi.spyOn(core, 'setOutput').mockImplementation((_n, _v) => {});
|
||||
vi.spyOn(core, 'debug').mockImplementation((_m) => {});
|
||||
vi.spyOn(core, 'info').mockImplementation((_m) => {});
|
||||
process.env = {
|
||||
...mocks.envs,
|
||||
AWS_ACCESS_KEY_ID: 'CLEANUPTEST',
|
||||
AWS_SECRET_ACCESS_KEY: 'CLEANUPTEST',
|
||||
AWS_SESSION_TOKEN: 'CLEANUPTEST',
|
||||
AWS_REGION: 'CLEANUPTEST',
|
||||
AWS_DEFAULT_REGION: 'CLEANUPTEST',
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.env = OLD_ENV;
|
||||
});
|
||||
|
||||
test('replaces AWS credential and region env vars with empty strings', () => {
|
||||
it('replaces AWS credential and region environment variables with empty strings', {}, () => {
|
||||
cleanup();
|
||||
expect(core.setFailed).toHaveBeenCalledTimes(0);
|
||||
expect(core.exportVariable).toHaveBeenCalledTimes(5);
|
||||
@@ -39,14 +38,11 @@ describe('Configure AWS Credentials', () => {
|
||||
expect(core.exportVariable).toHaveBeenCalledWith('AWS_DEFAULT_REGION', '');
|
||||
expect(core.exportVariable).toHaveBeenCalledWith('AWS_REGION', '');
|
||||
});
|
||||
|
||||
test('error is caught and fails the action', () => {
|
||||
jest.spyOn(core, 'exportVariable').mockImplementation(() => {
|
||||
throw new Error();
|
||||
it('handles errors', {}, () => {
|
||||
vi.spyOn(core, 'exportVariable').mockImplementationOnce(() => {
|
||||
throw new Error('Test error');
|
||||
});
|
||||
|
||||
cleanup();
|
||||
|
||||
expect(core.setFailed).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
+35
-16
@@ -1,26 +1,45 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import * as helpers from '../src/helpers';
|
||||
describe('helpers', () => {
|
||||
import * as core from '@actions/core';
|
||||
import { before, beforeEach } from 'node:test';
|
||||
|
||||
describe('Configure AWS Credentials helpers', {}, () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
jest.clearAllMocks();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
test('removes brackets from GitHub Actor', () => {
|
||||
expect(helpers.sanitizeGitHubVariables('foo[bot]')).toEqual('foo_bot_');
|
||||
it('removes brackets from GitHub Actor', {}, () => {
|
||||
const actor = 'actor[bot]';
|
||||
expect(helpers.sanitizeGitHubVariables(actor)).toBe('actor_bot_');
|
||||
});
|
||||
|
||||
test('removes special characters from worflow names', () => {
|
||||
it('can sleep', {}, () => {
|
||||
const sleep = helpers.defaultSleep(10);
|
||||
expect(Promise.race([sleep, new Promise((_, reject) => setTimeout(reject, 20))])).resolves.toBe(undefined);
|
||||
});
|
||||
it('removes special characters from workflow names', {}, () => {
|
||||
expect(helpers.sanitizeGitHubVariables('sdf234@#$%$^&*()_+{}|:"<>?')).toEqual('sdf234@__________+___:____');
|
||||
});
|
||||
|
||||
test('can sleep', () => {
|
||||
const sleep = helpers.defaultSleep(10);
|
||||
expect(Promise.race([sleep, new Promise((_res, rej) => setTimeout(rej, 20))])).resolves;
|
||||
});
|
||||
|
||||
test("backoff function doesn't retry non-retryable errors", async () => {
|
||||
const fn = jest.fn().mockRejectedValue('i am not retryable');
|
||||
it("doesn't retry non-retryable errors", {}, async () => {
|
||||
const fn = vi.fn().mockRejectedValue('i am not retryable');
|
||||
await expect(helpers.retryAndBackoff(fn, false)).rejects.toMatch('i am not retryable');
|
||||
expect(fn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
it('can output creds when told to', {}, () => {
|
||||
vi.spyOn(core, 'setOutput').mockImplementation(() => {});
|
||||
vi.spyOn(core, 'setSecret').mockImplementation(() => {});
|
||||
vi.spyOn(core, 'exportVariable').mockImplementation(() => {});
|
||||
helpers.exportCredentials({ AccessKeyId: 'test', SecretAccessKey: 'test', SessionToken: 'test' }, true);
|
||||
expect(core.setOutput).toHaveBeenCalledTimes(3);
|
||||
expect(core.setSecret).toHaveBeenCalledTimes(3);
|
||||
expect(core.exportVariable).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
it('can unset credentials', {}, () => {
|
||||
const env = process.env;
|
||||
helpers.unsetCredentials();
|
||||
expect(process.env.AWS_ACCESS_KEY_ID).toBeUndefined;
|
||||
expect(process.env.AWS_SECRET_ACCESS_KEY).toBeUndefined;
|
||||
expect(process.env.AWS_SESSION_TOKEN).toBeUndefined;
|
||||
expect(process.env.AWS_REGION).toBeUndefined;
|
||||
expect(process.env.AWS_DEFAULT_REGION).toBeUndefined;
|
||||
process.env = env;
|
||||
});
|
||||
});
|
||||
|
||||
+264
-832
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,98 @@
|
||||
import type * as core from '@actions/core';
|
||||
|
||||
const inputs = {
|
||||
GH_OIDC_INPUTS: {
|
||||
'role-to-assume': 'arn:aws:iam::111111111111:role/MY-ROLE',
|
||||
'aws-region': 'fake-region-1',
|
||||
'special-characters-workaround': 'true',
|
||||
},
|
||||
IAM_USER_INPUTS: {
|
||||
'aws-access-key-id': 'MYAWSACCESSKEYID',
|
||||
'aws-secret-access-key': 'MYAWSSECRETACCESSKEY',
|
||||
'aws-region': 'fake-region-1',
|
||||
},
|
||||
IAM_ASSUMEROLE_INPUTS: {
|
||||
'aws-access-key-id': 'MYAWSACCESSKEYID',
|
||||
'aws-secret-access-key': 'MYAWSSECRETACCESSKEY',
|
||||
'role-to-assume': 'arn:aws:iam::111111111111:role/MY-ROLE',
|
||||
'aws-region': 'fake-region-1',
|
||||
},
|
||||
WEBIDENTITY_TOKEN_FILE_INPUTS: {
|
||||
'web-identity-token-file': 'file.txt',
|
||||
'role-to-assume': 'arn:aws:iam::111111111111:role/MY-ROLE',
|
||||
'aws-region': 'fake-region-1',
|
||||
},
|
||||
EXISTING_ROLE_INPUTS: {
|
||||
'role-to-assume': 'arn:aws:iam::111111111111:role/MY-ROLE',
|
||||
'role-chaining': 'true',
|
||||
'aws-region': 'fake-region-1',
|
||||
},
|
||||
};
|
||||
|
||||
const envs = {
|
||||
GITHUB_REPOSITORY: 'MY-REPOSITORY-NAME',
|
||||
GITHUB_WORKFLOW: 'MY-WORKFLOW-ID',
|
||||
GITHUB_ACTION: 'MY-ACTION-NAME',
|
||||
GITHUB_ACTOR: 'MY-USERNAME[bot]',
|
||||
GITHUB_SHA: 'MY-COMMIT-ID',
|
||||
GITHUB_WORKSPACE: '/home/github',
|
||||
GITHUB_ACTIONS: 'true',
|
||||
};
|
||||
|
||||
const outputs = {
|
||||
STS_CREDENTIALS: {
|
||||
Credentials: {
|
||||
AccessKeyId: 'STSAWSACCESSKEYID',
|
||||
SecretAccessKey: 'STSAWSSECRETACCESSKEY',
|
||||
SessionToken: 'STSAWSSESSIONTOKEN',
|
||||
Expiration: new Date(8640000000000000),
|
||||
},
|
||||
AssumedRoleUser: {
|
||||
Arn: 'arn:aws:sts::111111111111:assumed-role/MY-ROLE/',
|
||||
AssumedRoleId: 'AROAFAKEASSUMEDROLEID',
|
||||
},
|
||||
},
|
||||
GET_CALLER_IDENTITY: {
|
||||
Account: '111111111111',
|
||||
Arn: 'arn:aws:iam::111111111111:role/MY-ROLE',
|
||||
},
|
||||
FAKE_STS_ACCESS_KEY_ID: 'STSAWSACCESSKEYID',
|
||||
FAKE_STS_SECRET_ACCESS_KEY: 'STSAWSSECRETACCESSKEY',
|
||||
FAKE_STS_SESSION_TOKEN: 'STSAWSSESSIONTOKEN',
|
||||
ODD_CHARACTER_CREDENTIALS: {
|
||||
Credentials: {
|
||||
AccessKeyId: 'STSA#$%^&',
|
||||
SecretAccessKey: 'STSA#$%^&Key',
|
||||
SessionToken: 'STSA#$%^',
|
||||
Expiration: new Date(8640000000000000),
|
||||
},
|
||||
AssumedRoleUser: {
|
||||
Arn: 'arn:aws:sts::111111111111:assumed-role/MY-ROLE/',
|
||||
AssumedRoleId: 'AROAFAKEASSUMEDROLEID',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
getInput: (fakeEnv: Record<string, string>) => {
|
||||
return (name: string, options?: core.InputOptions): string => {
|
||||
if (!fakeEnv[name]) {
|
||||
if (options?.required) throw new Error(`Input ${name} not found`);
|
||||
return '';
|
||||
}
|
||||
return fakeEnv[name];
|
||||
};
|
||||
},
|
||||
getMultilineInput: (fakeEnv: Record<string, string[]>) => {
|
||||
return (name: string, options?: core.InputOptions): string[] => {
|
||||
if (!fakeEnv[name]) {
|
||||
if (options?.required) throw new Error(`Input ${name} not found`);
|
||||
return [];
|
||||
}
|
||||
return fakeEnv[name];
|
||||
};
|
||||
},
|
||||
...inputs,
|
||||
outputs,
|
||||
envs,
|
||||
} as const;
|
||||
+2
-3
@@ -7,9 +7,8 @@
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"module": "CommonJS",
|
||||
"resolveJsonModule": true,
|
||||
@@ -27,7 +26,7 @@
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"test/**/*.ts"
|
||||
"test/**/*.test.ts"
|
||||
],
|
||||
"exclude": [],
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
passWithNoTests: true,
|
||||
include: ['test/**/*.test.ts'],
|
||||
coverage: { enabled: true },
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user