terraform error: unsupported argument in module in tf plan

2.4k views Asked by At

I am getting the Error: Unsupported argument, when I run terraform plan in version 12.24.

Error: Unsupported argument

  on .terraform/modules/admin_portal.cf_portal/modules/aws-terraform-cloudfront_s3_origin/main.tf line 60, in resource "aws_cloudfront_distribution" "cf_distribution":
  60:   logging_config = local.bucket_logging[local.bucket_logging_config]

An argument named "logging_config" is not expected here. Did you mean to
define a block of type "logging_config"?

Code in tf file:

  logging_config = local.bucket_logging[local.bucket_logging_config]

how do I fix it?

1

There are 1 answers

0
Derek Menénedez On BEST ANSWER
variable "logging" {
  default = local.bucket_logging[local.bucket_logging_config]
}

After that you can use that with var.logging on any statement

But I recommend you use the local. when you need inside the statements and not to put in a var.