Reputation: 14199
I am creating a tf module to abstract some of the launch darkly configuration in terraform.
I have defined one of my modules variables as feature_flags
which essentially is a map
of launchdarkly_feature_flag
resources.
At the moment I am to manually provide type safety to this variable, however I was wondering if there was a way of passing a type from the launchdarkly_provider.
# now | # expected
|
| variable "feature_flags" {
variable "feature_flags" { | type = map(launchdarkly_feature_flags)
type = map(any) | }
} |
Upvotes: 0
Views: 471
Reputation: 3238
As far as I know what you’re looking for is not possible using Terraform. One of the reasons I guess is that Terraform’s type system is not complex enough to fully represent a resource, some arguments (e.g. blocks, provider
, or lifecycle configuration) cannot be expressed using the current type system. If you’re willing to go down a rabbit hole however, you may be more strict about what you accept by defining a more stricter type:
variable "feature_flags" {
type = map(object({
description = optional(string)
tags = optional(map(string))
temporary = optional(bool)
# etc.
}))
}
Upvotes: 0