簡體   English   中英

python boto3將IAM角色附加/替換為ec2

[英]python boto3 attach/replace IAM role to ec2

我找不到通過boto3將IAM角色附加/替換到EC2實例的方法。
cloudhackers的文檔提供了一種運行具有IAM角色但不附加的映像的方法。

Boto可以嗎? 否則,我需要手動進行。

此處閱讀文檔

associate_iam_instance_profile(** kwargs)
將IAM實例配置文件與正在運行或已停止的實例相關聯。 您不能將一個以上的IAM實例配置文件與一個實例相關聯。

請求語法

response = client.associate_iam_instance_profile(
    IamInstanceProfile={
        'Arn': 'string',
        'Name': 'string'
    },
    InstanceId='string'
)

響應語法

{
    'IamInstanceProfileAssociation': {
        'AssociationId': 'string',
        'InstanceId': 'string',
        'IamInstanceProfile': {
            'Arn': 'string',
            'Id': 'string'
        },
        'State': 'associating'|'associated'|'disassociating'|'disassociated',
        'Timestamp': datetime(2015, 1, 1)
    }
}

順便說一句,您給的鏈接頂部有一個橫幅

注意您正在查看文檔的舊版本的boto(boto2)。 Boto3的下一個版本Boto3現在穩定並推薦用於一般用途。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM