Skip to content

Commit

Permalink
Merge branch 'release/4.19.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
npalm committed Jul 12, 2020
2 parents 9faa057 + 4a37d47 commit 53c6b52
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 25 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## 4.19.0 - 2020-07-12

- Changed: Variable aws_zone no longer needed (#232) by @kayma-hl
- Changed: Update default GitLab runner version to 13.1.1 (#239)
- Changed: Merge the tags for the runner agent to remove duplicate tags (#238) @kayma-hl


## 4.18.0 - 2020-06-01

- Changed: Update default runner version to 13.0.1


- Bugfix: Remove duplicate tag names from the tags assigned to the runner agent instance to ensure the correct name (#233) @kayma-hl

## 4.18.0 - 2020-06-01

Expand Down Expand Up @@ -367,7 +380,8 @@ Module is available as Terraform 0.11 module, pin module to version 3.x. Please
- Update default AMI's to The latest Amazon Linux AMI 2017.09.1 - released on 2018-01-17.
- Minor updates in the example

[unreleased]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/4.18.0...HEAD
[unreleased]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/4.19.0...HEAD
[4.19.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/4.19.0...4.18.0
[4.18.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/4.18.0...4.17.0
[4.17.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/4.17.0...4.16.0
[4.16.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/4.16.0...4.15.0
Expand Down
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ The runners created by the module using by default spot instances for running th
- Logs streamed to CloudWatch.
- Runner agents registered automatically.

The name of the runner agent and runner is set with the overrides variable. Adding an agent runner name tag does not work.

``` hcl
...
overrides = {
name_sg = ""
name_runner_agent_instance = "Gitlab Runner Agent"
name_docker_machine_runners = "Gitlab Runner Terraform"
}
//this doesn't work
agent_tags = merge(local.my_tags, map("Name", "Gitlab Runner Agent"))
```

The runner support 3 main scenario's:

### GitLab CI docker-machine runner - one runner agent
Expand Down Expand Up @@ -260,7 +274,7 @@ terraform destroy
| ami\_owners | The list of owners used to select the AMI of Gitlab runner agent instances. | `list(string)` | <pre>[<br> "amazon"<br>]</pre> | no |
| arn\_format | ARN format to be used. May be changed to support deployment in GovCloud/China regions. | `string` | `"arn:aws"` | no |
| aws\_region | AWS region. | `string` | n/a | yes |
| aws\_zone | AWS availability zone (typically 'a', 'b', or 'c'). | `string` | `"a"` | no |
| aws\_zone | Deprecated. Will be removed in the next major release. | `string` | `"a"` | no |
| cache\_bucket | Configuration to control the creation of the cache bucket. By default the bucket will be created and used as shared cache. To use the same cache across multiple runners disable the creation of the cache and provide a policy and bucket name. See the public runner example for more details. | `map` | <pre>{<br> "bucket": "",<br> "create": true,<br> "policy": ""<br>}</pre> | no |
| cache\_bucket\_name\_include\_account\_id | Boolean to add current account ID to cache bucket name. | `bool` | `true` | no |
| cache\_bucket\_prefix | Prefix for s3 cache bucket name. | `string` | `""` | no |
Expand Down Expand Up @@ -290,7 +304,7 @@ terraform destroy
| gitlab\_runner\_registration\_config | Configuration used to register the runner. See the README for an example, or reference the examples in the examples directory of this repo. | `map(string)` | <pre>{<br> "access_level": "",<br> "description": "",<br> "locked_to_project": "",<br> "maximum_timeout": "",<br> "registration_token": "",<br> "run_untagged": "",<br> "tag_list": ""<br>}</pre> | no |
| gitlab\_runner\_security\_group\_ids | A list of security group ids that are allowed to access the gitlab runner agent | `list(string)` | `[]` | no |
| gitlab\_runner\_ssh\_cidr\_blocks | List of CIDR blocks to allow SSH Access to the gitlab runner instance. | `list(string)` | `[]` | no |
| gitlab\_runner\_version | Version of the GitLab runner. | `string` | `"13.0.1"` | no |
| gitlab\_runner\_version | Version of the GitLab runner. | `string` | `"13.1.1"` | no |
| instance\_role\_json | Default runner instance override policy, expected to be in JSON format. | `string` | `""` | no |
| instance\_type | Instance type used for the GitLab runner. | `string` | `"t3.micro"` | no |
| kms\_deletion\_window\_in\_days | Key rotation window, set to 0 for no rotation. Only used when `enable_kms` is set to `true`. | `number` | `7` | no |
Expand Down Expand Up @@ -362,4 +376,4 @@ terraform destroy
| runner\_role\_name | Name of the role used for the docker machine runners. |
| runner\_sg\_id | ID of the security group attached to the docker machine runners. |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2 changes: 1 addition & 1 deletion examples/.terraform-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.25
0.12.26
2 changes: 1 addition & 1 deletion locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ locals {
secure_parameter_store_runner_token_key = "${var.environment}-${var.secure_parameter_store_runner_token_key}"

// custom names for instances and security groups
name_runner_instance = var.overrides["name_runner_agent_instance"] == "" ? local.tags["Name"] : var.overrides["name_runner_agent_instance"]
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"]
runners_additional_volumes = <<-EOT
%{~for volume in var.runners_additional_volumes~},"${volume}"%{endfor~}
Expand Down
27 changes: 10 additions & 17 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
data "aws_caller_identity" "current" {}

data "aws_subnet" "runners" {
id = var.subnet_id_runners
}

data "aws_availability_zone" "runners" {
name = data.aws_subnet.runners.availability_zone
}

# Parameter value is managed by the user-data script of the gitlab runner instance
resource "aws_ssm_parameter" "runner_registration_token" {
name = local.secure_parameter_store_runner_token_key
Expand Down Expand Up @@ -72,7 +80,7 @@ locals {
gitlab_url = var.runners_gitlab_url
runners_vpc_id = var.vpc_id
runners_subnet_id = var.subnet_id_runners
runners_aws_zone = var.aws_zone
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
runners_ami = data.aws_ami.docker-machine.id
Expand Down Expand Up @@ -151,22 +159,7 @@ resource "aws_autoscaling_group" "gitlab_runner_instance" {
health_check_grace_period = 0
launch_configuration = aws_launch_configuration.gitlab_runner_instance.name
enabled_metrics = var.metrics_autoscaling
tags = concat(
data.null_data_source.tags.*.outputs,
[
{
"key" = "Name"
"value" = local.name_runner_instance
"propagate_at_launch" = true
},
],
[for key in keys(var.agent_tags) : {
"key" = key,
"value" = lookup(var.agent_tags, key),
"propagate_at_launch" = true
}]
)

tags = data.null_data_source.agent_tags.*.outputs
}

resource "aws_autoscaling_schedule" "scale_in" {
Expand Down
20 changes: 20 additions & 0 deletions tags.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ locals {
var.tags,
)

agent_tags = merge(
{
"Name" = format("%s", local.name_runner_agent_instance)
},
{
"Environment" = format("%s", var.environment)
},
var.tags,
var.agent_tags
)

tags_string = join(",", flatten([
for key in keys(local.tags) : [key, lookup(local.tags, key)]
]))
Expand All @@ -28,3 +39,12 @@ data "null_data_source" "tags" {
}
}

data "null_data_source" "agent_tags" {
count = length(local.agent_tags)

inputs = {
key = element(keys(local.agent_tags), count.index)
value = element(values(local.agent_tags), count.index)
propagate_at_launch = "true"
}
}
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ variable "aws_region" {
}

variable "aws_zone" {
description = "AWS availability zone (typically 'a', 'b', or 'c')."
description = "Deprecated. Will be removed in the next major release."
type = string
default = "a"
}
Expand Down Expand Up @@ -312,7 +312,7 @@ variable "cache_shared" {
variable "gitlab_runner_version" {
description = "Version of the GitLab runner."
type = string
default = "13.0.1"
default = "13.1.1"
}

variable "enable_ping" {
Expand Down

0 comments on commit 53c6b52

Please sign in to comment.