使用BOTO3获取与角色关联的标签



有没有办法获得与特定角色关联的标签?以下内容不会为角色生成标签:

import boto3
iam=boto3.client('iam')
response = iam.get_role(RoleName='xxxxx')
print(response)

此外,IAM在标记api 的资源组中似乎不受支持

任何IAM角色都可以通过其arn(amazon资源名称(来识别。IAM角色没有标记。

如果要使用此函数,它将返回一个带有所有Role标记的dict:

list_role_tags(**kwargs)
Lists the tags that are attached to the specified role. The returned list of tags is sorted by tag key. For more information about tagging, see Tagging IAM Identities in the IAM User Guide .
See also: AWS API Documentation
Request Syntax
response = client.list_role_tags(
RoleName='string',
Marker='string',
MaxItems=123
)

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/iam.html#IAM.Client.list_role_tags

最新更新