Generate STS token with assume_role_with_web_identity

3/19/2020

I am looking to generate AWS token in my kubernetes pod using AWS_ROLE_ARN & AWS_WEB_IDENTITY_TOKEN_FILE specified in this documentation EKS Service Accounts. Would be able to generate the token using the code below or should I extract the token from AWS_WEB_IDENTITY_TOKEN_FILE before it can be passed as WebIdentityToken?

client = boto3.client('sts')
response = client.assume_role_with_web_identity(
    RoleArn=os.environ['AWS_ROLE_ARN'],
    RoleSessionName='mySession',
    WebIdentityToken=os.environ['AWS_WEB_IDENTITY_TOKEN_FILE']
)
-- Punter Vicky
amazon-eks
aws-sts
boto3
kubernetes
python

0 Answers