2

我正在 terragrunt 中部署不同的资源。当我在同一个 terragrunt.hcl 中我需要访问同一个模块中的输出基因时,我遇到了问题。

代码示例:

# Include VPC outputs as this module is a dependency
dependency "vpc" {
  config_path = "../../../vpc"
}

inputs = {
  name = "nginx"

  vpc_id          = dependency.vpc.outputs.vpc_id
  vpc_subnets     = dependency.vpc.outputs.private_subnets
  security_groups = [dependency.sg-redis-access.outputs.id]

  tg_port       = 80
  tg_protocol   = "HTTP"

  service_ecs_cluster_arn                    = dependency.ecs-cluster.outputs.cluster_arn
  service_desired_count                      = 1
  service_deployment_minimum_healthy_percent = 0

  task_definition_execution_role = aws_iam_role.this.arn
  task_definition_container_definitions = templatefile("task_definition.json", {
    name                  = "nginx"
    awslogs_group         = aws_cloudwatch_log_group.this.name
    awslogs_region        = local.region_vars.locals.aws_region
    awslogs_stream_prefix = "nginx"
  })

  tags = merge(local.account_vars.locals.account_tags, local.region_vars.locals.region_tags, {})
}

我需要提取在同一模块中生成的值:

  • aws_iam_role.this.arn
  • aws_cloudwatch_log_group.this.name

例如,访问其他目录中的输出对于dependency我在dependency-中的操作很容易vpc,因为输出位于其他父文件夹中。但是我从来没有遇到过我建议访问同一模块中生成的输出的情况

4

0 回答 0