-
-
Notifications
You must be signed in to change notification settings - Fork 997
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(remote_state): implement outputs fetching from gcs
This implements outputs fetching from the GCS backend, in a similar fashion to what has been implemented for S3. I've also added some misc fixes: * correct typo: steateBody -> stateBody * drop unused Path parameter on GCS config (it's not supported) Tested on my architecture, everything seems to work! Ref: https://developer.hashicorp.com/terraform/language/settings/backends/gcs
- Loading branch information
Showing
11 changed files
with
265 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
terraform { | ||
backend "gcs" {} | ||
} | ||
|
||
output "app1_text" { | ||
value = "app1 output" | ||
} |
7 changes: 7 additions & 0 deletions
7
test/fixtures/gcs-output-from-remote-state/env1/app1/terragrunt.hcl
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 @@ | ||
include { | ||
path = find_in_parent_folders() | ||
} | ||
|
||
dependencies { | ||
paths = ["../app3"] | ||
} |
15 changes: 15 additions & 0 deletions
15
test/fixtures/gcs-output-from-remote-state/env1/app2/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,15 @@ | ||
terraform { | ||
backend "gcs" {} | ||
} | ||
|
||
output "app1_text" { | ||
value = var.app1_text | ||
} | ||
|
||
output "app2_text" { | ||
value = "app2 output" | ||
} | ||
|
||
output "app3_text" { | ||
value = var.app3_text | ||
} |
24 changes: 24 additions & 0 deletions
24
test/fixtures/gcs-output-from-remote-state/env1/app2/terragrunt.hcl
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,24 @@ | ||
include { | ||
path = find_in_parent_folders() | ||
} | ||
|
||
dependency "app1" { | ||
config_path = "../app1" | ||
|
||
mock_outputs = { | ||
app1_text = "(known after apply-all)" | ||
} | ||
} | ||
|
||
dependency "app3" { | ||
config_path = "../app3" | ||
|
||
mock_outputs = { | ||
app3_text = "(known after apply-all)" | ||
} | ||
} | ||
|
||
inputs = { | ||
app1_text = dependency.app1.outputs.app1_text | ||
app3_text = dependency.app3.outputs.app3_text | ||
} |
7 changes: 7 additions & 0 deletions
7
test/fixtures/gcs-output-from-remote-state/env1/app2/variables.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,7 @@ | ||
variable "app1_text" { | ||
type = string | ||
} | ||
|
||
variable "app3_text" { | ||
type = string | ||
} |
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 @@ | ||
terraform { | ||
backend "gcs" {} | ||
} | ||
|
||
output "app3_text" { | ||
value = "app3 output" | ||
} |
3 changes: 3 additions & 0 deletions
3
test/fixtures/gcs-output-from-remote-state/env1/app3/terragrunt.hcl
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 @@ | ||
include { | ||
path = find_in_parent_folders() | ||
} |
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 @@ | ||
# Configure Terragrunt to automatically store tfstate files in a GCS bucket | ||
remote_state { | ||
backend = "gcs" | ||
|
||
config = { | ||
project = "__FILL_IN_PROJECT__" | ||
location = "__FILL_IN_LOCATION__" | ||
bucket = "__FILL_IN_BUCKET_NAME__" | ||
prefix = "${path_relative_to_include()}/terraform.tfstate" | ||
} | ||
} |
Oops, something went wrong.