Our terraform provisioning pipeline is multi-stage. For example, we provision our foundational infra services (like vault) first, then our control plane services like nomad and consul, followed by data infra services (kafka, zookeeper, cassandra, storm, databricks, etc), and eventually application iam roles whose access permissions are scoped to specific subset of infra services. We have a sandbox account where each SRE can deploy their own replica of the whole infra services and develop on it. This guarantees that SRE’s won’t step on each other’s toes. Then once the features are tested in sandbox, we do integration testing of all features in one release in our test account. As you can see, with a team of 8 SRE’s, we’ll have at most 8 complete replicas deployed in our sandbox account, which can be very wasteful since normally each SRE is really only touching a few services for their feature (for example, a feature in kafka will have nothing to do with databricks or cassandra).
In the past, we try to set the instance count of unused services to 0, which will not provision any EC2 instances for our databricks/cassandra clusters in the above example. This is not perfect but works fine. With terraform 13’s module count
feature, I tried to set the count
of the databricks module to 0
via a control flag in the calling module, which has all the application infra services (kafka, zookeeper, cassandra, storm, databricks), each as an individual module:
module "databricks" {
source = "git@github.com:myorg/terraform-aws-databricks-pvc.git?ref=tf13"
count = var.disable_databricks ? 0 : 1
...
}
The databricks module has an output parameter (as you can see, I try to include the disable_databricks
flag for this output in case it is disabled):
output "databricks_core_iam_role_name" {
value = var.disable_databricks ? "" : module.databricks.core_iam_role_name
}
However, I get the following error with terraform plan
:
Error: Unsupported attribute
on .terraform/modules/cell_shared/output.tf line 62, in output "databricks_core_iam_role_name":
62: value = var.disable_databricks_pvc ? "" : module.databrickspvc.core_iam_role_name
|----------------
| module.databrickspvc is tuple with 1 element
This value does not have any attributes.
Is there a way to resolve this error given our setup?