How do I use Boto3 to launch an EC2 instance with an IAM role?

后端 未结 2 1704
迷失自我
迷失自我 2021-02-19 02:01

I can not figure out how to launch an EC2 instance in Boto3 with a specified IAM role.

Here is some sampe code of how I have been able to successfully create an instanc

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-19 02:50

    Just an addition to the great answer by helloV (I can not comment due to reputation limitations). I encountered the same error message of "The parameter iamInstanceProfile.name may not be used in combination with iamInstanceProfile.arn. So only one key is allowed. I experimented with both and using

    IamInstanceProfile={ 'Name': 'ExampleInstanceProfile' }
    

    works for me, but not using

    IamInstanceProfile={'Arn':'arn:aws:iam::123456789012:instanceprofile/ExampleInstanceProfile'}
    

    I am using boto3 version 1.4.4

提交回复
热议问题