Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed May 5, 2022
1 parent 02fd840 commit 89113de
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 12 deletions.
47 changes: 47 additions & 0 deletions examples/dice-mojo-new/data.tf
Original file line number Diff line number Diff line change
@@ -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
}
23 changes: 11 additions & 12 deletions examples/dice-mojo-new/locals.tf
Original file line number Diff line number Diff line change
@@ -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)
}
3 changes: 3 additions & 0 deletions examples/dice-mojo-new/region.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
locals {
region = var.region
}
4 changes: 4 additions & 0 deletions examples/dice-mojo-new/variables.ecs.auto.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cluster_name = null
ecs_container_subnet_filter = "*-container-*"
ecs_apps_subnet_filter = "*-apps-*"
ecs_lb_subnet_filter = "*-private-lb-*"
24 changes: 24 additions & 0 deletions examples/dice-mojo-new/variables.ecs.tf
Original file line number Diff line number Diff line change
@@ -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-*"
}

0 comments on commit 89113de

Please sign in to comment.