|
1 | | -locals { |
2 | | - name = "kong-postgres" |
3 | | - db_identifier = "${local.name}-01" |
4 | | - rds_engine = "postgres" |
5 | | - storage_encrypted = true |
6 | | - storage_type = "gp3" |
7 | | - |
8 | | - postgres = { |
9 | | - engine_version = 16.3 |
10 | | - engine_family = "postgres16" |
11 | | - major_engine_version = 16 |
12 | | - port = 5432 |
13 | | - } |
14 | | - |
15 | | - ecs = { |
16 | | - user_data = <<EOF |
17 | | - #!/bin/bash |
18 | | - echo ECS_CLUSTER=${var.cluster_name} >> /etc/ecs/ecs.config; |
19 | | - EOF |
20 | | - ecs_node_sg_name = "kong" |
21 | | - } |
22 | | - |
23 | | - kong = { |
24 | | - name = "kong" |
25 | | - service_name = "kong" |
26 | | - task_definition_family = "kong" |
27 | | - network_mode = "awsvpc" |
28 | | - launch_template_name = "kong" |
29 | | - image_id = data.aws_ssm_parameter.ecs_node_ami.value |
30 | | - iam_role_policy_attachments = [ |
31 | | - "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy", |
32 | | - "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore", |
33 | | - "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role" |
34 | | - ] |
35 | | - |
36 | | - alb_sg_name = "kong" |
37 | | - ecs_task_sg_name = "kong" |
38 | | - commands = ["/bin/sh", "-c", "kong migrations bootstrap && ulimit -n 4096 && kong start"] |
39 | | - |
40 | | - portMappings = [ |
41 | | - { containerPort = 80, hostPort = 80 }, |
42 | | - { containerPort = 8000, hostPort = 8000 }, |
43 | | - { containerPort = 8443, hostPort = 8443 }, |
44 | | - { containerPort = 8001, hostPort = 8001 }, |
45 | | - { containerPort = 8002, hostPort = 8002 } |
46 | | - ] |
47 | | - |
48 | | - |
49 | | - admin_port = 8001 |
50 | | - proxy_port = 8000 |
51 | | - public_target_group = "kong_public" |
52 | | - internal_target_group = "kong_internal" |
53 | | - public_domains = [for subdomain in var.kong_public_sub_domain_names : "${subdomain}.${var.base_domain}"] |
54 | | - admin_domains = [for subdomain in var.kong_admin_sub_domain_names : "${subdomain}.${var.base_domain}"] |
55 | | - } |
56 | | - |
57 | | - kong_parameters = { |
58 | | - "KONG_ADMIN_LISTEN" = "0.0.0.0:8001, 0.0.0.0:8444 ssl" |
59 | | - "KONG_PROXY_LISTEN" = "0.0.0.0:8000, 0.0.0.0:8443 ssl, 0.0.0.0:9080 http2, 0.0.0.0:9081 http2 ssl" |
60 | | - "KONG_DATABASE" = local.rds_engine |
61 | | - "KONG_PG_HOST" = module.kong_rds.db_instance_address |
62 | | - "KONG_PG_USER" = var.db_username |
63 | | - "KONG_PG_PASSWORD" = var.db_password |
64 | | - "KONG_PG_DATABASE" = var.db_name |
65 | | - "KONG_PROXY_ACCESS_LOG" = "/dev/stdout" |
66 | | - "KONG_ADMIN_ACCESS_LOG" = "/dev/stdout" |
67 | | - "KONG_PROXY_ERROR_LOG" = "/dev/stderr" |
68 | | - "KONG_ADMIN_ERROR_LOG" = "/dev/stderr" |
69 | | - "KONG_LOG_LEVEL" = "debug" |
70 | | - "KONG_PG_SSL" = "on" |
71 | | - } |
72 | | - |
73 | | - default_tags = { |
74 | | - ManagedBy = "Terraform" |
75 | | - } |
76 | | -} |
77 | | - |
78 | | - |
79 | 1 | data "aws_ssm_parameter" "ecs_node_ami" { |
80 | 2 | name = "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" |
81 | 3 | } |
|
0 commit comments