# Trouble with ec2\_vpc\_vgw

**URL:** <https://forum.ansible.com/t/trouble-with-ec2-vpc-vgw/28254>\
**Category:** Ansible Project\
**Created:** [August 3, 2018, 4:35pm UTC](https://forum.ansible.com/t/trouble-with-ec2-vpc-vgw/28254 "2018-08-03T16:35:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ttwalto](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@ttwalto](https://forum.ansible.com/u/ttwalto)\
**Post date:** [August 3, 2018, 4:35pm UTC](https://forum.ansible.com/t/trouble-with-ec2-vpc-vgw/28254/1 "2018-08-03T16:35:20Z")

</div>

I am trying to run ec2\_vpc\_vgw just to attach a vpc to a vgw (virtual private gateway). The vgw and vpc both already exist. I don’t need to create them. Here’s what I run:

- name: attach vpc to virtual private gateway  
ec2\_vpc\_vgw:  
region: “{{ openshift\_aws\_region }}”  
vpc\_id: “{{ vpcout.vpcs[0].id }}”  
vpn\_gateway\_id: “{{ openshift\_aws\_vgw\_id }}”

Here is an error that results:

fatal: [localhost]: FAILED! =\> {  
“changed”: false,  
“invocation”: {  
“module\_args”: {  
“region”: “us-east-1”,  
“state”: “present”,  
“type”: “ipsec.1”,  
“validate\_certs”: true,  
“vpc\_id”: “vpc-427cb738”,  
“vpn\_gateway\_id”: “vgw-ff0ffe96”,  
“wait\_timeout”: 320  
}  
},  
“msg”: “state is present but all of the following are missing: name”  
}

The Ansible modules documentation doesn’t say that name is required. And in this scenario name shouldn’t matter anyway, I’m giving it the specific vgw I want to attach to. The documentation examples don’t give an example of just attaching an existing vpc to an existing vgw. It only has examples for creating a new vgw or deleting one. So it’s no help.

Anyone know what’s going on here? How do I attach an existing vpc to an existing vgw?

---

<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:** [August 3, 2018, 10:31pm UTC](https://forum.ansible.com/t/trouble-with-ec2-vpc-vgw/28254/2 "2018-08-03T22:31:06Z")

</div>

I have not tried this myself, but it occurs to me that maybe you should be using ec2\_vpc\_vpn to modify the VPN’s gateway, rather than using ec2\_vpc\_vgw to modify the gateway’s VPN.

That is, don’t think of it as attaching a VPN to a gateway, think of it as associating a gateway with a VPN.

BTW, name is a parameter for a gateway, though not for a VPN.

Regards, K.

---

<div class="post-metadata">

**Author:** ![ttwalto](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@ttwalto](https://forum.ansible.com/u/ttwalto)\
**Post date:** [August 6, 2018, 1:30pm UTC](https://forum.ansible.com/t/trouble-with-ec2-vpc-vgw/28254/3 "2018-08-06T13:30:30Z")

</div>

My reasoning on that was that I don’t need to set up a whole VPN connection. It’s already set up. I just need to attach the VPC to the gateway.

But maybe you’re right. It’s hard to tell from the documentation on [docs.ansible.com](http://docs.ansible.com).

---

<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:** [August 6, 2018, 2:29pm UTC](https://forum.ansible.com/t/trouble-with-ec2-vpc-vgw/28254/4 "2018-08-06T14:29:18Z")

</div>

Let us know when you’ve tried it…
