Skip to content

Commit 8c7a98c

Browse files
committed
Migrate to OpenTofu
1 parent 3cb6698 commit 8c7a98c

3 files changed

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

oci/Dockerfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ ARG KUBECTL_VERSION=v1.31.3
3131
# https://github.com/kubernetes-sigs/kustomize/releases
3232
ARG KUSTOMIZE_VERSION=v5.5.0
3333

34-
# https://www.terraform.io/downloads.html
35-
# 1.5.x is the last OSS Terraform
36-
# do not update major or minor!
37-
ARG TERRAFORM_VERSION=1.5.7
34+
# https://github.com/opentofu/opentofu/releases
35+
ARG OPENTOFU_VERSION=1.11.5
3836

3937
RUN echo "KUBECTL_VERSION: ${KUBECTL_VERSION}" \
4038
&& curl -LO https://dl.k8s.io/${KUBECTL_VERSION}/kubernetes-client-linux-${TARGETARCH}.tar.gz \
@@ -49,11 +47,12 @@ RUN echo "KUSTOMIZE_VERSION: ${KUSTOMIZE_VERSION}" \
4947
&& mv kustomize /opt/bin/kustomize \
5048
&& /opt/bin/kustomize version
5149

52-
RUN echo "TERRAFORM_VERSION: ${TERRAFORM_VERSION}" \
53-
&& curl -LO https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_${TARGETARCH}.zip \
54-
&& unzip terraform_${TERRAFORM_VERSION}_linux_${TARGETARCH}.zip -d /opt/bin \
55-
&& chmod +x /opt/bin/terraform \
56-
&& /opt/bin/terraform version
50+
RUN echo "OPENTOFU_VERSION: ${OPENTOFU_VERSION}" \
51+
&& curl -LO https://github.com/opentofu/opentofu/releases/download/v${OPENTOFU_VERSION}/tofu_${OPENTOFU_VERSION}_linux_${TARGETARCH}.tar.gz \
52+
&& tar -xf tofu_${OPENTOFU_VERSION}_linux_${TARGETARCH}.tar.gz \
53+
&& mv tofu /opt/bin/tofu \
54+
&& chmod +x /opt/bin/tofu \
55+
&& /opt/bin/tofu version
5756

5857
COPY oci/entrypoint oci/entrypoint_user /opt/bin/
5958

0 commit comments

Comments
 (0)