Creating a TFE Private Registry Module
Creating a TFE Private Registry Module
This guide demonstrates the process for publishing a Terraform Module to Optum's private Terraform Enterprise (TFE) registry.
Getting Help / Troubleshooting
For assistance, reach out on the TFE Teams Channel or the Automation Teams Channel
Prerequisites
Recommendations
A list of some good practices to follow when creating a module.
Local First Development
It is usually best to develop your module code as a local module in a TFE workspace to iron out all the kinks before publishing it to the TFE registry. Having a TFE workspace will allow you run both terraform plan and terraform apply. Publishing a new version to the registry involves a Pull Request (PR), and waiting for two approvals for every minor change can be time-consuming.
Follow Conventions
Try to make things as obvious as you can (within reason). For example, If everyone else uses a particular naming scheme for a particular set of resources, then you should too. This eliminates some initial friction for unfamiliar developers, making it easier for them to assist or possibly improve your work.
Be Informative
Name your variables clearly. If a module variable is merely a pass-through to one already defined in the provider's definition, then use the provider's name. Always use the provided description fields and be concise but complete when describing variables and outputs.
A good rule of thumb is to read through the provider's documentation to see how they describe their inputs and outputs. This will help users understand what the module does, and how to use it.
Steps
- Create a new module repository:
- In the
optum-tech-computeorganization, use the TFE Module template. - Name the repository following the pattern
ohemr-epic-private-registry-<module-name>, where<module-name>is the name of the module you are creating. Please use kebab-case for the module name.
- In the
- Clone uhg-arc/tfe-global-module-registry to your local machine.
- Create a new branch for your changes.
- Run
git checkout -b <branch-name>.
- Run
- Edit optum_tech_compute_modules.tf to include the new module repo you created in step #1.
- Commit and push your changes to the repository.
- Create a PR for your changes.
- This PR will need to be approved by a smaller subset of admins
- This PR will need to be merged by someone in
AZU_terraform_enterprise_module_admin
- Clone the new module repository from step #1 to your local machine.
- Create a new branch for your changes.
- Run
git checkout -b <branch-name>.
- Run
- Add your module code to the repository.
- Run
terraform-docs -c .terraform.docs.yml .to generate the module documentation. - Ensure
variables.tf, andoutputs.tfare up-to-date and documented properly.
- Run
- Commit and push your changes to the repository.
- Create a PR for your changes.
- Once the PRs from steps #6 and #11 are merged, a new module under the
<module-name>you declared above will be available in the TFE registry.