Skip to content

Commit 77cd089

Browse files
kellertklehmanmj
andauthored
chore: document container credentials provider support (and delete transitive tags in AssumeRoleWithWebIdentity) (#1780)
* chore: document container credentials provider support (and delete transitive tags in AssumeRoleWithWebIdentity) Closes #1546 Closes #942 Documents that eks and codebuild work when using the role-chaining flag. * revert force-skip-oidc changes * README changes for Container Credentials and adding missing input options * linting --------- Co-authored-by: Michael Lehmann <lehmanmj@amazon.com>
1 parent dbacf31 commit 77cd089

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ detail.
168168
| role-session-name | Defaults to "GitHubActions", but may be changed if required. | No |
169169
| role-skip-session-tagging | Skips session tagging if set. | No |
170170
| transitive-tag-keys | Define a list of transitive tag keys to pass when assuming a role. | No |
171+
| custom-tags | Additional tags to apply to the assumed role session. Must be a JSON object provided as a string. Custom tags are not usable with OIDC or web identity token authentication. | No |
171172
| inline-session-policy | You may further restrict the assumed role policy by defining an inline policy here. | No |
172173
| managed-session-policies | You may further restrict the assumed role policy by specifying a managed policy here. | No |
173174
| output-credentials | When set, outputs fetched credentials as action step output. (Outputs aws-access-key-id, aws-secret-access-key, aws-session-token, aws-account-id, authenticated-arn, and aws-expiration). Defaults to false. | No |
@@ -180,6 +181,8 @@ detail.
180181
| allowed-account-ids | A comma-delimited list of expected AWS account IDs. The action will fail if we receive credentials for the wrong account. | No |
181182
| force-skip-oidc | When set, the action will skip using GitHub OIDC provider even if the id-token permission is set. | No |
182183
| action-timeout-s | Global timeout for the action in seconds. If set to a value greater than 0, the action will fail if it takes longer than this time to complete. | No |
184+
| no-proxy | Hosts to skip for the proxy configuration. | No |
185+
| sts-endpoint | Custom STS endpoint URL. Use this to point to an STS-compatible API (e.g. MinIO, LocalStack) instead of the default AWS STS endpoint for the region. | No |
183186

184187
</details>
185188

@@ -617,6 +620,14 @@ For further information on OIDC and GitHub Actions, please see:
617620
- [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)
618621
- [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/)
619622

623+
## Running in AWS Containers
624+
625+
To run this action using self-hosted action runners on AWS Containers such as
626+
Codebuild or EKS, you may need to set `role-chaining: true`.
627+
628+
If you are using EKS and encountering an error related to the packed size of
629+
session tags, set `role-skip-session-tagging: true`.
630+
620631
## Compatibility with non-GitHub Actions environments
621632

622633
This action has been sucessfully tested with

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ inputs:
3434
description: Use the web identity token file from the provided file system path in order to assume an IAM role using a web identity, e.g. from within an Amazon EKS worker node.
3535
required: false
3636
role-chaining:
37-
description: Use existing credentials from the environment to assume a new role, rather than providing credentials as input.
37+
description: Use existing credentials from the environment to assume a new role, rather than providing credentials as input. This is sometimes useful when running on a self-hosted runner with container-sourced credentials.
3838
required: false
3939
audience:
4040
description: The audience to use for the OIDC provider

src/assumeRole.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ async function assumeRoleWithWebIdentityTokenFile(
4242
core.info('Assuming role with web identity token file');
4343
try {
4444
delete params.Tags;
45+
delete params.TransitiveTagKeys;
4546
const creds = await client.send(
4647
new AssumeRoleWithWebIdentityCommand({
4748
...params,

test/index.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ describe('Configure AWS Credentials', {}, () => {
202202
expect(core.setOutput).toHaveBeenCalledTimes(2);
203203
expect(core.setFailed).not.toHaveBeenCalled();
204204
});
205+
it('does not send Tags or TransitiveTagKeys to AssumeRoleWithWebIdentity', async () => {
206+
// AssumeRoleWithWebIdentity reads session tags from JWT claims, not the request.
207+
// Both fields must be stripped before the STS call.
208+
vi.mocked(core.getMultilineInput).mockImplementation((name: string) => {
209+
if (name === 'transitive-tag-keys') return ['Repository'];
210+
return [];
211+
});
212+
await run();
213+
const callInput = mockedSTSClient.commandCalls(AssumeRoleWithWebIdentityCommand)[0].args[0].input;
214+
expect(callInput.Tags).toBeUndefined();
215+
expect(callInput.TransitiveTagKeys).toBeUndefined();
216+
});
205217
});
206218

207219
describe('Assume existing role', {}, () => {

0 commit comments

Comments
 (0)