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 created before network configuration is completed #17558

Closed
gbonk opened this issue Mar 12, 2018 · 5 comments
Closed

AWS_Instance created before network configuration is completed #17558

gbonk opened this issue Mar 12, 2018 · 5 comments

Comments

@gbonk
Copy link

gbonk commented Mar 12, 2018

In our Terraform configuration, our AWS Instances are being created/started before the Security Groups and Network ACL creation is complete. With the servers already being started some of the services that have to 'call out' to the internet and other places are failing on startup. The services are failing because the network configuration is not complete and those service calls are being blocked.

I'm not entirely sure if this is a bug because I think Terraform should prioritize network configuration in it's dependency analysis, OR if it's something that I'm doing or should be doing.

Terraform Version

Terraform v0.11.3

Let me know what would be helpful, and I can add the additional details that you require.

@jbardin jbardin added the waiting-response An issue/pull request is waiting for a response from the community label Mar 12, 2018
@jbardin
Copy link
Member

jbardin commented Mar 12, 2018

Hi @gbonk,

Terraform should complete the network configuration before the instances, but you need to provide some hint in the configuration that there is a dependency there.

Can you provide a sample config that illustrates your problem?

@gbonk
Copy link
Author

gbonk commented Mar 12, 2018

Hi @jbardin, I've been working on a sample but when I simplify the configuration then you are correct and the network configuration completes first.

My network ACLs and Security Groups are in modules.

In the console output, I see where a network ACL starts its creation and rule application but terraform does not wait for the creation of the ACL rules to complete before starting to create AWS_Instances

I have been trying the examples/work-arounds in 1178

@jbardin
Copy link
Member

jbardin commented Mar 12, 2018

@gbonk,

Without any configuration, it hard for me to provide examples of what you should actually do.

While we can't depend on a module as a whole for various reasons, it is preferable anyway to depend only on the specific resources that are actually your dependencies. Providing an attribute from the dependency as a module output, then referencing that in the dependent resource will create the graph edges necessary to correctly order their creation.

As a small example, which will always create depends_on before dependent:

# module "foo"
resource "null_resource" "depends_on" {
}

output "depends_on_id" {
    value = "${null_resource.depends_on.id}"
}
# main.tf
module "foo" {
  source = "./foo"
}

resource "null_resource" "dependent" {
  triggers = {
    "depends_on" = "${module.foo.depends_on_id}"
  }
}

@hashibot
Copy link
Contributor

Hello again!

We didn't hear back from you, so I'm going to close this in the hope that a previous response gave you the information you needed. If not, please do feel free to re-open this and leave another comment with the information my human friends requested above. Thanks!

@ghost
Copy link

ghost commented Aug 15, 2019

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 Aug 15, 2019
@ghost ghost removed the waiting-response An issue/pull request is waiting for a response from the community label Aug 15, 2019
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

3 participants