From c2f4670605086aecac6188b47e205fbd356241a4 Mon Sep 17 00:00:00 2001 From: tylerthome Date: Wed, 2 Oct 2024 18:17:06 -0700 Subject: [PATCH] separate files, var fix for ecs task --- .../home-unite-us/dev/backend.tf | 12 ++++ .../home-unite-us/dev/dev.tfvars | 2 + terraform-incubator/home-unite-us/dev/ecr.tf | 17 ++++++ .../home-unite-us/dev/locals.tf | 14 +++++ terraform-incubator/home-unite-us/dev/main.tf | 56 ------------------- .../home-unite-us/dev/network.tf | 12 ++++ 6 files changed, 57 insertions(+), 56 deletions(-) create mode 100644 terraform-incubator/home-unite-us/dev/backend.tf create mode 100644 terraform-incubator/home-unite-us/dev/dev.tfvars create mode 100644 terraform-incubator/home-unite-us/dev/ecr.tf create mode 100644 terraform-incubator/home-unite-us/dev/locals.tf create mode 100644 terraform-incubator/home-unite-us/dev/network.tf diff --git a/terraform-incubator/home-unite-us/dev/backend.tf b/terraform-incubator/home-unite-us/dev/backend.tf new file mode 100644 index 0000000..7cb1f1f --- /dev/null +++ b/terraform-incubator/home-unite-us/dev/backend.tf @@ -0,0 +1,12 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + } + } + backend "s3" { + region = "us-west-2" + key = "incubator/home-unite-us/dev.tfstate" + bucket = "hlfa-incubator-terragrunt" + } +} diff --git a/terraform-incubator/home-unite-us/dev/dev.tfvars b/terraform-incubator/home-unite-us/dev/dev.tfvars new file mode 100644 index 0000000..0573223 --- /dev/null +++ b/terraform-incubator/home-unite-us/dev/dev.tfvars @@ -0,0 +1,2 @@ +listener_arn = "arn:aws:elasticloadbalancing:us-west-2:035866691871:listener/app/incubator-prod-lb/7451adf77133ef36/390a225766a4daf3" + diff --git a/terraform-incubator/home-unite-us/dev/ecr.tf b/terraform-incubator/home-unite-us/dev/ecr.tf new file mode 100644 index 0000000..4dc18ae --- /dev/null +++ b/terraform-incubator/home-unite-us/dev/ecr.tf @@ -0,0 +1,17 @@ + +resource "aws_ecr_repository" "this" { + image_tag_mutability = "MUTABLE" + name = local.app_name + tags = { + "Organization" = "Hack for LA" + } + + image_scanning_configuration { + scan_on_push = true + } +} + +data "aws_lb_listener" "listener" { + arn = local.listener_arn +} + diff --git a/terraform-incubator/home-unite-us/dev/locals.tf b/terraform-incubator/home-unite-us/dev/locals.tf new file mode 100644 index 0000000..5d9865f --- /dev/null +++ b/terraform-incubator/home-unite-us/dev/locals.tf @@ -0,0 +1,14 @@ +locals { + root_host_name = "homeunite.us" + app_name = "homeuniteus" + listener_arn = "arn:aws:elasticloadbalancing:us-west-2:035866691871:listener/app/incubator-prod-lb/7451adf77133ef36/390a225766a4daf3" + vpc_id = "vpc-0bec93a4d80243845" + path_pattens = ["/*"] + subdomains = [ + "dev", + "qa", + "incubator" + ] + host_names = [for subdomain in local.subdomains : "${subdomain}.${local.app_name}"] + +} diff --git a/terraform-incubator/home-unite-us/dev/main.tf b/terraform-incubator/home-unite-us/dev/main.tf index 99a8d80..495b346 100644 --- a/terraform-incubator/home-unite-us/dev/main.tf +++ b/terraform-incubator/home-unite-us/dev/main.tf @@ -1,63 +1,8 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - } - } - backend "s3" { - region = "us-west-2" - key = "incubator/home-unite-us/dev.tfstate" - bucket = "hlfa-incubator-terragrunt" - } -} provider "aws" { region = "us-west-2" } -locals { - root_host_name = "homeunite.us" - app_name = "homeuniteus" - listener_arn = "arn:aws:elasticloadbalancing:us-west-2:035866691871:listener/app/incubator-prod-lb/7451adf77133ef36/390a225766a4daf3" - vpc_id = "vpc-0bec93a4d80243845" - path_pattens = ["/*"] - subdomains = [ - "dev", - "qa", - "incubator" - ] - host_names = [for subdomain in local.subdomains : "${subdomain}.${local.app_name}"] - -} - -resource "aws_route53_zone" "main" { - name = local.root_host_name -} - -resource "aws_route53_record" "root_a_record" { - zone_id = aws_route53_zone.main.zone_id - name = local.root_host_name - type = "A" - ttl = 300 - records = ["18.223.160.58"] -} - -resource "aws_ecr_repository" "this" { - image_tag_mutability = "MUTABLE" - name = local.app_name - tags = { - "Organization" = "Hack for LA" - } - - image_scanning_configuration { - scan_on_push = true - } -} - -data "aws_lb_listener" "listener" { - arn = local.listener_arn -} - resource "aws_lb_target_group" "this" { target_type = "ip" @@ -147,7 +92,6 @@ resource "aws_ecs_task_definition" "task" { cpu = "256" execution_role_arn = "arn:aws:iam::035866691871:role/incubator-prod-ecs-task-role" family = "homeuniteus" - id = "homeuniteus" memory = "512" network_mode = "awsvpc" requires_compatibilities = [ diff --git a/terraform-incubator/home-unite-us/dev/network.tf b/terraform-incubator/home-unite-us/dev/network.tf new file mode 100644 index 0000000..685ebc1 --- /dev/null +++ b/terraform-incubator/home-unite-us/dev/network.tf @@ -0,0 +1,12 @@ + +resource "aws_route53_zone" "main" { + name = local.root_host_name +} + +resource "aws_route53_record" "root_a_record" { + zone_id = aws_route53_zone.main.zone_id + name = local.root_host_name + type = "A" + ttl = 300 + records = ["18.223.160.58"] +}