Skip to content

Commit f2e98bb

Browse files
aperigaultAntony Perigault
and
Antony Perigault
authored
feat: Tag aws_cloudwatch_event_rule resource + linting (#519)
Co-authored-by: Antony Perigault <[email protected]>
1 parent a5f53ae commit f2e98bb

File tree

9 files changed

+22
-42
lines changed

9 files changed

+22
-42
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ locals {
8181
runners_aws_zone = data.aws_availability_zone.runners.name_suffix
8282
runners_instance_type = var.docker_machine_instance_type
8383
runners_spot_price_bid = var.docker_machine_spot_price_bid == "on-demand-price" ? "" : var.docker_machine_spot_price_bid
84-
runners_ami = data.aws_ami.docker-machine.id
84+
runners_ami = data.aws_ami.docker_machine.id
8585
runners_security_group_name = aws_security_group.docker_machine.name
8686
runners_monitoring = var.runners_monitoring
8787
runners_ebs_optimized = var.runners_ebs_optimized
@@ -138,7 +138,7 @@ locals {
138138
)
139139
}
140140

141-
data "aws_ami" "docker-machine" {
141+
data "aws_ami" "docker_machine" {
142142
most_recent = "true"
143143

144144
dynamic "filter" {

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/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

+1-3
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
}
@@ -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
}

variables.tf

+2-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 = "DEPRECATED, 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
@@ -661,6 +639,7 @@ variable "enable_docker_machine_ssm_access" {
661639
}
662640

663641
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"
664643
type = list(object({
665644
volume = string
666645
options = string
@@ -669,6 +648,7 @@ variable "runners_volumes_tmpfs" {
669648
}
670649

671650
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"
672652
type = list(object({
673653
volume = string
674654
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)