Skip to content

zloeber/cdktf-for-tf-engineers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cdktf-for-tf-engineers

An example of migrating a terraform deployment into cdktf.

Requirements

To use this project, you need to have the following requirements met:

  1. 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.

  2. Docker/containerd

  3. Linux/osx

NOTE Make sure to have mise activated before running the script to avoid any issues.

Using

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

About

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.

Tips

  • 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 try task deploy. If that fails try removing the cluster kind delete cluster -n cluster1

About

An example terraform to cdktf migration.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published