Reputation: 93
I am using cdktf
for creating AWS resources. I want to create multiple .tfstate
files. I see that it is possible if I create multiple stacks. I see in many documents to use dedicated folders but that will be a separate code altogether. I saw in one of the GitHub community that it is there in the roadmap. Is it done? Any examples like on how to implement this would be of great help.
Upvotes: 2
Views: 729
Reputation: 1425
It is possible now. One way to do it is by creating a class for each stack that you want to create. For example in Python you can do it like this:
# vm.py
class Create(TerraformStack):
def __init__(self, scope: Construct, ns: str):
super().__init__(scope, ns)
...
...
# k8sCluster.py
class Create(TerraformStack):
def __init__(self, scope: Construct, ns: str):
super().__init__(scope, ns)
...
...
# main.py
from cdktf import App
import vm
import k8sCluster
app = App()
vm.create(app, 'the-vm')
k8sCluster.create(app, 'the-cluster')
Upvotes: 1