Skip to content

Commit

Permalink
updated terragrunt.hcl
Browse files Browse the repository at this point in the history
  • Loading branch information
HariSekhon committed Jun 27, 2024
1 parent 3efa4a7 commit 2029a61
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,28 @@
# $PWD

terraform {

# source your remote module with a couple variables, so you can reuse the code with only this tiny stub
# source is path to Terraform config or modules
#
# the double slash before //app denotes a sub-directory relative to the root of the package:
# the double slash before //app denotes a sub-directory relative to the root of the repo / package:
#
# https://developer.hashicorp.com/terraform/language/modules/sources#modules-in-package-sub-directories
#
# source follows the same syntax as Terraform modules (file, git) except not Terraform registry
#
# https://www.terraform.io/docs/modules/sources.html
#
source = "github.com:HariSekhon/Terraform.git//app?ref=v0.0.1"
# tfr:/// == tfr://registry.terraform.io/
#
# Registry Sources
#
# tfr:/// === $TG_TF_DEFAULT_REGISTRY_HOST if environment variable is set
# or
# tfr:/// === tfr://registry.terraform.io/ - for Terraform
# or
# tfr:/// === tfr://registry.opentofu.org/ - for Opentofu
#
# for private registries define TG_TF_REGISTRY_TOKEN environment variable with the registry API token
#
#source = "tfr:///terraform-aws-modules/vpc/aws?version=3.5.0"

# avoid having to remember to provide -var-file=... args every time to Terraform by specifying them like so
Expand All @@ -59,6 +72,8 @@ terraform {
# cannot contain whitespace, if you need whitespace separated arguments split them
"-var", "bucket=example.bucket.name"
]
# pass a map of environment variables to each terraform command
#env_vars = []
}
extra_arguments "retry_lock" {
commands = get_terraform_commands_that_need_locking()
Expand Down Expand Up @@ -100,9 +115,11 @@ terraform {
# https://terragrunt.gruntwork.io/docs/features/hooks/
#
# can have multiple before_hook or after_hook or different names, they'll execute in the order given
# hooks are run from the module directory except for terragrunt-read-config and init-from-module which are run from terragrunt.hcl directory
before_hook "before_hook" {
commands = ["apply", "plan"]
execute = ["tflint"]
commands = ["apply", "plan"] # commands for which the hook should run
execute = ["tflint"] # command to execute
#working_dir =
}
before_hook "before_hook2" {
commands = ["apply", "plan"]
Expand All @@ -111,7 +128,11 @@ terraform {
after_hook "after_hook" {
commands = ["apply", "plan"]
execute = ["echo", "Finished running Terraform"] # outputs regardless of whether Terraform fails
run_on_error = true
run_on_error = true # run even if previous hooks failed
}
error_hook "error_hook" {
on_errors = [".*"]
execute = ["echo", "A hook failed"] # executes after each 'before_hook' and 'after_hook' if their errors match on_errors regex
}
retryable_errors = [
"(?s).*Error installing provider.*tcp.*connection reset by peer.*",
Expand Down Expand Up @@ -158,7 +179,7 @@ remote_state {
# generate a backend.tf file with this config below
generate = {
path = "backend.tf"
if_exists = "overwrite_terragrunt"
if_exists = "overwrite_terragrunt" # overwrites only if it was generated by Terragrunt. Other options are: overwrite, skip, error
}
config = {
# creates the S3 bucket if not exists, with versioning enabled, server-side encryption and access logging
Expand Down

0 comments on commit 2029a61

Please sign in to comment.