Skip to content

Commit 920c4fb

Browse files
feat: generate random id for tests so they dont collide (#166)
1 parent 21350cc commit 920c4fb

File tree

17 files changed

+99
-59
lines changed

17 files changed

+99
-59
lines changed

.spacelift/config.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,37 @@ module_version: 4.4.3
44
tests:
55
- name: AMD64-based workerpool
66
project_root: examples/amd64
7-
environment:
8-
TF_VAR_worker_pool_id: "01HBD5QZ932J8EEH5GTBM1QMAA"
97

108
- name: ARM64-based workerpool
119
project_root: examples/arm64
12-
environment:
13-
TF_VAR_worker_pool_id: "01HBD5QZ932J8AEH5GTBM1QMAB"
1410

1511
- name: extra-iam-statements
1612
project_root: examples/extra-iam-statements
17-
environment:
18-
TF_VAR_worker_pool_id: "01HBD5QZ932J8CEH5GTBM1QMAH"
1913

2014
- name: Custom IAM Role
2115
project_root: examples/custom-iam-role
22-
environment:
23-
TF_VAR_worker_pool_id: "01HBD5QZ932J8CEH5GTBM1QMAC"
2416

2517
- name: With autoscaling
2618
project_root: examples/autoscaler
2719
environment:
28-
TF_VAR_worker_pool_id: "01HBD5QZ932J8CEH5GTBM1QMAD"
2920
TF_VAR_spacelift_api_key_id: "EXAMPLE0VOYU49U485BMZZVAWXU59VOW2"
3021
TF_VAR_spacelift_api_key_secret: "EXAMPLEf7anuofh4b6a4e43aplqt49099606de2mzbq4391tj1d3dc9872q23z8fvctu4kh"
3122
TF_VAR_spacelift_api_key_endpoint: "https://example.app.spacelift.io"
3223

3324
- name: S3-hosted autoscaler
3425
project_root: examples/autoscaler-custom-s3-package
3526
environment:
36-
TF_VAR_worker_pool_id: "01HBD5QZ932J8CEH5GTBM1QMAE"
3727
TF_VAR_spacelift_api_key_id: "EXAMPLE0VOYU49U485BMZZVAWXU59VOW2"
3828
TF_VAR_spacelift_api_key_secret: "EXAMPLEf7anuofh4b6a4e43aplqt49099606de2mzbq4391tj1d3dc9872q23z8fvctu4kh"
3929
TF_VAR_spacelift_api_key_endpoint: "https://example.app.spacelift.io"
4030
TF_VAR_autoscaler_version: "v1.0.3"
4131

4232
- name: Self-hosted setup
4333
project_root: examples/self-hosted
44-
environment:
45-
TF_VAR_worker_pool_id: "01HBD5QZ932J8CEH5GTBM1QMAF"
4634

4735
- name: With autoscaling, lifecycle rules and BYO ssm and secretsmanager
4836
project_root: examples/byo-ssm-secretsmanager-with-autoscaling-and-lifecycle
4937
environment:
50-
TF_VAR_worker_pool_id: "01HBD5QZ932J8CEH5GTBM1QMAG"
5138
TF_VAR_spacelift_api_key_id: "EXAMPLE0VOYU49U485BMZZVAWXU59JOEY1"
5239
TF_VAR_spacelift_api_key_secret: "EXAMPLE22anuofh4b6a4e43aplqt49099606de2mzbq4391tj1d3dc9872q23z8fvctu4kh"
5340
TF_VAR_spacelift_api_key_endpoint: "https://example.app.spacelift.io"

examples/amd64/main.tf

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ data "aws_subnets" "this" {
3636
}
3737
}
3838

39+
resource "random_string" "worker_pool_id" {
40+
length = 26
41+
numeric = true
42+
# Use special and override special to allow only uppercase letters and numbers
43+
# but exclude I, L, O, and U as it does not conform to the regex used by Spacelift
44+
special = true
45+
override_special = "ABCDEFGHJKMNPQRSTVWXYZ"
46+
lower = false
47+
upper = false
48+
}
49+
3950
#### Spacelift worker pool ####
4051

4152
module "this" {
@@ -51,25 +62,25 @@ module "this" {
5162
}
5263
security_groups = [data.aws_security_group.this.id]
5364
vpc_subnets = data.aws_subnets.this.ids
54-
worker_pool_id = var.worker_pool_id
65+
worker_pool_id = random_string.worker_pool_id.id
5566

5667
tag_specifications = [
5768
{
5869
resource_type = "instance"
5970
tags = {
60-
Name = "sp5ft-${var.worker_pool_id}"
71+
Name = "sp5ft-${random_string.worker_pool_id.id}"
6172
}
6273
},
6374
{
6475
resource_type = "volume"
6576
tags = {
66-
Name = "sp5ft-${var.worker_pool_id}"
77+
Name = "sp5ft-${random_string.worker_pool_id.id}"
6778
}
6879
},
6980
{
7081
resource_type = "network-interface"
7182
tags = {
72-
Name = "sp5ft-${var.worker_pool_id}"
83+
Name = "sp5ft-${random_string.worker_pool_id.id}"
7384
}
7485
}
7586
]

examples/amd64/variables.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/arm64/main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ data "aws_subnets" "this" {
3636
}
3737
}
3838

39+
resource "random_string" "worker_pool_id" {
40+
length = 26
41+
numeric = true
42+
# Use special and override special to allow only uppercase letters and numbers
43+
# but exclude I, L, O, and U as it does not conform to the regex used by Spacelift
44+
special = true
45+
override_special = "ABCDEFGHJKMNPQRSTVWXYZ"
46+
lower = false
47+
upper = false
48+
}
49+
3950
#### Spacelift worker pool ####
4051

4152
module "this" {
@@ -55,5 +66,5 @@ module "this" {
5566
ec2_instance_type = "t4g.micro"
5667
security_groups = [data.aws_security_group.this.id]
5768
vpc_subnets = data.aws_subnets.this.ids
58-
worker_pool_id = var.worker_pool_id
69+
worker_pool_id = random_string.worker_pool_id.id
5970
}

examples/arm64/variables.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/autoscaler-custom-s3-package/main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ data "aws_subnets" "this" {
3636
}
3737
}
3838

39+
resource "random_string" "worker_pool_id" {
40+
length = 26
41+
numeric = true
42+
# Use special and override special to allow only uppercase letters and numbers
43+
# but exclude I, L, O, and U as it does not conform to the regex used by Spacelift
44+
special = true
45+
override_special = "ABCDEFGHJKMNPQRSTVWXYZ"
46+
lower = false
47+
upper = false
48+
}
49+
3950
#### Spacelift worker pool ####
4051

4152
module "this" {
@@ -47,7 +58,7 @@ module "this" {
4758
}
4859
security_groups = [data.aws_security_group.this.id]
4960
vpc_subnets = data.aws_subnets.this.ids
50-
worker_pool_id = var.worker_pool_id
61+
worker_pool_id = random_string.worker_pool_id.id
5162

5263
autoscaling_configuration = {
5364
version = var.autoscaler_version

examples/autoscaler-custom-s3-package/variables.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ variable "spacelift_api_key_endpoint" {
1414
description = "Full URL of the Spacelift API endpoint to use, eg. https://demo.app.spacelift.io"
1515
}
1616

17-
variable "worker_pool_id" {
18-
type = string
19-
description = "ID (ULID) of the the worker pool."
20-
}
21-
2217
variable "autoscaler_version" {
2318
description = "Version of the autoscaler to deploy"
2419
type = string

examples/autoscaler/main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ data "aws_subnets" "this" {
3636
}
3737
}
3838

39+
resource "random_string" "worker_pool_id" {
40+
length = 26
41+
numeric = true
42+
# Use special and override special to allow only uppercase letters and numbers
43+
# but exclude I, L, O, and U as it does not conform to the regex used by Spacelift
44+
special = true
45+
override_special = "ABCDEFGHJKMNPQRSTVWXYZ"
46+
lower = false
47+
upper = false
48+
}
49+
3950
#### Spacelift worker pool ####
4051

4152
module "this" {
@@ -47,7 +58,7 @@ module "this" {
4758
}
4859
security_groups = [data.aws_security_group.this.id]
4960
vpc_subnets = data.aws_subnets.this.ids
50-
worker_pool_id = var.worker_pool_id
61+
worker_pool_id = random_string.worker_pool_id.id
5162

5263
# Autoscaler VPC configuration
5364
autoscaling_vpc_sg_ids = [data.aws_security_group.this.id]

examples/autoscaler/variables.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
variable "worker_pool_id" {
2-
type = string
3-
description = "ID (ULID) of the the worker pool."
4-
}
5-
61
variable "spacelift_api_key_id" {
72
type = string
83
description = "ID of the Spacelift API key to use"

examples/byo-ssm-secretsmanager-with-autoscaling-and-lifecycle/main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ data "aws_subnets" "this" {
3636
}
3737
}
3838

39+
resource "random_string" "worker_pool_id" {
40+
length = 26
41+
numeric = true
42+
# Use special and override special to allow only uppercase letters and numbers
43+
# but exclude I, L, O, and U as it does not conform to the regex used by Spacelift
44+
special = true
45+
override_special = "ABCDEFGHJKMNPQRSTVWXYZ"
46+
lower = false
47+
upper = false
48+
}
49+
3950
// This is just here for testing purposes.
4051
resource "random_pet" "byo" {
4152
prefix = "byo"
@@ -67,7 +78,7 @@ module "this" {
6778

6879
security_groups = [data.aws_security_group.this.id]
6980
vpc_subnets = data.aws_subnets.this.ids
70-
worker_pool_id = var.worker_pool_id
81+
worker_pool_id = random_string.worker_pool_id.id
7182

7283
byo_secretsmanager = {
7384
name = aws_secretsmanager_secret.byo.name

0 commit comments

Comments
 (0)