Skip to content

Commit 7f7f765

Browse files
authored
Dbeaver devops#2197 aws ecs deployment improvements (#200)
* dbeaver/dbeaver-devops#2197 Global refactoring AWS ECS deployment * dbeaver/dbeaver-devops#2197 Added optional creating ECS cluster in existing VPC * dbeaver/dbeaver-devops#2197 Fixed migration of old resources to new modules * dbeaver/dbeaver-devops#2197 Added removed old aws_route_table during mugration * dbeaver/dbeaver-devops#2197 Reverter remove * dbeaver/dbeaver-devops#2197 Fixed long destroying vpc * dbeaver/dbeaver-devops#2197 Removed rds vars * dbeaver/dbeaver-devops#2197 Created modules in AWS ECS deployment, added migration from flat deployment to modules * dbeaver/dbeaver-devops#2197 Added variable efs_encrypted and added warning about enabling encryption on existet EFS volumes * dbeaver/dbeaver-devops#2197 Added modules description
1 parent 0bd5fa3 commit 7f7f765

48 files changed

Lines changed: 2312 additions & 1437 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AWS/ecs-fargate/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,19 @@ git clone https://github.com/dbeaver/team-edition-deploy.git
7575
2. Specify the desired version in `variables.tf` in the `dbeaver_te_version` variable.
7676

7777
3. Run `terraform apply` to upgrade the ECS cluster and complete the deployment.
78+
79+
80+
## Modules description
81+
82+
This deployment is built on self-contained parameterized Terraform modules. All modules are located in the local [`./modules/`](./modules/) folder, so every piece of infrastructure can be reviewed, customized and maintained. Root `*.tf` files only wire modules together and pass variables, resource definitions are kept inside the modules.
83+
84+
- **alb** — Application Load Balancer with HTTP to HTTPS redirect and HTTPS listener.
85+
- **alb-route** — Target group and listener rule for a single backend service.
86+
- **ecs-cluster** — ECS cluster with Fargate capacity providers.
87+
- **ecs-service** — Fargate task definition and ECS service, with optional EFS volumes and ALB target group.
88+
- **efs-volume** — EFS file system, mount targets and optional access point.
89+
- **iam** — ECS task and execution IAM roles with CloudWatch Logs and EFS access policies.
90+
- **rds** — RDS instance and DB subnet group.
91+
- **vpc** — VPC with public/private subnets, Internet Gateway, NAT Gateway and route tables.
92+
93+
For customers who used the previous flat Terraform deployment, the [`migration.tf`](./migration.tf) file remaps the existing Terraform state to the new module layout, so `terraform apply` preserves the environment without losing data.

AWS/ecs-fargate/alb.tf

Lines changed: 12 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -1,194 +1,19 @@
11
################################################################################
2-
# ALB
2+
# AWS ALB
33
################################################################################
44

5-
resource "aws_lb" "dbeaver_te_lb" {
6-
name = "DBeaverTE-${var.deployment_id}-ALB"
7-
internal = false
8-
load_balancer_type = "application"
9-
security_groups = [aws_security_group.dbeaver_alb.id]
10-
subnets = aws_subnet.public_subnets[*].id
11-
tags = {
12-
env = var.deployment_id
13-
}
14-
}
15-
16-
17-
# This resources must be edited if HTTPS not used
18-
resource "aws_lb_listener" "dbeaver-te-listener" {
19-
20-
load_balancer_arn = aws_lb.dbeaver_te_lb.arn
21-
port = "80"
22-
protocol = "HTTP"
23-
24-
default_action {
25-
type = "redirect"
26-
27-
redirect {
28-
port = "443"
29-
protocol = "HTTPS"
30-
status_code = "HTTP_301"
31-
}
32-
}
33-
}
34-
35-
# This resources must be edited if HTTPS not used
36-
resource "aws_lb_listener" "dbeaver-te-listener-https" {
37-
38-
load_balancer_arn = aws_lb.dbeaver_te_lb.arn
39-
port = "443"
40-
protocol = "HTTPS"
41-
ssl_policy = "ELBSecurityPolicy-TLS-1-2-2017-01"
42-
certificate_arn = "arn:aws:acm:${var.aws_region}:${var.aws_account_id}:certificate/${var.alb_certificate_Identifier}"
43-
44-
default_action {
45-
type = "forward"
46-
target_group_arn = aws_lb_target_group.dbeaver_te.arn
47-
}
48-
}
5+
module "alb" {
6+
source = "./modules/alb"
497

50-
resource "aws_lb_listener_rule" "forward_to_service_uri_dc" {
51-
listener_arn = aws_lb_listener.dbeaver-te-listener-https.arn
52-
priority = 99
8+
name = "${local.name_prefix}-${var.deployment_id}-ALB"
9+
deployment_id = var.deployment_id
10+
vpc_id = local.vpc_id
11+
public_subnets = local.public_subnets
12+
security_group_ids = [aws_security_group.dbeaver_alb.id]
13+
certificate_arn = "arn:aws:acm:${var.aws_region}:${var.aws_account_id}:certificate/${var.alb_certificate_Identifier}"
14+
ssl_policy = "ELBSecurityPolicy-TLS13-1-2-2021-06"
5315

54-
condition {
55-
path_pattern {
56-
values = ["/dc*"]
57-
}
58-
}
59-
60-
action {
61-
type = "forward"
62-
target_group_arn = aws_lb_target_group.dbeaver_dc.arn
63-
}
64-
}
65-
66-
resource "aws_lb_listener_rule" "forward_to_service_uri_qm" {
67-
listener_arn = aws_lb_listener.dbeaver-te-listener-https.arn
68-
priority = 98
69-
70-
condition {
71-
path_pattern {
72-
values = ["/qm*"]
73-
}
74-
}
75-
76-
action {
77-
type = "forward"
78-
target_group_arn = aws_lb_target_group.dbeaver_qm.arn
79-
}
80-
}
81-
82-
resource "aws_lb_listener_rule" "forward_to_service_uri_rm" {
83-
listener_arn = aws_lb_listener.dbeaver-te-listener-https.arn
84-
priority = 97
85-
86-
condition {
87-
path_pattern {
88-
values = ["/rm*"]
89-
}
90-
}
91-
92-
action {
93-
type = "forward"
94-
target_group_arn = aws_lb_target_group.dbeaver_rm.arn
95-
}
96-
}
97-
98-
99-
resource "aws_lb_listener_rule" "forward_to_service_uri_tm" {
100-
listener_arn = aws_lb_listener.dbeaver-te-listener-https.arn
101-
priority = 94
102-
103-
condition {
104-
path_pattern {
105-
values = ["/tm*"]
106-
}
107-
}
108-
109-
action {
110-
type = "forward"
111-
target_group_arn = aws_lb_target_group.dbeaver_tm.arn
112-
}
113-
}
114-
115-
116-
resource "aws_lb_target_group" "dbeaver_dc" {
117-
name = "DBeaverTE-${var.deployment_id}-dc"
118-
port = 80
119-
protocol = "HTTP"
120-
target_type = "ip"
121-
vpc_id = aws_vpc.dbeaver_net.id
122-
123-
health_check {
124-
matcher = "200,302"
125-
unhealthy_threshold = 7
126-
enabled = true
127-
path = "/dc/health"
128-
}
129-
}
130-
131-
resource "aws_lb_target_group" "dbeaver_te" {
132-
name = "DBeaverTE-${var.deployment_id}"
133-
port = 80
134-
protocol = "HTTP"
135-
target_type = "ip"
136-
vpc_id = aws_vpc.dbeaver_net.id
137-
138-
health_check {
139-
matcher = "200,302"
140-
unhealthy_threshold = 10
141-
enabled = true
142-
path = "/"
143-
}
144-
stickiness {
145-
enabled = true
146-
type = "lb_cookie"
147-
cookie_duration = 86400
148-
}
149-
}
150-
151-
resource "aws_lb_target_group" "dbeaver_qm" {
152-
name = "DBeaverTE-${var.deployment_id}-qm"
153-
port = 80
154-
protocol = "HTTP"
155-
target_type = "ip"
156-
vpc_id = aws_vpc.dbeaver_net.id
157-
158-
health_check {
159-
matcher = "200,302"
160-
unhealthy_threshold = 7
161-
enabled = true
162-
path = "/qm/health"
163-
}
164-
}
165-
166-
resource "aws_lb_target_group" "dbeaver_rm" {
167-
name = "DBeaverTE-${var.deployment_id}-rm"
168-
port = 80
169-
protocol = "HTTP"
170-
target_type = "ip"
171-
vpc_id = aws_vpc.dbeaver_net.id
172-
173-
health_check {
174-
matcher = "200,302"
175-
unhealthy_threshold = 7
176-
enabled = true
177-
path = "/rm/health"
178-
}
179-
}
180-
181-
resource "aws_lb_target_group" "dbeaver_tm" {
182-
name = "DBeaverTE-${var.deployment_id}-tm"
183-
port = 80
184-
protocol = "HTTP"
185-
target_type = "ip"
186-
vpc_id = aws_vpc.dbeaver_net.id
187-
188-
health_check {
189-
matcher = "200,302"
190-
unhealthy_threshold = 7
191-
enabled = true
192-
path = "/tm/health"
16+
tags = {
17+
Env = var.deployment_id
19318
}
19419
}

AWS/ecs-fargate/aws-iam.tf

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)