This document provides instructions and usage examples for the config.sh script, which automates provisioning, managing, and cleaning up infrastructure and applications using Terraform, AWS, Helm, and Kubernetes.
The script helps with:
- Managing Terraform workflows (
fmt,init,validate,plan,apply,destroy). - Provisioning and tearing down full environments.
- Deploying Kubernetes applications with Helm.
- Managing AWS EKS clusters and kubeconfig.
- Encrypting and decrypting secrets using AWS KMS.
- Debugging and smoke testing applications.
- Cleaning up stuck cluster resources.
Default environment: production
Before running the script, ensure the following tools are installed:
Run the following to check prerequisites:
./config.sh prerequisitesAlso make sure to:
- Rename
terraform.tfvars.exampleasterraform.tfvarsinterraform/environments/production/folder - Edit it with your own values
- Configure files under
manifests/environments/productionfolder
-
Format code
./config.sh fmt
-
Initialize environment
./config.sh init
-
Validate code
./config.sh validate
-
Plan changes
./config.sh plan ./config.sh plan <target>
-
Import resource
./config.sh import <resource_address> <import_address>
-
Apply changes
./config.sh apply ./config.sh apply <target>
-
Destroy resources
./config.sh destroy ./config.sh destroy <target>
-
Provision all modules
./config.sh provision
Runs in order: VPC → EKS → Helm Base → Secret Store → Bucket → RDS.
-
Tear down modules
./config.sh tear-down
Runs in reverse order: RDS → Bucket → Secret Store → Helm Base → EKS → VPC.
-
Update kubeconfig
./config.sh kubeconfig
-
Template Helm chart
./config.sh template
-
Deploy application(s)
./config.sh deploy
Deploys Supabase and HAProxy manifests into the cluster.
-
Debug cluster
./config.sh debug
Opens an ephemeral
alpinepod withpsqlclient pre-installed for live debugging.
-
Clean up cluster resources
./config.sh cleanup
Cleans up:
- Karpenter CRDs & resources
- Stuck nodes
- Leftover resources in non-system namespaces
-
Encrypt secret with AWS KMS
./config.sh encrypt
-
Decrypt secret
./config.sh decrypt
-
Smoke test Supabase
./config.sh smoke
Retrieves the
anonKeyfrom AWS Secrets Manager and runs a test request against Supabase’s REST API endpoint.
-
If a required tool is missing, the script exits with installation instructions.
-
Unknown commands will produce:
❌ Unknown Command: <COMMAND>
- Always run
./config.sh prerequisitesbefore working in a new environment. - Use
planbeforeapplyordestroyto review changes. - Keep AWS credentials configured with the correct profile.
- Use
cleanupif resources get stuck (especially after partial deletions). - Use
smoketo validate app endpoints after deployment. - Encrypt secrets before committing them anywhere.
-
Check tools
./config.sh prerequisites
-
Provision infrastructure
./config.sh provision
-
Update kubeconfig
./config.sh kubeconfig
-
Deploy application
./config.sh deploy
-
Smoke test app
./config.sh smoke
-
Tear down when done
./config.sh tear-down
- Environment:
production - Cluster name:
production-cluster - App name:
supabase - Namespace:
supabase - Key alias:
production-secret-store-key - Secret ID Name:
production-supabase-jwt - Helm chart path:
manifests/environments/production/supabase