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

why does this module fail to find the aws_instance #1863

Closed
ketzacoatl opened this issue May 8, 2015 · 6 comments
Closed

why does this module fail to find the aws_instance #1863

ketzacoatl opened this issue May 8, 2015 · 6 comments

Comments

@ketzacoatl
Copy link
Contributor

I feel like I might be overlooking a simple mistake, but I've been over this again and again and I am still getting confusing behavior.

Here is a simplifed version of the code I'm working with..

In one source file...

# salt master instance
resource "aws_instance" "master" {
    ...
}

..and in another file:

# defines an ASG with some other stuff for us
module "cluster-a" {
    ...
    user_data = <<END_USER_DATA
...
salt:
  minion:
    master: ${aws_instance.master.private_dns}
...
END_USER_DATA

This fails:

* Resource 'aws_instance.master' not found for variable 'aws_instance.master.private_dns'

If I drop the reference to the aws_instance.master resource, the error goes away and the salt master instance is first in the build plan. tf graph shows the instance near last, while the cluster is first. Is this spin off from #1178 or un-related?

While debugging, I found that I could put in a reference to another resource in the same file as the aws_instance.master resource, and the module was happy with that reference.

This made me curious.. could I add another instance with a reference to the aws_instance.master? I added:

resource "aws_instance" "foo" {
    key_name = "${aws_instance.master.private_dns}"
    ami = "${var.ami}"
    associate_public_ip_address = true
    instance_type = "t2.small"
    availability_zone = "${aws_subnet.mgmt-a.availability_zone}"
    security_groups = ["${aws_security_group.salt-master.id}"]
    subnet_id = "${aws_subnet.mgmt-a.id}"
} 

and tf plan is fine and happy with that reference, but not when provided to the module. I tested that with and without depends_on = "aws_instance.master".

I first ran into the error with 0.4.x, so I upgrade to 0.5.x, but the problem persists.

@mitchellh
Copy link
Contributor

Well, at least the error existed with 0.4.x. I've tagged it so we can look at it.

@ketzacoatl
Copy link
Contributor Author

In case I was not clear, the error pasted above is from 0.5.x. Either way, let me know if more information or testing it helpful!

@ketzacoatl
Copy link
Contributor Author

This may be a duplicate of #1916, I will test to confirm. And the last comment above on versions was incorrrect (sorry!)

@mitchellh
Copy link
Contributor

This is a dup of #1916 and its fixed

@ketzacoatl
Copy link
Contributor Author

confirmed here too, sorry for the delayed reply!

@ghost
Copy link

ghost commented May 2, 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 May 2, 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