简体   繁体   中英

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

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))
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM