diff --git a/common/defaults.tf b/common/defaults.tf index cd94076..8fe66f9 100644 --- a/common/defaults.tf +++ b/common/defaults.tf @@ -1,4 +1,6 @@ locals { + vpc_id = data.aws_vpc.vpc.id + subnet_ids = data.aws_subnets.subnets.ids # Portfolio ID is required - must be provided via var.portfolio_id portfolio_id = var.portfolio_id @@ -16,9 +18,22 @@ locals { # Use provided path_id or default to latest provisioning_artifact_id = var.path_id != null ? var.path_id : local.latest_artifact_id - # Merge default parameters with user-provided parameters - default_parameters = {} + # Build default parameters from module variables + default_parameters = { + ProjectName = var.project_name + VpcId = local.vpc_id + AZName = data.aws_subnet.subnets[sort(data.aws_subnets.subnets.ids)[0]].availability_zone + InstanceType = var.instance_type + OSName = var.os_name + Creator = var.creator + ContactEmail = var.contact_email + IncPocEmail = var.inc_poc_email + RequiresBackup = var.requires_backup + PowerSchedule = var.power_schedule + FISMAID = var.fisma_id + } + # Merge defaults with user-provided parameters (user params override defaults) parameters = merge( local.default_parameters, var.parameters @@ -30,5 +45,6 @@ locals { key = key value = tostring(value) } + if value != "" # Only include non-empty values ] } diff --git a/common/outputs.tf b/common/outputs.tf index 23dfbe5..da95dd3 100644 --- a/common/outputs.tf +++ b/common/outputs.tf @@ -47,3 +47,18 @@ output "provisioning_artifact_id" { description = "The ID of the provisioning artifact used" value = local.provisioning_artifact_id } + +output "vpc_id" { + description = "The VPC ID where the instance will be provisioned" + value = data.aws_vpc.vpc.id +} + +output "subnet_ids" { + description = "The subnet IDs where the instance can be provisioned" + value = data.aws_subnets.subnets.ids +} + +output "availability_zone" { + description = "The availability zone of the first selected subnet" + value = data.aws_subnet.subnets[sort(data.aws_subnets.subnets.ids)[0]].availability_zone +} diff --git a/common/variables.parameters.tf b/common/variables.parameters.tf index 92e9357..23f6da2 100644 --- a/common/variables.parameters.tf +++ b/common/variables.parameters.tf @@ -3,3 +3,57 @@ variable "parameters" { type = map(string) default = {} } + +variable "project_name" { + description = "Project name (ProjectName parameter)" + type = string + default = "" +} + +variable "creator" { + description = "Creator's JBID (Creator parameter)" + type = string + default = "" +} + +variable "contact_email" { + description = "Provisioning user's email (ContactEmail parameter)" + type = string + default = "" +} + +variable "inc_poc_email" { + description = "Incident POC email (IncPocEmail parameter)" + type = string + default = "" +} + +variable "instance_type" { + description = "EC2 instance type" + type = string + default = "t3.small" +} + +variable "os_name" { + description = "Operating system version" + type = string + default = "RHEL9" +} + +variable "requires_backup" { + description = "Backup requirement" + type = string + default = "no" +} + +variable "power_schedule" { + description = "Power schedule" + type = string + default = "" +} + +variable "fisma_id" { + description = "FISMA ID" + type = string + default = "" +}