-
Notifications
You must be signed in to change notification settings - Fork 1
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
"Attach inline policy to user" (aws_s3.yml task) fails when using assumed IAM role #29
Comments
Maybe sts_assume_role could be used to obtain temporary access credentials before the |
Example script to add to local project: # deploy/boto-temporary-creds.py
import boto3, sys
session = boto3.Session(profile_name="MY-PROJECT-AWSCLI-PROFILE")
credentials = session.get_credentials().get_frozen_credentials()
print(f'export AWS_ACCESS_KEY_ID="{credentials.access_key}"')
print(f'export AWS_SECRET_ACCESS_KEY="{credentials.secret_key}"')
print(f'export AWS_SECURITY_TOKEN="{credentials.token}"')
print(f'export AWS_SESSION_TOKEN="{credentials.token}"') Then: python boto-temporary-creds.py
# copy printed export statements and run in shell
export AWS_ACCESS_KEY_ID="..."
# ...
# now run Ansible playbook that failed
ansible-playbook deploy... |
I can confirm the same issue when I tried to move the CI IAM user creation to this role. Here was my initial traceback.
Then when I switched my
Running the |
As far as I can tell, Ansible's iam_policy module doesn't work with an assumed IAM role due to a limitation of the underlying boto library.
This gist provides a workaround, which works by just running
assumed-role-credentials.py
before running the playbook which calls theaws_s3.yml
tasks.The text was updated successfully, but these errors were encountered: