From 04c498a0358d484ce23f0e49f47ccb7f0dd7d829 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Thu, 19 Feb 2026 16:26:06 -0500 Subject: [PATCH] variable movement --- modules/ec2/data.tf | 8 +++++--- modules/ec2/locals.tf | 9 +++++---- modules/ec2/module_name.tf | 1 + modules/ec2/settings.tf | 2 +- modules/ec2/variables.product.tf | 8 +++++++- modules/ec2/variables.tags.tf | 2 +- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/modules/ec2/data.tf b/modules/ec2/data.tf index 5ed2f8a..c8f6dd6 100644 --- a/modules/ec2/data.tf +++ b/modules/ec2/data.tf @@ -13,6 +13,7 @@ data "aws_vpc" "vpc" { } } +# Get all subnets matching name and VPC ID data "aws_subnets" "subnets" { filter { name = "tag:Name" @@ -24,26 +25,27 @@ data "aws_subnets" "subnets" { } } +# get ids for each subnet for use in provisioning data "aws_subnet" "subnets" { for_each = toset(data.aws_subnets.subnets.ids) id = each.key } -// Get portfolio details if we resolved an ID +# Get portfolio details if we resolved an ID data "aws_servicecatalog_portfolio" "by_id" { count = local.portfolio_id != null ? 1 : 0 id = local.portfolio_id accept_language = var.accept_language } -// Get product details by ID (requires product_id) +# Get product details by ID (requires product_id) data "aws_servicecatalog_product" "by_id" { count = local.product_id != null ? 1 : 0 id = local.product_id accept_language = var.accept_language } -// Get the latest provisioning artifact (product version) +# Get the latest provisioning artifact (product version) data "aws_servicecatalog_provisioning_artifacts" "this" { count = local.product_id != null ? 1 : 0 accept_language = var.accept_language diff --git a/modules/ec2/locals.tf b/modules/ec2/locals.tf index 5a24653..b18cf83 100644 --- a/modules/ec2/locals.tf +++ b/modules/ec2/locals.tf @@ -47,13 +47,14 @@ locals { if value != "" # Only include non-empty values ] - standard_tags = { - ManagedBy = "Terraform" - Module = local.module_name + base_tags = { + "boc:tf_module_name" = local.module_name + "boc:tf_module_version" = local.module_version + "boc:created_by" = "terraform" } tags = merge( - local.standard_tags, + local.base_tags, var.tags ) } \ No newline at end of file diff --git a/modules/ec2/module_name.tf b/modules/ec2/module_name.tf index 87a6a5c..0132a12 100644 --- a/modules/ec2/module_name.tf +++ b/modules/ec2/module_name.tf @@ -1,3 +1,4 @@ locals { module_name = "aws-servicecatalog/ec2" + module_version = "0.0.0" } diff --git a/modules/ec2/settings.tf b/modules/ec2/settings.tf index bd10689..89e24f0 100644 --- a/modules/ec2/settings.tf +++ b/modules/ec2/settings.tf @@ -6,7 +6,7 @@ locals { inc_poc_email = "morga471@example.com" fisma_id = "OCIO_CSVD (CEN16.09)" power_schedule = "Weekday_Core_Hours_7-7" - instance_type = "t3.small" + instance_type = "t3a.small" os_name = "RHEL9" requires_backup = "no" diff --git a/modules/ec2/variables.product.tf b/modules/ec2/variables.product.tf index b1f9981..a6eb533 100644 --- a/modules/ec2/variables.product.tf +++ b/modules/ec2/variables.product.tf @@ -15,9 +15,15 @@ variable "provisioned_product_name" { } variable "project_name" { - description = "Project name (ProjectName parameter)" + description = "Project name (ProjectName parameter) Make sure to select the project designated for your account. The build will fail if an incorrect project is selected. The list of values can be found in the ProjectName parameter of the product's provisioning artifact." type = string default = "" + + validation { + condition = var.project_name == "" || (length(var.project_name) >= 12 && substr(var.project_name, length(var.project_name) - 12, 12) == data.aws_caller_identity.current.account_id) + error_message = "The last 12 digits of project_name must match the AWS account ID" + } + } variable "creator" { diff --git a/modules/ec2/variables.tags.tf b/modules/ec2/variables.tags.tf index 511f276..c1a1c3f 100644 --- a/modules/ec2/variables.tags.tf +++ b/modules/ec2/variables.tags.tf @@ -1,5 +1,5 @@ variable "tags" { - description = "AWS Tags to apply to appropriate resources (S3, KMS). Do not include safeguard tags here, use the data_safeguard field for such things." + description = "AWS Tags to apply to appropriate resources." type = map(string) default = {} } \ No newline at end of file