From 954c0c99d54bea3b1fb61d29e80d97645950d62c Mon Sep 17 00:00:00 2001 From: Chris Banks Date: Fri, 20 Aug 2021 16:20:32 +0100 Subject: [PATCH] Add some default tags to the AWS resources for the EKS cluster. This adds some of the tags from the [tagging guide] from the previous ECS project. I've omitted `chargeable_entity` and `environment` because those might need a bit of a rethink in light of the switch to Kubernetes. (For example is the "environment" the same thing from an infrastructure perspective as it is from the cluster-user/developer/application perspective?) The idea here is really just to define a place to put the common tags so that we continue to set them in the right way. Using [provider default tags] (relatively new feature) is now the cleanest way to do this. Thanks to @kerin for the suggestion of using provider default tags. One caveat is that the default tags aren't propagated to ASGs, so this doesn't currently tag the node pool ASG. Passing the same set of tags to the `eks` module in order to tag the ASG doesn't work, because the TF provider unhelpfully forbids individual resources from overriding provider-specific tags because of a design limitation of TF. (See https://github.com/hashicorp/terraform-provider-aws/issues/19204.) [tagging guide]: https://github.com/alphagov/govuk-infrastructure/blob/main/terraform/docs/tagging-guide.md [provider default tags]: https://www.hashicorp.com/blog/default-tags-in-the-terraform-aws-provider --- terraform/deployments/cluster-infrastructure/main.tf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/terraform/deployments/cluster-infrastructure/main.tf b/terraform/deployments/cluster-infrastructure/main.tf index b8058e0b0..d54c8be50 100644 --- a/terraform/deployments/cluster-infrastructure/main.tf +++ b/terraform/deployments/cluster-infrastructure/main.tf @@ -11,6 +11,13 @@ terraform { provider "aws" { region = "eu-west-1" + default_tags { + tags = { + project = "replatforming" + repository = "govuk-infrastructure" + terraform_deployment = basename(abspath(path.root)) + } + } } module "eks" {