Skip to content

chore: Release #520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 20, 2022
4 changes: 0 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ YES | NO - If yes please describe the migration.

Please mention the examples you have verified.

## Documentation

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.

2 changes: 1 addition & 1 deletion .release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"@semantic-release/github": "^7.2.0",
"@semantic-release/release-notes-generator": "^9.0.1",
"conventional-changelog-conventionalcommits": "^4.5.0",
"semantic-release": "^17.3.9"
"semantic-release": "^19.0.3"
}
}
1,721 changes: 802 additions & 919 deletions .release/yarn.lock

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ Made with [contributors-img](https://contrib.rocks).
| [aws_security_group_rule.runner_ping_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_ssm_parameter.runner_registration_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
| [aws_ssm_parameter.runner_sentry_dsn](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
| [aws_ami.docker-machine](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
| [aws_ami.docker_machine](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
| [aws_ami.runner](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
| [aws_availability_zone.runners](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zone) | data source |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
Expand Down Expand Up @@ -450,14 +450,13 @@ Made with [contributors-img](https://contrib.rocks).
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down Expand Up @@ -486,11 +485,11 @@ Made with [contributors-img](https://contrib.rocks).
| <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 |
| <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 |
| <a name="input_runners_root_size"></a> [runners\_root\_size](#input\_runners\_root\_size) | Runner instance root size in GB. | `number` | `16` | no |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down
8 changes: 4 additions & 4 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
locals {
// Convert list to a string separated and prepend by a comma
# Convert list to a string separated and prepend by a comma
docker_machine_options_string = format(
",\"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",
join(",", formatlist("%q", concat(var.docker_machine_options, local.runners_docker_registry_mirror_option))),
)

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

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

// Define key for runner token for SSM
# Define key for runner token for SSM
secure_parameter_store_runner_token_key = "${var.environment}-${var.secure_parameter_store_runner_token_key}"
secure_parameter_store_runner_sentry_dsn = "${var.environment}-${var.secure_parameter_store_runner_sentry_dsn}"

// Custom names for runner agent instance, security groups, and IAM objects
# Custom names for runner agent instance, security groups, and IAM objects
name_runner_agent_instance = var.overrides["name_runner_agent_instance"] == "" ? local.tags["Name"] : var.overrides["name_runner_agent_instance"]
name_sg = var.overrides["name_sg"] == "" ? local.tags["Name"] : var.overrides["name_sg"]
name_iam_objects = lookup(var.overrides, "name_iam_objects", "") == "" ? local.tags["Name"] : var.overrides["name_iam_objects"]
Expand Down
5 changes: 3 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ locals {
{
aws_region = var.aws_region
gitlab_url = var.runners_gitlab_url
gitlab_clone_url = var.runners_clone_url
runners_vpc_id = var.vpc_id
runners_subnet_id = length(var.subnet_id) > 0 ? var.subnet_id : var.subnet_id_runners
runners_aws_zone = data.aws_availability_zone.runners.name_suffix
runners_instance_type = var.docker_machine_instance_type
runners_spot_price_bid = var.docker_machine_spot_price_bid == "on-demand-price" ? "" : var.docker_machine_spot_price_bid
runners_ami = data.aws_ami.docker-machine.id
runners_ami = data.aws_ami.docker_machine.id
runners_security_group_name = aws_security_group.docker_machine.name
runners_monitoring = var.runners_monitoring
runners_ebs_optimized = var.runners_ebs_optimized
Expand Down Expand Up @@ -137,7 +138,7 @@ locals {
)
}

data "aws_ami" "docker-machine" {
data "aws_ami" "docker_machine" {
most_recent = "true"

dynamic "filter" {
Expand Down
6 changes: 3 additions & 3 deletions modules/cache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ module "runner" {

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

## Providers

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

## Modules
Expand Down
1 change: 0 additions & 1 deletion modules/cache/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ resource "aws_s3_bucket" "build_cache" {
tags = local.tags

force_destroy = true

}

resource "aws_s3_bucket_acl" "build_cache_acl" {
Expand Down
5 changes: 2 additions & 3 deletions modules/cache/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

terraform {
required_version = ">= 0.15"
required_version = ">= 1"

required_providers {
aws = {
version = ">= 4.0"
version = ">= 4"
source = "hashicorp/aws"
}
}
Expand Down
6 changes: 3 additions & 3 deletions modules/terminate-instances/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ module "runner" {

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

## Providers

| Name | Version |
|------|---------|
| <a name="provider_archive"></a> [archive](#provider\_archive) | n/a |
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4 |

## Modules

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

Expand Down
4 changes: 3 additions & 1 deletion modules/terminate-instances/cloudwatch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ resource "aws_cloudwatch_event_rule" "terminate_instances" {
}
}
EOF

tags = var.tags
}

resource "aws_cloudwatch_event_target" "terminate_instances" {
Expand All @@ -30,4 +32,4 @@ resource "aws_cloudwatch_log_group" "lambda" {
retention_in_days = var.cloudwatch_logging_retention_in_days

tags = var.tags
}
}
6 changes: 2 additions & 4 deletions modules/terminate-instances/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# Deploys a Lambda function, CloudWatch rule, and associated resources for
# terminating orphaned runner instances.
# ----------------------------------------------------------------------------
data "aws_caller_identity" "current" {}

locals {
source_sha256 = filesha256("${path.module}/lambda/lambda_function.py")
}
Expand Down Expand Up @@ -43,7 +41,7 @@ resource "aws_lambda_permission" "current_version_triggers" {

resource "aws_lambda_permission" "unqualified_alias_triggers" {
function_name = aws_lambda_function.terminate_runner_instances.function_name
statement_id = "TerminateInstanceEvent"
statement_id = "TerminateInstanceEventUnqualified"
action = "lambda:InvokeFunction"
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.terminate_instances.arn
Expand All @@ -55,4 +53,4 @@ resource "aws_autoscaling_lifecycle_hook" "terminate_instances" {
default_result = "CONTINUE"
heartbeat_timeout = var.lifecycle_heartbeat_timeout
lifecycle_transition = "autoscaling:EC2_INSTANCE_TERMINATING"
}
}
10 changes: 8 additions & 2 deletions modules/terminate-instances/versions.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

terraform {
required_version = ">= 0.15"
required_version = ">= 1"

required_providers {
aws = {
version = ">= 4"
source = "hashicorp/aws"
}
}
}
1 change: 1 addition & 0 deletions template/runner-config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ listen_address = "${prometheus_listen_address}"
[[runners]]
name = "${runners_name}"
url = "${gitlab_url}"
clone_url = "${gitlab_clone_url}"
token = "${runners_token}"
executor = "${runners_executor}"
environment = ${runners_environment_vars}
Expand Down
30 changes: 8 additions & 22 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,28 +95,6 @@ variable "docker_machine_instance_metadata_options" {
}
}

variable "runner_instance_metadata_options_http_endpoint" {
description = "DEPRECATED, replaced by runner_instance_metadata_options. Enable the Gitlab runner agent instance metadata service. The allowed values are enabled, disabled."
type = string
default = null

validation {
condition = var.runner_instance_metadata_options_http_endpoint == null
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."
}
}

variable "runner_instance_metadata_options_http_tokens" {
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."
type = string
default = null

validation {
condition = var.runner_instance_metadata_options_http_tokens == null
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."
}
}

variable "docker_machine_instance_type" {
description = "Instance type used for the instances hosting docker-machine."
type = string
Expand Down Expand Up @@ -163,6 +141,12 @@ variable "runners_gitlab_url" {
type = string
}

variable "runners_clone_url" {
description = "Overwrites the URL for the GitLab instance. Use only if the runner can’t connect to the GitLab URL."
type = string
default = ""
}

variable "runners_token" {
description = "Token for the runner, will be used in the runner config.toml."
type = string
Expand Down Expand Up @@ -655,6 +639,7 @@ variable "enable_docker_machine_ssm_access" {
}

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

variable "runners_services_volumes_tmpfs" {
description = "Mount a tmpfs in gitlab service container. https://docs.gitlab.com/runner/executors/docker.html#mounting-a-directory-in-ram"
type = list(object({
volume = string
options = string
Expand Down
4 changes: 0 additions & 4 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@ terraform {
version = "~> 4"
source = "hashicorp/aws"
}

null = {
source = "hashicorp/null"
}
}
}