简体   繁体   English

Terraform 创建原则时出错

[英]Terraform error while creating principles

I am trying to add principles to my template, below is my code我正在尝试将原则添加到我的模板中,下面是我的代码

variable client_prod {
  default = 123456790123
}

output client_prod {
  value = var.cap_prod
}

variable client_non_prod {
  default = 987654321098
}

output client_non_prod {
  value = var.cap_prod
}

output client_prod_root {
  value = "arn:aws:iam::${var.client_prod}:root"
}

output client_non_prod_root {
  value = "arn:aws:iam::${var.client_non_prod}:root"
}

I am trying to create my principles like this我正在尝试像这样创建我的原则

locals {
  principals = module.common-prefix.isPROD ? list(module.const.client_prod_root):
    list(module.const.client_non_prod_root, module.const.client_prod_root)
}

Later I am going to use it like this稍后我将像这样使用它

jsonencode(distinct(local.principals))

I am getting the following error planning to terraform我收到以下错误计划到 terraform

Error: Argument or block definition required

  on main.tf line 46, in locals:
  46:     list(module.const.client_non_prod_root, module.const.client_prod_root)

What should I do to resolve this?我应该怎么做才能解决这个问题?

You can't break line like that.不能那样断线 It should be one line:它应该是一行:

locals {
  principals = module.common-prefix.isPROD ? list(module.const.client_prod_root): list(module.const.client_non_prod_root, module.const.client_prod_root)
}

or use () :或使用()

locals {
  principals = (module.common-prefix.isPROD ? list(module.const.client_prod_root):
    list(module.const.client_non_prod_root, module.const.client_prod_root))
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 terraform 创建 aks 集群时出现 Hashicorp 提供程序错误 - Getting Hashicorp Provider Error while creating aks cluster using terraform 从 terraform 创建的 pubsub 模式定义错误 - Error in pubsub schema definition creating from terraform 使用 Terraform 在 Azure 上创建 Liquid Map 时出错 - Error creating Liquid Map on Azure with Terraform 使用 terraform 在 aws_vpc 中创建 su.net 时出错 - Error creating subnet in aws_vpc with terraform 使用 terraform 创建 Cloud composer 2 时,显示错误,即无法配置工作负载身份:身份池不存在 - While creating Cloud composer 2 using terraform, it is showing error i.e. Could not configure workload identity: Identity Pool does not exist 为sqs及其访问策略创建terraform代码时出现循环错误 - cycle error when creating terraform code for sqs and its access policy 为 alb 侦听器规则创建动态 Terraform 规则时出错 - Error when creating dynamic terraform rule for alb listener rule 使用 terraform 创建多个实例和一个网络接口时出错 - Error when creating multiple instances and one network interface using terraform 使用 terraform 在 GCP 中创建云功能错误警报策略 - Creating a cloud-function error alerting policy in GCP with terraform 使用 Terraform 创建 StringLike 条件 - Creating a StringLike condition with Terraform
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM