diff --git a/examples/dice-mojo-new/data.tf b/examples/dice-mojo-new/data.tf new file mode 100644 index 0000000..5906456 --- /dev/null +++ b/examples/dice-mojo-new/data.tf @@ -0,0 +1,47 @@ +data "aws_subnets" "container_subnets" { + filter { + name = "vpc-id" + values = [local.vpc_id] + } + filter { + name = "tag:Name" + values = [var.ecs_container_subnet_filter] + } +} + +data "aws_subnet" "container_subnets" { + for_each = toset(data.aws_subnets.container_subnets.ids) + id = each.key +} + +data "aws_subnets" "apps_subnets" { + filter { + name = "vpc-id" + values = [local.vpc_id] + } + filter { + name = "tag:Name" + values = [var.ecs_apps_subnet_filter] + } +} + +data "aws_subnet" "apps_subnets" { + for_each = toset(data.aws_subnets.apps_subnets.ids) + id = each.key +} + +data "aws_subnets" "lb_subnets" { + filter { + name = "vpc-id" + values = [local.vpc_id] + } + filter { + name = "tag:Name" + values = [var.ecs_lb_subnet_filter] + } +} + +data "aws_subnet" "lb_subnets" { + for_each = toset(data.aws_subnets.lb_subnets.ids) + id = each.key +} diff --git a/examples/dice-mojo-new/locals.tf b/examples/dice-mojo-new/locals.tf index 8186bc5..d99c6c3 100644 --- a/examples/dice-mojo-new/locals.tf +++ b/examples/dice-mojo-new/locals.tf @@ -1,18 +1,17 @@ locals { - region = var.region - app_program = "dice" - app_project = "mojo" - app_environment = "dev" - - vpc_id = data.terraform_remote_state.vpc_east_vpc2.outputs.vpc_id - vpc_short_name = data.terraform_remote_state.vpc_east_vpc2.outputs.vpc_info["vpc_short_name"] - sg_web_id = data.terraform_remote_state.vpc_east_vpc2.outputs.sg_web_id - apps_subnet_ids = [for s in data.terraform_remote_state.vpc_east_vpc2.outputs.private_subnets_ids : s.id if length(regexall("^apps-", s.label)) > 0] - lb_subnet_ids = [for s in data.terraform_remote_state.vpc_east_vpc2.outputs.private_subnets_ids : s.id if length(regexall("^private-lb-", s.label)) > 0] - ecs_cluster_id = data.terraform_remote_state.vpc_east_vpc2_apps_dice-ecs-fargate.outputs.ecs_cluster_id - base_tags = { "boc:created_by" = "terraform" "CostAllocation" = format("%v:%v:%v", local.app_program, local.app_environment, local.app_project) } + + ecs_cluster_id = data.terraform_remote_state.vpc_east_vpc3_apps_dice-ecs-fargate.outputs.ecs_cluster_id + vpc_details = data.terraform_remote_state.vpc_east_vpc3.outputs + vpc_info = local.vpc_details.vpc_info + vpc_id = local.vpc_info["vpc_id"] + vpc_short_name = local.vpc_info["vpc_short_name"] + sg_web_id = local.vpc_details.sg_web_id + log_bucket_name = format("inf-logs-%v-%v", var.account_id, local.region) + apps_subnet_ids = tolist(data.aws_subnets.apps_subnets.ids) + container_subnet_ids = tolist(data.aws_subnets.container_subnets.ids) + lb_subnet_ids = tolist(data.aws_subnets.lb_subnets.ids) } diff --git a/examples/dice-mojo-new/region.tf b/examples/dice-mojo-new/region.tf new file mode 100644 index 0000000..f617506 --- /dev/null +++ b/examples/dice-mojo-new/region.tf @@ -0,0 +1,3 @@ +locals { + region = var.region +} diff --git a/examples/dice-mojo-new/variables.ecs.auto.tfvars b/examples/dice-mojo-new/variables.ecs.auto.tfvars new file mode 100644 index 0000000..5ddd7d3 --- /dev/null +++ b/examples/dice-mojo-new/variables.ecs.auto.tfvars @@ -0,0 +1,4 @@ +cluster_name = null +ecs_container_subnet_filter = "*-container-*" +ecs_apps_subnet_filter = "*-apps-*" +ecs_lb_subnet_filter = "*-private-lb-*" diff --git a/examples/dice-mojo-new/variables.ecs.tf b/examples/dice-mojo-new/variables.ecs.tf new file mode 100644 index 0000000..ba257c4 --- /dev/null +++ b/examples/dice-mojo-new/variables.ecs.tf @@ -0,0 +1,24 @@ +variable "cluster_name" { + description = "Cluster name of form {program}-{env}-fargate or {org}-{project}-{env}-fargate" + type = string +} +# examples: dice-qa-fargate +# examples: ditd-gups-test-fargate + +variable "ecs_container_subnet_filter" { + description = "Container subnet filter (ex., *-container-*) to use to select the container subents in this VPC" + type = string + defualt = "*-container-*" +} + +variable "ecs_apps_subnet_filter" { + description = "Apps subnet filter (ex., *-apps-*) to use to select the container subents in this VPC" + type = string + defualt = "*-apps-*" +} + +variable "ecs_lb_subnet_filter" { + description = "Private Load Balancer subnet filter (ex., *-private-lb-*) to use to select the container subents in this VPC" + type = string + defualt = "*-private-lb-*" +}