#terragrunt (2020-07)
Terragrunt discussions
Archive: https://archive.sweetops.com/terragrunt/
2020-07-22
Has anyone tried using terragrunt with tf 0.13.x? I’m curious how the module count/each will incorporate w/ terragrunt’s wrapping of tf modules.
Since terragrunt handles module instantiation, rather you than defining module "my_module {
, how would we pass in a count/each?
Presumably by extending https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#terraform to handle count/for_each, but curious if anyone has any details.
2020-07-23
I’ve got Error: No valid credential sources found for AWS Provider.
from yestarday, anyone else has that problem?
Nope.
When tried to migrate terraform code to terraform cloud using a chain of aws cli profiles, which assumes a role, the terraform cloud AWS provider fails to find credentials file, as the same credent…
Ah, you didn’t mention Terraform cloud. Not using that.
downgrading aws.provider from 2.70 to 2.69 solve the issue
# Generate an AWS provider block
generate "provider" {
path = "provider.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
provider "aws" {
region = "${local.vars.aws_region}"
profile = "${local.aws_profile}"
version = "<= 2.69"
# Only these AWS Account IDs may be operated on by this template
# allowed_account_ids = ["${local.vars.aws_account_id}"]
}
EOF
}
and I’m using local terraform/terragrunt setup
@som.ban.mca has joined the channel
2020-07-27
hey all, just starting the journey with terragrunt, I have a look around, however cant find any great example repo’s that are using gcp and have a gcs as the backend, anyone have any good examples to share?
Strategy defined and poc working… happy to help anyone who has similar starting out
questions
hi, i am getting started with terragrunt. do you mind sharing what helped you? thanks!
2020-07-28
2020-07-29
Do you find it difficult to search through official terragrunt documentation ? When it was on git I could just ctrl+f easily, and find what I need in second.
yes this is the resource i used
2020-07-30
back again I’m trying to get a clean way to pass in a project var into the provider, as im splitting out my infrastructure across projects.
has anyone done this before… this is in google cloud btw
this is what i currently have
generate "provider" {
path = "provider.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
provider "google" {
credentials = "account.json"
region = "europe-west2"
project = ${gcp_project}
}
EOF
}
remote_state {
backend = "gcs"
config = {
project = "${gcp_project}"
location = "eu"
bucket = "bucket_name"
prefix = "${path_relative_to_include()}/terraform.tfstate"
credentials = "account.json"
gcs_bucket_labels = {
owner = "terragrunt_test"
name = "terraform_state_storage"
}
}
generate = {
path = "backend.tf"
if_exists = "overwrite_terragrunt"
}
}
error is allong these lines
terragrunt-gcp-infra/terragrunt.hcl:33,19-30: Unknown variable; There is no variable named "gcp_project"., and 2 other diagnostic(s)
how is it that you are wanting to pass the value for gcp_project
?
at this stage in processing, you can read it from a yaml/json file, or pass it through an env
thanks for prompt response.. i was looking to pass it in with a local var file within the module
as in, a terraform variable?
for example this would be within the terragrunt.hcl for the module
locals {
# Automatically load environment-level variables
environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
# Extract out common variables for reuse
env = local.environment_vars.locals.environment
project_gcp = local.environment_vars.locals.project_gcp
}
this would be the env.hcl file referenced
ahh, then you have it already. for locals, terragrunt uses the same syntax as terraform, so instead of:
project = ${gcp_project}
use:
project = ${local.gcp_project}
or actually, because this is hcl2 and we do not need the interpolation syntax for this use case:
project = local.gcp_project
awesome, thanks @loren i will give it a go!