-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
99 lines (86 loc) · 2.43 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# https://registry.terraform.io/modules/terraform-aws-modules/ecs/aws/latest/submodules/service
resource "aws_security_group" "security_group_s3_manager" {
name = "${var.username_prefix}_allow_8080"
description = "allow 8080"
vpc_id = data.aws_vpc.default.id
ingress {
description = "TLS from VPC"
from_port = 8080
to_port = 8080
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
tags = {
Name = "${var.username_prefix}_allow_tls"
}
}
resource "aws_ecs_cluster" "ecs_s3_manager_cluster" {
name = "${var.username_prefix}-ecs-terraform"
}
resource "aws_ecs_service" "ecs_service" {
name = "${var.username_prefix}-ecs-service-terraform"
cluster = aws_ecs_cluster.ecs_s3_manager_cluster.id
task_definition = aws_ecs_task_definition.ecs_task_s3_manager.arn
desired_count = 1
capacity_provider_strategy {
capacity_provider = "FARGATE"
weight = 1
base = 0
}
network_configuration {
subnets = ["subnet-089fc7faf593f71ef", "subnet-084925d72ec5d9cda", "subnet-013343c36fea19c5b"]
security_groups = [aws_security_group.security_group_s3_manager.id]
assign_public_ip = true
}
depends_on = [
aws_ecs_cluster.ecs_s3_manager_cluster,
aws_ecs_task_definition.ecs_task_s3_manager,
aws_security_group.security_group_s3_manager
]
}
resource "aws_ecs_task_definition" "ecs_task_s3_manager" {
family = "${var.username_prefix}-ecs-terraform-s3-manager"
requires_compatibilities = ["FARGATE"]
network_mode = "awsvpc"
cpu = 256
memory = 512
container_definitions = jsonencode([
{
name = "s3-manager-tf"
image = "cloudlena/s3manager"
cpu = 256
memory = 512
essential = true
portMappings = [
{
containerPort = 8080
hostPort = 8080
}
],
environment = [
{
name = "region",
value = "eu-central-1"
},
{
name = "ACCESS_KEY_ID",
value = ""
},
{
name = "SECRET_ACCESS_KEY",
value = ""
}
]
}
])
depends_on = [
aws_ecs_cluster.ecs_s3_manager_cluster
]
}