feat: updates for transitive tagging

This commit is contained in:
kellertk
2026-01-27 15:56:05 -08:00
parent a9717e6ab0
commit 4f2ba7fe9c
3 changed files with 15 additions and 8 deletions
+7 -5
View File
@@ -218,7 +218,7 @@ run.*
The session will be tagged with the The session will be tagged with the
following tags: (Refer to [GitHub's documentation for `GITHUB_` environment following tags: (Refer to [GitHub's documentation for `GITHUB_` environment
variable definitions](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables)) variable definitions](https://docs.github.com/en/actions/reference/workflows-and-actions/variables#default-environment-variables))
| Key | Value | | Key | Value |
| ---------- | ----------------- | | ---------- | ----------------- |
@@ -238,12 +238,14 @@ will be replaced with an '*'._
The action will use session tagging by default unless you are using OIDC. The action will use session tagging by default unless you are using OIDC.
To forward session tags to subsequent sessions in a role chain, you can use the To [forward session tags to subsequent sessions in a role chain](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_role-chaining),
`transitive-tag-keys` input to specify the keys of the tags to be passed. Eg. you can use the `transitive-tag-keys` input to specify the keys of the tags to be passed.
_Note that all subsequent roles in the chain must have `role-skip-session-tagging` set to `true`_
```yaml ```yaml
uses: aws-actions/configure-aws-credentials@v4 uses: aws-actions/configure-aws-credentials@v5
with: with:
transitive-tag-keys: transitive-tag-keys: |
Repository Repository
Workflow Workflow
Action Action
+7 -3
View File
@@ -9,6 +9,7 @@ import { errorMessage, isDefined, sanitizeGitHubVariables } from './helpers';
async function assumeRoleWithOIDC(params: AssumeRoleCommandInput, client: STSClient, webIdentityToken: string) { async function assumeRoleWithOIDC(params: AssumeRoleCommandInput, client: STSClient, webIdentityToken: string) {
delete params.Tags; delete params.Tags;
delete params.TransitiveTagKeys;
core.info('Assuming role with OIDC'); core.info('Assuming role with OIDC');
try { try {
const creds = await client.send( const creds = await client.send(
@@ -123,7 +124,10 @@ export async function assumeRole(params: assumeRoleParams) {
core.debug(`${tags.length} role session tags are being used.`); core.debug(`${tags.length} role session tags are being used.`);
} }
const transitiveTagKeysArray = transitiveTagKeys?.filter((key) => tags?.some((tag) => tag.Key === key)); //only populate transitiveTagKeys array if user is actually using session tagging
const transitiveTagKeysArray = roleSkipSessionTagging
? undefined
: transitiveTagKeys?.filter((key) => tags?.some((tag) => tag.Key === key));
// Calculate role ARN from name and account ID (currently only supports `aws` partition) // Calculate role ARN from name and account ID (currently only supports `aws` partition)
let roleArn = roleToAssume; let roleArn = roleToAssume;
@@ -141,7 +145,7 @@ export async function assumeRole(params: assumeRoleParams) {
RoleSessionName: roleSessionName, RoleSessionName: roleSessionName,
DurationSeconds: roleDuration, DurationSeconds: roleDuration,
Tags: tags ? tags : undefined, Tags: tags ? tags : undefined,
TransitiveTagKeys: transitiveTagKeysArray, TransitiveTagKeys: transitiveTagKeysArray ? transitiveTagKeysArray : undefined,
ExternalId: roleExternalId ? roleExternalId : undefined, ExternalId: roleExternalId ? roleExternalId : undefined,
Policy: inlineSessionPolicy ? inlineSessionPolicy : undefined, Policy: inlineSessionPolicy ? inlineSessionPolicy : undefined,
PolicyArns: managedSessionPolicies?.length ? managedSessionPolicies : undefined, PolicyArns: managedSessionPolicies?.length ? managedSessionPolicies : undefined,
@@ -169,4 +173,4 @@ export async function assumeRole(params: assumeRoleParams) {
); );
} }
return assumeRoleWithCredentials(commonAssumeRoleParams, stsClient); return assumeRoleWithCredentials(commonAssumeRoleParams, stsClient);
} }
+1
View File
@@ -20,6 +20,7 @@ export function translateEnvVariables() {
'ROLE_EXTERNAL_ID', 'ROLE_EXTERNAL_ID',
'ROLE_SESSION_NAME', 'ROLE_SESSION_NAME',
'ROLE_SKIP_SESSION_TAGGING', 'ROLE_SKIP_SESSION_TAGGING',
'TRANSITIVE_TAG_KEYS',
'INLINE_SESSION_POLICY', 'INLINE_SESSION_POLICY',
'MANAGED_SESSION_POLICIES', 'MANAGED_SESSION_POLICIES',
'OUTPUT_CREDENTIALS', 'OUTPUT_CREDENTIALS',