You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
packer/website/content/partials/datasources/local-dependency-limitation...

43 lines
1.0 KiB

At this present time the use of locals within data sources such as the example below is not supported.
```hcl
locals {
cloud_owners = ["happycloud"]
cloud_base_filter_name = "cloud-hvm-2.0.*-x86_64-gp2"
}
data "happycloud" "happycloud-linux2-east" {
filters = {
name = local.cloud_base_filter_name
}
most_recent = true
owners = local.cloud_owners
}
```
Locals can reference data sources but data sources can not reference locals to avoid cyclic dependencies, where a local
may reference a data source that references the same local or some other locals variable. The preferred method, at this time,
for referencing user input data within a data source is to use the `variable` block.
```hcl
variable "cloud_base_filter_name" {
type = string
default = "cloud-hvm-2.0.*-x86_64-gp2"
}
variable "cloud_owners" {
type = string
default = "happycloud"
}
data "happycloud" "happycloud-linux2-east" {
filters = {
name = var.cloud_base_filter_name
}
most_recent = true
owners = var.cloud_owners
}
```