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

State file shows initial public_ip and not an eip #1425

Closed
alexclifford opened this issue Apr 8, 2015 · 4 comments
Closed

State file shows initial public_ip and not an eip #1425

alexclifford opened this issue Apr 8, 2015 · 4 comments

Comments

@alexclifford
Copy link

During the initial creation (for example during https://www.terraform.io/intro/getting-started/provision.html) if you have an EC2 instance with an EIP associated to it during apply terraform show lists the public_ip as what is presumably the IP address before the EIP is attached. Re-running terraform refresh fixes the state file. Should this detail be correct on first orchestration?

@robertfirek
Copy link

I have similar issue with my outputs. These outputs generate different public_ip during the first apply. The second apply fix that issue and output contains the right values. Adding depends_on doesn't help.

resource "template_file" "example_template" {
    depends_on = ["aws_eip.some_instance"]
    filename = "template-some_instance"
    vars {
        some_instance_public_ip     = "${aws_instance.some_instance.public_ip}"
    }
} 

output "public_ips" {
    value = "${template_file.example_template.rendered}"
}

@phinze
Copy link
Contributor

phinze commented Jan 20, 2016

Hey folks, definitely see the issue here. Terraform is simply reflecting the upstream behavior of the AWS API, which changes the reported value of PublicIP after an EIP is attached.

Since the aws_eip is attached after the aws_instance resource is fully created, Terraform doesn't have any way of knowing that one of those attributes will report differently, nor do we currently have any core facilities for "revisiting" a node after a downstream change has occurred.

I'm wondering if this is a scenario that we can handle with a documentation warning on the field? Something like:

If you are using an aws_eip with an instance, you should refer to the EIP's address directly and not use public_ip, as it will change after the EIP is attached.

What do you think?

@phinze phinze added provider/aws and removed core labels Jan 20, 2016
@alexclifford
Copy link
Author

Hi @phinze,
Thanks for reviewing this and your explanation of how this interacts with the AWS API.
Until Terraform can refresh its state for aws_instance, after an aws_eip action updates it, the documentation workaround seems good to me.

@phinze phinze closed this as completed in 14ca7e3 Mar 11, 2016
@ghost
Copy link

ghost commented Apr 27, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 27, 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

4 participants