|
3 | 3 | # outdated docker+machine driver. The docker+machine driver is a legacy driver that is no longer maintained by GitLab.
|
4 | 4 | #
|
5 | 5 |
|
6 |
| -######################################## |
7 |
| -###### Security Group and SG rules ##### |
8 |
| -######################################## |
9 |
| - |
10 |
| -# Base security group |
11 |
| -resource "aws_security_group" "docker_autoscaler" { |
12 |
| - count = var.runner_worker.type == "docker-autoscaler" ? 1 : 0 |
13 |
| - name_prefix = "${local.name_sg}-docker-autoscaler" |
14 |
| - vpc_id = var.vpc_id |
15 |
| - description = "Docker-autoscaler security group" |
16 |
| - |
17 |
| - tags = merge( |
18 |
| - local.tags, |
19 |
| - { |
20 |
| - "Name" = format("%s", local.name_sg) |
21 |
| - }, |
22 |
| - ) |
23 |
| -} |
24 |
| - |
25 |
| -# Ingress rules |
26 |
| -resource "aws_vpc_security_group_ingress_rule" "docker_autoscaler_ingress" { |
27 |
| - for_each = var.runner_worker.type == "docker-autoscaler" ? var.runner_worker_ingress_rules : {} |
28 |
| - |
29 |
| - security_group_id = aws_security_group.docker_autoscaler[0].id |
30 |
| - |
31 |
| - from_port = each.value.from_port |
32 |
| - to_port = each.value.to_port |
33 |
| - ip_protocol = each.value.protocol |
34 |
| - |
35 |
| - description = each.value.description |
36 |
| - prefix_list_id = each.value.prefix_list_id |
37 |
| - referenced_security_group_id = each.value.security_group |
38 |
| - cidr_ipv4 = each.value.cidr_block |
39 |
| - cidr_ipv6 = each.value.ipv6_cidr_block |
40 |
| -} |
41 |
| - |
42 |
| -resource "aws_vpc_security_group_ingress_rule" "docker_autoscaler_internal_traffic" { |
43 |
| - count = var.runner_worker.type == "docker-autoscaler" ? 1 : 0 |
44 |
| - |
45 |
| - security_group_id = aws_security_group.docker_autoscaler[0].id |
46 |
| - from_port = -1 |
47 |
| - to_port = -1 |
48 |
| - ip_protocol = "-1" |
49 |
| - description = "Allow ALL Ingress traffic between Runner Manager and Docker-autoscaler workers security group" |
50 |
| - referenced_security_group_id = aws_security_group.runner.id |
51 |
| -} |
52 |
| - |
53 |
| -# Egress rules |
54 |
| -resource "aws_vpc_security_group_egress_rule" "docker_autoscaler_egress" { |
55 |
| - for_each = var.runner_worker.type == "docker-autoscaler" ? var.runner_worker_egress_rules : {} |
56 |
| - |
57 |
| - security_group_id = aws_security_group.docker_autoscaler[0].id |
58 |
| - |
59 |
| - from_port = each.value.from_port |
60 |
| - to_port = each.value.to_port |
61 |
| - ip_protocol = each.value.protocol |
62 |
| - |
63 |
| - description = each.value.description |
64 |
| - prefix_list_id = each.value.prefix_list_id |
65 |
| - referenced_security_group_id = each.value.security_group |
66 |
| - cidr_ipv4 = each.value.cidr_block |
67 |
| - cidr_ipv6 = each.value.ipv6_cidr_block |
68 |
| -} |
69 |
| - |
70 | 6 | ####################################
|
71 | 7 | ###### Launch template Workers #####
|
72 | 8 | ####################################
|
@@ -215,3 +151,26 @@ resource "aws_autoscaling_group" "autoscaler" {
|
215 | 151 | ]
|
216 | 152 | }
|
217 | 153 | }
|
| 154 | + |
| 155 | +resource "aws_iam_instance_profile" "docker_autoscaler" { |
| 156 | + count = var.runner_worker.type == "docker-autoscaler" ? 1 : 0 |
| 157 | + name = "${local.name_iam_objects}-docker-autoscaler" |
| 158 | + role = aws_iam_role.docker_autoscaler[0].name |
| 159 | + tags = local.tags |
| 160 | +} |
| 161 | + |
| 162 | +resource "tls_private_key" "autoscaler" { |
| 163 | + count = var.runner_worker.type == "docker-autoscaler" ? 1 : 0 |
| 164 | + |
| 165 | + algorithm = "RSA" |
| 166 | + rsa_bits = 4096 |
| 167 | +} |
| 168 | + |
| 169 | +resource "aws_key_pair" "autoscaler" { |
| 170 | + count = var.runner_worker.type == "docker-autoscaler" ? 1 : 0 |
| 171 | + |
| 172 | + key_name = "${var.environment}-${var.runner_worker_docker_autoscaler.key_pair_name}" |
| 173 | + public_key = tls_private_key.autoscaler[0].public_key_openssh |
| 174 | + |
| 175 | + tags = local.tags |
| 176 | +} |
0 commit comments