mirror of
https://github.com/aws-actions/configure-aws-credentials.git
synced 2026-08-25 04:35:06 +09:00
Compare commits
95 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e1e17a757e | |||
| bab55d3830 | |||
| 07b737a14f | |||
| 26e4efa71f | |||
| 7e0ecf0346 | |||
| 567d4149d6 | |||
| 32eb1b4a66 | |||
| 6ca2577643 | |||
| f1de076135 | |||
| 077fd1fc8f | |||
| 1416c559c0 | |||
| c3f9f9cde3 | |||
| 1a61b71d4c | |||
| 07d5781915 | |||
| 5ed46d9d6a | |||
| 0d34112acb | |||
| fa45146389 | |||
| a075dc0410 | |||
| 3e21ee4ae7 | |||
| 491cd39cf6 | |||
| 3654529dc6 | |||
| aa5a031041 | |||
| 55443b3d5b | |||
| 48f0cb7848 | |||
| 90d1b38cb5 | |||
| 422c797285 | |||
| 4b942d82b0 | |||
| 7437ed192e | |||
| ed4ba44f95 | |||
| 10dc6d923a | |||
| 956e0a1a39 | |||
| 3f68e499fc | |||
| fc695622db | |||
| 6e4fb66443 | |||
| 6ffa76b6bb | |||
| cb8cd6cf32 | |||
| 27645f79fb | |||
| a54abfbe45 | |||
| c719b7b5e1 | |||
| 0cc6258771 | |||
| 8fb0af0a95 | |||
| 0d6d720d5d | |||
| 260cb07c24 | |||
| 67ebae4d90 | |||
| 2303fbd559 | |||
| 1c8164725c | |||
| 3eb235fc77 | |||
| 604caa0b29 | |||
| 30dd5aee3e | |||
| f4ef658335 | |||
| 6d8fe38ac8 | |||
| e0f275d6a6 | |||
| 85ec61b5fe | |||
| 3179f23dc4 | |||
| 6047a42774 | |||
| aeb090a13a | |||
| 20a08551f4 | |||
| 0ce040565f | |||
| 0ce30af4a2 | |||
| bad8bcf67a | |||
| f468b7f05b | |||
| a7871f486f | |||
| 4600c3d3ab | |||
| 654c85c3bd | |||
| 3771c04929 | |||
| a12c502993 | |||
| 201c28e22a | |||
| e23a123a7b | |||
| 0b60d8cf35 | |||
| 50eedb0bfd | |||
| 298d89ed65 | |||
| bf1b24f227 | |||
| 59e17413a1 | |||
| 5e8f93f56c | |||
| 227293d1f1 | |||
| 02d64821f5 | |||
| eb745fe265 | |||
| 5820660064 | |||
| 5a4b8f03d1 | |||
| 1a8c67f224 | |||
| 4c43463bca | |||
| 1cb4968956 | |||
| 2fd1c82a69 | |||
| b76492e92a | |||
| 26b8f023a5 | |||
| 17bbe90162 | |||
| 8a11b8d838 | |||
| 82d0c78cbe | |||
| fa4d57d969 | |||
| 0d787d7f01 | |||
| 3cca7ed9f3 | |||
| d2f61a0379 | |||
| 499b4f9c35 | |||
| b03c2c7012 | |||
| f9dc1b2393 |
@@ -0,0 +1,61 @@
|
||||
---
|
||||
name: "🐛 Bug Report"
|
||||
description: Report a bug
|
||||
title: "short issue description"
|
||||
labels: [bug, needs-triage]
|
||||
assignees: []
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: What is the problem? A clear and concise description of the bug.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: |
|
||||
What did you expect to happen?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: current
|
||||
attributes:
|
||||
label: Current Behavior
|
||||
description: |
|
||||
What actually happened?
|
||||
|
||||
Please include full errors, uncaught exceptions, stack traces, and relevant logs.
|
||||
If service responses are relevant, please include wire logs.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
attributes:
|
||||
label: Reproduction Steps
|
||||
description: |
|
||||
Provide a self-contained, concise snippet of code that can be used to reproduce the issue.
|
||||
For more complex issues provide a repo with the smallest sample that reproduces the bug.
|
||||
|
||||
Avoid including business logic or unrelated code, it makes diagnosis more difficult.
|
||||
The code sample should be an SSCCE. See http://sscce.org/ for details. In short, please provide a code sample that we can copy/paste, run and reproduce.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Possible Solution
|
||||
description: |
|
||||
Suggest a fix/reason for the bug
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional Information/Context
|
||||
description: |
|
||||
Anything else that might be relevant for troubleshooting this bug. Providing context helps us come up with a solution that is most useful in the real world.
|
||||
validations:
|
||||
required: false
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 💬 General Question
|
||||
url: https://github.com/aws-actions/configure-aws-credentials/discussions/categories/q-a
|
||||
about: Please ask and answer questions as a discussion thread
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
name: "📕 Documentation Issue"
|
||||
description: Report an issue in the README or a suggestion to improve documentation
|
||||
title: "short issue description"
|
||||
labels: [documentation, needs-triage]
|
||||
assignees: []
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe the issue
|
||||
description: A clear and concise description of the issue.
|
||||
validations:
|
||||
required: true
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
name: 🚀 Feature Request
|
||||
description: Suggest an idea for this project
|
||||
title: "short issue description"
|
||||
labels: [feature-request, needs-triage]
|
||||
assignees: []
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe the feature
|
||||
description: A clear and concise description of the feature you are proposing.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: use-case
|
||||
attributes:
|
||||
label: Use Case
|
||||
description: |
|
||||
Why do you need this feature? For example: "I'm always frustrated when..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Proposed Solution
|
||||
description: |
|
||||
Suggest how to implement the addition or change. Please include prototype/workaround/sketch/reference implementation.
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: other
|
||||
attributes:
|
||||
label: Other Information
|
||||
description: |
|
||||
Any alternative solutions or features you considered, a more detailed explanation, stack traces, related issues, links for context, etc.
|
||||
validations:
|
||||
required: false
|
||||
- type: checkboxes
|
||||
id: ack
|
||||
attributes:
|
||||
label: Acknowledgements
|
||||
options:
|
||||
- label: I may be able to implement this feature request
|
||||
required: false
|
||||
- label: This feature might incur a breaking change
|
||||
required: false
|
||||
@@ -2,5 +2,8 @@
|
||||
|
||||
*Description of changes:*
|
||||
|
||||
---
|
||||
|
||||
* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws-actions/configure-aws-credentials/blob/master/CONTRIBUTING.md)
|
||||
|
||||
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
|
||||
|
||||
@@ -6,3 +6,4 @@ updates:
|
||||
interval: weekly
|
||||
day: tuesday
|
||||
open-pull-requests-limit: 10
|
||||
target-branch: 'master'
|
||||
|
||||
@@ -9,7 +9,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Run tests
|
||||
run: |
|
||||
npm ci
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
name: "Close Stale Issues"
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 */4 * * *"
|
||||
|
||||
jobs:
|
||||
cleanup:
|
||||
permissions:
|
||||
issues: write
|
||||
contents: read
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
name: Stale issue job
|
||||
steps:
|
||||
- uses: aws-actions/stale-issue-cleanup@v5
|
||||
with:
|
||||
# Setting messages to an empty string will cause the automation to skip
|
||||
# that category
|
||||
ancient-issue-message: This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
|
||||
stale-issue-message: This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
|
||||
stale-pr-message: This PR has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
|
||||
|
||||
# These labels are required
|
||||
stale-issue-label: closing-soon
|
||||
exempt-issue-labels: no-autoclose
|
||||
stale-pr-label: closing-soon
|
||||
exempt-pr-labels: no-autoclose
|
||||
response-requested-label: response-requested
|
||||
|
||||
# Don't set closed-for-staleness label to skip closing very old issues
|
||||
# regardless of label
|
||||
closed-for-staleness-label: closed-for-staleness
|
||||
|
||||
# Issue timing
|
||||
days-before-stale: 5
|
||||
days-before-close: 2
|
||||
days-before-ancient: 365
|
||||
|
||||
# If you don't want to mark a issue as being ancient based on a
|
||||
# threshold of "upvotes", you can set this here. An "upvote" is
|
||||
# the total number of +1, heart, hooray, and rocket reactions
|
||||
# on an issue.
|
||||
minimum-upvotes-to-exempt: 5
|
||||
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
loglevel: DEBUG
|
||||
# Set dry-run to true to not perform label or close actions.
|
||||
dry-run: false
|
||||
@@ -0,0 +1,18 @@
|
||||
name: Closed Issue Message
|
||||
on:
|
||||
issues:
|
||||
types: [closed]
|
||||
jobs:
|
||||
auto_comment:
|
||||
permissions:
|
||||
issues: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: aws-actions/closed-issue-message@v1
|
||||
with:
|
||||
# These inputs are both required
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
message: |
|
||||
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.
|
||||
@@ -1,71 +0,0 @@
|
||||
# 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
|
||||
@@ -1,27 +1,50 @@
|
||||
name: Update dist files on
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
name: Package
|
||||
paths-ignore:
|
||||
- 'dist/**'
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Package distribution file
|
||||
package:
|
||||
name: Package dist files
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: master
|
||||
- name: Package
|
||||
run: |
|
||||
npm ci
|
||||
npm test
|
||||
npm run package
|
||||
- name: Commit
|
||||
run: |
|
||||
git config --global user.name "GitHub Actions"
|
||||
git add dist/
|
||||
git commit -m "chore: Update dist" || echo "No changes to commit"
|
||||
git push origin HEAD:master
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.ref_name }}
|
||||
persist-credentials: false
|
||||
- name: Package
|
||||
run: |
|
||||
npm ci
|
||||
npm test
|
||||
npm run package
|
||||
- name: Configure AWS credentials
|
||||
uses: aws-actions/configure-aws-credentials@v2
|
||||
with:
|
||||
aws-region: us-west-2
|
||||
role-to-assume: ${{ secrets.SECRETS_AWS_ROLE_TO_ASSUME }}
|
||||
role-duration-seconds: 900
|
||||
role-session-name: SecretsManagerFetch
|
||||
- name: Get bot user token
|
||||
uses: aws-actions/aws-secretsmanager-get-secrets@v1
|
||||
with:
|
||||
parse-json-secrets: true
|
||||
secret-ids: |
|
||||
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 }}"
|
||||
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 add dist
|
||||
git commit -m "chore: Update dist" || echo "No changes to commit"
|
||||
git push origin
|
||||
|
||||
+1
-5
@@ -3,17 +3,14 @@ queue_rules:
|
||||
conditions:
|
||||
# Conditions to get out of the queue (= merged)
|
||||
- status-success=Run Unit Tests
|
||||
- status-success=Semantic Pull Request
|
||||
|
||||
pull_request_rules:
|
||||
- name: Automatically merge on CI success and review approval
|
||||
conditions:
|
||||
- base~=master|integ-tests
|
||||
- "#approved-reviews-by>=1"
|
||||
- approved-reviews-by=@aws-actions/aws-ecs-devx
|
||||
- -approved-reviews-by~=author
|
||||
- status-success=Run Unit Tests
|
||||
- status-success=Semantic Pull Request
|
||||
- label!=work-in-progress
|
||||
- -title~=(WIP|wip)
|
||||
- -merged
|
||||
@@ -26,10 +23,9 @@ pull_request_rules:
|
||||
|
||||
- name: Automatically approve and merge Dependabot PRs
|
||||
conditions:
|
||||
- base=master
|
||||
- base~=master
|
||||
- author=dependabot[bot]
|
||||
- status-success=Run Unit Tests
|
||||
- status-success=Semantic Pull Request
|
||||
- -title~=(WIP|wip)
|
||||
- -label~=(blocked|do-not-merge)
|
||||
- -merged
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
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,36 +1,60 @@
|
||||
## "Configure AWS Credentials" Action For GitHub Actions
|
||||
## 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 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.
|
||||
### 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.
|
||||
|
||||
**Table of Contents**
|
||||
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.
|
||||
|
||||
### 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.
|
||||
|
||||
Add the following step to your workflow:
|
||||
To to that, you would add the following step to your workflow:
|
||||
|
||||
```yaml
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
uses: aws-actions/configure-aws-credentials@v2
|
||||
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).
|
||||
|
||||
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.
|
||||
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:
|
||||
@@ -43,61 +67,73 @@ jobs:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
uses: actions/checkout@v3
|
||||
- name: Configure AWS credentials from Test account
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
uses: aws-actions/configure-aws-credentials@v2
|
||||
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
|
||||
We recommend using GitHub's OIDC provider 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 default session duration is 1 hour when using the OIDC provider to directly assume an IAM Role.
|
||||
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`) .
|
||||
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.
|
||||
|
||||
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 | | ✔ | ✔ |
|
||||
|
||||
### 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`) .
|
||||
|
||||
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@v1
|
||||
uses: aws-actions/configure-aws-credentials@v2
|
||||
with:
|
||||
aws-region: us-east-2
|
||||
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
|
||||
@@ -105,9 +141,10 @@ The following table describes which identity is used based on which values are s
|
||||
```
|
||||
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@v1
|
||||
uses: aws-actions/configure-aws-credentials@v2
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
@@ -119,6 +156,7 @@ 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
|
||||
@@ -132,7 +170,27 @@ 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).
|
||||
|
||||
### Sample IAM Role CloudFormation Template
|
||||
#### 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.
|
||||
```yaml
|
||||
Parameters:
|
||||
GitHubOrg:
|
||||
@@ -143,6 +201,10 @@ 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
|
||||
@@ -163,6 +225,8 @@ Resources:
|
||||
- !Ref GithubOidc
|
||||
- !Ref OIDCProviderArn
|
||||
Condition:
|
||||
StringEquals:
|
||||
token.actions.githubusercontent.com:aud: !Ref OIDCAudience
|
||||
StringLike:
|
||||
token.actions.githubusercontent.com:sub: !Sub repo:${GitHubOrg}/${RepositoryName}:*
|
||||
|
||||
@@ -181,29 +245,52 @@ Outputs:
|
||||
Value: !GetAtt Role.Arn
|
||||
```
|
||||
|
||||
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 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.
|
||||
|
||||
For further information on OIDC and GitHub Actions, please see:
|
||||
|
||||
* [AWS docs: Creating OpenID Connect (OIDC) identity providers](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html)
|
||||
* [AWS docs: IAM JSON policy elements: Condition](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html)
|
||||
* [GitHub docs: About security hardening with OpenID Connect](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
||||
* [GitHub docs: Configuring OpenID Connect in Amazon Web Services](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services)
|
||||
* [GitHub changelog: GitHub Actions: Secure cloud deployments with OpenID Connect](https://github.blog/changelog/2021-10-27-github-actions-secure-cloud-deployments-with-openid-connect/)
|
||||
|
||||
### 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:
|
||||
@@ -212,48 +299,81 @@ You can skip this session tagging by providing `role-skip-session-tagging` as tr
|
||||
|
||||
## 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.
|
||||
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 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:
|
||||
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:
|
||||
```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.
|
||||
|
||||
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
|
||||
Proxy configured in the environment variable:
|
||||
```bash
|
||||
# Your environment configuration
|
||||
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 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).
|
||||
|
||||
+6
-3
@@ -1,4 +1,4 @@
|
||||
name: '"Configure AWS Credentials" Action For GitHub Actions'
|
||||
name: 'Configure AWS Credentials For GitHub Actions'
|
||||
description: 'Configure AWS credential and region environment variables for use with the AWS CLI and AWS SDKs'
|
||||
branding:
|
||||
icon: 'cloud'
|
||||
@@ -44,7 +44,7 @@ inputs:
|
||||
assume an IAM role using a web identity. E.g., from within an Amazon EKS worker node
|
||||
required: false
|
||||
role-duration-seconds:
|
||||
description: "Role duration in seconds (default: 6 hours)"
|
||||
description: "Role duration in seconds (default: 6 hours, 1 hour for OIDC/specified aws-session-token)"
|
||||
required: false
|
||||
role-session-name:
|
||||
description: 'Role session name (default: GitHubActions)'
|
||||
@@ -55,10 +55,13 @@ 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'
|
||||
runs:
|
||||
using: 'node12'
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
post: 'dist/cleanup/index.js'
|
||||
|
||||
Vendored
+2494
-1345
File diff suppressed because it is too large
Load Diff
Vendored
+40438
-33903
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
|
||||
# Examples
|
||||
|
||||
## [federated-setup](./federated-setup/README.md)
|
||||
|
||||
The directory contains templates for setting up the `configure-aws-credentials` federation between your GitHub Organization/repository and your AWS account.
|
||||
|
||||
## [cfn-deploy-example](./cfn-deploy-example/README.md)
|
||||
|
||||
Repository example uses aws-action `configure-aws-credentials` with OIDC federation template [github-actions-oidc-federation-and-role](./github-actions-oidc-federation-and-role.yml). Example demonstrates a repository that deploys AWS CloudFormation template using cfn-deploy GitHub Action.
|
||||
@@ -0,0 +1,15 @@
|
||||
name: 'compliance'
|
||||
## run ci testing on all push events
|
||||
on: [push]
|
||||
jobs:
|
||||
## Guard rule set
|
||||
sast-guard:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: grolston/guard-action@main
|
||||
with:
|
||||
data_directory: './cloudformation/' ## change to your template directory
|
||||
rule_set: 'FedRAMP-Moderate'
|
||||
show_summary: 'all'
|
||||
output_format: 'single-line-summary'
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: deploy
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
env:
|
||||
AWS_DEFAULT_REGION: us-east-1
|
||||
AWS_DEFAULT_OUTPUT: json
|
||||
|
||||
jobs:
|
||||
deploy-cfn:
|
||||
name: deploy
|
||||
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
|
||||
uses: aws-actions/configure-aws-credentials@v1-node16
|
||||
with:
|
||||
aws-region: us-east-1
|
||||
## the following creates an ARN based on the values entered into github secrets
|
||||
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
|
||||
with:
|
||||
name: myEC2bastion
|
||||
## change to path to template in your github repo
|
||||
template: cloudformation/ec2-bastion.yml
|
||||
capabilities: CAPABILITY_IAM, CAPABILITY_NAMED_IAM
|
||||
no-fail-on-empty-changeset: "1"
|
||||
## parameter set in github secrets
|
||||
parameter-overrides: "pVpc=${{ secrets.VPC_ID }},pSubnet=${{ secrets.SUBNET_ID }}"
|
||||
@@ -0,0 +1,14 @@
|
||||
# cfn-deploy example
|
||||
|
||||
Example uses aws-action `configure-aws-credentials` with OIDC federation. Prior to using this example project, the user needs to deploy the [github-actions-oidc-federation-and-role](../federated-setup/github-actions-oidc-federation-and-role.yml) template in the AWS account they want to deploy the CloudFormation template into. Specify the GitHub Organization name, repository name, and the specific branch you want to deploy on.
|
||||
|
||||
Within the [github/workflows](./.github/workflows/) directory there is a [compliance.yml](./.github/workflows/compliance.yml) and a [deploy.yml](./.github/workflows/deploy.yml). The deploy.yml file leverages the aws-action `configure-aws-credentials` and accesses GitHub Action Secrets for some of the variables. The compliance.yml runs static application security testing using cfn-guard.
|
||||
|
||||
To use the example you will need to set the following GitHub Action Secrets:
|
||||
|
||||
| Secret Key | Used With | Description |
|
||||
| --------- | -------- | -----------|
|
||||
| AWS_ACCOUNT_ID | configure-aws-credentials | The AWS account ID |
|
||||
| AWS_DEPLOY_ROLE | configure-aws-credentials | The name of the IAM role |
|
||||
| VPC_ID | aws-cloudformation-github-deploy | VPC ID the EC2 Bastion is deployed to |
|
||||
| SUBNET_ID | aws-cloudformation-github-deploy | Subnet ID the EC2 Bastion is deployed to |
|
||||
@@ -0,0 +1,150 @@
|
||||
---
|
||||
AWSTemplateFormatVersion: "2010-09-09"
|
||||
Description: EC2 bastion for latest AWS Linux 2 EC2 deployment
|
||||
Metadata:
|
||||
AWS::CloudFormation::Interface:
|
||||
ParameterGroups:
|
||||
- Label:
|
||||
default: "EC2 Configuration"
|
||||
Parameters:
|
||||
- pTagNameValue
|
||||
- pOperatingSystem
|
||||
- pInstanceType
|
||||
- pVolumeSize
|
||||
- pEbsDeleteOnTermination
|
||||
- Label:
|
||||
default: "Network Configuration"
|
||||
Parameters:
|
||||
- pVpc
|
||||
- pSubnet
|
||||
ParameterLabels:
|
||||
pOperatingSystem:
|
||||
default: "Operating System"
|
||||
pInstanceType:
|
||||
default: "Instance Type"
|
||||
pTagNameValue:
|
||||
default: "EC2 Name"
|
||||
pVolumeSize:
|
||||
default: "Volume Size"
|
||||
pEbsDeleteOnTermination:
|
||||
default: "Delete EBS Volume on Termination"
|
||||
pSubnet:
|
||||
default: "Subnet"
|
||||
pVpc:
|
||||
default: "VPC"
|
||||
Parameters:
|
||||
pSubnet:
|
||||
Description: The subnet to launch the instance in to. It must be part of the VPC chosen above.
|
||||
Type: AWS::EC2::Subnet::Id
|
||||
pVpc:
|
||||
Description: The VPC to launch the EC2 instance in to.
|
||||
Type: AWS::EC2::VPC::Id
|
||||
pOperatingSystem:
|
||||
Type: "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>"
|
||||
Default: "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs"
|
||||
pInstanceType:
|
||||
Description: Desired Instance Size
|
||||
Type: String
|
||||
Default: t3.small
|
||||
AllowedValues:
|
||||
- t3.small
|
||||
- t3.medium
|
||||
- t3.nano
|
||||
pTagNameValue:
|
||||
Description: "Required: Enter the tag name you'd like applied to the instance. Tag Name gives the name to the EC2 instance."
|
||||
Type: String
|
||||
MinLength: 1
|
||||
Default: "myBastion"
|
||||
pVolumeSize:
|
||||
Description:
|
||||
Enter the number of GBs you want your volume to be. The minimum value
|
||||
is 8 GBs
|
||||
Type: Number
|
||||
Default: 50
|
||||
MinValue: 8
|
||||
pEbsDeleteOnTermination:
|
||||
Description: "Specify if the EBS volume should be deleted if EC2 is deleted."
|
||||
Type: String
|
||||
Default: true
|
||||
AllowedValues:
|
||||
- true
|
||||
- false
|
||||
Rules:
|
||||
SubnetInVPC:
|
||||
Assertions:
|
||||
- Assert: !EachMemberIn
|
||||
- !ValueOfAll
|
||||
- AWS::EC2::Subnet::Id
|
||||
- VpcId
|
||||
- !RefAll "AWS::EC2::VPC::Id"
|
||||
AssertDescription: All subnets must in the VPC
|
||||
Resources:
|
||||
rSecurityGroupDefault:
|
||||
Type: AWS::EC2::SecurityGroup
|
||||
Properties:
|
||||
GroupDescription: !Sub "Default SG for SC Product ${pTagNameValue} "
|
||||
VpcId: !Ref pVpc
|
||||
SecurityGroupEgress:
|
||||
- Description: Outbound unrestricted traffic
|
||||
IpProtocol: "-1"
|
||||
CidrIp: 0.0.0.0/0
|
||||
Tags:
|
||||
- Key: Name
|
||||
Value: !Ref pTagNameValue
|
||||
rLinuxEc2:
|
||||
Type: AWS::EC2::Instance
|
||||
Metadata:
|
||||
guard:
|
||||
SuppressedRules:
|
||||
- 'EC2_INSTANCE_DETAILED_MONITORING_ENABLED'
|
||||
Properties:
|
||||
ImageId: !Ref pOperatingSystem
|
||||
IamInstanceProfile: !Ref rec2InstanceProfile
|
||||
Monitoring: false
|
||||
InstanceType: !Ref pInstanceType
|
||||
EbsOptimized: true
|
||||
SourceDestCheck: true
|
||||
SubnetId: !Ref pSubnet
|
||||
SecurityGroupIds:
|
||||
- !Ref rSecurityGroupDefault
|
||||
BlockDeviceMappings:
|
||||
- DeviceName: "/dev/xvda"
|
||||
Ebs:
|
||||
VolumeSize: !Ref pVolumeSize
|
||||
DeleteOnTermination: !Ref pEbsDeleteOnTermination
|
||||
Tags:
|
||||
- Key: Name
|
||||
Value: !Ref pTagNameValue
|
||||
UserData:
|
||||
Fn::Base64:
|
||||
yum update -y
|
||||
## Instance Profiles
|
||||
## EC2 IAM Roles
|
||||
rEc2Role:
|
||||
Type: AWS::IAM::Role
|
||||
Properties:
|
||||
RoleName: !Sub "ec2-role-${AWS::StackName}"
|
||||
AssumeRolePolicyDocument:
|
||||
Statement:
|
||||
- Effect: Allow
|
||||
Principal:
|
||||
Service: [ec2.amazonaws.com]
|
||||
Action: ['sts:AssumeRole']
|
||||
Path: /
|
||||
ManagedPolicyArns:
|
||||
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/AmazonSSMManagedInstanceCore'
|
||||
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/CloudWatchAgentServerPolicy'
|
||||
rec2InstanceProfile:
|
||||
Type: AWS::IAM::InstanceProfile
|
||||
Properties:
|
||||
InstanceProfileName: !Sub "ec2-profile-${AWS::StackName}"
|
||||
Path: /
|
||||
Roles:
|
||||
- !Ref rEc2Role
|
||||
Outputs:
|
||||
oLinuxEc2InstanceId:
|
||||
Description: Resource ID of the newly created EC2 instance
|
||||
Value: !Ref rLinuxEc2
|
||||
oLinuxEc2PrivateIP:
|
||||
Description: Private IP Address for EC2
|
||||
Value: !GetAtt rLinuxEc2.PrivateIp
|
||||
@@ -0,0 +1,9 @@
|
||||
# federated-setup
|
||||
|
||||
## [github-action-oidc-federation](./github-actions-odic-federation.yml)
|
||||
|
||||
Setup of the OIDC federation between your GitHub Organization/repository and your AWS account.
|
||||
|
||||
## [github-actions-oidc-federation-and-role](./github-actions-oidc-federation-and-role.yml)
|
||||
|
||||
Setup of the OIDC federation between your GitHub Organization/repository and your AWS account along with a role that only executes on specific branch.
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
AWSTemplateFormatVersion: "2010-09-09"
|
||||
Description: Github Actions configuration - OIDC IAM IdP Federation
|
||||
|
||||
Parameters:
|
||||
|
||||
GitHubOrganization:
|
||||
Type: String
|
||||
Description: This is the root organization or personal account where repos are stored (Case Sensitive)
|
||||
Default: ""
|
||||
|
||||
RepositoryName:
|
||||
Type: String
|
||||
Description: The repo(s) these roles will have access to. (Use * for all org or personal repos)
|
||||
Default: "*"
|
||||
|
||||
RoleName:
|
||||
Type: String
|
||||
Description: Name the Role
|
||||
Default: ""
|
||||
|
||||
|
||||
Resources:
|
||||
|
||||
IdpGitHubOidc:
|
||||
Type: AWS::IAM::OIDCProvider
|
||||
Properties:
|
||||
Url: https://token.actions.githubusercontent.com
|
||||
ClientIdList:
|
||||
- sts.amazonaws.com
|
||||
- !Sub https://github.com/${GitHubOrganization}/${RepositoryName}
|
||||
ThumbprintList:
|
||||
- 6938fd4d98bab03faadb97b34396831e3780aea1
|
||||
Tags:
|
||||
- Key: Name
|
||||
Value: !Sub ${RoleName}-OIDC-Provider
|
||||
|
||||
|
||||
Outputs:
|
||||
|
||||
IdpGitHubOidc:
|
||||
Description: "ARN of Github OIDC Provider"
|
||||
Value: !GetAtt IdpGitHubOidc.Arn
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
AWSTemplateFormatVersion: "2010-09-09"
|
||||
Description: Github Actions configuration - OIDC IAM IdP and associated role CI/CD
|
||||
|
||||
Parameters:
|
||||
|
||||
GitHubOrganization:
|
||||
Type: String
|
||||
Description: This is the root organization or personal account where repos are stored (Case Sensitive)
|
||||
|
||||
RepositoryName:
|
||||
Type: String
|
||||
Description: The repo(s) these roles will have access to. (Use * for all org or personal repos)
|
||||
Default: "*"
|
||||
|
||||
BranchName:
|
||||
Type: String
|
||||
Description: Name of the git branch to to trust. (Use * for all branches)
|
||||
Default: "*"
|
||||
|
||||
RoleName:
|
||||
Type: String
|
||||
Description: Name the Role
|
||||
|
||||
UseExistingProvider:
|
||||
Type: String
|
||||
Description: "Only one GitHub Provider can exists. Choose yes if one is already present in account"
|
||||
Default: "no"
|
||||
AllowedValues:
|
||||
- "yes"
|
||||
- "no"
|
||||
|
||||
Conditions:
|
||||
|
||||
CreateProvider: !Equals ["no", !Ref UseExistingProvider]
|
||||
|
||||
Resources:
|
||||
|
||||
IdpGitHubOidc:
|
||||
Type: AWS::IAM::OIDCProvider
|
||||
Condition: CreateProvider
|
||||
Properties:
|
||||
Url: https://token.actions.githubusercontent.com
|
||||
ClientIdList:
|
||||
- sts.amazonaws.com
|
||||
- !Sub https://github.com/${GitHubOrganization}/${RepositoryName}
|
||||
ThumbprintList:
|
||||
- 6938fd4d98bab03faadb97b34396831e3780aea1
|
||||
Tags:
|
||||
- Key: Name
|
||||
Value: !Sub ${RoleName}-OIDC-Provider
|
||||
|
||||
RoleGithubActions:
|
||||
Type: AWS::IAM::Role
|
||||
Properties:
|
||||
RoleName: !Ref RoleName
|
||||
AssumeRolePolicyDocument:
|
||||
Statement:
|
||||
- Effect: Allow
|
||||
Action: sts:AssumeRoleWithWebIdentity
|
||||
Principal:
|
||||
Federated: !If
|
||||
- CreateProvider
|
||||
- !Ref IdpGitHubOidc
|
||||
- !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:oidc-provider/token.actions.githubusercontent.com
|
||||
Condition:
|
||||
StringLike:
|
||||
token.actions.githubusercontent.com:sub: !Sub repo:${GitHubOrganization}/${RepositoryName}:ref:refs/heads/${BranchName}
|
||||
ManagedPolicyArns:
|
||||
## edit the managed policy to give least privileges
|
||||
- !Sub arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess
|
||||
|
||||
Outputs:
|
||||
|
||||
IdpGitHubOidc:
|
||||
Condition: CreateProvider
|
||||
Description: "ARN of Github OIDC Provider"
|
||||
Value: !GetAtt IdpGitHubOidc.Arn
|
||||
|
||||
RoleGithubActionsARN:
|
||||
Description: "CICD Role for GitHub Actions"
|
||||
Value: !GetAtt RoleGithubActions.Arn
|
||||
@@ -3,10 +3,12 @@ const aws = require('aws-sdk');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const proxy = require('https-proxy-agent');
|
||||
|
||||
// The max time that a GitHub action is allowed to run is 6 hours.
|
||||
// That seems like a reasonable default to use if no role duration is defined.
|
||||
// Use 1hr as role duration when using session token or OIDC
|
||||
// Otherwise, use the max duration of GitHub action (6hr)
|
||||
const MAX_ACTION_RUNTIME = 6 * 3600;
|
||||
const SESSION_ROLE_DURATION = 3600;
|
||||
const DEFAULT_ROLE_DURATION_FOR_OIDC_ROLES = 3600;
|
||||
const USER_AGENT = 'configure-aws-credentials-for-github-actions';
|
||||
const MAX_TAG_VALUE_LENGTH = 256;
|
||||
@@ -85,7 +87,7 @@ async function assumeRole(params) {
|
||||
}
|
||||
|
||||
let assumeFunction = sts.assumeRole.bind(sts);
|
||||
|
||||
|
||||
// These are customizations needed for the GH OIDC Provider
|
||||
if(isDefined(webIdentityToken)) {
|
||||
delete assumeRoleRequest.Tags;
|
||||
@@ -110,8 +112,8 @@ async function assumeRole(params) {
|
||||
} catch(error) {
|
||||
throw new Error(`Web identity token file could not be read: ${error.message}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return assumeFunction(assumeRoleRequest)
|
||||
.promise()
|
||||
@@ -259,6 +261,26 @@ 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
|
||||
@@ -270,11 +292,14 @@ async function run() {
|
||||
const maskAccountId = core.getInput('mask-aws-account-id', { required: false });
|
||||
const roleToAssume = core.getInput('role-to-assume', {required: false});
|
||||
const roleExternalId = core.getInput('role-external-id', { required: false });
|
||||
let roleDurationSeconds = core.getInput('role-duration-seconds', {required: false}) || MAX_ACTION_RUNTIME;
|
||||
let roleDurationSeconds = core.getInput('role-duration-seconds', {required: false})
|
||||
|| (sessionToken && SESSION_ROLE_DURATION)
|
||||
|| MAX_ACTION_RUNTIME;
|
||||
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 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}`);
|
||||
@@ -305,6 +330,9 @@ 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
|
||||
// The only way to assume the role is via GitHub's OIDC provider.
|
||||
|
||||
+116
-5
@@ -2,6 +2,7 @@ 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');
|
||||
|
||||
@@ -33,6 +34,7 @@ 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
|
||||
@@ -52,7 +54,8 @@ const mockStsAssumeRoleWithWebIdentity = jest.fn();
|
||||
jest.mock('aws-sdk', () => {
|
||||
return {
|
||||
config: {
|
||||
getCredentials: jest.fn()
|
||||
getCredentials: jest.fn(),
|
||||
update: jest.fn(),
|
||||
},
|
||||
STS: jest.fn(() => ({
|
||||
getCallerIdentity: mockStsCallerIdentity,
|
||||
@@ -77,11 +80,9 @@ jest.mock('axios', () => ({
|
||||
}));
|
||||
|
||||
describe('Configure AWS Credentials', () => {
|
||||
const OLD_ENV = process.env;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
process.env = {...OLD_ENV, ...ENVIRONMENT_VARIABLE_OVERRIDES};
|
||||
process.env = { ...ENVIRONMENT_VARIABLE_OVERRIDES };
|
||||
|
||||
jest.clearAllMocks();
|
||||
|
||||
@@ -129,6 +130,9 @@ describe('Configure AWS Credentials', () => {
|
||||
callback(null);
|
||||
});
|
||||
|
||||
aws.config.update.mockReset();
|
||||
aws.config.update.mockImplementationOnce();
|
||||
|
||||
mockStsAssumeRole.mockImplementation(() => {
|
||||
return {
|
||||
promise() {
|
||||
@@ -163,7 +167,6 @@ describe('Configure AWS Credentials', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.env = OLD_ENV;
|
||||
reset();
|
||||
});
|
||||
|
||||
@@ -527,6 +530,50 @@ describe('Configure AWS Credentials', () => {
|
||||
})
|
||||
});
|
||||
|
||||
test('sets durationSeconds to one hour when session token provided and no duration is provided', async () => {
|
||||
core.getInput = jest
|
||||
.fn()
|
||||
.mockImplementation(mockGetInput({...ASSUME_ROLE_INPUTS, 'aws-session-token': FAKE_SESSION_TOKEN}));
|
||||
|
||||
await run();
|
||||
expect(mockStsAssumeRole).toHaveBeenCalledWith({
|
||||
RoleArn: ROLE_ARN,
|
||||
RoleSessionName: 'GitHubActions',
|
||||
DurationSeconds: 3600,
|
||||
Tags: [
|
||||
{Key: 'GitHub', Value: 'Actions'},
|
||||
{Key: 'Repository', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_REPOSITORY},
|
||||
{Key: 'Workflow', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_WORKFLOW},
|
||||
{Key: 'Action', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_ACTION},
|
||||
{Key: 'Actor', Value: GITHUB_ACTOR_SANITIZED},
|
||||
{Key: 'Commit', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_SHA},
|
||||
{Key: 'Branch', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_REF},
|
||||
]
|
||||
})
|
||||
});
|
||||
|
||||
test('sets durationSeconds to one 6 hours no session token or duration is provided', async () => {
|
||||
core.getInput = jest
|
||||
.fn()
|
||||
.mockImplementation(mockGetInput({...ASSUME_ROLE_INPUTS}));
|
||||
|
||||
await run();
|
||||
expect(mockStsAssumeRole).toHaveBeenCalledWith({
|
||||
RoleArn: ROLE_ARN,
|
||||
RoleSessionName: 'GitHubActions',
|
||||
DurationSeconds: 6 * 3600,
|
||||
Tags: [
|
||||
{Key: 'GitHub', Value: 'Actions'},
|
||||
{Key: 'Repository', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_REPOSITORY},
|
||||
{Key: 'Workflow', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_WORKFLOW},
|
||||
{Key: 'Action', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_ACTION},
|
||||
{Key: 'Actor', Value: GITHUB_ACTOR_SANITIZED},
|
||||
{Key: 'Commit', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_SHA},
|
||||
{Key: 'Branch', Value: ENVIRONMENT_VARIABLE_OVERRIDES.GITHUB_REF},
|
||||
]
|
||||
})
|
||||
});
|
||||
|
||||
test('role name provided instead of ARN', async () => {
|
||||
core.getInput = jest
|
||||
.fn()
|
||||
@@ -763,4 +810,68 @@ 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
+3676
-2657
File diff suppressed because it is too large
Load Diff
+8
-7
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aws-actions-configure-aws-credentials",
|
||||
"version": "1.7.0",
|
||||
"version": "2.0.0",
|
||||
"description": "Configure AWS Credentials",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -25,13 +25,14 @@
|
||||
},
|
||||
"homepage": "https://github.com/aws-actions/configure-aws-credentials#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.6.0",
|
||||
"aws-sdk": "^2.1112.0",
|
||||
"axios": "^0.26.1"
|
||||
"@actions/core": "^1.10.0",
|
||||
"aws-sdk": "^2.1329.0",
|
||||
"axios": "^1.3.4",
|
||||
"https-proxy-agent": "^5.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"eslint": "^8.13.0",
|
||||
"jest": "^27.5.1"
|
||||
"@vercel/ncc": "^0.36.1",
|
||||
"eslint": "^8.35.0",
|
||||
"jest": "^29.4.3"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user