Skip to content

Commit d056b09

Browse files
authored
Merge pull request #581 from npalm/develop
chore: Release
2 parents 1f3fce9 + a67b87b commit d056b09

16 files changed

+113
-127
lines changed

Diff for: .release/yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ compare-func@^2.0.0:
928928
929929
version "0.0.1"
930930
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
931-
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
931+
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
932932

933933
console-control-strings@^1.1.0:
934934
version "1.1.0"
@@ -2148,9 +2148,9 @@ min-indent@^1.0.0:
21482148
integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==
21492149

21502150
minimatch@^3.0.4:
2151-
version "3.0.4"
2152-
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
2153-
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
2151+
version "3.1.2"
2152+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
2153+
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
21542154
dependencies:
21552155
brace-expansion "^1.1.7"
21562156

Diff for: README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
- [Usage](#usage)
88
- [Examples](#examples)
99
- [Contributors ✨](#contributors-)
10+
- [Requirements](#requirements)
11+
- [Providers](#providers)
12+
- [Modules](#modules)
13+
- [Resources](#resources)
14+
- [Inputs](#inputs)
15+
- [Outputs](#outputs)
1016

1117
## The module
1218

@@ -159,10 +165,8 @@ persist that contains the packaged Lambda function.
159165

160166
A few option are provided to access the runner instance:
161167

162-
1. Provide a public ssh key to access the runner by setting \`\`.
163-
2. Provide a EC2 key pair to access the runner by setting \`\`.
164-
3. Access via the Session Manager (SSM) by setting `enable_runner_ssm_access` to `true`. The policy to allow access via SSM is not very restrictive.
165-
4. By setting none of the above, no keys or extra policies will be attached to the instance. You can still configure you own policies by attaching them to `runner_agent_role_arn`.
168+
1. Access via the Session Manager (SSM) by setting `enable_runner_ssm_access` to `true`. The policy to allow access via SSM is not very restrictive.
169+
2. By setting none of the above, no keys or extra policies will be attached to the instance. You can still configure you own policies by attaching them to `runner_agent_role_arn`.
166170

167171
### GitLab runner cache
168172

@@ -188,7 +192,7 @@ The base image used to host the GitLab Runner agent is the latest available Amaz
188192

189193
### Scenario: Basic usage
190194

191-
Below is a basic examples of usages of the module. Regarding the dependencies such as a VPC and SSH keys, have a look at the [default example](https://github.com/npalm/terraform-aws-gitlab-runner/tree/develop/examples/runner-default).
195+
Below is a basic examples of usages of the module. Regarding the dependencies such as a VPC, have a look at the [default example](https://github.com/npalm/terraform-aws-gitlab-runner/tree/develop/examples/runner-default).
192196

193197
```hcl
194198
module "runner" {
@@ -198,8 +202,6 @@ module "runner" {
198202
aws_region = "eu-west-1"
199203
environment = "spot-runners"
200204
201-
ssh_public_key = local_file.public_ssh_key.content
202-
203205
vpc_id = module.vpc.vpc_id
204206
subnet_ids_gitlab_runner = module.vpc.private_subnets
205207
subnet_id_runners = element(module.vpc.private_subnets, 0)
@@ -236,8 +238,6 @@ module "runner" {
236238
aws_region = "eu-west-1"
237239
environment = "spot-runners"
238240
239-
ssh_public_key = local_file.public_ssh_key.content
240-
241241
vpc_id = module.vpc.vpc_id
242242
subnet_ids_gitlab_runner = module.vpc.private_subnets
243243
subnet_id_runners = element(module.vpc.private_subnets, 0)
@@ -266,17 +266,13 @@ module "runner" {
266266

267267
A few [examples](https://github.com/npalm/terraform-aws-gitlab-runner/tree/develop/examples/) are provided. Use the following steps to deploy. Ensure your AWS and Terraform environment is set up correctly. All commands below should be run from the `terraform-aws-gitlab-runner/examples/<example-dir>` directory. Don't forget to remove the runners manually from your Gitlab instance as soon as your are done.
268268

269-
### SSH keys
270-
271-
SSH keys are generated by Terraform and stored in the `generated` directory of each example directory.
272-
273269
### Versions
274270

275271
The version of Terraform is locked down via tfenv, see the `.terraform-version` file for the expected versions. Providers are locked down as well in the `providers.tf` file.
276272

277273
### Configure
278274

279-
The examples are configured with defaults that should work in general. The examples are in general configured for the region Ireland `eu-west-1`. The only parameter that needs to be provided is the GitLab registration token. The token can be found in GitLab in the runner section (global, group or repo scope). Create a file `terrafrom.tfvars` and the registration token.
275+
The examples are configured with defaults that should work in general. The examples are in general configured for the region Ireland `eu-west-1`. The only parameter that needs to be provided is the GitLab registration token. The token can be found in GitLab in the runner section (global, group or repo scope). Create a file `terraform.tfvars` and the registration token.
280276

281277
registration_token = "MY_TOKEN"
282278

@@ -376,6 +372,7 @@ Made with [contributors-img](https://contrib.rocks).
376372
| [aws_ami.runner](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
377373
| [aws_availability_zone.runners](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zone) | data source |
378374
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
375+
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
379376
| [aws_subnet.runners](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet) | data source |
380377

381378
## Inputs
@@ -386,7 +383,7 @@ Made with [contributors-img](https://contrib.rocks).
386383
| <a name="input_allow_iam_service_linked_role_creation"></a> [allow\_iam\_service\_linked\_role\_creation](#input\_allow\_iam\_service\_linked\_role\_creation) | Boolean used to control attaching the policy to a runner instance to create service linked roles. | `bool` | `true` | no |
387384
| <a name="input_ami_filter"></a> [ami\_filter](#input\_ami\_filter) | List of maps used to create the AMI filter for the Gitlab runner agent AMI. Must resolve to an Amazon Linux 1 or 2 image. | `map(list(string))` | <pre>{<br> "name": [<br> "amzn2-ami-hvm-2.*-x86_64-ebs"<br> ]<br>}</pre> | no |
388385
| <a name="input_ami_owners"></a> [ami\_owners](#input\_ami\_owners) | The list of owners used to select the AMI of Gitlab runner agent instances. | `list(string)` | <pre>[<br> "amazon"<br>]</pre> | no |
389-
| <a name="input_arn_format"></a> [arn\_format](#input\_arn\_format) | ARN format to be used. May be changed to support deployment in GovCloud/China regions. | `string` | `"arn:aws"` | no |
386+
| <a name="input_arn_format"></a> [arn\_format](#input\_arn\_format) | Deprecated! Calculated automatically by the module. ARN format to be used. May be changed to support deployment in GovCloud/China regions. | `string` | `null` | no |
390387
| <a name="input_asg_delete_timeout"></a> [asg\_delete\_timeout](#input\_asg\_delete\_timeout) | Timeout when trying to delete the Runner ASG. | `string` | `"10m"` | no |
391388
| <a name="input_asg_max_instance_lifetime"></a> [asg\_max\_instance\_lifetime](#input\_asg\_max\_instance\_lifetime) | The seconds before an instance is refreshed in the ASG. | `number` | `null` | no |
392389
| <a name="input_asg_terminate_lifecycle_hook_create"></a> [asg\_terminate\_lifecycle\_hook\_create](#input\_asg\_terminate\_lifecycle\_hook\_create) | Boolean toggling the creation of the ASG instance terminate lifecycle hook. | `bool` | `true` | no |
@@ -405,6 +402,7 @@ Made with [contributors-img](https://contrib.rocks).
405402
| <a name="input_cache_expiration_days"></a> [cache\_expiration\_days](#input\_cache\_expiration\_days) | Number of days before cache objects expires. | `number` | `1` | no |
406403
| <a name="input_cache_shared"></a> [cache\_shared](#input\_cache\_shared) | Enables cache sharing between runners, false by default. | `bool` | `false` | no |
407404
| <a name="input_cloudwatch_logging_retention_in_days"></a> [cloudwatch\_logging\_retention\_in\_days](#input\_cloudwatch\_logging\_retention\_in\_days) | Retention for cloudwatch logs. Defaults to unlimited | `number` | `0` | no |
405+
| <a name="input_create_runner_iam_role"></a> [create\_runner\_iam\_role](#input\_create\_runner\_iam\_role) | Whether to create the runner IAM role of the gitlab runner agent EC2 instance. | `bool` | `true` | no |
408406
| <a name="input_docker_machine_download_url"></a> [docker\_machine\_download\_url](#input\_docker\_machine\_download\_url) | (Optional) By default the module will use `docker_machine_version` to download the GitLab mantained version of Docker Machine. Alternative you can set this property to download location of the distribution of for the OS. See also https://docs.gitlab.com/runner/executors/docker_machine.html#install | `string` | `""` | no |
409407
| <a name="input_docker_machine_egress_rules"></a> [docker\_machine\_egress\_rules](#input\_docker\_machine\_egress\_rules) | List of egress rules for the docker-machine instance(s). | <pre>list(object({<br> cidr_blocks = list(string)<br> ipv6_cidr_blocks = list(string)<br> prefix_list_ids = list(string)<br> from_port = number<br> protocol = string<br> security_groups = list(string)<br> self = bool<br> to_port = number<br> description = string<br> }))</pre> | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "description": "Allow all egress traffic for docker machine build runners",<br> "from_port": 0,<br> "ipv6_cidr_blocks": [<br> "::/0"<br> ],<br> "prefix_list_ids": null,<br> "protocol": "-1",<br> "security_groups": null,<br> "self": null,<br> "to_port": 0<br> }<br>]</pre> | no |
410408
| <a name="input_docker_machine_iam_policy_arns"></a> [docker\_machine\_iam\_policy\_arns](#input\_docker\_machine\_iam\_policy\_arns) | List of policy ARNs to be added to the instance profile of the docker machine runners. | `list(string)` | `[]` | no |
@@ -447,6 +445,7 @@ Made with [contributors-img](https://contrib.rocks).
447445
| <a name="input_runner_ami_filter"></a> [runner\_ami\_filter](#input\_runner\_ami\_filter) | List of maps used to create the AMI filter for the Gitlab runner docker-machine AMI. | `map(list(string))` | <pre>{<br> "name": [<br> "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"<br> ]<br>}</pre> | no |
448446
| <a name="input_runner_ami_owners"></a> [runner\_ami\_owners](#input\_runner\_ami\_owners) | The list of owners used to select the AMI of Gitlab runner docker-machine instances. | `list(string)` | <pre>[<br> "099720109477"<br>]</pre> | no |
449447
| <a name="input_runner_iam_policy_arns"></a> [runner\_iam\_policy\_arns](#input\_runner\_iam\_policy\_arns) | List of policy ARNs to be added to the instance profile of the gitlab runner agent ec2 instance. | `list(string)` | `[]` | no |
448+
| <a name="input_runner_iam_role_name"></a> [runner\_iam\_role\_name](#input\_runner\_iam\_role\_name) | IAM role name of the gitlab runner agent EC2 instance. If unspecified then `{name_iam_objects}-instance` is used | `string` | `""` | no |
450449
| <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 |
451450
| <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 |
452451
| <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 |
@@ -492,6 +491,7 @@ Made with [contributors-img](https://contrib.rocks).
492491
| <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 |
493492
| <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 |
494493
| <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 |
494+
| <a name="input_runners_volume_type"></a> [runners\_volume\_type](#input\_runners\_volume\_type) | Runner instance volume type | `string` | `"gp2"` | no |
495495
| <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 |
496496
| <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 |
497497
| <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 |

Diff for: examples/runner-multi-region/_docs/README.md

-18
This file was deleted.

Diff for: examples/runner-multi-region/_docs/TF_MODULE.md

-25
This file was deleted.

Diff for: kms.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ resource "aws_kms_key" "default" {
77
tags = local.tags
88
policy = templatefile("${path.module}/policies/kms-policy.json",
99
{
10-
arn_format = var.arn_format
10+
partition = data.aws_partition.current.partition
1111
aws_region = var.aws_region
1212
account_id = data.aws_caller_identity.current.account_id
1313
}

Diff for: locals.tf

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
locals {
2+
# Determine IAM role for runner instance
3+
aws_iam_role_instance_name = coalesce(
4+
var.runner_iam_role_name,
5+
"${local.name_iam_objects}-instance"
6+
)
7+
aws_iam_role_instance_arn = "arn:${data.aws_partition.current.partition}:iam:${data.aws_caller_identity.current.account_id}:role/${local.aws_iam_role_instance_name}"
8+
29
# Convert list to a string separated and prepend by a comma
310
docker_machine_options_string = format(
411
",\"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",

Diff for: logging.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
resource "aws_iam_role_policy" "instance" {
22
count = var.enable_cloudwatch_logging ? 1 : 0
33
name = "${local.name_iam_objects}-instance-role"
4-
role = aws_iam_role.instance.name
5-
policy = templatefile("${path.module}/policies/instance-logging-policy.json", { arn_format = var.arn_format })
4+
role = local.aws_iam_role_instance_name
5+
policy = templatefile("${path.module}/policies/instance-logging-policy.json", { partition = data.aws_partition.current.partition })
66
}
77

88
locals {

0 commit comments

Comments
 (0)