Open kinseii opened 3 months ago
Hello.
You can use multiple backends for terraform states (configured in kind: stack
). The backend is tied to the stack.
But cdev's own state (configured in project.yaml
, kind: project
) can be stored only in one backend.
Here is a conditional example:
project.yaml
name: example
kind: Project
backend: aws-backend # save cdev state in aws s3
variables:
organization: cluster-dev
region: eu-central-1
state_bucket_name: cluster-dev-gha-tests
stack.yaml
name: aws-backend
kind: Backend
provider: s3
spec:
bucket: {{ .project.variables.state_bucket_name }}
region: {{ .project.variables.region }}
---
name: azurerm-backend
kind: backend
provider: azurerm
spec:
resource_group_name: "StorageAccount-ResourceGroup"
storage_account_name: "example"
container_name: "cdev-states"
---
name: aws-stack
template: https://...
kind: Stack
backend: aws-backend # save tf states in aws s3
---
name: azure-stack
template: https://...
kind: Stack
backend: azurerm-backend # save tf states in azure
Does this answer the question?
I've suspended PoC for cdev for now, but I'd like to report the following.
We are using Azure Blob Storage (ABS), we have multiple stacks in our project that use separate Subscriptions. I can manually switch Subscriptions with the command az account set -n $SUBSCRIPTION-NAME
.
If I am in Subscription1 and if we have a Stack using Subscription1 in the backend. And Cdev itself is using Subscription2, then plan/apply gives an error (just the string “Error”), if you enable debug, you will see that it can't access Blob Storage for Cdev itself. So we have several subscriptions in our configuration and we need to define where to save the states of cdev itself and if I specify one of them (in the kind: Project
), I will get an error when running for a subscription other than cdev backend.
I have so far used backend: default
so that the cdev states are saved locally, but of course we have to do something about it.
Understood, i changed label of this issue to bug
. Will check this problem.
We have multiple subscriptions in a cloud provider and we would like to store the state files for each StackTemplate in separate storages (backends). The documentation says (https://docs.cluster.dev/structure-project):
That is, it seems to be the way it was intended, since this parameter is optional in the Project. However, the
validate
andplan
commands produce an error:Thus I can't specify multiple backends. If this is not a bug, I would like to request such a feature, thank you very much!