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

pull/46087/head
Vinay Dandekar 6 years ago committed by Ryan Brown
parent 485320aab8
commit fe6b7f6b5d

@ -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

Loading…
Cancel
Save