Hello,
I’m building a module and attempting to use optional arguments for variables. Based on all of the documentation that I’ve reviewed, I believe that my variable configuration should be functional. However, if the optional arguments are omitted, the provider raises an error that they are required.
variable "metric_configuration" {
type = list(object({
name = string
filter = optional(object({
prefix = optional(string)
tags = optional(map(string))
}))
}))
description = "Metric Configuration"
default = []
}
# from the calling module:
metric_configuration = [{
name = "EntireBucket"
}]
Here is the error with debug logging:
2023-12-20T10:00:22.763-0600 [ERROR] provider.terraform-provider-aws_v4.67.0_x5: Response contains error diagnostic: diagnostic_detail="\"filter.0.prefix\": one of `filter.0.prefix,filter.0.tags` must be specified" diagnostic_attribute="AttributeName(\"filter\").ElementKeyInt(0).AttributeName(\"prefix\")" tf_proto_version=5.3 tf_req_id=35854cf0-ea83-ae66-b073-625692549bd7 tf_resource_type=aws_s3_bucket_metric diagnostic_severity=ERROR @caller=github.com/hashicorp/terraform-plugin-go@v0.15.0/tfprotov5/internal/diag/diagnostics.go:55 diagnostic_summary="Missing required argument" tf_provider_addr=registry.terraform.io/hashicorp/aws tf_rpc=ValidateResourceTypeConfig @module=sdk.proto timestamp=2023-12-20T10:00:22.762-0600
2023-12-20T10:00:22.763-0600 [ERROR] provider.terraform-provider-aws_v4.67.0_x5: Response contains error diagnostic: diagnostic_summary="Missing required argument" @caller=github.com/hashicorp/terraform-plugin-go@v0.15.0/tfprotov5/internal/diag/diagnostics.go:55 tf_req_id=35854cf0-ea83-ae66-b073-625692549bd7 diagnostic_detail="\"filter.0.tags\": one of `filter.0.prefix,filter.0.tags` must be specified" diagnostic_severity=ERROR tf_proto_version=5.3 tf_provider_addr=registry.terraform.io/hashicorp/aws tf_resource_type=aws_s3_bucket_metric tf_rpc=ValidateResourceTypeConfig @module=sdk.proto diagnostic_attribute="AttributeName(\"filter\").ElementKeyInt(0).AttributeName(\"tags\")" timestamp=2023-12-20T10:00:22.762-0600
Do I need to modify my variable configuration? Thanks for any assistance.