For azure cdn i’m excpecting to add rule engine/delivery rules ,so here in one of the block called request_scheme_condition contains two arguments are match_value & operator here match_value is expecting list of strings and operator is expecting string only.
variable "delivery_rules" {
default = {
name = "test"
order = 1
request_scheme_condition = {
match_value = ["HTTP"]
operator = "Equal"
}
}
type = object(
{
name = string
order = number
request_scheme_condition = map(list(string))
}
)
}
error:
│ Error: Invalid default value for variable
│
│ on variables.tf line 92, in variable "delivery_rules":
│ 92: default = {
│ 93: name = "test"
│ 94: order = 1
│ 95: request_scheme_condition = {
│ 96: match_value = "HTTP"
│ 97:
│ 98: operator = "Equal"
│ 99: }
│ 100: }
│
│ This default value is not compatible with the variable's type constraint: attribute "request_scheme_condition": element "
2
Answers
Instead of
map(list(string))
you need object again:I also got the same error when I run your terraform code in my environment as shown:
Cause is: The map type in Terraform is collection and all elements of a collection must always be of the same type.
As your variable has several types for distinct fields, map(list(string)) will not work.
I made a few changes to your script and was able to properly initialize the terraform with
terraform init
.Output:
Check to know the Type constraints in Terraform.