Skip to content

Commit 2f8dfd0

Browse files
committed
feat: Allow audience to be explicitly specified
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.
1 parent f350a92 commit 2f8dfd0

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ The following table describes which identity is used based on which values are s
9898
- name: Configure AWS Credentials
9999
uses: aws-actions/configure-aws-credentials@v1
100100
with:
101+
audience: sts.amazonaws.com
101102
aws-region: us-east-2
102103
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
103104
role-session-name: MySessionName
@@ -108,6 +109,7 @@ In this example, the Action will load the OIDC token from the GitHub-provided en
108109
- name: Configure AWS Credentials
109110
uses: aws-actions/configure-aws-credentials@v1
110111
with:
112+
audience: sts.amazonaws.com
111113
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
112114
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
113115
aws-region: us-east-2

Diff for: action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ branding:
44
icon: 'cloud'
55
color: 'orange'
66
inputs:
7+
audience:
8+
default: 'sts.amazonaws.com'
9+
description: 'The audience to use for the OIDC provider'
10+
required: false
711
aws-access-key-id:
812
description: >-
913
AWS Access Key ID. This input is required if running in the GitHub hosted environment.

Diff for: index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ async function assumeRole(params) {
1919
const isDefined = i => !!i;
2020

2121
const {
22+
audience,
2223
sourceAccountId,
2324
roleToAssume,
2425
roleExternalId,
@@ -263,6 +264,7 @@ async function run() {
263264
try {
264265
// Get inputs
265266
const accessKeyId = core.getInput('aws-access-key-id', { required: false });
267+
const audience = core.getInput('audience', { required: false });
266268
const secretAccessKey = core.getInput('aws-secret-access-key', { required: false });
267269
const region = core.getInput('aws-region', { required: true });
268270
const sessionToken = core.getInput('aws-session-token', { required: false });
@@ -310,7 +312,7 @@ async function run() {
310312
let sourceAccountId;
311313
let webIdentityToken;
312314
if(useGitHubOIDCProvider()) {
313-
webIdentityToken = await core.getIDToken('sts.amazonaws.com');
315+
webIdentityToken = await core.getIDToken(audience);
314316
roleDurationSeconds = core.getInput('role-duration-seconds', {required: false}) || DEFAULT_ROLE_DURATION_FOR_OIDC_ROLES;
315317
// We don't validate the credentials here because we don't have them yet when using OIDC.
316318
} else {

0 commit comments

Comments
 (0)