Skip to content

Commit 02d6e8c

Browse files
committed
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]> # Conflicts: # main.tf
1 parent c8e8a94 commit 02d6e8c

File tree

7 files changed

+36
-80
lines changed

7 files changed

+36
-80
lines changed

.cspell.json

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 4 additions & 5 deletions
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" {
@@ -95,8 +95,8 @@ locals {
9595
tls_ca_file = length(var.runners_gitlab_certificate) > 0 ? "tls-ca-file=\"/etc/gitlab-runner/certs/gitlab.crt\"" : ""
9696
runners_extra_hosts = var.runners_extra_hosts
9797
runners_vpc_id = var.vpc_id
98-
runners_subnet_id = length(var.subnet_id) > 0 ? var.subnet_id : var.subnet_id_runners
99-
runners_subnet_ids = length(var.fleet_executor_subnet_ids) > 0 ? var.fleet_executor_subnet_ids : length(var.subnet_id) > 0 ? [var.subnet_id] : [var.subnet_id_runners]
98+
runners_subnet_id = var.subnet_id
99+
runners_subnet_ids = length(var.fleet_executor_subnet_ids) > 0 ? var.fleet_executor_subnet_ids : [var.subnet_id]
100100
runners_aws_zone = data.aws_availability_zone.runners.name_suffix
101101
runners_instance_type = var.docker_machine_instance_type
102102
runners_instance_types = length(var.docker_machine_instance_types_fleet) > 0 ? var.docker_machine_instance_types_fleet : [var.docker_machine_instance_type]
@@ -176,7 +176,7 @@ data "aws_ami" "docker-machine" {
176176
# kics-scan ignore-line
177177
resource "aws_autoscaling_group" "gitlab_runner_instance" {
178178
name = var.enable_asg_recreation ? "${aws_launch_template.gitlab_runner_instance.name}-asg" : "${var.environment}-as-group"
179-
vpc_zone_identifier = length(var.fleet_executor_subnet_ids) > 0 ? var.fleet_executor_subnet_ids : length(var.subnet_id) > 0 ? [var.subnet_id] : var.subnet_ids_gitlab_runner
179+
vpc_zone_identifier = length(var.fleet_executor_subnet_ids) > 0 ? var.fleet_executor_subnet_ids : [var.subnet_id]
180180
min_size = "1"
181181
max_size = "1"
182182
desired_capacity = "1"
@@ -680,7 +680,6 @@ module "terminate_agent_hook" {
680680
name_docker_machine_runners = local.runner_tags_merged["Name"]
681681
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}"
682682
kms_key_id = local.kms_key
683-
arn_format = var.arn_format
684683

685684
tags = local.tags
686685
}

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

Lines changed: 25 additions & 0 deletions
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

Lines changed: 0 additions & 6 deletions
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

Lines changed: 0 additions & 64 deletions
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
@@ -891,70 +885,12 @@ variable "docker_machine_egress_rules" {
891885
}]
892886
}
893887

894-
variable "subnet_id_runners" {
895-
description = "Deprecated! Use subnet_id instead. List of subnets used for hosting the gitlab-runners."
896-
type = string
897-
default = ""
898-
}
899-
900-
variable "subnet_ids_gitlab_runner" {
901-
description = "Deprecated! Use subnet_id instead. Subnet used for hosting the GitLab runner."
902-
type = list(string)
903-
default = []
904-
}
905-
906888
variable "asg_terminate_lifecycle_hook_name" {
907889
description = "Specifies a custom name for the ASG terminate lifecycle hook and related resources."
908890
type = string
909891
default = null
910892
}
911893

912-
variable "asg_terminate_lifecycle_hook_create" {
913-
description = "(Deprecated and always true now) Boolean toggling the creation of the ASG instance terminate lifecycle hook."
914-
type = bool
915-
default = true
916-
917-
validation {
918-
condition = var.asg_terminate_lifecycle_hook_create
919-
error_message = "The hook must be created. Please remove the variable declaration."
920-
}
921-
}
922-
923-
variable "asg_terminate_lifecycle_hook_heartbeat_timeout" {
924-
description = "(Deprecated and no longer in use) The amount of time, in seconds, for the instances to remain in wait state."
925-
type = number
926-
default = null
927-
928-
validation {
929-
condition = var.asg_terminate_lifecycle_hook_heartbeat_timeout == null
930-
error_message = "The timeout value is managed by the module. Please remove the variable declaration."
931-
}
932-
}
933-
934-
# to be removed in future release
935-
# tflint-ignore: terraform_unused_declarations
936-
variable "asg_terminate_lifecycle_lambda_memory_size" {
937-
description = "(Deprecated and no longer in use) The memory size in MB to allocate to the terminate-instances Lambda function."
938-
type = number
939-
default = 128
940-
}
941-
942-
# to be removed in future release
943-
# tflint-ignore: terraform_unused_declarations
944-
variable "asg_terminate_lifecycle_lambda_runtime" {
945-
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."
946-
type = string
947-
default = "python3.8"
948-
}
949-
950-
# to be removed in future release
951-
# tflint-ignore: terraform_unused_declarations
952-
variable "asg_terminate_lifecycle_lambda_timeout" {
953-
description = "(Deprecated and no longer in use) Amount of time the terminate-instances Lambda Function has to run in seconds."
954-
default = 30
955-
type = number
956-
}
957-
958894
variable "runner_yum_update" {
959895
description = "Run a yum update as part of starting the runner"
960896
type = bool

0 commit comments

Comments
 (0)