UPD: sample code for validating default_tags keys
This commit is contained in:
parent
18944c32f0
commit
1d743725cd
@ -91,8 +91,12 @@ resource "aws_eip" "ec2-eip" {
|
|||||||
data "aws_default_tags" "this" {
|
data "aws_default_tags" "this" {
|
||||||
lifecycle {
|
lifecycle {
|
||||||
postcondition {
|
postcondition {
|
||||||
|
# check default_tags size
|
||||||
condition = length(self.tags) >= 1
|
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."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
version = "~> 5.0.0"
|
version = "~> 5.32.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user