Create a Bundle from an OpenTofu Module
If you already have existing Infrastructure-as-Code (IaC) modules you'd like to deploy and manage through Massdriver, you'll need to import the IaC into a Massdriver bundle. Fortunately, the Massdriver CLI makes it easy to create bundles from existing IaC. To demonstrate, this guide provides step-by-step instructions on how to create a new bundle in Massdriver from an existing OpenTofu module.
Be sure to complete the prerequisites in order to complete this guide.
Step 1: Create a New Massdriver Bundle
Navigate to where you would like to store the Massdriver bundle, and run:
mass bundle new
This command will walk you through a wizard to configure a new Massdriver bundle. Give the bundle a useful name and description. When you are prompted to select the template, select
opentofu-module
(or optionally, you can selectterraform module
):$ mass bundle new
Name: bundle-name
Description: Description of the bundle
Use the arrow keys to navigate: ↓ ↑ → ←
? Template:
↑ kubernetes-deployment
kubernetes-job
▸ opentofu-module
phoenix-kubernetes
↓ rails-kubernetesNext, you will be prompted to specify the path to your existing module. This will allow the CLI to inspect your existing module, generate the proper configuration, and copy over the necessary files:
✔ Path to an existing opentofu-module to generate params from, leave blank to skip: path/to/your/module█
Next you will be prompted to specify any connections. Connections are dependencies your module has on external bundles or inputs. If your module needs to authenticate to AWS, GCP or Azure, be sure to specify the appropriate credential:
Cloud Connection Name AWS massdriver/aws-iam-role
aws_authentication
GCP massdriver/gcp-service-account
gcp_authentication
Azure massdriver/azure-service-principal
azure_service_principal
Next you'll be prompted to name your connections. If you selected a cloud credential as a connection, use the appropriate name in the above table to simplify your bundle.
Please enter a name for the connection: "massdriver/aws-iam-role"
This will be the variable name used to reference it in your app|bundle IaC
✔ Name: aws_authenticationFinally, you'll be asked where you would like the bundle to be written. This will vary depending on your IaC management strategy, but for now you can use the default of
massdriver
.
Step 2: Customize Bundle
Next, we will review the bundle configuration files and make necessary updates.
Open the
massdriver.yaml
file and review the imported parameters. You'll notice that all variables declared in the module should be imported into theparams
block.Open the
src/_providers.tf
file. This file is generated by the template to simplify bundle creation. However, if you have your own provider configuration, it can be discarded. Just be sure to copy the appropriate provider authentication configuration into your own file.Publish the bundle to Massdriver:
mass bundle publish
Step 3: Deploy the Bundle Using Massdriver
Once the bundle is published, you can deploy it using the Massdriver platform.
- Log into Massdriver Cloud.
- Navigate to (or create) a project and environment in which to deploy the bundle.note
Be sure this environment has the proper cloud credential specified
- Drag your new bundle from the sidebar onto the canvas.
- Specify a name for the bundle.
- Click on the bundle, navigate to the Config tag, specify your desired configuration
- Click Deploy
Conclusion
Congratulations, you've deployed your first custom Massdriver bundle!