I am creating an EC2 instance with SSM attached to the instance.
def createInstances(self):
instances = self.ec2_client.create_instances(
ImageId="ami-09e67e426f25ce0d7", # Ubuntu Server 20.04 LTS (HVM), SSD Volume Type
MinCount=1,
MaxCount=1,
InstanceType="m4.2xlarge",
KeyName="ec2-key-pair",
IamInstanceProfile={
'Arn': 'arn:aws:iam::aws:instance-profile/AmazonEC2RoleforSSM',
'Name': 'AmazonEC2RoleforSSM'
},
DryRun=True,
TagSpecifications=[
{
'ResourceType': 'instance',
'Tags': [
{
'Key': 'department',
'Value': 'dev'
},
]
},
],
)
print(instances["Instances"][0])
I am getting an error as:
botocore.exceptions.ClientError: An error occurred (InvalidParameterCombination) when calling the RunInstances operation: The parameter 'iamInstanceProfile.name' may not be used in combination with 'iamInstanceProfile.arn'
when I removed 'iamInstanceProfile.name' I got another error as:
botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the RunInstances operation: Value (arn:aws:iam::aws:instance-profile/AmazonEC2RoleforSSM) for parameter iamInstanceProfile.arn is invalid. Invalid IAM Instance Profile ARN