给定角色ARN,您如何找出哪个堆栈和区域创建了该角色?

时间:2019-07-30 17:48:10

标签: amazon-web-services amazon-cloudformation amazon-iam

任何人都可以提供CLI命令来获取创建特定IAM角色的堆栈名称和区域吗?

2 个答案:

答案 0 :(得分:0)

您将必须编写一个遍历所有区域和所有堆栈的小型循环脚本(假设状态为“ CREATE_COMPLETE”),并使用describe-stack-resources CLI命令。

https://docs.aws.amazon.com/cli/latest/reference/cloudformation/describe-stack-resources.html

这是一个小例子:

class ThirdWindow(Screen):
    strain = StringProperty()

    def on_pre_enter(self, *args):
        with open('text.txt', 'r') as myfile:
            data = myfile.read().strip()
            self.strain = str(df[df['Strain'].str.match(str(data))])

别忘了,如果您拥有角色ARN,则可以轻松获取您的帐号和角色名称。格式为

  

arn:aws:iam :: account-id:role / role-name

我希望对您有所帮助,对单线纸抱歉,它的可读性较差。

答案 1 :(得分:-1)

aws cloudformation describe-stacks --stack-name myteststack