DEV Community

Discussion on: AWS Site-to-Site VPN with NAT

Collapse
 
lunaticzorr profile image
Lunatic Zorr

This article was exactly what I had been looking for for some time now. I've tried to re-create this but I've run into an issue. The following causes an error when applying:

resource "aws_eip_association" "nat_gw" {
  network_interface_id = aws_network_interface.nat_gw.id
  allocation_id = "1.2.3.4"
}
Enter fullscreen mode Exit fullscreen mode

The error I get is:

│ Error: Error associating EIP: InvalidAllocationID.NotFound: The allocation ID '1.2.3.4' does not exist
│     status code: 400, request id: 99c84351-a519-4d81-8dc3-7fb10ed51e17
│ 
│   with module.mvrv3_vpn.aws_eip_association.nat_gw,
│   on ../../../../modules/networking/dev_nat_setup/main.tf line 231, in resource "aws_eip_association" "nat_gw":
│  231: resource "aws_eip_association" "nat_gw" {

Enter fullscreen mode Exit fullscreen mode

Looking at the Terrafrom Documentation, I see that under allocation_id they don't use an IP:

resource "aws_eip_association" "eip_assoc" {
  instance_id   = aws_instance.web.id
  allocation_id = aws_eip.example.id
}
Enter fullscreen mode Exit fullscreen mode
  • Do I need to create an EIP first, and then use the EIPs allocation ID?
  • Is 1.2.3.4 just a random example IP you use in the code, or can it actually be used?

Would really appreciate the help! This article itself was already a revelation!