hashicorp / terraform-cloud-operator

Kubernetes Operator allows managing HCP Terraform resources via Kubernetes Custom Resources.
https://developer.hashicorp.com/terraform/cloud-docs
Mozilla Public License 2.0
114 stars 27 forks source link

Do we have a support to define dependency between Module kind? #408

Open Ashish7812 opened 2 months ago

Ashish7812 commented 2 months ago

Operator Version, Kind and Kubernetes Version

YAML Manifest File

# Copy-paste your YAML manifest here

Output Log

Kubectl Outputs

Question

I am using the Module kind to deploy my infrastructure. The infrastructure layer is divided into two modules.

  1. Network
  2. Compute

The following one is for the Network module.

apiVersion: app.terraform.io/v1alpha2 kind: Module metadata: name: network spec: organization: token: secretKeyRef: name: terraformrc key: token destroyOnDeletion: true module: source: "s3::https://s3.amazonaws.com//network.zip" variables:

Similarly I have created for the compute module. The question is how can I define the dependency between these two modules so that the network should be deployed first and then the compute module will be deployed.

The two modules will be deployed in the same workspace. Can we define a dependency between modules in the same workspace?

References

Community Note

Ashish7812 commented 1 month ago

I came across the terraform stack concept. In the stack concept, there is a component-level dependency that suits my requirements.

so do we have a plan to support the terraform stack in the HCP terraform cloud operator?

arybolovlev commented 1 month ago

Hi @Ashish7812,

If I understand you correctly, this cannot be achieved now with the Module controller. It implements API-driven workflow, which would be a limitation if we talk about a single Workspace. A potential workaround would be a new module that includes those 2 that you have and set dependencies in there, however, as of today it might not work well in some configurations and might require restarting a run.

As you have mentioned, the stack concept is something that may help to address your needs. Once it is GA it will take some time for us to discuss whether or not a support for it would be added to the operator. and if we decide positively -- it will take some time to develop a new controller.

Thanks!