[aws] Fix IAM role name parsing to come from the ARN (#46076)
* [aws] Change IAM role name parsing to come from the ARN (#45534)
(cherry picked from commit fe6b7f6b5d
)
* Changelog
This commit is contained in:
parent
4fe7671d34
commit
d46ed88fa3
2 changed files with 4 additions and 2 deletions
2
changelogs/fragments/54434-iam-role-arn-parsing.yml
Normal file
2
changelogs/fragments/54434-iam-role-arn-parsing.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- ec2_metadata_facts - Parse IAM role name from metadata ARN instead of security credential field.
|
|
@ -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…
Reference in a new issue