# Need assist with syntax to launch with EC2 profile

**URL:** <https://forum.ansible.com/t/need-assist-with-syntax-to-launch-with-ec2-profile/15026>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [April 15, 2014, 9:52pm UTC](https://forum.ansible.com/t/need-assist-with-syntax-to-launch-with-ec2-profile/15026 "2014-04-15T21:52:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark\_david\_mcCreary](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@mark\_david\_mcCreary](https://forum.ansible.com/u/mark_david_mcCreary)\
**Post date:** [April 15, 2014, 9:52pm UTC](https://forum.ansible.com/t/need-assist-with-syntax-to-launch-with-ec2-profile/15026/1 "2014-04-15T21:52:51Z")

</div>

- name: Launch instance  
local\_action: ec2 keypair={{ keypair }} instance\_type={{ instance\_type }}  
image={{ image }} region={{ region }}  
aws\_access\_key={{ aws\_access\_key }}  
aws\_secret\_key={{ aws\_secret\_key }}  
group={{ security\_group }} wait=true  
instance\_profile\_name=arn:aws:iam::127847392001:instance-profile/administrator  
register: ec2

and Ansible says

# Instance Profile ARN(s) arn:aws:iam::127847392001:instance-profile/administrator

# TASK: [ec2 | Launch instance] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

# failed: [localhost] =\> {“failed”: true, “item”: “”}

# msg: Instance creation failed =\> InvalidParameterValue: Value (arn:aws:iam::127847392001:instance-profile/administrator) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name

Have also tried with double quotes around name

instance\_profile\_name=“arn:aws:iam::127847392001:instance-profile/administrator”

Looking at Amazon console I see a role named - administrator. I can launch instances without Ansible using the above profile.

Is this a syntax problem, or am I in the wrong environment or something.

Thaks

mark

---

<div class="post-metadata">

**Author:** ![willthames](https://avatars.discourse-cdn.com/v4/letter/w/8dc957/32.png) [@willthames](https://forum.ansible.com/u/willthames)\
**Post date:** [April 15, 2014, 11:32pm UTC](https://forum.ansible.com/t/need-assist-with-syntax-to-launch-with-ec2-profile/15026/2 "2014-04-15T23:32:05Z")

</div>

I wonder if you should just use administrator (rather than the full ARN) for instance\_profile\_name.

From [http://boto.readthedocs.org/en/latest/ref/ec2.html#boto.ec2.connection.EC2Connection.run\_instances](http://boto.readthedocs.org/en/latest/ref/ec2.html#boto.ec2.connection.EC2Connection.run_instances)

- **instance\_profile\_arn** ([_string_](http://docs.python.org/library/string.html#module-string)) – The Amazon resource name (ARN) of the IAM Instance Profile (IIP) to associate with the instances.
- **instance\_profile\_name** ([_string_](http://docs.python.org/library/string.html#module-string)) – The name of the IAM Instance Profile (IIP) to associate with the instances.  
The ec2 module only uses the latter, I think, although it could presumably be tweaked to use the former in addition.

Will

---

<div class="post-metadata">

**Author:** ![mark\_david\_mcCreary](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@mark\_david\_mcCreary](https://forum.ansible.com/u/mark_david_mcCreary)\
**Post date:** [April 16, 2014, 8:22pm UTC](https://forum.ansible.com/t/need-assist-with-syntax-to-launch-with-ec2-profile/15026/3 "2014-04-16T20:22:48Z")

</div>

Will

Thank you.

Yes, you are correct, I had the wrong value for the argument I was using.

instance\_profile\_name=administrator

is now working for me.

The complete stanza is

- name: Launch instance  
local\_action: ec2 keypair={{ keypair }} instance\_type={{ instance\_type }}  
image={{ image }} region={{ region }}  
aws\_access\_key={{ aws\_access\_key }}  
aws\_secret\_key={{ aws\_secret\_key }}  
group={{ security\_group }} wait=true  
instance\_profile\_name=administrator  
register: ec2

Thanks much.

mark
