From fb6c3710ade473c3faaa9b8ca27f451b85e94c05 Mon Sep 17 00:00:00 2001 From: Christopher Boyd <6323077+cpboyd@users.noreply.github.com> Date: Fri, 31 Jan 2025 18:27:30 -0500 Subject: [PATCH] feat: add aws_account_alias override --- modules/config/alias.tf | 4 ++-- modules/config/variables.tf | 9 +++++++++ modules/configsubscription/alias.tf | 4 ++-- modules/configsubscription/variables.tf | 9 +++++++++ modules/stack/config.tf | 1 + modules/stack/configsubscription.tf | 1 + modules/stack/variables.tf | 2 ++ 7 files changed, 26 insertions(+), 4 deletions(-) diff --git a/modules/config/alias.tf b/modules/config/alias.tf index c5f5ccd..0a90770 100644 --- a/modules/config/alias.tf +++ b/modules/config/alias.tf @@ -1,9 +1,9 @@ data "aws_iam_account_alias" "current" { - count = var.tag_account_alias ? 1 : 0 + count = var.tag_account_alias && var.aws_account_alias == null ? 1 : 0 } locals { tags = var.tag_account_alias ? { - "observeinc.com/accountalias" = data.aws_iam_account_alias.current[0].account_alias + "observeinc.com/accountalias" = var.aws_account_alias == null ? data.aws_iam_account_alias.current[0].account_alias : var.aws_account_alias } : {} } diff --git a/modules/config/variables.tf b/modules/config/variables.tf index 000a27b..8331aad 100644 --- a/modules/config/variables.tf +++ b/modules/config/variables.tf @@ -80,6 +80,15 @@ variable "sns_topic_arn" { nullable = true } +variable "aws_account_alias" { + description = <<-EOF + Override AWS account alias tag. + EOF + type = string + default = null + nullable = true +} + variable "tag_account_alias" { type = bool description = <<-EOF diff --git a/modules/configsubscription/alias.tf b/modules/configsubscription/alias.tf index c5f5ccd..0a90770 100644 --- a/modules/configsubscription/alias.tf +++ b/modules/configsubscription/alias.tf @@ -1,9 +1,9 @@ data "aws_iam_account_alias" "current" { - count = var.tag_account_alias ? 1 : 0 + count = var.tag_account_alias && var.aws_account_alias == null ? 1 : 0 } locals { tags = var.tag_account_alias ? { - "observeinc.com/accountalias" = data.aws_iam_account_alias.current[0].account_alias + "observeinc.com/accountalias" = var.aws_account_alias == null ? data.aws_iam_account_alias.current[0].account_alias : var.aws_account_alias } : {} } diff --git a/modules/configsubscription/variables.tf b/modules/configsubscription/variables.tf index a0d41a2..7d4d0ec 100644 --- a/modules/configsubscription/variables.tf +++ b/modules/configsubscription/variables.tf @@ -14,6 +14,15 @@ variable "name_prefix" { nullable = false } +variable "aws_account_alias" { + description = <<-EOF + Override AWS account alias tag. + EOF + type = string + default = null + nullable = true +} + variable "tag_account_alias" { type = bool description = <<-EOF diff --git a/modules/stack/config.tf b/modules/stack/config.tf index 034486a..11417ab 100644 --- a/modules/stack/config.tf +++ b/modules/stack/config.tf @@ -11,6 +11,7 @@ module "config" { delivery_frequency = var.config.delivery_frequency include_global_resource_types = var.config.include_global_resource_types tag_account_alias = var.config.tag_account_alias + aws_account_alias = var.config.aws_account_alias depends_on = [aws_s3_bucket_notification.this] } diff --git a/modules/stack/configsubscription.tf b/modules/stack/configsubscription.tf index 2cb5441..61c1788 100644 --- a/modules/stack/configsubscription.tf +++ b/modules/stack/configsubscription.tf @@ -6,5 +6,6 @@ module "configsubscription" { target_arn = module.forwarder.queue_arn tag_account_alias = var.configsubscription.tag_account_alias + aws_account_alias = var.configsubscription.aws_account_alias } diff --git a/modules/stack/variables.tf b/modules/stack/variables.tf index f4eb25d..f64054a 100644 --- a/modules/stack/variables.tf +++ b/modules/stack/variables.tf @@ -61,6 +61,7 @@ variable "config" { delivery_frequency = optional(string) include_global_resource_types = optional(bool) tag_account_alias = optional(bool) + aws_account_alias = optional(string) }) default = null } @@ -72,6 +73,7 @@ variable "configsubscription" { type = object({ delivery_bucket_name = string tag_account_alias = optional(bool) + aws_account_alias = optional(string) }) default = null }