An example of migrating a terraform deployment into cdktf.
To use this project, you need to have the following requirements met:
-
Mise: Ensure you have mise activated in your terminal. Mise is a tool that helps manage your development environment on a per-folder basis. This is incredibly useful for polyglot coding like this particular example. I find it to be less overhead than devcontainers. It does not replace virtual environments but can augment your use of them. It als replaces direnv for automatic loading of variables and secrets and more.
-
Docker/containerd
-
Linux/osx
NOTE Make sure to have mise activated before running the script to avoid any issues.
configure.sh: Run the configure.sh
script to set up your environment. This script will configure necessary dependencies and settings for the project.
./configure.sh
# Use this for further tasks if not already in your profile
eval "$(mise activate bash)"
Run task
at any time to see a list of additional tasks. For this example most tasks are at the root Taskfile.yml
manifest.
To deploy run task deploy:all
To destroy run task destroy
Terraform is in the main branch
cdktf is in the cdktf branch
NOTE In either branch run
task deploy:all
to run a multiple part terraform deployment using modules and multiple state files.
-
This builds a kube cluster then drops a private key and the kube config file locally in an ignored
./secrets
path. You can use this to your advantage and target that folder with sops to encrypt things per cluster with just a wee bit more work ;) -
You can use OpenLens to explore your local cluster by pointing it at the kube config file.
-
Most everything can be configured in the
Taskfile.yml
file, including if you'd like to use tofu or terraform. Fun for testing some of the new tofu features out. -
If
task deploy:all
fails trytask deploy
. If that fails try removing the clusterkind delete cluster -n cluster1