Terraform provider based on workspace

I have 2 providers in my terraform (0.14) code, I would like to separate it based on my environment (workspace). So workspace A will not call workspace B provider.

Please help

Hi @suvro,

Workspaces exist to allow you to have multiple states for a single configuration, but this question suggests that you want to have a separate configuration for each workspace. That’s not a capability of workspaces, so to meet this requirement you’ll need to use some other technique.

I would suggest factoring out the elements that are common to both of your environments into one or more shared modules and then writing a separate configuration for each environment, but with each one mostly just calling into the same module(s) to achieve the same behavior. You can then adjust what you call in each environment to omit any parts that are not relevant to that environment.

1 Like