Skip to content

Commit

Permalink
feat: Allow audience to be explicitly specified
Browse files Browse the repository at this point in the history
The default audience for the GitHub OIDC uses sts.amazonaws.com, but there are
situations when it would be desirable to allow different audience names to be
used instead. Allow this to be specified as an argument to the action.
  • Loading branch information
alblue committed Mar 24, 2022
1 parent f350a92 commit 2f8dfd0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ The following table describes which identity is used based on which values are s
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
audience: sts.amazonaws.com
aws-region: us-east-2
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
role-session-name: MySessionName
Expand All @@ -108,6 +109,7 @@ In this example, the Action will load the OIDC token from the GitHub-provided en
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
audience: sts.amazonaws.com
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ branding:
icon: 'cloud'
color: 'orange'
inputs:
audience:
default: 'sts.amazonaws.com'
description: 'The audience to use for the OIDC provider'
required: false
aws-access-key-id:
description: >-
AWS Access Key ID. This input is required if running in the GitHub hosted environment.
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ async function assumeRole(params) {
const isDefined = i => !!i;

const {
audience,
sourceAccountId,
roleToAssume,
roleExternalId,
Expand Down Expand Up @@ -263,6 +264,7 @@ async function run() {
try {
// Get inputs
const accessKeyId = core.getInput('aws-access-key-id', { required: false });
const audience = core.getInput('audience', { required: false });
const secretAccessKey = core.getInput('aws-secret-access-key', { required: false });
const region = core.getInput('aws-region', { required: true });
const sessionToken = core.getInput('aws-session-token', { required: false });
Expand Down Expand Up @@ -310,7 +312,7 @@ async function run() {
let sourceAccountId;
let webIdentityToken;
if(useGitHubOIDCProvider()) {
webIdentityToken = await core.getIDToken('sts.amazonaws.com');
webIdentityToken = await core.getIDToken(audience);
roleDurationSeconds = core.getInput('role-duration-seconds', {required: false}) || DEFAULT_ROLE_DURATION_FOR_OIDC_ROLES;
// We don't validate the credentials here because we don't have them yet when using OIDC.
} else {
Expand Down

0 comments on commit 2f8dfd0

Please sign in to comment.