Skip to content

Commit bf7f81f

Browse files
Merge pull request #362 from alblue/allow-audience
feat: Allow audience to be explicitly specified
2 parents 8a84b07 + 79fafe3 commit bf7f81f

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ The default session duration is 1 hour when using the OIDC provider to directly
8282
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`) .
8383
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.
8484
The default session name is GitHubActions, and you can modify it by specifying the desired name in `role-session-name`.
85+
The default audience is `sts.amazonaws.com` which you can replace by specifying the desired audience name in `audience`.
8586

8687
The following table describes which identity is used based on which values are supplied to the Action:
8788

@@ -118,6 +119,19 @@ In this example, the Action will load the OIDC token from the GitHub-provided en
118119
```
119120
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`.
120121

122+
```yaml
123+
- name: Configure AWS Credentials for Beta Customers
124+
uses: aws-actions/configure-aws-credentials@v1
125+
with:
126+
audience: beta-customers
127+
aws-region: us-east-3
128+
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
129+
role-session-name: MySessionName
130+
```
131+
In this example, the audience has been changed from the default to use a different audience name `beta-customers`. This can help ensure that the role can only affect those AWS accounts whose GitHub OIDC providers have explicitly opted in to the `beta-customers` label.
132+
133+
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).
134+
121135
### Sample IAM Role CloudFormation Template
122136
```yaml
123137
Parameters:

action.yml

Lines changed: 4 additions & 0 deletions
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.

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ async function run() {
263263
try {
264264
// Get inputs
265265
const accessKeyId = core.getInput('aws-access-key-id', { required: false });
266+
const audience = core.getInput('audience', { required: false });
266267
const secretAccessKey = core.getInput('aws-secret-access-key', { required: false });
267268
const region = core.getInput('aws-region', { required: true });
268269
const sessionToken = core.getInput('aws-session-token', { required: false });
@@ -310,7 +311,7 @@ async function run() {
310311
let sourceAccountId;
311312
let webIdentityToken;
312313
if(useGitHubOIDCProvider()) {
313-
webIdentityToken = await core.getIDToken('sts.amazonaws.com');
314+
webIdentityToken = await core.getIDToken(audience);
314315
roleDurationSeconds = core.getInput('role-duration-seconds', {required: false}) || DEFAULT_ROLE_DURATION_FOR_OIDC_ROLES;
315316
// We don't validate the credentials here because we don't have them yet when using OIDC.
316317
} else {

0 commit comments

Comments
 (0)