@@ -15,7 +15,7 @@ locals {
1515 )
1616
1717 # VPC and Subnet ID resolution - names take precedence over IDs
18- vpc_id = length ( var. vpc_name ) > 0 ? one (data. aws_vpc . selected [* ]. id ) : var. vpc_id
18+ vpc_id = var. vpc_name != null ? one (data. aws_vpc . selected [* ]. id ) : var. vpc_id
1919 subnet_ids = length (var. subnet_names ) > 0 ? values (data. aws_subnet . selected )[* ]. id : var. subnet_ids
2020
2121}
@@ -31,33 +31,6 @@ resource "null_resource" "validate_instance_type" {
3131 }
3232}
3333
34- # Validation using terraform_data to halt execution if requirements aren't met
35- resource "terraform_data" "vpc_subnet_validation" {
36- lifecycle {
37- precondition {
38- condition = length (var. vpc_name ) > 0 || length (var. vpc_id ) > 0
39- error_message = " Either vpc_name or vpc_id must be provided."
40- }
41-
42- precondition {
43- condition = length (var. subnet_names ) > 0 || length (var. subnet_ids ) > 0
44- error_message = " Either subnet_names or subnet_ids must be provided."
45- }
46- }
47- }
48-
49- # Warning checks for VPC and subnet configuration (non-blocking)
50- check "vpc_subnet_warnings" {
51- assert {
52- condition = ! (length (var. vpc_name ) > 0 && length (var. vpc_id ) > 0 )
53- error_message = " Both vpc_name and vpc_id are provided. When vpc_name is specified, vpc_id will be ignored."
54- }
55-
56- assert {
57- condition = ! (length (var. subnet_names ) > 0 && length (var. subnet_ids ) > 0 )
58- error_message = " Both subnet_names and subnet_ids are provided. When subnet_names are specified, subnet_ids will be ignored."
59- }
60- }
6134
6235module "role_label" {
6336 source = " cloudposse/label/null"
@@ -79,8 +52,10 @@ locals {
7952 region = coalesce (var. region , data. aws_region . current . region )
8053 account_id = data. aws_caller_identity . current . account_id
8154
82- session_logging_bucket_name = try (coalesce (var. session_logging_bucket_name , module. logs_label . id ), " " )
83- session_logging_kms_key_arn = try (coalesce (var. session_logging_kms_key_arn , module. kms_key . key_arn ), " " )
55+ session_logging_bucket_name = try (coalesce (var. session_logging_bucket_name , module. logs_label . id ), " " )
56+ session_logging_kms_key_arn = try (coalesce (var. session_logging_kms_key_arn , module. kms_key . key_arn ), " " )
57+ session_logging_bucket_arn = var. session_logging_enabled ? " arn:aws:s3:::${ local . session_logging_bucket_name } " : " "
58+ session_logging_log_group_arn = var. session_logging_enabled ? " arn:aws:logs:${ local . region } :${ local . account_id } :log-group:${ module . logs_label . id } " : " "
8459
8560 logs_bucket_enabled = var. session_logging_enabled && length (var. session_logging_bucket_name ) == 0
8661}
0 commit comments