UPD: added default_tags validation

This commit is contained in:
xpk 2023-11-23 17:00:16 +08:00
parent fc88634341
commit c3b62a163b
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
2 changed files with 9 additions and 5 deletions

View File

@ -3,10 +3,7 @@ resource "aws_security_group" "sg" {
name = var.security-groups[count.index].name
description = var.security-groups[count.index].description
vpc_id = var.vpc-id
tags = merge(
var.tags,
{Name = var.security-groups[count.index].name}
)
tags = { Name = var.security-groups[count.index].name }
}
// see https://www.terraform.io/docs/configuration/functions/flatten.html

View File

@ -1,4 +1,11 @@
data aws_default_tags this {}
data "aws_default_tags" "this" {
lifecycle {
postcondition {
condition = length(self.tags) >= 1
error_message = "Validation failed: Provider default_tags not set."
}
}
}
resource "aws_security_group" "sg" {
name = var.name