【问题标题】:AttributeError: 'EC2' object has no attribute 'associate_iam_instance_profile'AttributeError:“EC2”对象没有属性“associate_iam_instance_profile”
【发布时间】:2021-09-24 08:52:48
【问题描述】:

我正在尝试使用 boto3 将实例配置文件附加到 EC2 实例。我正在关注 boto3 文档https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.associate_iam_instance_profile

但它失败并出现以下错误:

AttributeError: 'EC2' 对象没有属性 'associate_iam_instance_profile'

你能帮我解决这个问题吗?

这是代码sn-p

import boto3

ec2=boto3.client('ec2',region_name='ca-central-1')

response = ec2.associate_iam_instance_profile(IamInstanceProfile={'Arn': 'arn:aws:iam::1234567890:instance-profile/instanceprofilename','Name': 'instanceprofilename'},InstanceId='i-1234567890')

我们将不胜感激。

boto3==1.4.3

Python 3.8.6

谢谢

【问题讨论】:

标签: python amazon-web-services amazon-ec2 boto3 amazon-iam


【解决方案1】:

您指的是 boto3 版本 1.17.112 的文档,并且您使用的是有点过时的 boto 版本。因此,如果没有版本约束,您可以做的第一件事就是更新您的 boto3 版本。

pip install boto3==1.17.112

【讨论】:

    猜你喜欢
    • 2016-03-28
    • 1970-01-01
    • 2012-12-01
    • 2021-04-19
    • 2021-11-22
    • 1970-01-01
    • 1970-01-01
    • 2018-08-28
    • 1970-01-01
    相关资源
    最近更新 更多