I wanted to ask if anyone knew how to handle with terragrunt the phantom vpc’s that are created when the apply goes wrong
below i post some pictures so you can have more ideas
eip limit’s because terragrunt create 2 clone of equal vpc
now i delete the vpc clone, but terragrunt create 2 istance of sandbox-eu-west-1-…
folder organization
<code>sandbox
│ ├── common.tfvars
│ ├── eu-west-1
│ │ ├── ecs-cluster
│ │ │ └── terragrunt.hcl
│ │ ├── ecs-service
│ │ │ └── terragrunt.hcl
│ │ ├── regional.tfvars
│ │ ├── s3-static-website
│ │ │ └── terragrunt.hcl
│ │ └── vpc
│ │ └── terragrunt.hcl
│ └── terragrunt.hcl
</code>
<code>sandbox
│ ├── common.tfvars
│ ├── eu-west-1
│ │ ├── ecs-cluster
│ │ │ └── terragrunt.hcl
│ │ ├── ecs-service
│ │ │ └── terragrunt.hcl
│ │ ├── regional.tfvars
│ │ ├── s3-static-website
│ │ │ └── terragrunt.hcl
│ │ └── vpc
│ │ └── terragrunt.hcl
│ └── terragrunt.hcl
</code>
sandbox
│ ├── common.tfvars
│ ├── eu-west-1
│ │ ├── ecs-cluster
│ │ │ └── terragrunt.hcl
│ │ ├── ecs-service
│ │ │ └── terragrunt.hcl
│ │ ├── regional.tfvars
│ │ ├── s3-static-website
│ │ │ └── terragrunt.hcl
│ │ └── vpc
│ │ └── terragrunt.hcl
│ └── terragrunt.hcl
root code
<code>locals {
rel_path = get_path_from_repo_root()
environment = split("/", local.rel_path)[1]
common_vars = jsondecode(read_tfvars_file(find_in_parent_folders("common.tfvars")))
regional_vars = jsondecode(read_tfvars_file(find_in_parent_folders("regional.tfvars")))
aws_profile = get_env("AWS_PROFILE", "${local.environment}")
cluster_name = get_env("AWS_CLUSTER_NAME", "${local.environment}-terragrunt")
tfvars = merge(merge(local.common_vars, {region = get_env("AWS_REGION", split("/", local.rel_path)[2])}),local.regional_vars)
}
remote_state {
backend = "s3"
disable_init = tobool(get_env("TERRAGRUNT_DISABLE_INIT", "false"))
generate = {
path = "_backend.tf"
if_exists = "overwrite"
}
...
generate "main_providers" {
path = "main_providers.tf"
if_exists = "overwrite"
contents = <<EOF
...
</code>
<code>locals {
rel_path = get_path_from_repo_root()
environment = split("/", local.rel_path)[1]
common_vars = jsondecode(read_tfvars_file(find_in_parent_folders("common.tfvars")))
regional_vars = jsondecode(read_tfvars_file(find_in_parent_folders("regional.tfvars")))
aws_profile = get_env("AWS_PROFILE", "${local.environment}")
cluster_name = get_env("AWS_CLUSTER_NAME", "${local.environment}-terragrunt")
tfvars = merge(merge(local.common_vars, {region = get_env("AWS_REGION", split("/", local.rel_path)[2])}),local.regional_vars)
}
remote_state {
backend = "s3"
disable_init = tobool(get_env("TERRAGRUNT_DISABLE_INIT", "false"))
generate = {
path = "_backend.tf"
if_exists = "overwrite"
}
...
generate "main_providers" {
path = "main_providers.tf"
if_exists = "overwrite"
contents = <<EOF
...
</code>
locals {
rel_path = get_path_from_repo_root()
environment = split("/", local.rel_path)[1]
common_vars = jsondecode(read_tfvars_file(find_in_parent_folders("common.tfvars")))
regional_vars = jsondecode(read_tfvars_file(find_in_parent_folders("regional.tfvars")))
aws_profile = get_env("AWS_PROFILE", "${local.environment}")
cluster_name = get_env("AWS_CLUSTER_NAME", "${local.environment}-terragrunt")
tfvars = merge(merge(local.common_vars, {region = get_env("AWS_REGION", split("/", local.rel_path)[2])}),local.regional_vars)
}
remote_state {
backend = "s3"
disable_init = tobool(get_env("TERRAGRUNT_DISABLE_INIT", "false"))
generate = {
path = "_backend.tf"
if_exists = "overwrite"
}
...
generate "main_providers" {
path = "main_providers.tf"
if_exists = "overwrite"
contents = <<EOF
...
I expect that when terragrunt goes into error it will try to use the same vpc already created so that there are no clones
2