Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS VPC support: assignment and routing of public IPs is broken #277

Closed
arnuschky opened this issue Sep 9, 2014 · 4 comments
Closed

AWS VPC support: assignment and routing of public IPs is broken #277

arnuschky opened this issue Sep 9, 2014 · 4 comments

Comments

@arnuschky
Copy link

This is my VPC setup:

resource "aws_vpc" "default" {
  cidr_block = "10.1.0.0/16"
}

resource "aws_internet_gateway" "gw" {
    vpc_id = "${aws_vpc.default.id}"
}

resource "aws_subnet" "default" {
  vpc_id = "${aws_vpc.default.id}"
  cidr_block = "10.1.1.0/24"
}

This setup has the following issues:

  • public IPs are not assigned to instances, even if associate_public_ip_address = true is set in the instance resource configuration
  • routing to internet does not work, elastic IPs cannot be accessed
  • the routing problem cannot be fixed as terraform does not allow to edit the routing table auto-created on subnet creation
    • maybe an extra table can be created, but this would require manual assignment of subnets as main/default table already exists

I got this to work as follows:

  1. execute terraform apply
  2. delete all instances
  3. on AWS web console, set vpc subnet: set Auto-assign Public IP in the created subnet to true
  4. on AWS web console, modify auto-created routing table to include an entry cidr 0.0.0.0/0 to created gateway
  5. execute terraform apply to recreate instances, which will now get public IPs assigned that are properly routed

I am using 0.2.1

@arnuschky arnuschky changed the title Fix VPC support AWS VPC support: assignment and routing of public IPs is broken Sep 9, 2014
@arnuschky
Copy link
Author

Just realized that the "modify main routing table" request is already there: #193

@mitchellh
Copy link
Contributor

Thanks, I'll take a look at this sans the routing table since that is a separte issue.

@mitchellh
Copy link
Contributor

Looks like we don't support enabling that "Auto-Assign Public IP" feature yet in configs. I've re-tagged this as an enhancement.

@mitchellh
Copy link
Contributor

Just tested and this works:

resource "aws_vpc" "default" {
    cidr_block = "10.1.0.0/16"
    enable_dns_hostnames = true
}

resource "aws_internet_gateway" "gw" {
    vpc_id = "${aws_vpc.default.id}"
}

resource "aws_subnet" "default" {
  vpc_id = "${aws_vpc.default.id}"
  cidr_block = "10.1.1.0/24"
}

resource "aws_instance" "foo" {
    ami = "ami-3d50120d"
    instance_type = "t2.micro"
    subnet_id = "${aws_subnet.default.id}"
    associate_public_ip_address = true
}

@ghost ghost locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants