# New Vpc created. Where do i specify the new VPC id

**URL:** <https://forum.ansible.com/t/new-vpc-created-where-do-i-specify-the-new-vpc-id/27998>\
**Category:** Ansible Project\
**Created:** [July 10, 2018, 12:52am UTC](https://forum.ansible.com/t/new-vpc-created-where-do-i-specify-the-new-vpc-id/27998 "2018-07-10T00:52:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sloan](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@Sloan](https://forum.ansible.com/u/Sloan)\
**Post date:** [July 10, 2018, 12:52am UTC](https://forum.ansible.com/t/new-vpc-created-where-do-i-specify-the-new-vpc-id/27998/1 "2018-07-10T00:52:28Z")

</div>

I’m spinning up new servers in a newly-created VPC I’m not sure which file contains the directive to change the VPC ID so the servers are created in the correct new VPC?

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [July 10, 2018, 1:45am UTC](https://forum.ansible.com/t/new-vpc-created-where-do-i-specify-the-new-vpc-id/27998/2 "2018-07-10T01:45:03Z")

</div>

Hi,

I presume here you’re using the ‘ec2’ module to create your instances. If so the module has a ‘vpc\_subnet\_id’ option, where you have to specify the id of the subnet that you want your instance attached to. The subnet is already bound to a VPC.

kind regards  
Pshem

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [July 10, 2018, 2:51am UTC](https://forum.ansible.com/t/new-vpc-created-where-do-i-specify-the-new-vpc-id/27998/3 "2018-07-10T02:51:57Z")

</div>

Further to this, if you specify network interfaces, they will be in subnets too, so the VPC is implied.

Regards, K.

---

<div class="post-metadata">

**Author:** ![Syed\_Jafar](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@Syed\_Jafar](https://forum.ansible.com/u/Syed_Jafar)\
**Post date:** [July 10, 2018, 5:26am UTC](https://forum.ansible.com/t/new-vpc-created-where-do-i-specify-the-new-vpc-id/27998/4 "2018-07-10T05:26:27Z")

</div>

I am trying to setup a playbook that launches new instance but keep running into issues like “local” or "localhost not found. Do you have a playbook that you could share.

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [July 10, 2018, 6:36am UTC](https://forum.ansible.com/t/new-vpc-created-where-do-i-specify-the-new-vpc-id/27998/5 "2018-07-10T06:36:32Z")

</div>

Post your playbook here. 99% of errors in beginners’ playbooks are simple syntax errors.

To create an instance, you first need to create a VPC, at least one subnet, a keypair and a security group. If you don’t create a VPC and a subnet, your new instance will end up in the default VPC in one of the default subnets and that is almost certainly NOT what you want, though it might be OK for initial experimenting.

I’ve posted a very small snippet separately that builds an instance.

While researching, remember that the older ec2 module is different to the newer ec2\_instance module. A lot of examples on the Internet refer to the older module.

Regards, K.
