Home > database >  Terraform error while creating principles
Terraform error while creating principles

Time:09-29

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?

CodePudding user response:

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