Hi TF forum
I am trying to create some policies on openPolicyAgent related to Terraform so I need to convert the plan into a plan json which is created with the terraform show -json command.
If I have this on the providers.tf file:
provider "aws" {
default_tags {
tags = {
BusinessUnit = "Risk"
Tribe = "Cash Management"
Project = "risk-api"
CostCenter = "123456"
}
}
}
I get the below json
"configuration": {
"provider_config": {
"aws": {
"name": "aws",
"full_name": "registry.terraform.io/hashicorp/aws",
"version_constraint": "~> 5.70.0",
"expressions": {
"default_tags": [
{
"tags": {
"constant_value": {
"BusinessUnit": "Risk",
"CostCenter": "123456",
"Project": "risk-api",
"Tribe": "Cash Management"
}
}
}
]
}
}
},
But the monent I put in the defaults_tags a variable sustitution (var.xxxxx)
provider "aws" {
default_tags {
tags = {
BusinessUnit = "Risk"
Tribe = "Cash Management"
Project = "risk-api"
CostCenter = "123456"
Dop = var.dop_tag
}
}
}
I just get below json conversion … as you see now the static values are hidden and only the var.xxxxxx is shown.
"provider_config": {
"aws": {
"name": "aws",
"full_name": "registry.terraform.io/hashicorp/aws",
"version_constraint": "~> 5.70.0",
"expressions": {
"default_tags": [
{
"tags": {
"references": [
"var.dop_tag"
]
}
}
]
}
}
},
The static values will ONLY be seen on the resources you create on the tags_all section (together with the dynamic value), so there is only one place the static values can be check.
I would love to get some advice …. What I am looking for is to enforce users to add specific tags (CostCenter) to their default_tags (so they are sync to ALL the resouces they create - and we can charge them on those resource created). If static values are hidden (we have some other dynamic values added to the default_tags) I can never know if the CostCenter was added to the default_tags unless I check specific resources which they might be or might not be deploy …. so it is a bit awkards just the sudden hidden of the static values when var.xxxx is use in the default_tags.
Sentinel is out of the question since open policy agent was the tchnology that was choosen.
Many Thanks
Jo