-
-
Save jpedro/a89f1941279c95546adcde884fc88a72 to your computer and use it in GitHub Desktop.
Hack for Terraform Module depends_on
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This file would need to be in its own folder like /tf-bar/main.tf | |
| variable "bar" { | |
| default = "foo" | |
| } | |
| resource "null_resource" "bar" { | |
| triggers { | |
| bar = "${var.bar}" | |
| } | |
| provisioner "local-exec" { | |
| command = "echo 'tf-2.bar sleeping for 5 seconds' && sleep 5" | |
| } | |
| } | |
| output "bar" { | |
| value = "${null_resource.bar.triggers.bar}" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This file would need to be in its own folder like /tf-foo/main.tf | |
| variable "foo" { | |
| default = "foo" | |
| } | |
| resource "null_resource" "foo" { | |
| triggers { | |
| foo = "${var.foo}" | |
| } | |
| provisioner "local-exec" { | |
| command = "echo 'tf-1.foo sleeping for 2 seconds' && sleep 2" | |
| } | |
| } | |
| variable "foo2" { | |
| default = "foo" | |
| } | |
| resource "null_resource" "foo2" { | |
| triggers { | |
| foo2 = "${var.foo2}" | |
| } | |
| provisioner "local-exec" { | |
| command = "echo 'tf-1.foo2 sleeping for 5 seconds' && sleep 5" | |
| } | |
| } | |
| # You must list all resources in the module here, or a resource that depends on an unlisted resource will begin creating | |
| # before the rest of the module's resources have been created. | |
| output "foo" { | |
| value = <<-EOF | |
| ${null_resource.foo.triggers.foo} | |
| ${null_resource.foo2.triggers.foo2} | |
| EOF | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This file would need to be in its own folder like /tf-modules/main.tf | |
| module "foo" { | |
| source = "../tf-foo" | |
| } | |
| module "bar" { | |
| source = "../tf-bar" | |
| bar = "${module.foo.foo}" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment