Skip to content

Commit

Permalink
variable movement
Browse files Browse the repository at this point in the history
  • Loading branch information
morga471 committed Feb 19, 2026
1 parent db212d8 commit 04c498a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
8 changes: 5 additions & 3 deletions modules/ec2/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data "aws_vpc" "vpc" {
}
}

# Get all subnets matching name and VPC ID
data "aws_subnets" "subnets" {
filter {
name = "tag:Name"
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions modules/ec2/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
1 change: 1 addition & 0 deletions modules/ec2/module_name.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
locals {
module_name = "aws-servicecatalog/ec2"
module_version = "0.0.0"
}
2 changes: 1 addition & 1 deletion modules/ec2/settings.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 7 additions & 1 deletion modules/ec2/variables.product.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
2 changes: 1 addition & 1 deletion modules/ec2/variables.tags.tf
Original file line number Diff line number Diff line change
@@ -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 = {}
}

0 comments on commit 04c498a

Please sign in to comment.