Skip to content

[Feature]: Autocorrect values #686

@skyzyx

Description

@skyzyx

What functionality would you like to see?

AWS only has free-form tags for keys/values. Your organization might have a type tag that expects a freeform value, but spelled correctly. But because of typos, laziness, or a field of f***s being bare, you might end up with:

  • type = Applicatoin
  • type = Aplication
  • type = Applucation
  • type = app

This can cause inconsistencies when trying to report on resources, costs, and other things.

The idea here is something like:

variable "app_tag" {
  description = "The name of your application tag."
  type = string
}

locals {
  allowed_tag_names = ["Application", "Platform", "DevTeam", "OpsTeam", "Account"]
}

tags_module = {
  type = provider::corefunc::autocorrect(var.app_tag, local.allowed_tag_names)
}

Using the tag value as input, and a list of valid responses as input, this function would compare the value to the list and return the value from the list that is the closest match. Think of it like autocorrect, autotune, "did you mean…?".

Why wouldn't I just use variable validation blocks?

If you can, you should. But the more complex your code gets, things like this don't always follow the golden path. This is intended to help snap a value back to its corrected self.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions