terragruntArchived
19 messages
Terragrunt discussions
Archive: https://archive.sweetops.com/terragrunt/
Phucover 6 years ago
Hi guys
Phucover 6 years ago
Is there anyway I can use terragrunt.hcl with a module that contains a module inside it ?
Phucover 6 years ago
for example:
In the terragrunt.hcl
The module custom_ecs_cluster main.tf's content:
In the terragrunt.hcl
terraform_version_constraint = "<0.12"
include {
path = find_in_parent_folders()
}
terraform {
source = "git::<ssh://xxx/custom_ecs_cluster.git?ref=terraform_0.11>"
}
inputs = {
name = "xxx"
profile = "xxx"
region = "xxx"
}
The module custom_ecs_cluster main.tf's content:
module "aws_ecs_cluster" {
source = "git::<ssh://xxx:aws-ecs-cluster.git?ref=terraform_0.11>"
Phucover 6 years ago(edited)
also, does anyone know how to transfer output of other dependency as list value ?
as I declare the output in the module and testing with showing output successfully.But when running the terragrunt apply.
it keep show the error as " Underlying error: invalid primitive type name "list"
example:
as I declare the output in the module and testing with showing output successfully.But when running the terragrunt apply.
it keep show the error as " Underlying error: invalid primitive type name "list"
example:
dependency "vpc" {
config_path = "../vpc"
}
terraform_version_constraint = "<0.12"
include {
path = find_in_parent_folders()
}
terraform {
source = "git::<ssh://git@devel.redcrane.tech/redcrane/sandbox/terraform-modules/linux-bastion.git?ref=staging>"
}
inputs = {
profile = "xxx-sg1"
region = "ap-southeast-1"
name = "xxx"
environment = "staging"
number_hosts = "1"
instance_type = "t2.micro"
key_name = "xxx-staging"
security_groups [dependency.vpc.outputs.sg_id] <== this part is that allowed ? Or is there anyway that I can parse the output as list value to this
}
antonbabenkoover 6 years ago
You can use functions like
list() or element() inside of inputs to modify as what you want from the outputs.M
Milos Backonjaover 6 years ago(edited)
Hi Guys, Should this create tags for backend resoruces (dynamodb and s3)? s3 and dynamodb are created with terragrunt, but without tags
Todd Lyonsover 6 years ago
Possibly a dumb question: I import aws resources that were manually created into terraform configs, and generally have gotten decent at it. (It helps that the latest
1. New resources: use terragrunt and terraform modules for all new resources.
2. Existing resources: use straight terraform when need to import existing infrastructure.
3. New resources: terragrunt is acceptable when work flow is to create and destroy resources but without service disruption.
terraform state show prints things out in hcl format.) The concept of importing things into terragrunt seems nearly impossible to get right. Would I be off base for settling on this:1. New resources: use terragrunt and terraform modules for all new resources.
2. Existing resources: use straight terraform when need to import existing infrastructure.
3. New resources: terragrunt is acceptable when work flow is to create and destroy resources but without service disruption.
SimonWover 6 years ago(edited)
I've started to test out terragrunt to separate my terraform modules from my configuration-data and really like it so far but I have one thing I can't figure out.
I have one repo with only folders and terragrunt.hcl files, looks similar to this:
I'm configuring remote state in each root config (this works great!)
Now I want to send different config for the provider in DEV vs PROD.
I'm using the azurerm provider and I want to set the subscription_id parameter per environment.
Each generic module has a provider config in main.tf that looks like this:
The azurerm provider has a parameter called [subscription_id](https://www.terraform.io/docs/providers/azurerm/index.html#subscription_id)
Is there a way I can configure subscription_id for the provider in each "root" configuration file?
I've tried to add an input block to my root file like this:
but it seems to have no effect.
Is this possible? Am I doing it wrong? Do I have to use a hook instead?
(Sorry for the multiple edits, apparently I suck at Slack)
I have one repo with only folders and terragrunt.hcl files, looks similar to this:
DEV
- terragrunt.hcl <--- "root" config file only to be inherited by children
- RG
- terragrunt.hcl <--- child config that uses generic module "RG" as source
- Compute
- terragrunt.hcl <--- child config that uses generic module "Compute" as source
- Network
- terragrint.hcl <--- child config that uses generic module "Network" as source
PROD
- terragrunt.hcl <--- "root" config file only to be inherited by children
- RG
- terragrunt.hcl <--- child config that uses generic module "RG" as source
- Compute
- terragrunt.hcl <--- child config that uses generic module "Compute" as source
- Network
- terragrint.hcl <--- child config that uses generic module "Network" as source
I'm configuring remote state in each root config (this works great!)
Now I want to send different config for the provider in DEV vs PROD.
I'm using the azurerm provider and I want to set the subscription_id parameter per environment.
Each generic module has a provider config in main.tf that looks like this:
provider "azurerm" {
version = ">= 1.1.0"
}
The azurerm provider has a parameter called [subscription_id](https://www.terraform.io/docs/providers/azurerm/index.html#subscription_id)
Is there a way I can configure subscription_id for the provider in each "root" configuration file?
I've tried to add an input block to my root file like this:
inputs = {
subscription_id = "dc15404b-802b-4e2e-a22a-c772807b1c1d"
}
but it seems to have no effect.
Is this possible? Am I doing it wrong? Do I have to use a hook instead?
(Sorry for the multiple edits, apparently I suck at Slack)
SimonWover 6 years ago
Not sure if this is the place to ask or if I should open an Issue on github
lorenover 6 years ago
I've used hooks for this type of workflow, keeping the provider .tf config in a parent directory and copying the provider config into the terragrunt working dir on the fly. I'm on my phone right now so can't get you an example easily. Maybe @antonbabenko has something handy he can share...
lorenover 6 years ago
Actually, we had a convo about this in this channel not long ago... start reading from here... https://sweetops.slack.com/archives/CDMJ4BBR8/p1567775756001800
antonbabenkoover 6 years ago
I donโt have possibility to help more (traveling now), but you can use env variables to set subscription ids based on folder you run terrafgrunt at (eg, using direnv).
antonbabenkoover 6 years ago
Either using ARM_SUBSCRIPTION_ID (or how azure provider expects it) or using TF_VAR_foobar and use $var.foobar in provider block. And, as @loren said, I also rely on hooks to copy that one from central place. Unfortunately, thee is still an open issue 785.
SimonWover 6 years ago
Thanks for the pointers! I'll read up on the previous conversation and issue 785!
I was hoping there was a similar solution for provider as there are for remote-state where I could have an empty provider block in my module that would be merged/overwritten with whats in the .hcl
I was hoping there was a similar solution for provider as there are for remote-state where I could have an empty provider block in my module that would be merged/overwritten with whats in the .hcl
lorenover 6 years ago
That would be awesome
Valentin LANDEMAINEover 6 years ago
Hello everybody, I have a question : Have you ever used the inputs in Terragrunt from dependencies with a list ?
Valentin LANDEMAINEover 6 years ago
I feel that this form : dependency.mydependency.outputs.mylist[0] does not work
Phucover 6 years ago
Hi Valentin, we met that issue before. And it's very trouble to achieve that. Unless terragrunt comes up with the new advance feature. For now, to pass output, we use mostly :
- data source
- remote tfstate
- data source
- remote tfstate
Valentin LANDEMAINEover 6 years ago
Hi Phuc, thanks for your reply. I found the issue, the form dependency.mydependency.outputs.mylist[0] is working. The issue was the output format of my modules [data.myoutput] to data.myoutput fix this issue.