Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Online Documentation does not seem to work for lambda/EC2 #640

Open
lukepmanion opened this issue Oct 28, 2020 · 0 comments
Open

Online Documentation does not seem to work for lambda/EC2 #640

lukepmanion opened this issue Oct 28, 2020 · 0 comments

Comments

@lukepmanion
Copy link

Spent quite a while trying to get this code snippet to work:
https://hvac.readthedocs.io/en/stable/usage/auth_methods/aws.html#lambda-and-or-ec2-instance

I believe it is missing the session token which I've updated below.


def infer_credentials_from_iam_role(iam_role):
    on_lambda = 'AWS_LAMBDA_FUNCTION_NAME' in os.environ
    if on_lambda:
        return os.environ['AWS_ACCESS_KEY_ID'], os.environ['AWS_SECRET_ACCESS_KEY'], os.environ['AWS_SESSION_TOKEN']
    else:
        security_credentials = load_aws_ec2_role_iam_credentials(iam_role)
        return security_credentials['AccessKeyId'], security_credentials['SecretAccessKey'], security_credentials['Token']



access_key_id, secret_access_key, token = infer_credentials_from_iam_role('vaultSecretAccess')
client.auth.aws.iam_login(access_key_id, secret_access_key, token)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant