-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #540 from lorengordon/hook-init-once
Adds options attribute to track state of the terraform command
- Loading branch information
Showing
15 changed files
with
344 additions
and
76 deletions.
There are no files selected for viewing
This file contains 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 contains 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 contains 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 contains 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 contains 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 contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
terraform { | ||
backend "s3" {} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
data "template_file" "example" { | ||
template = "hello, world" | ||
} | ||
|
||
output "example" { | ||
value = "${data.template_file.example.rendered}" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
data "template_file" "example" { | ||
template = "hello, world" | ||
} | ||
|
||
output "example" { | ||
value = "${data.template_file.example.rendered}" | ||
} |
17 changes: 17 additions & 0 deletions
17
test/fixture-hooks/init-once/no-source-no-backend/terraform.tfvars
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
terragrunt = { | ||
terraform { | ||
# Should NOT execute. With no source, init-from-module should never execute. | ||
# If AFTER_INIT_FROM_MODULE_ONLY_ONCE is present in output, the test failed | ||
after_hook "after_init_from_module" { | ||
commands = ["init-from-module"] | ||
execute = ["echo","AFTER_INIT_FROM_MODULE_ONLY_ONCE"] | ||
} | ||
|
||
# SHOULD execute | ||
# If AFTER_INIT_ONLY_ONCE is not present exactly once in output, the test failed | ||
after_hook "after_init" { | ||
commands = ["init"] | ||
execute = ["echo","AFTER_INIT_ONLY_ONCE"] | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
test/fixture-hooks/init-once/no-source-with-backend/main.tf
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
terraform { | ||
backend "s3" {} | ||
} | ||
|
||
data "template_file" "example" { | ||
template = "hello, world" | ||
} | ||
|
||
output "example" { | ||
value = "${data.template_file.example.rendered}" | ||
} |
27 changes: 27 additions & 0 deletions
27
test/fixture-hooks/init-once/no-source-with-backend/terraform.tfvars
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
terragrunt = { | ||
remote_state { | ||
backend = "s3" | ||
config { | ||
encrypt = true | ||
bucket = "__FILL_IN_BUCKET_NAME__" | ||
key = "terraform.tfstate" | ||
region = "__FILL_IN_REGION__" | ||
} | ||
} | ||
|
||
terraform { | ||
# Should NOT execute. With no source, init-from-module should never execute. | ||
# If AFTER_INIT_FROM_MODULE_ONLY_ONCE is present in output, the test failed | ||
after_hook "after_init_from_module" { | ||
commands = ["init-from-module"] | ||
execute = ["echo","AFTER_INIT_FROM_MODULE_ONLY_ONCE"] | ||
} | ||
|
||
# SHOULD execute. | ||
# If AFTER_INIT_ONLY_ONCE is not echoed exactly once, the test failed | ||
after_hook "after_init" { | ||
commands = ["init"] | ||
execute = ["echo","AFTER_INIT_ONLY_ONCE"] | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
test/fixture-hooks/init-once/with-source-no-backend/terraform.tfvars
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
terragrunt = { | ||
terraform { | ||
source = "../base-module" | ||
|
||
# SHOULD execute. | ||
# If AFTER_INIT_FROM_MODULE_ONLY_ONCE is not echoed exactly once, the test failed | ||
after_hook "after_init_from_module" { | ||
commands = ["init-from-module"] | ||
execute = ["echo","AFTER_INIT_FROM_MODULE_ONLY_ONCE"] | ||
} | ||
|
||
# SHOULD execute. | ||
# If AFTER_INIT_ONLY_ONCE is not echoed exactly once, the test failed | ||
after_hook "after_init" { | ||
commands = ["init"] | ||
execute = ["echo","AFTER_INIT_ONLY_ONCE"] | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
test/fixture-hooks/init-once/with-source-with-backend/terraform.tfvars
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
terragrunt = { | ||
remote_state { | ||
backend = "s3" | ||
config { | ||
encrypt = true | ||
bucket = "__FILL_IN_BUCKET_NAME__" | ||
key = "terraform.tfstate" | ||
region = "__FILL_IN_REGION__" | ||
} | ||
} | ||
|
||
terraform { | ||
source = "../base-module" | ||
|
||
after_hook "backend" { | ||
commands = ["init-from-module"] | ||
execute = ["cp", "${get_tfvars_dir()}/../backend.tf", "."] | ||
} | ||
|
||
# SHOULD execute. | ||
# If AFTER_INIT_FROM_MODULE_ONLY_ONCE is not echoed exactly once, the test failed | ||
after_hook "after_init_from_module" { | ||
commands = ["init-from-module"] | ||
execute = ["echo","AFTER_INIT_FROM_MODULE_ONLY_ONCE"] | ||
} | ||
|
||
# SHOULD execute. | ||
# If AFTER_INIT_ONLY_ONCE is not echoed exactly once, the test failed | ||
after_hook "after_init" { | ||
commands = ["init"] | ||
execute = ["echo","AFTER_INIT_ONLY_ONCE"] | ||
} | ||
} | ||
} |
Oops, something went wrong.