terragrunt
terragrunt copied to clipboard
Dependency is taking mock instead of output during apply
I developed two modules:
REQUIRED_CAD terragrunt.hcl:
locals {
region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
aws_region = local.region_vars.locals.aws_region
}
dependency "sns" {
config_path = "${get_terragrunt_dir()}/../../../config-sns"
mock_outputs_allowed_terraform_commands = ["plan"]
mock_outputs = {
sns_role_arn = "mock"
}
}
terraform {
source = "${get_terragrunt_dir()}/../modules/rules/REQUIRED_CAD"
}
include {
path = find_in_parent_folders()
}
inputs = {
aws_region = local.region_vars.locals.aws_region
output_role_arn = dependency.sns.outputs.sns_role_arn
output_path = abspath("${get_parent_terragrunt_dir()}/../build/cad_lambda.zip")
}
CONFIG_SNS terragrunt.hcl:
terraform {
source = "${get_terragrunt_dir()}}/../modules/sns/"
}
include {
path = find_in_parent_folders()
}
resource.tf:
resource "aws_config_remediation_configuration" "rule-required-cad" {
config_rule_name = aws_config_config_rule.rule-required-cad.name
target_id = "AWS-PublishSNSNotification"
target_type = "SSM_DOCUMENT"
parameter {
name = "TopicArn"
static_value = var.output_role_arn #GET FROM DEPENDENCY NO DEFAULT VALUE
}
...
}
REQUIRED_CAD requires output from the SNS module which is SNS topic ARN.
terragrunt run-all plan
Changes to Outputs:
+ sns_role_arn = (known after apply)
# aws_config_remediation_configuration.rule-required-cad will be created
+ resource "aws_config_remediation_configuration" "rule-required-cad" {
+ arn = (known after apply)
...
+ parameter {
+ name = "TopicArn"
+ static_value = "mock"
}
}
terragrunt run-all apply
is not replacing "mock" with real value from module output.
Added: disable_dependency_optimization = true
without change. Apply command still is getting mock.
Hi, the execution was performed in a clean state or with existing state? It can be that value is loaded from the existing state