Hello Terraform users,
I’m new with terraform and I would like to use it to deploy and control infrastructure resources (AWS) of my customer for each of its environments. So I saw Terraform workspace to be able to switch between environment and to have a separate tfstate file for each of them. But, now I would like to know if we can exclude the deployment of a resource for a specific environment. Let’s take an example, Imagine, I have 3 environments : dev, staging and prod and I would like to deploy a S3 bucket for each environment and a documentDB instance for prod and one shared documentDB instance for dev and staging. How can I do this by using workspace with terraform? How can I exclude some resources for a specific workspace?
I saw that we can use conditionals with terraform but If I don’t make a mistake its working if we have a count
property. But in my example DocumentDB have no count
property so I can’t have a map for each environment and specify 1
if we want this resource and 0
if we don’t want.
If someone can help me to structure my project it’s will be really cool because I have never use terraform for a real project.
If you need more context about the environment of my customer I can give you more details or we can also discuss on slack
on somewhere else.
Thanks you for our help,
Best regards,
Rayane.