mirror of
https://github.com/aws-actions/configure-aws-credentials.git
synced 2026-09-03 06:05:04 +09:00
feat: optional policy inputs when assuming role
This commit is contained in:
@@ -52,6 +52,12 @@ inputs:
|
|||||||
web-identity-token-file:
|
web-identity-token-file:
|
||||||
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.
|
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.
|
||||||
required: false
|
required: false
|
||||||
|
inline-session-policy:
|
||||||
|
description: 'Inline session policy'
|
||||||
|
required: false
|
||||||
|
managed-session-policies:
|
||||||
|
description: 'List of managed session policies'
|
||||||
|
required: false
|
||||||
outputs:
|
outputs:
|
||||||
aws-account-id:
|
aws-account-id:
|
||||||
description: The AWS account ID for the provided credentials
|
description: The AWS account ID for the provided credentials
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ export interface assumeRoleParams {
|
|||||||
roleExternalId?: string;
|
roleExternalId?: string;
|
||||||
webIdentityTokenFile?: string;
|
webIdentityTokenFile?: string;
|
||||||
webIdentityToken?: string;
|
webIdentityToken?: string;
|
||||||
|
inlineSessionPolicy?: string;
|
||||||
|
managedSessionPolicies?: any[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function assumeRole(params: assumeRoleParams) {
|
export async function assumeRole(params: assumeRoleParams) {
|
||||||
@@ -84,6 +86,8 @@ export async function assumeRole(params: assumeRoleParams) {
|
|||||||
roleSkipSessionTagging,
|
roleSkipSessionTagging,
|
||||||
webIdentityTokenFile,
|
webIdentityTokenFile,
|
||||||
webIdentityToken,
|
webIdentityToken,
|
||||||
|
inlineSessionPolicy,
|
||||||
|
managedSessionPolicies
|
||||||
} = { ...params };
|
} = { ...params };
|
||||||
|
|
||||||
// Load GitHub environment variables
|
// Load GitHub environment variables
|
||||||
@@ -128,6 +132,8 @@ export async function assumeRole(params: assumeRoleParams) {
|
|||||||
DurationSeconds: roleDuration,
|
DurationSeconds: roleDuration,
|
||||||
Tags: tags ? tags : undefined,
|
Tags: tags ? tags : undefined,
|
||||||
ExternalId: roleExternalId ? roleExternalId : undefined,
|
ExternalId: roleExternalId ? roleExternalId : undefined,
|
||||||
|
Policy: inlineSessionPolicy ? inlineSessionPolicy : undefined,
|
||||||
|
PolicyArns: managedSessionPolicies ? managedSessionPolicies : undefined,
|
||||||
};
|
};
|
||||||
const keys = Object.keys(commonAssumeRoleParams) as Array<keyof typeof commonAssumeRoleParams>;
|
const keys = Object.keys(commonAssumeRoleParams) as Array<keyof typeof commonAssumeRoleParams>;
|
||||||
keys.forEach((k) => commonAssumeRoleParams[k] === undefined && delete commonAssumeRoleParams[k]);
|
keys.forEach((k) => commonAssumeRoleParams[k] === undefined && delete commonAssumeRoleParams[k]);
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ export async function run() {
|
|||||||
const roleSkipSessionTagging = roleSkipSessionTaggingInput.toLowerCase() === 'true';
|
const roleSkipSessionTagging = roleSkipSessionTaggingInput.toLowerCase() === 'true';
|
||||||
const proxyServer = core.getInput('http-proxy', { required: false });
|
const proxyServer = core.getInput('http-proxy', { required: false });
|
||||||
const disableOIDC = core.getInput('disable-oidc', { required: false });
|
const disableOIDC = core.getInput('disable-oidc', { required: false });
|
||||||
|
const inlineSessionPolicy = core.getInput('inline-session-policy', { required: false });
|
||||||
|
const managedSessionPoliciesInput = core.getMultilineInput('managed-session-policies', { required: false })
|
||||||
|
const managedSessionPolicies: any[] = [];
|
||||||
|
for (const managedSessionPolicy of managedSessionPoliciesInput) {
|
||||||
|
managedSessionPolicies.push({arn: managedSessionPolicy})
|
||||||
|
}
|
||||||
|
|
||||||
// Logic to decide whether to attempt to use OIDC or not
|
// Logic to decide whether to attempt to use OIDC or not
|
||||||
const useGitHubOIDCProvider = () => {
|
const useGitHubOIDCProvider = () => {
|
||||||
@@ -110,6 +116,8 @@ export async function run() {
|
|||||||
roleSkipSessionTagging,
|
roleSkipSessionTagging,
|
||||||
webIdentityTokenFile,
|
webIdentityTokenFile,
|
||||||
webIdentityToken,
|
webIdentityToken,
|
||||||
|
inlineSessionPolicy,
|
||||||
|
managedSessionPolicies,
|
||||||
});
|
});
|
||||||
}, true);
|
}, true);
|
||||||
core.info(`Authenticated as assumedRoleId ${roleCredentials.AssumedRoleUser!.AssumedRoleId!}`);
|
core.info(`Authenticated as assumedRoleId ${roleCredentials.AssumedRoleUser!.AssumedRoleId!}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user