I'm confused how to create an IAM role for an ec2 ...
# python
t
I'm confused how to create an IAM role for an ec2 machine and then use it. The error message is super confusing. First I create an IAM role:
Copy code
machine_role = aws.iam.Role("dockerbuilder-role", ...)
and then I try to create an EC2 instance that uses this role:
Copy code
server = aws.ec2.Instance('dockerbuilder-pulumi',
    iam_instance_profile=machine_role,
...)
The error message (which annoyingly takes 2 minutes to resolve annoyingly) is
InvalidParameterValue: Value (dockerbuilder-role-908245c) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name
. Now if I instantiate the Instance with `
Copy code
iam_instance_profile="dockerbuilder-role-908245c",
it works. How do I get the name out of the role object to pass into the instance?
Same problem if I try
Copy code
iam_instance_profile=machine_role.name,
Figured it out. Not sure why I thought it was working before - I think I was confused. But I needed.
Copy code
machine_profile = aws.iam.InstanceProfile("dockerbuilder-profile", role=machine_role.name)

...

    iam_instance_profile=machine_profile,
228 Views