title: Ansible, EC2 and Instance Profile
body: <p>I am trying to create via ansible with the following code:</p>
  
  <pre><code>– name: Create EC2 Instance(s)
  
  ec2:
    region: “{{ vpc_region }}”
    instance_profile_name: “{{ instance_profile_name }}”
    group: “{{ ec2_security_group_name }}”
    keypair: “{{ ec2_key_name }}”
    …..
  </code></pre>
  
  <p>Still it always output the following:</p>
  
  <blockquote>
    <p>TASK [scanner : Create EC2 Instance(s)] ****************************************<br>
    fatal: [127.0.0.1]: FAILED! => {“changed”: false, “failed”: true, “msg”: “Instance creation failed => InvalidParameterValue: Value (my-role-for-ansible) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name”}</p>
  </blockquote>
  
  <p>Although i think i defined the right policies to my user in AWS as follows:</p>
  
  <pre><code>{
      "Version": "2012-10-17",
      "Statement": [
          {
              "Sid": "Stmt14844231360000",
              "Effect": "Allow",
              "Action": [
                  "iam:PassRole"
              ],
              "Resource": [
                  "arn:aws:iam::11111111:role/my-role-for-ansible"
              ]
          }
      ]
  }
  </code></pre>
  
  <p>Anything wrong with the above?</p>