UPD: sample code for validating default_tags keys

This commit is contained in:
xpk 2024-01-31 09:20:53 +08:00
parent 18944c32f0
commit 1d743725cd
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
2 changed files with 6 additions and 2 deletions

View File

@ -91,8 +91,12 @@ resource "aws_eip" "ec2-eip" {
data "aws_default_tags" "this" {
lifecycle {
postcondition {
# check default_tags size
condition = length(self.tags) >= 1
error_message = "Validation failed: Provider default_tags not set."
error_message = "Provider default_tags not set."
# to check for specific keys
# condition = alltrue([for t in ["CostCenter", "Owner", "Project", "Application", "DynamicAddressGroup", "Environment"] : contains(keys(self.tags), t)])
# error_message = "Required tag(s) not set in provider default tags."
}
}
}

View File

@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0.0"
version = "~> 5.32.0"
}
}
}