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

[aws] Fix IAM role name parsing to come from the ARN #46076

Merged
merged 2 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/54434-iam-role-arn-parsing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- ec2_metadata_facts - Parse IAM role name from metadata ARN instead of security credential field.
4 changes: 2 additions & 2 deletions lib/ansible/modules/cloud/amazon/ec2_metadata_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,8 @@ def _mangle_fields(self, fields, uri, filter_patterns=None):
new_fields = {}
for key, value in fields.items():
split_fields = key[len(uri):].split('/')
if len(split_fields) == 3 and split_fields[0:2] == ['iam', 'security-credentials']:
new_fields[self._prefix % "iam-instance-profile-role"] = split_fields[2]
if len(split_fields) == 2 and split_fields[0:2] == ['iam', 'info_instanceprofilearn']:
new_fields[self._prefix % "iam-instance-profile-role"] = value.split('/')[1]
if len(split_fields) > 1 and split_fields[1]:
new_key = "-".join(split_fields)
new_fields[self._prefix % new_key] = value
Expand Down