Skip to content

Commit b5bbfd9

Browse files
authored
fix: hardcoded sensitive env vars (#6)
2 parents 5c7d79b + eb230e1 commit b5bbfd9

File tree

5 files changed

+41
-43
lines changed

5 files changed

+41
-43
lines changed

main.tf

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ resource "aws_ecs_task_definition" "this" {
1010
cpu = 256
1111
memory = 512
1212
requires_compatibilities = ["FARGATE"]
13-
container_definitions = jsonencode(
13+
container_definitions = jsonencode(
1414
[
1515
{
1616
name : "soat-ecs-cluster-task",
@@ -51,12 +51,12 @@ resource "aws_ecs_task_definition" "this" {
5151
options : {
5252
awslogs-create-group : "true",
5353
awslogs-group : "awslogs-backend",
54-
awslogs-region : "us-east-2",
54+
awslogs-region : var.aws_region,
5555
awslogs-stream-prefix : "awslogs-backend"
5656
}
5757
},
5858
}
59-
])
59+
])
6060

6161
runtime_platform {
6262
cpu_architecture = "X86_64"
@@ -65,13 +65,13 @@ resource "aws_ecs_task_definition" "this" {
6565
}
6666

6767
resource "aws_ecs_service" "this" {
68-
name = "soat-ecs-service"
69-
cluster = aws_ecs_cluster.this.id
70-
task_definition = aws_ecs_task_definition.this.arn
71-
desired_count = 1
72-
launch_type = "FARGATE"
73-
scheduling_strategy = "REPLICA"
74-
force_new_deployment = true
68+
name = "soat-ecs-service"
69+
cluster = aws_ecs_cluster.this.id
70+
task_definition = aws_ecs_task_definition.this.arn
71+
desired_count = 1
72+
launch_type = "FARGATE"
73+
scheduling_strategy = "REPLICA"
74+
force_new_deployment = true
7575
health_check_grace_period_seconds = 600
7676

7777
network_configuration {
@@ -82,7 +82,7 @@ resource "aws_ecs_service" "this" {
8282

8383
load_balancer {
8484
container_name = "soat-ecs-cluster-task"
85-
container_port = var.port
85+
container_port = var.ecs_service_lb_container_port
8686
target_group_arn = data.aws_alb_target_group.tg_alb.arn
8787
}
8888
}

providers.tf

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
provider "aws" {
2+
region = var.aws_region
3+
4+
access_key = var.aws_access_key
5+
secret_key = var.aws_secret_key
6+
7+
default_tags {
8+
tags = {
9+
Organization = "soat-tech-challenge"
10+
Workspace = "database-staging"
11+
}
12+
}
13+
}

terraform.tfvars.example

-8
This file was deleted.

variables.tf

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
variable "aws_region" {
2-
description = "Região AWS onde criar a instância RDS"
2+
description = "AWS Region to create resources on"
33
type = string
44
default = "us-east-2"
55
}
66

7-
variable "port" {
8-
description = "Port"
7+
variable "aws_access_key" {
8+
description = "AWS Access Key"
9+
type = string
10+
}
11+
12+
variable "aws_secret_key" {
13+
description = "AWS Secret Key"
914
type = string
1015
}
1116

1217
variable "ecs_container_db_username" {
13-
default = "postgres"
14-
type = string
18+
type = string
1519
}
1620

1721
variable "ecs_container_db_password" {
18-
default = "postgres"
19-
type = string
22+
type = string
2023
}
2124

2225
variable "ecs_container_db_name" {
23-
default = "backend"
26+
default = "backend_db"
2427
type = string
2528
}
2629

30+
variable "ecs_service_lb_container_port" {
31+
description = "ECS Service load balancing container port"
32+
type = number
33+
default = 8080
34+
}
35+
2736
variable "ecs_container_jwt_public_key" {
2837
default = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqStd8n4SGNM0eZhV/hzU+urHA5/IMZPoP9YQ9ZcLKWiX33nI6bSuZMCrLZcJExf63xS+uxDpGxM8Mnk2zOdl+lPwANXLzP1us5P1PyA3YPycW9J7C5YTQW0GiEL3M93ZX7vMJiVoBYblP3JPlYnoYlBORuc0JPk33KtfEZP+78qXpPHM8imYrJLe8ceiDLLFDU/nh5KC2dWAy3ci1ahoJ1Q9ELhp3IZLvOTX57H/T2VKOYOya5+ST41h+JjzI+qGTVnLcKaW+k25YLlVnkSspvdx98+yQDi7kbOTS6yRZHUPD6wPk/nUozpD0nZKccoH4W+zMwmQVtsAA6JCA9gfGwIDAQAB"
2938
type = string
3039
}
31-
32-
variable "aws_access_key" {
33-
description = "AWS Access Key"
34-
type = string
35-
}
36-
37-
variable "aws_secret_key" {
38-
description = "AWS Secret Key"
39-
type = string
40-
}

versions.tf

-6
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,3 @@ terraform {
1616
}
1717
}
1818
}
19-
20-
provider "aws" {
21-
region = var.aws_region
22-
access_key = var.aws_access_key
23-
secret_key = var.aws_secret_key
24-
}

0 commit comments

Comments
 (0)