mirror of
https://github.com/aws-actions/configure-aws-credentials.git
synced 2026-08-25 04:35:06 +09:00
Compare commits
80 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 023daa7fe5 | |||
| f586cc8d6c | |||
| 5726671b7e | |||
| 682539baa7 | |||
| 186395a864 | |||
| a19d847176 | |||
| afbf093795 | |||
| df03f9f89e | |||
| 5f641521a3 | |||
| cf1ab7af03 | |||
| feaa7fa4a6 | |||
| 4f2f92e5ab | |||
| 63c92be916 | |||
| d57f6a99b2 | |||
| b10102e8c0 | |||
| 329c87d69e | |||
| 7c78a8afc0 | |||
| bfc885690a | |||
| b8843be31a | |||
| 07c2f971ba | |||
| afaecf5658 | |||
| 9395f54576 | |||
| 15bf15ef24 | |||
| 0bb734a034 | |||
| 104814938c | |||
| 8203047ce9 | |||
| a3d672ff77 | |||
| 3c5e8d9305 | |||
| 26c46c2ae7 | |||
| 011701cc1b | |||
| b9e6c47506 | |||
| 9727186006 | |||
| 8c40159721 | |||
| ada05fa00e | |||
| 90be1075bb | |||
| b1e291fd46 | |||
| 5bf8e889ef | |||
| 8fd75be9bb | |||
| 65cd794383 | |||
| 56320524c9 | |||
| 4a10c382ea | |||
| d4fb44140f | |||
| 95bc17402b | |||
| b016bfd40a | |||
| abcf4fe216 | |||
| 6a502811f6 | |||
| fc10f5e66c | |||
| 2fbb264794 | |||
| 7704dba423 | |||
| 495fc37803 | |||
| c44e4cd308 | |||
| 5db0c4b245 | |||
| 8962602b76 | |||
| 996af9a61b | |||
| 70f70f3d01 | |||
| 40d50e0dc7 | |||
| d70ae8a9b8 | |||
| 29858782df | |||
| daed12437b | |||
| 3d0ec8cfd7 | |||
| 89d6bf8b63 | |||
| 89d9dc8901 | |||
| 59775fae63 | |||
| 8461db48ce | |||
| 1c6d3132e1 | |||
| 77b504aefa | |||
| 993b6a062d | |||
| 1fee7bbf94 | |||
| 096a34b527 | |||
| 036f9c6a9f | |||
| 1908557210 | |||
| 7be15a02d9 | |||
| 7289c29462 | |||
| a485a1e9a4 | |||
| c3748b7f3f | |||
| 2db6cd9a80 | |||
| d90b587a73 | |||
| 2aed65ee75 | |||
| cdfc29bebf | |||
| a30b23eed5 |
@@ -7,3 +7,10 @@ updates:
|
||||
day: tuesday
|
||||
open-pull-requests-limit: 10
|
||||
target-branch: 'master'
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: tuesday
|
||||
open-pull-requests-limit: 10
|
||||
target-branch: 'v1-node16'
|
||||
|
||||
@@ -9,7 +9,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v2
|
||||
- name: Run tests
|
||||
run: |
|
||||
npm ci
|
||||
|
||||
@@ -13,6 +13,7 @@ jobs:
|
||||
# These inputs are both required
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
message: |
|
||||
### ⚠️Comment Visibility Warning⚠️
|
||||
Comments on closed issues are hard for our team to see.
|
||||
If you need more assistance, please either tag a team member or open a new issue that references this one.
|
||||
If you wish to keep having a conversation with other community members under this issue feel free to do so.
|
||||
@@ -0,0 +1,71 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [master]
|
||||
schedule:
|
||||
- cron: '0 0 * * 2'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# Override automatic language detection by changing the below list
|
||||
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
|
||||
language: ['javascript']
|
||||
# Learn more...
|
||||
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
fetch-depth: 2
|
||||
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
# the head of the pull request instead of the merge commit.
|
||||
- run: git checkout HEAD^2
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
@@ -4,6 +4,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- v1-node16
|
||||
paths-ignore:
|
||||
- 'dist/**'
|
||||
|
||||
@@ -27,7 +28,7 @@ jobs:
|
||||
npm test
|
||||
npm run package
|
||||
- name: Configure AWS credentials
|
||||
uses: aws-actions/configure-aws-credentials@v2
|
||||
uses: aws-actions/configure-aws-credentials@v1-node16
|
||||
with:
|
||||
aws-region: us-west-2
|
||||
role-to-assume: ${{ secrets.SECRETS_AWS_ROLE_TO_ASSUME }}
|
||||
@@ -41,10 +42,10 @@ jobs:
|
||||
OSDS,arn:aws:secretsmanager:us-west-2:294535624312:secret:github-aws-sdk-osds-automation-ZHNalp
|
||||
- name: Commit
|
||||
run: |
|
||||
echo "::add-mask::${{ env.OSDS_ACCESS_TOKEN }}"
|
||||
echo "::add-mask::${{ env.OSDS_ACCESS_TOKEN }}}"
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "github-aws-sdk-osds-automation@amazon.com"
|
||||
git remote set-url origin https://${{ env.OSDS_ACCESS_TOKEN }}@github.com/aws-actions/configure-aws-credentials.git
|
||||
git remote set-url origin https://x-access-token:${{ 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
|
||||
|
||||
+3
-2
@@ -1,3 +1,4 @@
|
||||
|
||||
queue_rules:
|
||||
- name: default
|
||||
conditions:
|
||||
@@ -7,7 +8,7 @@ queue_rules:
|
||||
pull_request_rules:
|
||||
- name: Automatically merge on CI success and review approval
|
||||
conditions:
|
||||
- base~=master|integ-tests
|
||||
- base~=master|v1-node16|integ-tests
|
||||
- "#approved-reviews-by>=1"
|
||||
- -approved-reviews-by~=author
|
||||
- status-success=Run Unit Tests
|
||||
@@ -23,7 +24,7 @@ pull_request_rules:
|
||||
|
||||
- name: Automatically approve and merge Dependabot PRs
|
||||
conditions:
|
||||
- base~=master
|
||||
- base~=master|v1-node16
|
||||
- author=dependabot[bot]
|
||||
- status-success=Run Unit Tests
|
||||
- -title~=(WIP|wip)
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
|
||||
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.
|
||||
|
||||
## [2.0.0](https://github.com/aws-actions/configure-aws-credentials/compare/v1.7.0...v2.0.0) (2023-03-06)
|
||||
|
||||
### Features
|
||||
* Version bump to use Node 16 by default.
|
||||
|
||||
## [1.7.0](https://github.com/aws-actions/configure-aws-credentials/compare/v1.6.1...v1.7.0) (2022-08-03)
|
||||
|
||||
|
||||
|
||||
@@ -1,60 +1,39 @@
|
||||
## 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.
|
||||
## "Configure AWS Credentials" Action For GitHub Actions
|
||||
|
||||
### Recent updates
|
||||
We've recently released a `v2` of this action that uses the Node 16 runtime by
|
||||
default. You should update your action references to `v2`. We intend `v2` to be
|
||||
the new default for this action and will no longer be providing updates to the
|
||||
`v1` tag.
|
||||
Configure AWS credential and region environment variables for use in other GitHub Actions. The environment variables will be detected by both the AWS SDKs and the AWS CLI to determine the credentials and region to use for AWS API calls.
|
||||
|
||||
As is usual for GitHub Actions, we provide release tags for you to reference in
|
||||
your repository's workflow files. The `v2` tag is a moving tag that will always
|
||||
apply to the lastest version 2 train release. We will also provide minor version
|
||||
tags on every release, and create a `v3` tag when we are ready for a new major
|
||||
release. If you had been following the development of this action so far, this
|
||||
is a change to previous states release policy.
|
||||
## NOTICE: node12 deprecation warning
|
||||
GitHub actions has recently started throwing warning messages regarding the deprecation of Node 12. If you would like to stop seeing this warning, configure your action to use `aws-actions/configure-aws-credentials@v1-node16`. Both the `v1` branch and the `v1-node16` branch will receive the same updates moving forward. See [this issue](https://github.com/aws-actions/configure-aws-credentials/issues/489) for more information on this topic.
|
||||
|
||||
**Table of Contents**
|
||||
|
||||
### Table of Contents
|
||||
<!-- toc -->
|
||||
|
||||
- [Usage](#usage)
|
||||
- [Credentials](#credentials)
|
||||
- [Assuming a Role](#assuming-a-role)
|
||||
+ [Session tagging](#session-tagging)
|
||||
+ [Sample IAM Role Permissions](#sample-iam-role-cloudformation-template)
|
||||
- [Self-Hosted Runners](#self-hosted-runners)
|
||||
+ [Proxy Configuration](#proxy-configuration)
|
||||
- [License Summary](#license-summary)
|
||||
- [Security Disclosures](#security-disclosures)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Usage
|
||||
We support four 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 to that, you would add the following step to your workflow:
|
||||
Add the following step to your workflow:
|
||||
|
||||
```yaml
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v2
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
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` call and
|
||||
return temporary security credentials for use by other actions. In order for
|
||||
this to work, you'll need to preconfigure the IAM IdP in your AWS account
|
||||
(see [Assuming a Role](#assuming-a-role) 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.
|
||||
For example, 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).
|
||||
You can also run this action multiple times to use different AWS accounts, regions, or IAM roles in the same GitHub Actions workflow job.
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
@@ -67,73 +46,64 @@ jobs:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Configure AWS credentials from Test account
|
||||
uses: aws-actions/configure-aws-credentials@v2
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
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@v1
|
||||
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.
|
||||
See [action.yml](action.yml) for the full documentation for this action's inputs and outputs.
|
||||
|
||||
## Credentials
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
## Assuming a Role
|
||||
There are four different supported ways to retrieve credentials. 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 credentials needed for your actions. Specifying
|
||||
`role-to-assume` **without** providing an `aws-access-key-id` or a
|
||||
`web-identity-token-file` will signal to the action that you wish to use the
|
||||
OIDC provider.
|
||||
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 credentials needed for your actions.
|
||||
Specifying `role-to-assume` **without** providing an `aws-access-key-id` or a `web-identity-token-file` will signal to the action that you wish to use the OIDC provider.
|
||||
|
||||
The following table describes which identity is used based on which values are supplied to the Action:
|
||||
The default session duration is **1 hour** when using the OIDC provider to directly assume an IAM Role or when an `aws-session-token` is directly provided.
|
||||
|
||||
| **Identity Used** | `aws-access-key-id` | `role-to-assume` | `web-identity-token-file` |
|
||||
| --------------------------------------------------------------- | ------------------- | ---------------- | ------------------------- |
|
||||
| [✅ Recommended] Assume Role directly using GitHub OIDC provider | | ✔ | |
|
||||
| IAM User | ✔ | | |
|
||||
| Assume Role using IAM User credentials | ✔ | ✔ | |
|
||||
| Assume Role using WebIdentity Token File credentials | | ✔ | ✔ |
|
||||
|
||||
### Credential Lifetime
|
||||
The default session duration is **1 hour** when using the OIDC provider to
|
||||
directly assume an IAM Role or when an `aws-session-token` is directly provided.
|
||||
The default session duration is **6 hours** when using an IAM User to assume an
|
||||
IAM Role (by providing an `aws-access-key-id`, `aws-secret-access-key`, and a
|
||||
`role-to-assume`) .
|
||||
The default session duration is **6 hours** when using an IAM User to assume an IAM Role (by providing an `aws-access-key-id`, `aws-secret-access-key`, and a `role-to-assume`) .
|
||||
|
||||
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.
|
||||
The default session name is GitHubActions, and you can modify it by specifying the desired name in `role-session-name`.
|
||||
The default audience is `sts.amazonaws.com` which you can replace by specifying the desired audience name in `audience`.
|
||||
|
||||
The following table describes which identity is used based on which values are supplied to the Action:
|
||||
|
||||
| **Identity Used** | `aws-access-key-id` | `role-to-assume` | `web-identity-token-file` |
|
||||
|------------------------------------------------------------------|---------------------|------------------|---------------------------|
|
||||
| [✅ Recommended] Assume Role directly using GitHub OIDC provider | | ✔ | |
|
||||
| IAM User | ✔ | | |
|
||||
| Assume Role using IAM User credentials | ✔ | ✔ | |
|
||||
| Assume Role using WebIdentity Token File credentials | | ✔ | ✔ |
|
||||
|
||||
### Examples
|
||||
|
||||
#### AssumeRoleWithWebIdentity (recommended)
|
||||
```yaml
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v2
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-region: us-east-2
|
||||
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
|
||||
@@ -141,10 +111,9 @@ The default audience is `sts.amazonaws.com` which you can replace by specifying
|
||||
```
|
||||
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 static IAM credentials in repository secrets
|
||||
```yaml
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v2
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
@@ -156,7 +125,6 @@ In this example, the Action will load the OIDC token from the GitHub-provided en
|
||||
```
|
||||
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`.
|
||||
|
||||
#### AssumeRoleWithWebIdentity using a custom audience
|
||||
```yaml
|
||||
- name: Configure AWS Credentials for Beta Customers
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
@@ -170,27 +138,7 @@ In this example, the audience has been changed from the default to use a differe
|
||||
|
||||
Changing the default audience may be necessary when using non-default [AWS partitions](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html).
|
||||
|
||||
#### AssumeRoleWithWebIdentity and disable secure Action outputs
|
||||
```yaml
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-region: us-east-2
|
||||
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
|
||||
role-session-name: MySessionName
|
||||
mask-aws-account-id: false
|
||||
```
|
||||
In this example, account ID masking has been disabled. By default, the AWS
|
||||
account ID will be obscured in the action's output. This may be helpful when
|
||||
debugging action failures.
|
||||
|
||||
## Sample IAM OIDC CloudFormation Template
|
||||
If you choose 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
|
||||
created once per account (i.e. multiple IAM Roles that can be assumed by the
|
||||
GitHub's OIDC can share a single OIDC Provider).
|
||||
|
||||
This CloudFormation template will configure the IdP for you.
|
||||
### Sample IAM Role CloudFormation Template
|
||||
```yaml
|
||||
Parameters:
|
||||
GitHubOrg:
|
||||
@@ -201,10 +149,6 @@ Parameters:
|
||||
Description: Arn for the GitHub OIDC Provider.
|
||||
Default: ""
|
||||
Type: String
|
||||
OIDCAudience:
|
||||
Description: Audience supplied to configure-aws-credentials.
|
||||
Default: "sts.amazonaws.com"
|
||||
Type: String
|
||||
|
||||
Conditions:
|
||||
CreateOIDCProvider: !Equals
|
||||
@@ -225,8 +169,6 @@ Resources:
|
||||
- !Ref GithubOidc
|
||||
- !Ref OIDCProviderArn
|
||||
Condition:
|
||||
StringEquals:
|
||||
token.actions.githubusercontent.com:aud: !Ref OIDCAudience
|
||||
StringLike:
|
||||
token.actions.githubusercontent.com:sub: !Sub repo:${GitHubOrg}/${RepositoryName}:*
|
||||
|
||||
@@ -245,16 +187,9 @@ Outputs:
|
||||
Value: !GetAtt Role.Arn
|
||||
```
|
||||
|
||||
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 allowed to assume the role. Without a subject
|
||||
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. 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.
|
||||
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).
|
||||
|
||||
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 allowed to assume the role. Without a subject 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. Additional claim conditions can be added for higher specificity as explained in the [GitHub docs](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect).
|
||||
|
||||
For further information on OIDC and GitHub Actions, please see:
|
||||
|
||||
@@ -265,32 +200,26 @@ For further information on OIDC and GitHub Actions, please see:
|
||||
* [GitHub changelog: GitHub Actions: Secure cloud deployments with OpenID Connect](https://github.blog/changelog/2021-10-27-github-actions-secure-cloud-deployments-with-openid-connect/)
|
||||
|
||||
### Session tagging
|
||||
The session will have the name "GitHubActions" and 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))
|
||||
The session will have the name "GitHubActions" and 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))
|
||||
|
||||
| Key | Value |
|
||||
| ---------- | ----------------- |
|
||||
| GitHub | "Actions" |
|
||||
| Key | Value|
|
||||
| --- | --- |
|
||||
| GitHub | "Actions" |
|
||||
| Repository | GITHUB_REPOSITORY |
|
||||
| Workflow | GITHUB_WORKFLOW |
|
||||
| Action | GITHUB_ACTION |
|
||||
| Actor | GITHUB_ACTOR |
|
||||
| Branch | GITHUB_REF |
|
||||
| Commit | GITHUB_SHA |
|
||||
| Workflow | GITHUB_WORKFLOW |
|
||||
| Action | GITHUB_ACTION |
|
||||
| Actor | GITHUB_ACTOR |
|
||||
| Branch | GITHUB_REF |
|
||||
| Commit | GITHUB_SHA |
|
||||
|
||||
_Note: all tag values must conform to
|
||||
[the 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 '*'._
|
||||
_Note: all tag values must conform to [the 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.
|
||||
Note that 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 not set during the AssumeRoleWithWebIdentity API call
|
||||
within the Action. You can skip this session tagging by providing
|
||||
`role-skip-session-tagging` as true in the action's inputs:
|
||||
Note that 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 not set during the AssumeRoleWithWebIdentity API call within the Action.
|
||||
You can skip this session tagging by providing `role-skip-session-tagging` as true in the action's inputs:
|
||||
|
||||
```yaml
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
@@ -299,81 +228,48 @@ within the Action. You can skip this session tagging by providing
|
||||
|
||||
## Self-Hosted Runners
|
||||
|
||||
If you run your GitHub Actions in a
|
||||
[self-hosted runner](https://help.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners) that already has access to AWS credentials, such as
|
||||
an EC2 instance, then you do not need to provide IAM user access key credentials
|
||||
to this action. We will use the standard AWS JavaScript SDK credential
|
||||
resolution methods to find your credentials, so if the AWS JS SDK can
|
||||
authenticate on your runner, this Action will as well.
|
||||
If you run your GitHub Actions in a [self-hosted runner](https://help.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners) that already has access to AWS credentials, such as an EC2 instance, then you do not need to provide IAM user access key credentials to this action.
|
||||
|
||||
If no access key credentials are given in the action inputs, this action will
|
||||
use credentials from the runner environment using the
|
||||
[default methods for the AWS SDK for Javascript](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html).
|
||||
If no access key credentials are given in the action inputs, this action will use credentials from the runner environment using the [default methods for the AWS SDK for Javascript](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html).
|
||||
|
||||
You can use this action to simply configure the region and account ID in the
|
||||
environment, and then use the runner's credentials for all AWS API calls made by
|
||||
your Actions workflow:
|
||||
You can use this action to simply configure the region and account ID in the environment, and then use the runner's credentials for all AWS API calls made by your Actions workflow:
|
||||
```yaml
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-region: us-east-2
|
||||
```
|
||||
In this case, your runner's credentials must have permissions to call any AWS
|
||||
APIs called by your Actions workflow.
|
||||
In this case, your runner's credentials must have permissions to call any AWS APIs called by your Actions workflow.
|
||||
|
||||
Or, you can use this action to assume a role, and then use the role credentials
|
||||
for all AWS API calls made by your Actions workflow:
|
||||
```yaml
|
||||
uses: aws-actions/configure-aws-credentials@v2
|
||||
with:
|
||||
aws-region: us-east-2
|
||||
role-to-assume: my-github-actions-role
|
||||
```
|
||||
In this case, your runner's credentials must have permissions to assume the
|
||||
role.
|
||||
|
||||
You can also assume a role using a web identity token file, such as if using
|
||||
[Amazon EKS IRSA](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-technical-overview.html). Pods running in EKS
|
||||
worker nodes that do not run as root can use this file to assume a role with a
|
||||
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.
|
||||
|
||||
Additionally this action will always consider already configured proxy in the
|
||||
environment.
|
||||
|
||||
Manually configured proxy:
|
||||
Or, you can use this action to assume a role, and then use the role credentials for all AWS API calls made by your Actions workflow:
|
||||
```yaml
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-region: us-east-2
|
||||
role-to-assume: my-github-actions-role
|
||||
http-proxy: "http://companydomain.com:3128"
|
||||
```
|
||||
In this case, your runner's credentials must have permissions to assume the role.
|
||||
|
||||
Proxy configured in the environment variable:
|
||||
```bash
|
||||
# Your environment configuration
|
||||
HTTP_PROXY="http://companydomain.com:3128"
|
||||
You can also assume a role using a web identity token file, such as if using [Amazon EKS IRSA](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-technical-overview.html).
|
||||
Pods running in EKS worker nodes that do not run as root can use this file to assume a role with a web identity.
|
||||
|
||||
You can configure your workflow as follows in order to use this file:
|
||||
```yaml
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-region: us-east-2
|
||||
role-to-assume: my-github-actions-role
|
||||
web-identity-token-file: /var/run/secrets/eks.amazonaws.com/serviceaccount/token
|
||||
```
|
||||
|
||||
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
|
||||
to executing `aws` commands need to have the AWS CLI
|
||||
[installed](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html)
|
||||
if it's not already present.
|
||||
Most [GitHub hosted runner environments](https://github.com/actions/virtual-environments)
|
||||
should include the AWS CLI by default.
|
||||
|
||||
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 to executing `aws` commands need to have the AWS CLI [installed](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) if it's not already present.
|
||||
Most [GitHub hosted runner environments](https://github.com/actions/virtual-environments) should include the AWS CLI by default.
|
||||
|
||||
## 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).
|
||||
|
||||
+1
-4
@@ -1,4 +1,4 @@
|
||||
name: 'Configure AWS Credentials For GitHub Actions'
|
||||
name: '"Configure AWS Credentials" Action For GitHub Actions'
|
||||
description: 'Configure AWS credential and region environment variables for use with the AWS CLI and AWS SDKs'
|
||||
branding:
|
||||
icon: 'cloud'
|
||||
@@ -55,9 +55,6 @@ inputs:
|
||||
role-skip-session-tagging:
|
||||
description: 'Skip session tagging during role assumption'
|
||||
required: false
|
||||
http-proxy:
|
||||
description: 'Proxy to use for the AWS SDK agent'
|
||||
required: false
|
||||
outputs:
|
||||
aws-account-id:
|
||||
description: 'The AWS account ID for the provided credentials'
|
||||
|
||||
Vendored
-1718
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,6 @@ const aws = require('aws-sdk');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const proxy = require('https-proxy-agent');
|
||||
|
||||
// Use 1hr as role duration when using session token or OIDC
|
||||
// Otherwise, use the max duration of GitHub action (6hr)
|
||||
@@ -261,26 +260,6 @@ const retryAndBackoff = async (fn, isRetryable, retries = 0, maxRetries = 12, ba
|
||||
}
|
||||
}
|
||||
|
||||
function configureProxy(proxyServer) {
|
||||
const proxyFromEnv = process.env.HTTP_PROXY || process.env.http_proxy;
|
||||
|
||||
if (proxyFromEnv || proxyServer) {
|
||||
let proxyToSet = null;
|
||||
|
||||
if (proxyServer){
|
||||
console.log(`Setting proxy from actions input: ${proxyServer}`);
|
||||
proxyToSet = proxyServer;
|
||||
} else {
|
||||
console.log(`Setting proxy from environment: ${proxyFromEnv}`);
|
||||
proxyToSet = proxyFromEnv;
|
||||
}
|
||||
|
||||
aws.config.update({
|
||||
httpOptions: { agent: proxy(proxyToSet) }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
// Get inputs
|
||||
@@ -299,7 +278,6 @@ async function run() {
|
||||
const roleSkipSessionTaggingInput = core.getInput('role-skip-session-tagging', { required: false })|| 'false';
|
||||
const roleSkipSessionTagging = roleSkipSessionTaggingInput.toLowerCase() === 'true';
|
||||
const webIdentityTokenFile = core.getInput('web-identity-token-file', { required: false });
|
||||
const proxyServer = core.getInput('http-proxy', { required: false });
|
||||
|
||||
if (!region.match(REGION_REGEX)) {
|
||||
throw new Error(`Region is not valid: ${region}`);
|
||||
@@ -329,9 +307,6 @@ async function run() {
|
||||
|
||||
exportCredentials({accessKeyId, secretAccessKey, sessionToken});
|
||||
}
|
||||
|
||||
// Configures proxy
|
||||
configureProxy(proxyServer);
|
||||
|
||||
// Attempt to load credentials from the GitHub OIDC provider.
|
||||
// If a user provides an IAM Role Arn and DOESN'T provide an Access Key Id
|
||||
|
||||
+1
-71
@@ -2,7 +2,6 @@ const core = require('@actions/core');
|
||||
const assert = require('assert');
|
||||
const aws = require('aws-sdk');
|
||||
const { run, withSleep, reset } = require('./index.js');
|
||||
const proxy = require('https-proxy-agent');
|
||||
|
||||
jest.mock('@actions/core');
|
||||
|
||||
@@ -34,7 +33,6 @@ function mockGetInput(requestResponse) {
|
||||
return requestResponse[name]
|
||||
}
|
||||
}
|
||||
|
||||
const CREDS_INPUTS = {
|
||||
'aws-access-key-id': FAKE_ACCESS_KEY_ID,
|
||||
'aws-secret-access-key': FAKE_SECRET_ACCESS_KEY
|
||||
@@ -54,8 +52,7 @@ const mockStsAssumeRoleWithWebIdentity = jest.fn();
|
||||
jest.mock('aws-sdk', () => {
|
||||
return {
|
||||
config: {
|
||||
getCredentials: jest.fn(),
|
||||
update: jest.fn(),
|
||||
getCredentials: jest.fn()
|
||||
},
|
||||
STS: jest.fn(() => ({
|
||||
getCallerIdentity: mockStsCallerIdentity,
|
||||
@@ -130,9 +127,6 @@ describe('Configure AWS Credentials', () => {
|
||||
callback(null);
|
||||
});
|
||||
|
||||
aws.config.update.mockReset();
|
||||
aws.config.update.mockImplementationOnce();
|
||||
|
||||
mockStsAssumeRole.mockImplementation(() => {
|
||||
return {
|
||||
promise() {
|
||||
@@ -810,68 +804,4 @@ describe('Configure AWS Credentials', () => {
|
||||
await run();
|
||||
});
|
||||
|
||||
describe('proxy settings', () => {
|
||||
|
||||
test('setting proxy with actions input', async () => {
|
||||
const EXPECTED_PROXY = 'http://test.me'
|
||||
core.getInput = jest
|
||||
.fn()
|
||||
.mockImplementation(
|
||||
mockGetInput({ ...DEFAULT_INPUTS, 'http-proxy': EXPECTED_PROXY })
|
||||
);
|
||||
|
||||
await run();
|
||||
|
||||
expect(aws.config.update).toHaveBeenCalledTimes(1);
|
||||
expect(aws.config.update).toHaveBeenCalledWith({
|
||||
httpOptions: { agent: proxy(EXPECTED_PROXY) }
|
||||
});
|
||||
});
|
||||
test('setting proxy from environment vars', async () => {
|
||||
const EXPECTED_PROXY = 'http://test.me'
|
||||
process.env.HTTP_PROXY = EXPECTED_PROXY;
|
||||
core.getInput = jest
|
||||
.fn()
|
||||
.mockImplementation(
|
||||
mockGetInput({ ...DEFAULT_INPUTS })
|
||||
);
|
||||
|
||||
await run();
|
||||
|
||||
expect(aws.config.update).toHaveBeenCalledTimes(1);
|
||||
expect(aws.config.update).toHaveBeenCalledWith({
|
||||
httpOptions: { agent: proxy(EXPECTED_PROXY) }
|
||||
});
|
||||
});
|
||||
|
||||
test('setting proxy - prefer action input', async () => {
|
||||
const EXPECTED_PROXY = 'http://test.me'
|
||||
const FALSE_PROXY = 'http://env.me'
|
||||
process.env.HTTP_PROXY = FALSE_PROXY;
|
||||
core.getInput = jest
|
||||
.fn()
|
||||
.mockImplementation(
|
||||
mockGetInput({ ...DEFAULT_INPUTS, 'http-proxy': EXPECTED_PROXY })
|
||||
);
|
||||
|
||||
await run();
|
||||
|
||||
expect(aws.config.update).toHaveBeenCalledTimes(1);
|
||||
expect(aws.config.update).toHaveBeenCalledWith({
|
||||
httpOptions: { agent: proxy(EXPECTED_PROXY) }
|
||||
});
|
||||
});
|
||||
|
||||
test('ignoring proxy - without anything set', async () => {
|
||||
core.getInput = jest
|
||||
.fn()
|
||||
.mockImplementation(
|
||||
mockGetInput({ ...DEFAULT_INPUTS})
|
||||
);
|
||||
|
||||
await run();
|
||||
|
||||
expect(aws.config.update).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Generated
+1254
-2493
File diff suppressed because it is too large
Load Diff
+3
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aws-actions-configure-aws-credentials",
|
||||
"version": "2.0.0",
|
||||
"version": "1.7.0",
|
||||
"description": "Configure AWS Credentials",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -26,9 +26,8 @@
|
||||
"homepage": "https://github.com/aws-actions/configure-aws-credentials#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"aws-sdk": "^2.1329.0",
|
||||
"axios": "^1.3.4",
|
||||
"https-proxy-agent": "^5.0.1"
|
||||
"aws-sdk": "^2.1324.0",
|
||||
"axios": "^1.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "^0.36.1",
|
||||
|
||||
Reference in New Issue
Block a user