Skip to content

Commit 56658ae

Browse files
authored
Merge pull request #520 from npalm/develop
chore: Release
2 parents 900f8aa + 5b7bf4c commit 56658ae

16 files changed

+844
-978
lines changed

.github/pull_request_template.md

-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,3 @@ YES | NO - If yes please describe the migration.
1010

1111
Please mention the examples you have verified.
1212

13-
## Documentation
14-
15-
We use [pre-commit](https://pre-commit.com/) to update the Terraform inputs and outputs in the documentation via [terraform-docs](https://github.com/terraform-docs/terraform-docs). Ensure you have installed those components.
16-

.release/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"@semantic-release/github": "^7.2.0",
1414
"@semantic-release/release-notes-generator": "^9.0.1",
1515
"conventional-changelog-conventionalcommits": "^4.5.0",
16-
"semantic-release": "^17.3.9"
16+
"semantic-release": "^19.0.3"
1717
}
1818
}

.release/yarn.lock

+802-919
Large diffs are not rendered by default.

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ Made with [contributors-img](https://contrib.rocks).
372372
| [aws_security_group_rule.runner_ping_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
373373
| [aws_ssm_parameter.runner_registration_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
374374
| [aws_ssm_parameter.runner_sentry_dsn](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
375-
| [aws_ami.docker-machine](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
375+
| [aws_ami.docker_machine](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
376376
| [aws_ami.runner](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
377377
| [aws_availability_zone.runners](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zone) | data source |
378378
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
@@ -450,14 +450,13 @@ Made with [contributors-img](https://contrib.rocks).
450450
| <a name="input_runner_instance_ebs_optimized"></a> [runner\_instance\_ebs\_optimized](#input\_runner\_instance\_ebs\_optimized) | Enable the GitLab runner instance to be EBS-optimized. | `bool` | `true` | no |
451451
| <a name="input_runner_instance_enable_monitoring"></a> [runner\_instance\_enable\_monitoring](#input\_runner\_instance\_enable\_monitoring) | Enable the GitLab runner instance to have detailed monitoring. | `bool` | `true` | no |
452452
| <a name="input_runner_instance_metadata_options"></a> [runner\_instance\_metadata\_options](#input\_runner\_instance\_metadata\_options) | Enable the Gitlab runner agent instance metadata service. | <pre>object({<br> http_endpoint = string<br> http_tokens = string<br> http_put_response_hop_limit = number<br> instance_metadata_tags = string<br> })</pre> | <pre>{<br> "http_endpoint": "enabled",<br> "http_put_response_hop_limit": 2,<br> "http_tokens": "required",<br> "instance_metadata_tags": "disabled"<br>}</pre> | no |
453-
| <a name="input_runner_instance_metadata_options_http_endpoint"></a> [runner\_instance\_metadata\_options\_http\_endpoint](#input\_runner\_instance\_metadata\_options\_http\_endpoint) | DEPRECATED, replaced by runner\_instance\_metadata\_options. Enable the Gitlab runner agent instance metadata service. The allowed values are enabled, disabled. | `string` | `null` | no |
454-
| <a name="input_runner_instance_metadata_options_http_tokens"></a> [runner\_instance\_metadata\_options\_http\_tokens](#input\_runner\_instance\_metadata\_options\_http\_tokens) | EPRECATED, replaced by runner\_instance\_metadata\_options. Set if Gitlab runner agent instance metadata service session tokens are required. The allowed values are optional, required. | `string` | `null` | no |
455453
| <a name="input_runner_instance_spot_price"></a> [runner\_instance\_spot\_price](#input\_runner\_instance\_spot\_price) | By setting a spot price bid price the runner agent will be created via a spot request. Be aware that spot instances can be stopped by AWS. Choose "on-demand-price" to pay up to the current on demand price for the instance type chosen. | `string` | `null` | no |
456454
| <a name="input_runner_root_block_device"></a> [runner\_root\_block\_device](#input\_runner\_root\_block\_device) | The EC2 instance root block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops`, `throughput`, `kms_key_id` | `map(string)` | `{}` | no |
457455
| <a name="input_runner_tags"></a> [runner\_tags](#input\_runner\_tags) | Map of tags that will be added to runner EC2 instances. | `map(string)` | `{}` | no |
458456
| <a name="input_runners_add_dind_volumes"></a> [runners\_add\_dind\_volumes](#input\_runners\_add\_dind\_volumes) | Add certificates and docker.sock to the volumes to support docker-in-docker (dind) | `bool` | `false` | no |
459457
| <a name="input_runners_additional_volumes"></a> [runners\_additional\_volumes](#input\_runners\_additional\_volumes) | Additional volumes that will be used in the runner config.toml, e.g Docker socket | `list(any)` | `[]` | no |
460458
| <a name="input_runners_check_interval"></a> [runners\_check\_interval](#input\_runners\_check\_interval) | defines the interval length, in seconds, between new jobs check. | `number` | `3` | no |
459+
| <a name="input_runners_clone_url"></a> [runners\_clone\_url](#input\_runners\_clone\_url) | Overwrites the URL for the GitLab instance. Use only if the runner can’t connect to the GitLab URL. | `string` | `""` | no |
461460
| <a name="input_runners_concurrent"></a> [runners\_concurrent](#input\_runners\_concurrent) | Concurrent value for the runners, will be used in the runner config.toml. | `number` | `10` | no |
462461
| <a name="input_runners_disable_cache"></a> [runners\_disable\_cache](#input\_runners\_disable\_cache) | Runners will not use local cache, will be used in the runner config.toml | `bool` | `false` | no |
463462
| <a name="input_runners_docker_registry_mirror"></a> [runners\_docker\_registry\_mirror](#input\_runners\_docker\_registry\_mirror) | The docker registry mirror to use to avoid rate limiting by hub.docker.com | `string` | `""` | no |
@@ -486,11 +485,11 @@ Made with [contributors-img](https://contrib.rocks).
486485
| <a name="input_runners_request_concurrency"></a> [runners\_request\_concurrency](#input\_runners\_request\_concurrency) | Limit number of concurrent requests for new jobs from GitLab (default 1). | `number` | `1` | no |
487486
| <a name="input_runners_request_spot_instance"></a> [runners\_request\_spot\_instance](#input\_runners\_request\_spot\_instance) | Whether or not to request spot instances via docker-machine | `bool` | `true` | no |
488487
| <a name="input_runners_root_size"></a> [runners\_root\_size](#input\_runners\_root\_size) | Runner instance root size in GB. | `number` | `16` | no |
489-
| <a name="input_runners_services_volumes_tmpfs"></a> [runners\_services\_volumes\_tmpfs](#input\_runners\_services\_volumes\_tmpfs) | n/a | <pre>list(object({<br> volume = string<br> options = string<br> }))</pre> | `[]` | no |
488+
| <a name="input_runners_services_volumes_tmpfs"></a> [runners\_services\_volumes\_tmpfs](#input\_runners\_services\_volumes\_tmpfs) | Mount a tmpfs in gitlab service container. https://docs.gitlab.com/runner/executors/docker.html#mounting-a-directory-in-ram | <pre>list(object({<br> volume = string<br> options = string<br> }))</pre> | `[]` | no |
490489
| <a name="input_runners_shm_size"></a> [runners\_shm\_size](#input\_runners\_shm\_size) | shm\_size for the runners, will be used in the runner config.toml | `number` | `0` | no |
491490
| <a name="input_runners_token"></a> [runners\_token](#input\_runners\_token) | Token for the runner, will be used in the runner config.toml. | `string` | `"__REPLACED_BY_USER_DATA__"` | no |
492491
| <a name="input_runners_use_private_address"></a> [runners\_use\_private\_address](#input\_runners\_use\_private\_address) | Restrict runners to the use of a private IP address. If `runner_agent_uses_private_address` is set to `true`(default), `runners_use_private_address` will also apply for the agent. | `bool` | `true` | no |
493-
| <a name="input_runners_volumes_tmpfs"></a> [runners\_volumes\_tmpfs](#input\_runners\_volumes\_tmpfs) | n/a | <pre>list(object({<br> volume = string<br> options = string<br> }))</pre> | `[]` | no |
492+
| <a name="input_runners_volumes_tmpfs"></a> [runners\_volumes\_tmpfs](#input\_runners\_volumes\_tmpfs) | Mount a tmpfs in runner container. https://docs.gitlab.com/runner/executors/docker.html#mounting-a-directory-in-ram | <pre>list(object({<br> volume = string<br> options = string<br> }))</pre> | `[]` | no |
494493
| <a name="input_schedule_config"></a> [schedule\_config](#input\_schedule\_config) | Map containing the configuration of the ASG scale-in and scale-up for the runner instance. Will only be used if enable\_schedule is set to true. | `map(any)` | <pre>{<br> "scale_in_count": 0,<br> "scale_in_recurrence": "0 18 * * 1-5",<br> "scale_out_count": 1,<br> "scale_out_recurrence": "0 8 * * 1-5"<br>}</pre> | no |
495494
| <a name="input_secure_parameter_store_runner_sentry_dsn"></a> [secure\_parameter\_store\_runner\_sentry\_dsn](#input\_secure\_parameter\_store\_runner\_sentry\_dsn) | The Sentry DSN name used to store the Sentry DSN in Secure Parameter Store | `string` | `"sentry-dsn"` | no |
496495
| <a name="input_secure_parameter_store_runner_token_key"></a> [secure\_parameter\_store\_runner\_token\_key](#input\_secure\_parameter\_store\_runner\_token\_key) | The key name used store the Gitlab runner token in Secure Parameter Store | `string` | `"runner-token"` | no |

locals.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
locals {
2-
// Convert list to a string separated and prepend by a comma
2+
# Convert list to a string separated and prepend by a comma
33
docker_machine_options_string = format(
44
",\"amazonec2-metadata-token=${var.docker_machine_instance_metadata_options.http_tokens}\", \"amazonec2-metadata-token-response-hop-limit=${var.docker_machine_instance_metadata_options.http_put_response_hop_limit}\",%s",
55
join(",", formatlist("%q", concat(var.docker_machine_options, local.runners_docker_registry_mirror_option))),
66
)
77

88
runners_docker_registry_mirror_option = var.runners_docker_registry_mirror == "" ? [] : ["engine-registry-mirror=${var.runners_docker_registry_mirror}"]
99

10-
// Ensure max builds is optional
10+
# Ensure max builds is optional
1111
runners_max_builds_string = var.runners_max_builds == 0 ? "" : format("MaxBuilds = %d", var.runners_max_builds)
1212

13-
// Define key for runner token for SSM
13+
# Define key for runner token for SSM
1414
secure_parameter_store_runner_token_key = "${var.environment}-${var.secure_parameter_store_runner_token_key}"
1515
secure_parameter_store_runner_sentry_dsn = "${var.environment}-${var.secure_parameter_store_runner_sentry_dsn}"
1616

17-
// Custom names for runner agent instance, security groups, and IAM objects
17+
# Custom names for runner agent instance, security groups, and IAM objects
1818
name_runner_agent_instance = var.overrides["name_runner_agent_instance"] == "" ? local.tags["Name"] : var.overrides["name_runner_agent_instance"]
1919
name_sg = var.overrides["name_sg"] == "" ? local.tags["Name"] : var.overrides["name_sg"]
2020
name_iam_objects = lookup(var.overrides, "name_iam_objects", "") == "" ? local.tags["Name"] : var.overrides["name_iam_objects"]

main.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,13 @@ locals {
7575
{
7676
aws_region = var.aws_region
7777
gitlab_url = var.runners_gitlab_url
78+
gitlab_clone_url = var.runners_clone_url
7879
runners_vpc_id = var.vpc_id
7980
runners_subnet_id = length(var.subnet_id) > 0 ? var.subnet_id : var.subnet_id_runners
8081
runners_aws_zone = data.aws_availability_zone.runners.name_suffix
8182
runners_instance_type = var.docker_machine_instance_type
8283
runners_spot_price_bid = var.docker_machine_spot_price_bid == "on-demand-price" ? "" : var.docker_machine_spot_price_bid
83-
runners_ami = data.aws_ami.docker-machine.id
84+
runners_ami = data.aws_ami.docker_machine.id
8485
runners_security_group_name = aws_security_group.docker_machine.name
8586
runners_monitoring = var.runners_monitoring
8687
runners_ebs_optimized = var.runners_ebs_optimized
@@ -137,7 +138,7 @@ locals {
137138
)
138139
}
139140

140-
data "aws_ami" "docker-machine" {
141+
data "aws_ami" "docker_machine" {
141142
most_recent = "true"
142143

143144
dynamic "filter" {

modules/cache/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ module "runner" {
3131

3232
| Name | Version |
3333
|------|---------|
34-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.15 |
35-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0 |
34+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1 |
35+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4 |
3636

3737
## Providers
3838

3939
| Name | Version |
4040
|------|---------|
41-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.0 |
41+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4 |
4242
| <a name="provider_random"></a> [random](#provider\_random) | n/a |
4343

4444
## Modules

modules/cache/main.tf

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ resource "aws_s3_bucket" "build_cache" {
3333
tags = local.tags
3434

3535
force_destroy = true
36-
3736
}
3837

3938
resource "aws_s3_bucket_acl" "build_cache_acl" {

modules/cache/versions.tf

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
21
terraform {
3-
required_version = ">= 0.15"
2+
required_version = ">= 1"
43

54
required_providers {
65
aws = {
7-
version = ">= 4.0"
6+
version = ">= 4"
87
source = "hashicorp/aws"
98
}
109
}

modules/terminate-instances/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,15 @@ module "runner" {
9898

9999
| Name | Version |
100100
|------|---------|
101-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.15 |
101+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1 |
102+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4 |
102103

103104
## Providers
104105

105106
| Name | Version |
106107
|------|---------|
107108
| <a name="provider_archive"></a> [archive](#provider\_archive) | n/a |
108-
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
109+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4 |
109110

110111
## Modules
111112

@@ -126,7 +127,6 @@ No modules.
126127
| [aws_lambda_permission.current_version_triggers](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
127128
| [aws_lambda_permission.unqualified_alias_triggers](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
128129
| [archive_file.terminate_runner_instances_lambda](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source |
129-
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
130130
| [aws_iam_policy_document.assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
131131
| [aws_iam_policy_document.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
132132

modules/terminate-instances/cloudwatch.tf

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ resource "aws_cloudwatch_event_rule" "terminate_instances" {
1717
}
1818
}
1919
EOF
20+
21+
tags = var.tags
2022
}
2123

2224
resource "aws_cloudwatch_event_target" "terminate_instances" {
@@ -30,4 +32,4 @@ resource "aws_cloudwatch_log_group" "lambda" {
3032
retention_in_days = var.cloudwatch_logging_retention_in_days
3133

3234
tags = var.tags
33-
}
35+
}

modules/terminate-instances/main.tf

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# Deploys a Lambda function, CloudWatch rule, and associated resources for
55
# terminating orphaned runner instances.
66
# ----------------------------------------------------------------------------
7-
data "aws_caller_identity" "current" {}
8-
97
locals {
108
source_sha256 = filesha256("${path.module}/lambda/lambda_function.py")
119
}
@@ -43,7 +41,7 @@ resource "aws_lambda_permission" "current_version_triggers" {
4341

4442
resource "aws_lambda_permission" "unqualified_alias_triggers" {
4543
function_name = aws_lambda_function.terminate_runner_instances.function_name
46-
statement_id = "TerminateInstanceEvent"
44+
statement_id = "TerminateInstanceEventUnqualified"
4745
action = "lambda:InvokeFunction"
4846
principal = "events.amazonaws.com"
4947
source_arn = aws_cloudwatch_event_rule.terminate_instances.arn
@@ -55,4 +53,4 @@ resource "aws_autoscaling_lifecycle_hook" "terminate_instances" {
5553
default_result = "CONTINUE"
5654
heartbeat_timeout = var.lifecycle_heartbeat_timeout
5755
lifecycle_transition = "autoscaling:EC2_INSTANCE_TERMINATING"
58-
}
56+
}
+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
21
terraform {
3-
required_version = ">= 0.15"
2+
required_version = ">= 1"
3+
4+
required_providers {
5+
aws = {
6+
version = ">= 4"
7+
source = "hashicorp/aws"
8+
}
9+
}
410
}

template/runner-config.tpl

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ listen_address = "${prometheus_listen_address}"
77
[[runners]]
88
name = "${runners_name}"
99
url = "${gitlab_url}"
10+
clone_url = "${gitlab_clone_url}"
1011
token = "${runners_token}"
1112
executor = "${runners_executor}"
1213
environment = ${runners_environment_vars}

variables.tf

+8-22
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,6 @@ variable "docker_machine_instance_metadata_options" {
9595
}
9696
}
9797

98-
variable "runner_instance_metadata_options_http_endpoint" {
99-
description = "DEPRECATED, replaced by runner_instance_metadata_options. Enable the Gitlab runner agent instance metadata service. The allowed values are enabled, disabled."
100-
type = string
101-
default = null
102-
103-
validation {
104-
condition = var.runner_instance_metadata_options_http_endpoint == null
105-
error_message = "The \"runner_instance_metadata_options_http_endpoint\" variable is no longer used. To migrate, set the \"runner_instance_metadata_options.http_endpoint\" variable to the original value."
106-
}
107-
}
108-
109-
variable "runner_instance_metadata_options_http_tokens" {
110-
description = "EPRECATED, replaced by runner_instance_metadata_options. Set if Gitlab runner agent instance metadata service session tokens are required. The allowed values are optional, required."
111-
type = string
112-
default = null
113-
114-
validation {
115-
condition = var.runner_instance_metadata_options_http_tokens == null
116-
error_message = "The \"runner_instance_metadata_options_http_tokens\" variable is no longer used. To migrate, set the \"runner_instance_metadata_options.http_token\" variable to the original value."
117-
}
118-
}
119-
12098
variable "docker_machine_instance_type" {
12199
description = "Instance type used for the instances hosting docker-machine."
122100
type = string
@@ -163,6 +141,12 @@ variable "runners_gitlab_url" {
163141
type = string
164142
}
165143

144+
variable "runners_clone_url" {
145+
description = "Overwrites the URL for the GitLab instance. Use only if the runner can’t connect to the GitLab URL."
146+
type = string
147+
default = ""
148+
}
149+
166150
variable "runners_token" {
167151
description = "Token for the runner, will be used in the runner config.toml."
168152
type = string
@@ -655,6 +639,7 @@ variable "enable_docker_machine_ssm_access" {
655639
}
656640

657641
variable "runners_volumes_tmpfs" {
642+
description = "Mount a tmpfs in runner container. https://docs.gitlab.com/runner/executors/docker.html#mounting-a-directory-in-ram"
658643
type = list(object({
659644
volume = string
660645
options = string
@@ -663,6 +648,7 @@ variable "runners_volumes_tmpfs" {
663648
}
664649

665650
variable "runners_services_volumes_tmpfs" {
651+
description = "Mount a tmpfs in gitlab service container. https://docs.gitlab.com/runner/executors/docker.html#mounting-a-directory-in-ram"
666652
type = list(object({
667653
volume = string
668654
options = string

versions.tf

-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,5 @@ terraform {
66
version = "~> 4"
77
source = "hashicorp/aws"
88
}
9-
10-
null = {
11-
source = "hashicorp/null"
12-
}
139
}
1410
}

0 commit comments

Comments
 (0)