hashicorp / terraform-k8s

Terraform Cloud Operator for Kubernetes
https://learn.hashicorp.com/tutorials/terraform/kubernetes-operator?in=terraform/kubernetes
Mozilla Public License 2.0
453 stars 71 forks source link

Run dependencies between workspaces #128

Open OlegGorj opened 2 years ago

OlegGorj commented 2 years ago

Community Note

Description

Implement run dependencies between workspaces, as in one workspace won't trigger the run until specified pre-requisite workspace finish its run(s). This can be used to create tree-like running hierarchies for the workspaces, and achieve fairly complex orchestration of multiple runs.

Suggest using Run Trigger AP https://www.terraform.io/cloud-docs/api-docs/run-triggers

Potential Terraform Configuration

Workspace configuration may look like this:

apiVersion: app.terraform.io/v1alpha1
kind: Workspace
metadata:
 name: demo
spec:

 # The workspace name that needs to finish the run before
 #  this workspace can be triggered
 workspaceTrigger: <Name-of-pre-requisite-workspace>

 organization: demo
 secretsMountPath: "/tmp/secrets"
 module:
   source: "github.com/koikonom/terraform-nullresource-example"
 variables:
   - key: CONFIRM_DESTROY
     value: "1"
     sensitive: false
     environmentVariable: true
 outputs:
   - key: pet
     moduleOutputName: rofl

References

Run Trigger AP https://www.terraform.io/cloud-docs/api-docs/run-triggers

KamalAman commented 1 year ago

Implemented in v2 https://github.com/hashicorp/terraform-cloud-operator/blob/main/docs/examples/workspace-runTriggers.yaml