python boto3 将 IAM 角色附加/替换到 EC2



我找不到通过 boto3 将 IAM 角色附加/替换到 EC2 实例的方法。
云黑客的文档提供了一种使用 IAM 角色运行映像的方法,但不能附加。

博托可以吗?否则,我需要手动完成。

在此处阅读文档

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 的文档 (博托2(。Boto3,Boto的下一个版本,现在已经稳定了,并且 建议一般使用。

最新更新