1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[aws] Change IAM role name parsing to come from the ARN (#45534)

This commit is contained in:
Vinay Dandekar 2018-09-24 12:41:23 -04:00 committed by Ryan Brown
parent 485320aab8
commit fe6b7f6b5d

View file

@ -467,8 +467,8 @@ class Ec2Metadata(object):
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