-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
[cloud] Add support for updating IAM role with ec2_instance module #38812
Conversation
if instance_profile_setting.get('Arn') == desired_arn: | ||
return False | ||
# update association | ||
ec2 = module.client('ec2') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep forgetting module is global :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it? That seems wrong to me. Is it global in every module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not global in every module, but it is global in this module https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/ec2_instance.py#L1409
try: | ||
role = iam.get_instance_profile(InstanceProfileName=name_or_arn) | ||
role = iam.get_instance_profile(InstanceProfileName=name_or_arn, aws_retry=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update the GUIDELINES if we're happy enough to use it now (it's so much nicer than creating _backoff
methods with @AWSRetry
decorators)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm quite happy with it (so nice to use!) but s-hertel brought up an interesting point about it for library/common functions. In module_utils files, we probably can't expect the caller to always have a retry decorator turned on for whatever client they pass in, so I think for utils we still have to use the decorators directly for now. What do you think?
…nsible#38812) * [cloud] Add support for updating IAM role with ec2_instance module * Add test for updating IAM role
SUMMARY
IAM instance profiles can't be switched via the
modify_instance_attribute
API call. This pull request adds checks on already-existing instances for the IAM instance profile ARN and name, then updates the profile association.ISSUE TYPE
COMPONENT NAME
ec2_instance
ANSIBLE VERSION
ADDITIONAL INFORMATION
Before:
After: