At my job we a have a customer that wanted our services running in his own cloud (GCP), we have access to it and have the necessary rights to work like in ours (GCP as well).
Until now we create the instances and deploy the services there but that not scale well. We want to migrate to kubernetes, and we are evaluating terraform to build the infrastructure
Take into account that I want to have one terraform backend for our cloud and another for the customer’s cloud (at least), because timings for updates, deploys and other changes aren’t always the same.
After reading the documentation, doing the tutorials, etc… This is my current approach.
gke/
├── configurations
│ ├── customer
│ │ ├── develop
│ │ │ ├── config.tfbackend
│ │ │ └── terraform.tfvars
│ │ ├── production
│ │ │ ├── config.tfbackend
│ │ │ └── terraform.tfvars
│ │ └── staging
│ │ ├── config.tfbackend
│ │ └── terraform.tfvars
│ └── us
│ ├── develop
│ │ ├── config.tfbackend
│ │ └── terraform.tfvars
│ ├── production
│ │ ├── config.tfbackend
│ │ └── terraform.tfvars
│ └── staging
│ ├── config.tfbackend
│ └── terraform.tfvars
└── main.tf
In main.tf there is an empty backend config, and I specify one of the congif.tfbackend files above when do a terraform init:
- terraform init -backend-config=pathToFile
And the same for plan and apply:
- terraform plan -var-file=pathToFile
Is this structure correct or it’s a nonsense in the long term?
Nothing is in stone yet, feel free to suggest changes. Any advice will be really appreciated
Thanks