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

depends_on not applied for data source #15851

Closed
laurent-perrin opened this issue Aug 18, 2017 · 2 comments
Closed

depends_on not applied for data source #15851

laurent-perrin opened this issue Aug 18, 2017 · 2 comments

Comments

@laurent-perrin
Copy link

Terraform Version

v0.10.2

Terraform Configuration Files

resource "openstack_compute_instance_v2" "db" {
  name = "db"
  image_name = "${var.image_name}"
  flavor_name = "${var.flavor_name}"
  security_groups = ["default"]
  key_pair = "${var.key_pair}"

  network {
    name = "${var.network_name}"
  }
}

data "template_file" "user_data_web" {
  depends_on = ["openstack_compute_instance_v2.db"]
  template = "${file("${path.module}/user-data-web.sh")}"

  vars {
    db_address = "${openstack_compute_instance_v2.db.network.0.fixed_ip_v4}"
  }
}

resource "openstack_compute_instance_v2" "web" {
  name = "web"
  image_name = "${var.image_name}"
  flavor_name = "${var.flavor_name}"
  security_groups = ["default"]
  key_pair = "${var.key_pair}"

  network {
    name = "${var.network_name}"
  }

  user_data = "${data.template_file.user_data_web.rendered}"
}

Expected Behavior

The instance "db" should be created before the data source template_file so the variable openstack_compute_instance_v2.db.network.0.fixed_ip_v4 could be used.

Actual Behavior

A terraform plan produces this error:

Error asking for user input: 1 error(s) occurred:

* Cycle: data.template_file.user_data_web, openstack_compute_instance_v2.web, openstack_compute_instance_v2.db

The data source seems to be created before the openstack_compute_instance_v2.db and the variable openstack_compute_instance_v2.db.network.0.fixed_ip_v4 is not yet created.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan

Important Factoids

No

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

@laurent-perrin
Copy link
Author

I found the cause of my issue, there was dependencies between the security group for my web and db servers.

Sorry but this issue can be closed

@jbardin jbardin closed this as completed Aug 18, 2017
@ghost
Copy link

ghost commented Apr 7, 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 7, 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

2 participants