Creating a Bundle from an OpenTofu Module
This guide wraps an existing OpenTofu module in a bundle and deploys it.
If you are designing a catalog of bundles, model the bundle interfaces and resource types with the Massdriver Catalog first, then fill in the IaC with this guide.
Prerequisites​
The Massdriver CLI, configured for your organization
Bundle templates on your templates path, for example the
templatesdirectory of the Massdriver Catalog:shellmass config set default --templates-path ./massdriver-catalog/templates
Step 1: Create the bundle​
mass bundle new
The prompts ask for:
Name and Description.
Template: choose
opentofu, orterraform.Dependencies: the resource types the module consumes. For cloud credentials, choose the credential type and use the conventional name:
Cloud Resource type Name AWS aws-iam-roleaws_authenticationGCP gcp-service-accountgcp_authenticationAzure azure-service-principalazure_service_principalOutput directory: defaults to
massdriver.
Without prompts:
mass bundle new -n my-bucket -t opentofu -c aws_authentication=aws-iam-role -o massdriver
Step 2: Add the module​
Copy the module's
.tffiles into the bundle'ssrcdirectory, replacing the template'smain.tf.Add a
paramsentry inmassdriver.yamlfor each module variable:shellcd massdriver
mass bundle importmass bundle importfinds variables declared in each step's directory that are not yet params, dependencies, ormd_metadata, and asks before adding each one.-aadds them all.Review
src/providers.tf. Uncomment the provider for your cloud, or keep your module's own provider configuration and use the credential dependency in it, for examplevar.aws_authentication.data.arn.To produce resources for other bundles, declare them under
resourcesinmassdriver.yamland create them withmassdriver_resource. See Custom Resource Types.Create the repository once, then check and publish:
shellmass bundle create my-bucket
mass bundle lint
mass bundle publish
Step 3: Deploy​
- Open or create a project and environment in Massdriver.
- Set the cloud credential as an environment default.
- Open the Bundles drawer on the canvas and add a component from your bundle.
- Open the instance, set its configuration on the Config tab, and deploy.
If the repository was created restricted, grant it to the project first.