Skip to content

Commit 6bb608c

Browse files
committed
Migrate to OpenTofu
1 parent 3cb6698 commit 6bb608c

21 files changed

Lines changed: 493 additions & 761 deletions

File tree

.github/workflows/main.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,31 +184,31 @@ jobs:
184184
# GKE: set cluster_node_locations
185185
sed -i 's/cluster_node_locations = \[\]/cluster_node_locations = ["europe-west1-b", "europe-west1-c", "europe-west1-d"]/g' gke_zero_cluster.tf || true
186186
187-
- name: "Terraform init"
187+
- name: "OpenTofu init"
188188
working-directory: ./kubestack-starter-${{ matrix.starter }}
189189
run: |
190190
docker run --rm \
191191
-v `pwd`:/infra \
192192
test-image:${{ github.sha }} \
193-
terraform init
193+
tofu init
194194
195-
- name: "Terraform workspace new ops"
195+
- name: "OpenTofu workspace new ops"
196196
working-directory: ./kubestack-starter-${{ matrix.starter }}
197197
run: |
198198
docker run --rm \
199199
-v `pwd`:/infra \
200200
test-image:${{ github.sha }} \
201-
terraform workspace new ops
201+
tofu workspace new ops
202202
203-
- name: "Terraform validate"
203+
- name: "OpenTofu validate"
204204
working-directory: ./kubestack-starter-${{ matrix.starter }}
205205
run: |
206206
docker run --rm \
207207
-v `pwd`:/infra \
208208
test-image:${{ github.sha }} \
209-
terraform validate
209+
tofu validate
210210
211-
- name: "Terraform plan"
211+
- name: "OpenTofu plan"
212212
working-directory: ./kubestack-starter-${{ matrix.starter }}
213213
env:
214214
KBST_AUTH_AWS: ${{ secrets.KBST_AUTH_AWS }}
@@ -222,7 +222,7 @@ jobs:
222222
-v `pwd`:/infra \
223223
-v /var/run/docker.sock:/var/run/docker.sock \
224224
test-image:${{ github.sha }} \
225-
terraform plan --target module.aks_zero --target module.eks_zero --target module.gke_zero
225+
tofu plan --target module.aks_zero --target module.eks_zero --target module.gke_zero
226226
227227
publish-image:
228228
runs-on: ubuntu-latest

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ BUILD_CACHE_DIST := --cache-to type=registry,mode=max,ref=ghcr.io/kbst/terraform
1212
BUILD_OUTPUT := --output type=registry,push=${DOCKER_PUSH}
1313
BUILD_CACHE := --cache-to type=registry,mode=max,ref=ghcr.io/kbst/terraform-kubestack/dev:buildcache-${DOCKER_TARGET},push=${DOCKER_PUSH}
1414
else
15-
BUILD_PLATFORM :=
15+
BUILD_PLATFORM :=
1616
BUILD_OUTPUT := --output type=docker
1717
endif
1818

@@ -57,24 +57,24 @@ build:
5757
validate: .init
5858
docker exec \
5959
test-container-$(GIT_SHA) \
60-
entrypoint terraform validate
60+
entrypoint tofu validate
6161

6262
test: validate
6363
docker exec \
6464
test-container-$(GIT_SHA) \
65-
entrypoint terraform apply --target module.aks_zero --target module.eks_zero --target module.gke_zero --input=false --auto-approve
65+
entrypoint tofu apply --target module.aks_zero --target module.eks_zero --target module.gke_zero --input=false --auto-approve
6666
docker exec \
6767
test-container-$(GIT_SHA) \
68-
entrypoint terraform apply --target module.eks_zero_nginx --input=false --auto-approve
68+
entrypoint tofu apply --target module.eks_zero_nginx --input=false --auto-approve
6969
docker exec \
7070
test-container-$(GIT_SHA) \
71-
entrypoint terraform apply --input=false --auto-approve
71+
entrypoint tofu apply --input=false --auto-approve
7272

7373
cleanup: .init
7474
docker exec \
7575
-ti \
7676
test-container-$(GIT_SHA) \
77-
entrypoint terraform destroy --input=false --auto-approve
77+
entrypoint tofu destroy --input=false --auto-approve
7878
$(MAKE) .stop-container
7979

8080
shell: .check-container
@@ -106,7 +106,7 @@ shell: .check-container
106106
.init: .check-container
107107
docker exec \
108108
test-container-$(GIT_SHA) \
109-
entrypoint terraform init
109+
entrypoint tofu init
110110
docker exec \
111111
test-container-$(GIT_SHA) \
112-
entrypoint terraform workspace select ops
112+
entrypoint tofu workspace select ops
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
variables {
2+
configuration = {
3+
apps_production = {
4+
apps_key1 = "from_apps_production"
5+
apps_key2 = "from_apps_production"
6+
}
7+
8+
apps_staging = {
9+
apps_key1 = "from_apps_staging"
10+
apps_key2 = "from_apps_staging"
11+
}
12+
13+
ops = {
14+
ops_key = "from_ops"
15+
apps_key1 = "from_ops"
16+
}
17+
18+
loc = {}
19+
}
20+
21+
base_key = "apps_production"
22+
}
23+
24+
run "custom_envs" {
25+
assert {
26+
condition = output.merged["apps_production"] == { apps_key1 = "from_apps_production", apps_key2 = "from_apps_production" }
27+
error_message = "apps_production is unchanged"
28+
}
29+
30+
assert {
31+
condition = output.merged["apps_staging"] == { apps_key1 = "from_apps_staging", apps_key2 = "from_apps_staging" }
32+
error_message = "apps_staging overwrites everything from apps_production"
33+
}
34+
35+
assert {
36+
condition = output.merged["ops"] == { apps_key1 = "from_ops", apps_key2 = "from_apps_production", ops_key = "from_ops" }
37+
error_message = "ops inherits from apps_production, overwrites apps_key1 and adds ops_key"
38+
}
39+
40+
assert {
41+
condition = output.merged["loc"] == { apps_key1 = "from_apps_production", apps_key2 = "from_apps_production" }
42+
error_message = "loc inherits everything from apps_production"
43+
}
44+
}

common/configuration/tests/custom_envs/test_envs.tf

Lines changed: 0 additions & 85 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
variables {
2+
configuration = {
3+
apps = {
4+
apps_key1 = "from_apps"
5+
apps_key2 = "from_apps"
6+
}
7+
8+
ops = {
9+
ops_key = "from_ops"
10+
apps_key1 = "from_ops"
11+
}
12+
13+
loc = {
14+
loc_key = "from_loc"
15+
}
16+
}
17+
18+
base_key = "apps"
19+
}
20+
21+
run "default_envs" {
22+
assert {
23+
condition = output.merged["apps"] == { apps_key1 = "from_apps", apps_key2 = "from_apps" }
24+
error_message = "apps is unchanged"
25+
}
26+
27+
assert {
28+
condition = output.merged["ops"] == { apps_key1 = "from_ops", apps_key2 = "from_apps", ops_key = "from_ops" }
29+
error_message = "ops inherits from apps, overwrites apps_key1 and adds ops_key"
30+
}
31+
32+
assert {
33+
condition = output.merged["loc"] == { apps_key1 = "from_apps", apps_key2 = "from_apps", loc_key = "from_loc" }
34+
error_message = "loc inherits from apps and adds loc_key"
35+
}
36+
}

common/configuration/tests/default_envs/test_envs.tf

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

0 commit comments

Comments
 (0)