You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
The NX plugin currently passes a bunch of -tfvar arguments, we could instead flip it so our terraform projects read the info from the project.
By default the NX plugin puts config into docs/environments/.md as frontmatter, with a little bit of a hack, we could drop in a file which makes the config available. I'm not sure how to type it though inside terraform.
This would make it easier to 'exit' NX later as well, because it makes the terragrunt commands much simpler.
locals {
# Create a map { "kind--name" => yaml_doc } from the yaml frontmatter text.
# Must use \n---\n to avoid splitting on strings and comments containing "---".
# YAML allows "---" to be the first and last line of a file, so make sure
# raw yaml begins and ends with a newline.
# The "---" can be followed by spaces, so need to remove those too.
# Skip blocks that are empty or comments-only in case yaml began with a comment before "---".
yaml_file = [
for yaml in split(
"\n---\n",
"\n${replace(file("${path.root}/../../../docs/environments/${var.environment_tag}.md"), "/(?m)^---[[:blank:]]*(#.*)?$/", "---")}\n"
) :
yaml
]
frontmatter = local.yaml_file[1]
environment_config = yamldecode(local.frontmatter)
repo_config = jsondecode(file("${path.root}/../../../package.json"))
}
output "environment_config" {
value = local.environment_config
}
output "repo_config" {
value = local.repo_config
}
This would remove the need for nx-vars.tf, but to allow backwards compatibility we can switch from command line args to TF_VAR_ environmental variables because it would work with either approach.
Then instead of var.environment_tag or var.resource_group_id you would local.environment_config.resource_group_id
The text was updated successfully, but these errors were encountered:
The NX plugin currently passes a bunch of -tfvar arguments, we could instead flip it so our terraform projects read the info from the project.
By default the NX plugin puts config into docs/environments/.md as frontmatter, with a little bit of a hack, we could drop in a file which makes the config available. I'm not sure how to type it though inside terraform.
This would make it easier to 'exit' NX later as well, because it makes the terragrunt commands much simpler.
This would remove the need for nx-vars.tf, but to allow backwards compatibility we can switch from command line args to TF_VAR_ environmental variables because it would work with either approach.
Then instead of
var.environment_tag
orvar.resource_group_id
you wouldlocal.environment_config.resource_group_id
The text was updated successfully, but these errors were encountered: