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_instance associate_public_ip_address doesn't seem to work #252

Closed
levinotik opened this issue Sep 1, 2014 · 8 comments
Closed

aws_instance associate_public_ip_address doesn't seem to work #252

levinotik opened this issue Sep 1, 2014 · 8 comments

Comments

@levinotik
Copy link

I have the following .tf file:

provider "aws" {
    access_key = "..."
    secret_key = "..."
    region = "us-west-2"
}

resource "aws_instance" "example" {
    ami = "ami-65f9be55"
    associate_public_ip_address = true
    instance_type = "m3.medium"
    subnet_id = "subnet-0be8c24d"
    security_groups = ["sg-62659f07"]
    key_name = "gw-key-pair"
}


resource "aws_elb" "bar" {
  name = "foobar-terraform-elb"
  subnets = ["subnet-0be8c24d"]

  listener {
    instance_port = 8080
    instance_protocol = "http"
    lb_port = 80
    lb_protocol = "http"
  }

  health_check {
    healthy_threshold = 2
    unhealthy_threshold = 2
    timeout = 3
    target = "HTTP:8080/healthcheck"
    interval = 30
  }

  instances = ["${aws_instance.example.id}"]
}

resource "aws_route53_record" "api-stage" {
   zone_id = "Z36X3B64AO2X4F"
   name = "api.mydomain.com"
   type = "CNAME"
   ttl = "300"
   records = ["${aws_elb.bar.dns_name}"]
}

I have tried applying this plan several times and each time it creates all of the specified resources, but the EC2 instance is not launched with a public ip address.

Is this a bug or am I doing something wrong?

@hden
Copy link
Contributor

hden commented Sep 2, 2014

eip resource?

resource "aws_eip" "example" {
    instance = "${aws_instance.example.id}"
}

@levinotik
Copy link
Author

@hden That worked, thanks.

@mitchellh
Copy link
Contributor

I just tested and we're sending it properly, but it is up to whether or not you configure your VPC properly to determine if it gets one. It appears Amazon doesn't give us any error. I'd have to say this is working as intended. Glad you figured it out!

@levinotik
Copy link
Author

@mitchellh Alright. I'm probably misunderstanding something about the way instances launched into a VPC work, but can't you have public ips that are not EIPs? I can use the EC2 launch wizard to do that.

@arnuschky
Copy link

I am having the exact same problem. I used VPCs before from the webinterface, and I was always able to attach public IPs.

@mitchellh could you please clarify what you mean with "it is up to whether or not you configure your VPC properly to determine if it gets one". In what way are we configuring our VPC wrongly?

@arnuschky
Copy link

See #277 how to (temporarily) solve the issue

@levinotik
Copy link
Author

@arnuschky thanks. if i understood your solution in #277 it's pretty manual... using terraform to avoid those kind of headaches! Thanks for the temp workaround though.

@arnuschky
Copy link

@levinotik yes, it is very manual - it's more a proof of what's missing/going wrong than an actual workaround.

@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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants