Reputation: 3287
I define a provider containing modules.
I can call terraform apply at the provider level with two different workspace:
workspace list
default
wk-p1
* wk-p2
I would like the following module only to be launch when I use the workspace wk-1:
module "sync" {
source = "./../test-modules/sync"
workspace="${local.workspace}"
entity = "${local.entity}"
}
I would like something like this:
module "sync" {
if ("${local.workspace}" == "wk-p2") {
source = "./../test-modules/sync"
workspace="${local.workspace}"
entity = "${local.entity}"
}
}
Do you have any idea?
Upvotes: 1
Views: 1943
Reputation: 4408
For this you could use the terraform.workspace
variable in conjuction with the count
directive
count = (terraform.workspace == "wk-p2") ? 1 : 0
This way when the workspace is wk-p2
, terraform will create an instance of the module.
On the other hand if it evaluates to false it will create 0
instances of the modules, meaning it will not
create anything
Upvotes: 4
Reputation: 21
Maybe try with "count". Something like:
count = terraform.workspace == "default" ? 1 : 0
Upvotes: 2