- modules - contains terraform configuration files to build the Kubernetes cluster.
- production - contains all of our production instances
- Create a secret called GH_TERRAFORM, use the gcloud util to generate a key.json file from your service account and run this to format it correctly:
vi gcp-credential.json press :
Add the following %s;\n; ;g and press enter
press : again
type wq!
- Add two secrets, AWS_ACCESS_KEY and AWS_SECRET_ACCESS_KEY with your AWS IAM credentials.
-
Create a new branch, typically call it the name of the new instance e.g.
instance-name.example.com
-
Create a new folder in the production folder, name it the instance name e.g.
instance-name.example.com
and create a file calledterragrunt.hcl
-
The
terragrunt.hcl
file should contain a reference to the terraform module and inputs:terraform { source = "../../../modules/gcp/gke" } inputs = { env_name = "instance-name-example" node_poolname = "test-instance-node-pool" project_id = "google-cloud-project-id" region = "europe-west1" network = "gke-network" subnetwork = "gke-subnet" ip_range_pods_name = "ip-range-pods" ip_range_services_name = "ip-range-services" }
-
Push your changes, create a pull request and wait for the tests to be run.
-
If the tests all pass, and the terraform plan output looks okay (e.g. no instances are going to be deleted!) then merge your branch to main and GitHub actions will run terragrunt apply and create the infrastructure.
- Clone the git repository
- Move to the correct directory (e.g. ./production/instance-name.example.com)
- Run
terragrunt destory