Open davidkelliott opened 2 years ago
Spotted a couple of other tidy up issues related to tags that may be needed too. Will look are removing quotes from around the tag name and replacing https://github.com/ministryofjustice/modernisation-platform with https://github.com/ministryofjustice/modernisation-platform-environments
Not fit for purpose now, parking.
https://github.com/hashicorp/terraform-provider-aws/issues/29842
According to Hashicorp, enhancements to how default tags are supported are due in the next major release of the Terraform AWS provider
This looks relatively straightforward to do now: https://www.hashicorp.com/blog/terraform-aws-provider-5-0-adds-updates-to-default-tags
From a skim, it's as simple as defining the default tags that we already do within a local to the providers.tf
provider block like so:
provider "aws" {
default_tags {
tags = {
environment = "Dev"
department = "WebEng"
application = "HashiCafe website"
cost_center = "8675309"
}
}
}
Further to this, from skimming the docs the use of input variables is also supported here, so this should be as simple as lifting-and-shifting from local.tags
to a default_tags
block, and tidying up code in the repository.
I spent a little time investigating this in example
and found that we'd also need to support this in modules we use. When we apply it to locally-created resources we can see the tags reflected in the tags_all
value when a plan is run. However, this isn't always the case with modules. I saw that with the modernisation-platform-terraform-ecs-cluster
, removing the tags {}
variable didn't result in the default tags being applied.
The light touch approach with this story would be to simply add the default_tags {}
block to the provider statements and reference the local tags inside it.
This issue is stale because it has been open 90 days with no activity.
User Story
As part of keeping track of our infrastructure we can add default tags to AWS providers, this will mean that at if people forget to add tags that at least we can have a few basic tags such as this resource was created in terraform.
Value
Helps to keep track of our infrastructure
Questions / Assumptions
Definition of done
Reference
How to write good user stories