Skip to content

Instantly share code, notes, and snippets.

@rms1000watt
rms1000watt / assumeRoleWithWebIdentity-in-eks-k8s-pod.js
Last active March 3, 2022 14:25
NodeJS in EKS/K8s to assumeRoleWithWebIdentity
const AWS = require('aws-sdk');
const fs = require('fs');
const sts = new AWS.STS();
sts.getCallerIdentity({}, console.log);
const webIdentityToken = fs.readFileSync(process.env.AWS_WEB_IDENTITY_TOKEN_FILE, "utf8");
const role = sts.assumeRoleWithWebIdentity({
RoleArn: process.env.AWS_ROLE_ARN,
RoleSessionName: "todo-put-something-dynamic-maybe",