Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default tags to terraform providers across the modernisation platform #1519

Open
2 tasks
davidkelliott opened this issue Mar 7, 2022 · 8 comments
Open
2 tasks
Labels
Low Priority On hold - but would be good to do

Comments

@davidkelliott
Copy link
Contributor

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

  • default tags added to core repos
  • default tags added to member repos

Reference

How to write good user stories

@davidkelliott davidkelliott added the enhancement New feature or request label Mar 7, 2022
@SteveLinden SteveLinden self-assigned this Sep 26, 2022
@davidkelliott
Copy link
Contributor Author

@SteveLinden SteveLinden moved this from To Do to In Progress in Modernisation Platform Sep 26, 2022
@SteveLinden
Copy link
Contributor

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

@davidkelliott
Copy link
Contributor Author

Not fit for purpose now, parking.

@dms1981 dms1981 moved this from In Progress to Blocked in Modernisation Platform Oct 12, 2022
@seanprivett seanprivett removed the enhancement New feature or request label Jan 31, 2023
@dms1981
Copy link
Contributor

dms1981 commented Apr 27, 2023

hashicorp/terraform-provider-aws#29842

According to Hashicorp, enhancements to how default tags are supported are due in the next major release of the Terraform AWS provider

@SimonPPledger SimonPPledger moved this from Blocked to To Do in Modernisation Platform Aug 31, 2023
@SimonPPledger SimonPPledger changed the title Add default tags to providers across the modernisation platform Add default tags to terraform providers across the modernisation platform Oct 31, 2023
@SimonPPledger SimonPPledger added the Low Priority On hold - but would be good to do label Oct 31, 2023
@SteveLinden SteveLinden removed their assignment Jan 8, 2024
@dms1981
Copy link
Contributor

dms1981 commented Feb 14, 2024

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.

@dms1981
Copy link
Contributor

dms1981 commented Apr 9, 2024

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.

Copy link
Contributor

github-actions bot commented Jul 9, 2024

This issue is stale because it has been open 90 days with no activity.

@github-actions github-actions bot added the Stale label Jul 9, 2024
@github-actions github-actions bot removed the Stale label Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Low Priority On hold - but would be good to do
Projects
Status: To Do
Development

No branches or pull requests

5 participants