feat: Recommending using OIDC (#871)

* Recommending using OIDC

* Added tests

* fix test and package

* update readme

---------

Co-authored-by: peterwoodworth <woodwoop@amazon.com>
This commit is contained in:
Justin Plock
2023-09-29 17:05:32 -04:00
committed by GitHub
parent 164817a8f8
commit f31c158843
5 changed files with 244 additions and 0 deletions
+6
View File
@@ -56,6 +56,12 @@ async function assumeRoleWithWebIdentityTokenFile(
async function assumeRoleWithCredentials(params: AssumeRoleCommandInput, client: STSClient) {
core.info('Assuming role with user credentials');
if (!process.env['AWS_SESSION_TOKEN']) {
core.warning(
'To avoid using long-term AWS credentials, please update your workflows to authenticate using OpenID Connect.' +
' See https://s12d.com/gha-oidc-aws for more information.'
);
}
try {
const creds = await client.send(new AssumeRoleCommand({ ...params }));
return creds;