This provider implements data sources that can be used to perform hierachical data lookups with Hiera.
This is useful for providing configuration values in an environment with a high level of dimensionality or for making values from an existing Puppet deployment available in Terraform.
It's based on Terraform hiera provider and SmilingNavern's fork
- Clean implementation based on Terraform Plugin SDK
- Clean API implementatation based on Lyra's Hiera in golang
- Painless migration from Terraform hiera provider, keeping around some naming and data sources
- Terraform 0.12.x
To configure the provider:
provider "hiera5" {
# Optional
config = "~/hiera.yaml"
# Optional
scope = {
environment = "live"
service = "api"
# Complex variables are supported using pdialect
facts = "{timezone=>'CET'}"
}
# Optional
merge = "deep"
}
This provider only implements data sources.
To retrieve a hash:
data "hiera5_hash" "aws_tags" {
key = "aws_tags"
}
The following output parameters are returned:
id
- matches the keykey
- the queried keyvalue
- the hash, represented as a map
Terraform doesn't support nested maps or other more complex data structures. Any keys containing nested elements won't be returned.
To retrieve an array:
data "hiera5_array" "java_opts" {
key = "java_opts"
}
The following output parameters are returned:
id
- matches the keykey
- the queried keyvalue
- the array (list)
To retrieve any other flat value:
data "hiera5" "aws_cloudwatch_enable" {
key = "aws_cloudwatch_enable"
}
The following output parameters are returned:
id
- matches the keykey
- the queried keyvalue
- the value
All values are returned as strings because Terraform doesn't implement other types like int, float or bool. The values will be implicitly converted into the appropriate type depending on usage.
To retrieve anything JSON encoded:
data "hiera5_json" "aws_tags" {
key = "aws_tags"
}
The following output parameters are returned:
id
- matches the keykey
- the queried keyvalue
- the returned value, JSON encoded
As Terraform doesn't support nested maps or other more complex data structures this data source makes perfect fit dealing with complex values.
Take a look at test-fixtures
- Julien Andrieux for writting Go tools and GitLab: How to do continuous integration like a boss, a really good starting point.
- Go 1.14+
This repository is vendored as recomended on Terraform's docs
- Support overriding merge strategy in Data Sources
- Support overriding scope variables in Data Sources