diff --git a/modules/compute/security-groups/main.tf b/modules/compute/security-groups/main.tf index 189a435..be6bc55 100644 --- a/modules/compute/security-groups/main.tf +++ b/modules/compute/security-groups/main.tf @@ -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 diff --git a/modules/compute/security_group/main.tf b/modules/compute/security_group/main.tf index 136c277..590eb9b 100644 --- a/modules/compute/security_group/main.tf +++ b/modules/compute/security_group/main.tf @@ -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