You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the sources of misunderstanding and friction in the Terraform language is type (constraint) mismatch, which is in part because types were added in a later version of HCL/Terraform and - relatedly - because Terraform is still relatively permissive when comparing and converting types.
Here count expects cty.Number and we're passing cty.String, then associate_public_ip_address expects cty.Bool and we're passing cty.String.
In either case the value happens to be convertible to the constraint type (i.e. "0" converts to 0 and "false" converts to false). So this is accepted but does not represent good practice and users should avoid it.
Context
One of the sources of misunderstanding and friction in the Terraform language is type (constraint) mismatch, which is in part because types were added in a later version of HCL/Terraform and - relatedly - because Terraform is still relatively permissive when comparing and converting types.
Wrong Type
Here
ami
has constraint ofcty.String
and we're supplying a function with return type ofcty.List(cty.String)
.Here the
compact
function expects acty.List(cty.String)
but we're supplying acty.Object()
.Convertible Types (bad practice)
Here
count
expectscty.Number
and we're passingcty.String
, thenassociate_public_ip_address
expectscty.Bool
and we're passingcty.String
.In either case the value happens to be convertible to the constraint type (i.e.
"0"
converts to0
and"false"
converts tofalse
). So this is accepted but does not represent good practice and users should avoid it.Proposal
The text was updated successfully, but these errors were encountered: