Skip to content

Commit 9057ae1

Browse files
kayman-mktmeijn
andcommitted
fix: correct the bugs of major version 7 (pre-release) (#860)
## Description Corrects all bugs of the pre-release version 7 of the module before roll-out. --------- Co-authored-by: Tyrone Meijn <[email protected]>
1 parent 49a37d5 commit 9057ae1

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ jobs:
138138

139139
- name: Run TFLint
140140
# assign necessary variables to avoid errors
141-
run: "tflint --var 'enable_kms=true' --var='runner_instance={\"name_prefix\": \"a\", \"name\": \"b\"}'"
141+
run: "tflint --var 'enable_managed_kms_key=true' --var='runner_instance={\"name_prefix\": \"a\", \"name\": \"b\"}'"
142142

143143
tfsec:
144144
name: tfsec PR commenter

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ locals {
8181
gitlab_runner_locked_to_project = var.runner_gitlab_registration_config["locked_to_project"]
8282
gitlab_runner_run_untagged = var.runner_gitlab_registration_config["run_untagged"]
8383
gitlab_runner_maximum_timeout = var.runner_gitlab_registration_config["maximum_timeout"]
84-
gitlab_runner_access_level = lookup(var.runner_gitlab_registration_config, "access_level", "not_protected")
84+
gitlab_runner_access_level = var.runner_gitlab_registration_config.access_level
8585
sentry_dsn = var.runner_manager.sentry_dsn
8686
public_key = var.runner_worker_docker_machine_fleet.enable == true ? tls_private_key.fleet[0].public_key_openssh : ""
8787
use_fleet = var.runner_worker_docker_machine_fleet.enable

migrations/migrate-to-7-0-0.sh

+13-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ cp "$1" "$converted_file"
1616
# PR #738 chore!: remove deprecated variables
1717
#
1818
sed -i '/arn_format/d' "$converted_file"
19-
sed -i '/subnet_id_runners/d' "$converted_file"
2019
sed -i '/subnet_ids_gitlab_runner/d' "$converted_file"
2120
sed -i '/asg_terminate_lifecycle_hook_create/d' "$converted_file"
2221
sed -i '/asg_terminate_lifecycle_hook_heartbeat_timeout/d' "$converted_file"
@@ -133,7 +132,7 @@ sed 's/role_tags/runner_extra_role_tags/g' | \
133132
sed 's/runner_tags/runner_worker_docker_machine_extra_role_tags/g' | \
134133
sed 's/agent_tags/runner_extra_instance_tags/g' | \
135134
sed 's/enable_ping/runner_ping_enable/g' | \
136-
sed 's/gitlab_runner_version/runner_gitlab_runner_version/g' | \
135+
sed 's/[^\.]gitlab_runner_version/runner_gitlab_runner_version/g' | \
137136
sed 's/gitlab_runner_egress_rules/runner_extra_egress_rules/g' | \
138137
sed 's/gitlab_runner_security_group_ids/runner_ping_allow_from_security_groups/g' | \
139138
sed 's/gitlab_runner_security_group_description/runner_security_group_description/g' | \
@@ -650,12 +649,23 @@ if [ -n "$extracted_variables" ]; then
650649
" > x && mv x "$converted_file"
651650
fi
652651

652+
# rename the subnet_id_runners variable
653+
sed -i 's/subnet_id_runners/subnet_id/g' "$converted_file"
654+
655+
# remove the \" from the autoscaling periods. No longer needed as jsonencode(value) is used
656+
sed -i '/periods/s/\\"//g' "$converted_file"
657+
653658
# change the module source to cattle-ops
654659
sed -i 's/npalm/cattle-ops/g' "$converted_file"
655660

656661
cat <<EOT
657662
Not all cases are handled by this script. Please check the output file and make sure that all variables are converted correctly.
658-
Especially it you have comments or multiline templates in your file.
663+
Take some time and sort the variables again for better readability.
664+
665+
Known issues:
666+
- commented lines are not supported. Remove them.
667+
- variable definitions with multiple lines are not supported. Rework manually.
668+
- `subnet_id` was taken from `subnet_id_runners`. Make sure that this is correct.
659669
EOT
660670

661671
echo

modules/terminate-agent-hook/cloudwatch.tf

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ resource "aws_cloudwatch_event_target" "terminate_instances" {
2929
}
3030

3131
resource "aws_cloudwatch_log_group" "lambda" {
32-
name = "/aws/lambda/${var.environment}-${var.name}"
32+
name = "/aws/lambda/${var.environment}-${var.name}"
33+
# checkov:skip=CKV_AWS_338:There is no need to store the logs for 1+ years. They are not critical.
3334
retention_in_days = var.cloudwatch_logging_retention_in_days
3435

3536
# ok as encryption can be activated by the user

variables.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ variable "runner_instance" {
123123
name = string
124124
name_prefix = optional(string)
125125
private_address_only = optional(bool, true)
126-
root_device_config = optional(map(string))
126+
root_device_config = optional(map(string), {})
127127
spot_price = optional(string, null)
128128
ssm_access = optional(bool, false)
129129
type = optional(string, "t3.micro")
@@ -305,7 +305,7 @@ variable "runner_gitlab_registration_config" {
305305
locked_to_project = optional(string, "")
306306
run_untagged = optional(string, "")
307307
maximum_timeout = optional(string, "")
308-
access_level = optional(string, "")
308+
access_level = optional(string, "not_protected") # this is the only mandatory field calling the GitLab get token for executor operation
309309
})
310310

311311
default = {}

0 commit comments

Comments
 (0)