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
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 mapTerraform 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 valueAll 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 encodedAs 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
This repository is vendored as recomended on Terraform's docs