Skip to content

Commit 93657e6

Browse files
kayman-mktmeijn
andcommitted
chore!: remove deprecated variables (#738)
This PR removes all variables which are marked as deprecated. - `arn_format` - `subnet_id_runners` - `subnet_ids_gitlab_runner` - `asg_terminate_lifecycle_hook_create` - `asg_terminate_lifecycle_hook_heartbeat_timeout` - `asg_terminate_lifecycle_lambda_memory_size` - `asg_terminate_lifecycle_lambda_runtime` - `asg_terminate_lifecycle_lambda_timeout` Yes. Remove the variables from your configuration. This is done automatically by the migration script. None. --------- Co-authored-by: Tyrone Meijn <[email protected]>
1 parent 323e198 commit 93657e6

File tree

7 files changed

+35
-79
lines changed

7 files changed

+35
-79
lines changed

.cspell.json

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"words": [
55
"amazonec",
66
"amannn",
7+
"amazonec",
78
"anytrue",
89
"aquasecurity",
910
"awscli",
@@ -50,6 +51,7 @@
5051
"tflint",
5152
"tftpl",
5253
"tfsec",
54+
"tftpl",
5355
"tfvars",
5456
"tmpfs",
5557
"trivy",

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<!-- First line should be a H1: Badges on top please! -->
2-
<!-- markdownlint-disable MD041 -->
2+
<!-- markdownlint-disable MD041/first-line-heading/first-line-h1 -->
33
[![Terraform registry](https://img.shields.io/github/v/release/cattle-ops/terraform-aws-gitlab-runner?label=Terraform%20Registry)](https://registry.terraform.io/modules/cattle-ops/gitlab-runner/aws/)
44
[![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
55
[![Actions](https://github.com/cattle-ops/terraform-aws-gitlab-runner/workflows/CI/badge.svg)](https://github.com/cattle-ops/terraform-aws-gitlab-runner/actions)
6+
<!-- markdownlint-enable MD041/first-line-heading/first-line-h1 -->
67

78
# Terraform module for GitLab auto scaling runners on AWS spot instances <!-- omit in toc -->
89

examples/runner-public/main.tf

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ data "aws_availability_zones" "available" {
22
state = "available"
33
}
44

5-
# VPC Flow logs are not needed here
5+
# Every VPC resource should have an associated Flow Log: This is an example only. No flow logs are created.
66
# kics-scan ignore-line
77
module "vpc" {
88
source = "terraform-aws-modules/vpc/aws"
@@ -79,9 +79,8 @@ module "runner2" {
7979

8080
runners_use_private_address = false
8181

82-
vpc_id = module.vpc.vpc_id
83-
subnet_ids_gitlab_runner = module.vpc.public_subnets
84-
subnet_id_runners = element(module.vpc.public_subnets, 0)
82+
vpc_id = module.vpc.vpc_id
83+
subnet_id = element(module.vpc.public_subnets, 0)
8584

8685
docker_machine_spot_price_bid = "on-demand-price"
8786

main.tf

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ data "aws_caller_identity" "current" {}
22
data "aws_partition" "current" {}
33

44
data "aws_subnet" "runners" {
5-
id = length(var.subnet_id) > 0 ? var.subnet_id : var.subnet_id_runners
5+
id = var.subnet_id
66
}
77

88
data "aws_availability_zone" "runners" {
@@ -87,7 +87,7 @@ locals {
8787
tls_ca_file = length(var.runners_gitlab_certificate) > 0 ? "tls-ca-file=\"/etc/gitlab-runner/certs/gitlab.crt\"" : ""
8888
runners_extra_hosts = var.runners_extra_hosts
8989
runners_vpc_id = var.vpc_id
90-
runners_subnet_id = length(var.subnet_id) > 0 ? var.subnet_id : var.subnet_id_runners
90+
runners_subnet_id = var.subnet_id
9191
runners_aws_zone = data.aws_availability_zone.runners.name_suffix
9292
runners_instance_type = var.docker_machine_instance_type
9393
runners_spot_price_bid = var.docker_machine_spot_price_bid == "on-demand-price" || var.docker_machine_spot_price_bid == null ? "" : var.docker_machine_spot_price_bid
@@ -163,7 +163,7 @@ data "aws_ami" "docker-machine" {
163163
# kics-scan ignore-line
164164
resource "aws_autoscaling_group" "gitlab_runner_instance" {
165165
name = var.enable_asg_recreation ? "${aws_launch_template.gitlab_runner_instance.name}-asg" : "${var.environment}-as-group"
166-
vpc_zone_identifier = length(var.subnet_id) > 0 ? [var.subnet_id] : var.subnet_ids_gitlab_runner
166+
vpc_zone_identifier = [var.subnet_id]
167167
min_size = "1"
168168
max_size = "1"
169169
desired_capacity = "1"
@@ -565,7 +565,6 @@ module "terminate_agent_hook" {
565565
name_docker_machine_runners = local.runner_tags_merged["Name"]
566566
role_permissions_boundary = var.permissions_boundary == "" ? null : "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:policy/${var.permissions_boundary}"
567567
kms_key_id = local.kms_key
568-
arn_format = var.arn_format
569568

570569
tags = local.tags
571570
}

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

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
#
5+
# Precondition: The module call has been extracted to a separate file given in "$1". The code is well-formatted.
6+
# Run `terraform fmt` to do that
7+
#
8+
# $1: file name containing the module call to be converted
9+
#
10+
11+
converted_file="$1.new"
12+
13+
cp "$1" "$converted_file"
14+
15+
#
16+
# PR #738 chore!: remove deprecated variables
17+
#
18+
sed -i '/arn_format/d' "$converted_file"
19+
sed -i '/subnet_id_runners/d' "$converted_file"
20+
sed -i '/subnet_ids_gitlab_runner/d' "$converted_file"
21+
sed -i '/asg_terminate_lifecycle_hook_create/d' "$converted_file"
22+
sed -i '/asg_terminate_lifecycle_hook_heartbeat_timeout/d' "$converted_file"
23+
sed -i '/asg_terminate_lifecycle_lambda_memory_size/d' "$converted_file"
24+
sed -i '/asg_terminate_lifecycle_lambda_runtime/d' "$converted_file"
25+
sed -i '/asg_terminate_lifecycle_lambda_timeout/d' "$converted_file"

modules/terminate-agent-hook/variables.tf

-6
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,3 @@ variable "enable_xray_tracing" {
6060
type = bool
6161
default = false
6262
}
63-
64-
variable "arn_format" {
65-
type = string
66-
default = "arn:aws"
67-
description = "ARN format to be used. May be changed to support deployment in GovCloud/China regions."
68-
}

variables.tf

-64
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ variable "aws_region" {
33
type = string
44
}
55

6-
variable "arn_format" {
7-
type = string
8-
default = null
9-
description = "Deprecated! Calculated automatically by the module. ARN format to be used. May be changed to support deployment in GovCloud/China regions."
10-
}
11-
126
variable "auth_type_cache_sr" {
137
description = "A string that declares the AuthenticationType for [runners.cache.s3]. Can either be 'iam' or 'credentials'"
148
type = string
@@ -855,70 +849,12 @@ variable "docker_machine_egress_rules" {
855849
}]
856850
}
857851

858-
variable "subnet_id_runners" {
859-
description = "Deprecated! Use subnet_id instead. List of subnets used for hosting the gitlab-runners."
860-
type = string
861-
default = ""
862-
}
863-
864-
variable "subnet_ids_gitlab_runner" {
865-
description = "Deprecated! Use subnet_id instead. Subnet used for hosting the GitLab runner."
866-
type = list(string)
867-
default = []
868-
}
869-
870852
variable "asg_terminate_lifecycle_hook_name" {
871853
description = "Specifies a custom name for the ASG terminate lifecycle hook and related resources."
872854
type = string
873855
default = null
874856
}
875857

876-
variable "asg_terminate_lifecycle_hook_create" {
877-
description = "(Deprecated and always true now) Boolean toggling the creation of the ASG instance terminate lifecycle hook."
878-
type = bool
879-
default = true
880-
881-
validation {
882-
condition = var.asg_terminate_lifecycle_hook_create
883-
error_message = "The hook must be created. Please remove the variable declaration."
884-
}
885-
}
886-
887-
variable "asg_terminate_lifecycle_hook_heartbeat_timeout" {
888-
description = "(Deprecated and no longer in use) The amount of time, in seconds, for the instances to remain in wait state."
889-
type = number
890-
default = null
891-
892-
validation {
893-
condition = var.asg_terminate_lifecycle_hook_heartbeat_timeout == null
894-
error_message = "The timeout value is managed by the module. Please remove the variable declaration."
895-
}
896-
}
897-
898-
# to be removed in future release
899-
# tflint-ignore: terraform_unused_declarations
900-
variable "asg_terminate_lifecycle_lambda_memory_size" {
901-
description = "(Deprecated and no longer in use) The memory size in MB to allocate to the terminate-instances Lambda function."
902-
type = number
903-
default = 128
904-
}
905-
906-
# to be removed in future release
907-
# tflint-ignore: terraform_unused_declarations
908-
variable "asg_terminate_lifecycle_lambda_runtime" {
909-
description = "(Deprecated and no longer in use) Identifier of the function's runtime. This should be a python3.x runtime. See https://docs.aws.amazon.com/lambda/latest/dg/API_CreateFunction.html#SSS-CreateFunction-request-Runtime for more information."
910-
type = string
911-
default = "python3.8"
912-
}
913-
914-
# to be removed in future release
915-
# tflint-ignore: terraform_unused_declarations
916-
variable "asg_terminate_lifecycle_lambda_timeout" {
917-
description = "(Deprecated and no longer in use) Amount of time the terminate-instances Lambda Function has to run in seconds."
918-
default = 30
919-
type = number
920-
}
921-
922858
variable "runner_yum_update" {
923859
description = "Run a yum update as part of starting the runner"
924860
type = bool

0 commit comments

Comments
 (0)