/terraform-data-env

Primary LanguageHCLMIT LicenseMIT

Terraform data env

This module is created to expose the module versions in a Terraform run.

The epp0/environment provider is used to allow you to go splunking through run and environment data.

The main contribution, is a use of the terraform local resource to pull the ./terraform/modules/modules.json file content as json data that can be utilised with policy enforcement and other features.

Usage

see examples folder and default example

Sentinel usage

the data is exposed as an out put in mock-tfstate-v2.sentinel

outputs = {
    ...
"modules_json": {
		"name":      "modules_json",
		"sensitive": false,
		"value": {
			"Modules": [
                ...
				{
					"Dir":     ".terraform/modules/helloworld",
					"Key":     "helloworld",
					"Source":  "registry.terraform.io/briancain/helloworld/aws",
					"Version": "2020.4.21",
				},

while the mock-tfconfig-v2.sentinel only shows the constraint not the actual module

module_calls = {
...
        "source":             "briancain/helloworld/aws",
		"version_constraint": "> 2020.3",
	},

worth noting the raw data is also available in the local resource which parses the file, but that is a much more complex structure to operate over.

Authors

Currently maintained by these contributors.

License

MIT License. See LICENSE for full details.

Requirements

Name Version
terraform >= 1.5
environment 1.3.4

Providers

Name Version
environment 1.3.4
local 2.4.0
terraform n/a

Modules

Name Source Version
helloworld briancain/helloworld/aws 2020.4.21

Resources

Name Type
terraform_data.test resource
environment_variables.all data source
local_file.modules_json data source

Inputs

No inputs.

Outputs

Name Description
environment_data_all All environment variables, derived from Epp0/environment provider
modules_json The content of the modules.json file