# AWS module woes in Ansible

**URL:** <https://forum.ansible.com/t/aws-module-woes-in-ansible/25016>\
**Category:** Ansible Project\
**Tags:** ubuntu, aws\
**Created:** [July 18, 2017, 8:38pm UTC](https://forum.ansible.com/t/aws-module-woes-in-ansible/25016 "2017-07-18T20:38:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve2](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@Steve2](https://forum.ansible.com/u/Steve2)\
**Post date:** [July 18, 2017, 8:38pm UTC](https://forum.ansible.com/t/aws-module-woes-in-ansible/25016/1 "2017-07-18T20:38:33Z")

</div>

Hi Ansible peeps,

Trying to get an AWS modules working in an Ansible playbook. Specifically I want to create a VPC using an Ansible playbook, but no matter what I do, always get the error:

ERROR! ‘ec2\_vpc\_net’ is not a valid attribute for a Play (for VPC obviously)

Doesn’t seem to matter which aws module I try to use, always gives similar error. For example, ec2:

ERROR! ‘ec2’ is not a valid attribute for a Play (for VPC obviously)

Have created several playbooks using the manual examples, as well as other online examples.

[http://docs.ansible.com/ansible/ec2\_vpc\_net\_module.html#support](http://docs.ansible.com/ansible/ec2_vpc_net_module.html#support)

[http://jeremievallee.com/2016/07/27/aws-vpc-ansible/](http://jeremievallee.com/2016/07/27/aws-vpc-ansible/)

I’ve copied these playbooks verbatim, checked the yaml format thru a linter, etc. Doesn’t matter always get the same error using ansible-playbook, i.e.

ansible-playbook -i localhost, vpc-template.yml

ERROR! ‘ec2\_vpc\_net’ is not a valid attribute for a Play

The error appears to have been in ‘/home/ubuntu/ansible/playbooks/networking/vpc-template.yml’: line 1, column 3, but may  
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- ec2\_vpc\_net:  
^ here

If I run the module manually, it works fine:

ansible local -m ec2\_vpc\_net -a “name=test.vpc cidr\_block=10.153.0.0/22 region=us-west-2”

I’m pretty sure that error message is a false flag and I’m missing something really simple, but I’ve been unable to track it down. Any help or pointers appreciated.

I’m running Ansible 2.3.0.0  
Ubuntu 16.04  
python 2.7.12  
boto 2.48.0

---

<div class="post-metadata">

**Author:** ![Paul\_Markham](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@Paul\_Markham](https://forum.ansible.com/u/Paul_Markham)\
**Post date:** [July 18, 2017, 9:40pm UTC](https://forum.ansible.com/t/aws-module-woes-in-ansible/25016/2 "2017-07-18T21:40:12Z")

</div>

Can you show us your playbook.

---

<div class="post-metadata">

**Author:** ![Steve2](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@Steve2](https://forum.ansible.com/u/Steve2)\
**Post date:** [July 18, 2017, 9:58pm UTC](https://forum.ansible.com/t/aws-module-woes-in-ansible/25016/3 "2017-07-18T21:58:02Z")

</div>

I found another user having the same problem. Not sure if it was having the hosts: or tasks: defined (or both?) but it works now with this

Working playbook:

- hosts: localhost  
connection: local  
tasks:
- name: Create vpc  
ec2\_vpc\_net:  
name: “Test.VPC”  
state: present  
cidr\_block: 10.151.0.0/22  
region: us-west-2

Original playbook:

- ec2\_vpc\_net:  
name: “Test.VPC”  
state: present  
cidr\_block: 10.151.0.0/22  
region: us-west-2

---

<div class="post-metadata">

**Author:** ![Paul\_Markham](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@Paul\_Markham](https://forum.ansible.com/u/Paul_Markham)\
**Post date:** [July 18, 2017, 11:06pm UTC](https://forum.ansible.com/t/aws-module-woes-in-ansible/25016/4 "2017-07-18T23:06:32Z")

</div>

Yes, having hosts: and tasks: is requires to make it a valid playbook. Your original one is valid YAML, but not a valid playbook.
