Create and manage templates in Terraform Developer Portal
Terraform Developer Portal templates give application developers a starting point for new applications by deploying an HCP Terraform no-code module that creates the application's main infrastructure. For example, a template can create a code repository with your organization's standard libraries and best practices. Platform engineers typically create, edit, and delete templates.
Template creation workflow
The following steps describe the procedure for creating templates:
- For each template you want to create, define a no-code module in HCP Terraform that specifies a common infrastructure pattern.
- Use the Terraform Developer Portal UI to create the template.
After creating a template, application developers can use it to deploy their applications.
Prerequisites
- An HCP Terraform organization on the Standard edition or higher to use HCP Terraform no-code modules and the private module registry. Refer to HCP Terraform pricing for plan details.
Create a no-code module
Terraform Developer Portal templates deploy no-code modules from your organization's private module registry. Define the common infrastructure pattern in an HCP Terraform no-code module. Refer to Design no-code ready modules for instructions on how to create no-code modules.
Declare a developer_portal_application variable in your no-code module to reference the name of your Terraform Developer Portal application. Terraform Developer Portal sets that variable to the application name when an application developer uses a template. You can use this variable to label infrastructure resources in the no-code module so you can associate them with the Terraform Developer Portal application. Refer to Input variables for instructions on how to define variables in Terraform.
You may need to create organization-scoped or project-scoped variable sets within your HCP Terraform organization so your no-code modules can authenticate and interact with your cloud provider. Refer to Variable sets for more information.
Create a template
After you create the no-code module, complete the following steps in Terraform Developer Portal to create a new template:
- Sign in to HCP Terraform and select the organization where you want to create your template.
- In the navigation menu, click Developer Portal.
- Click Templates in the sidebar, then click New Template.
- Specify a unique identifier for the template in the Name field.
- Choose a no-code module to use as the source for the template from the Base module menu. No-code modules published in your organization's private registry appear in the menu.
- Provide values for the input variables of the no-code module. Optionally, you can enable the User can configure this variable when creating an application checkbox to let users provide a value when they deploy the template.
- Optionally, configure the execution mode that HCP Terraform uses to perform Terraform operations. By default, templates use the organization's default execution mode. You can override the default by disabling Use Terraform organization's default mode and choosing one of the following options:
- Remote: Run Terraform operations in HCP Terraform's infrastructure.
- Agent: Use a self-managed agent pool. Refer to Manage Agent Pools to learn how to create and manage agent pools.
- Click Continue.
- Add a short description of the template in the Summary field. This field can be up to 110 characters. HCP Terraform presents the description when users create a new application from a template.
- Specify instructions for application developers on how to use the template in the Developer Instructions field. This field supports markdown. Optionally, click Update from module's README to automatically populate this field with the value of the no-code module's README file. You can reference the following variables in the developer instructions. Refer to Terraform Developer Portal template and add-on variables for the complete list.
{{ .ApplicationName }}: Populates the name of the developer's application in the instructions.
- Click Save.
Edit a template
Modifying a template does not affect existing applications or underlying resources that were created by the template. Changes only apply to new applications.
To edit a template, complete the following steps:
- Sign in to HCP Terraform and select the organization where you want to edit your template.
- In the navigation menu, click Developer Portal.
- Click Templates in the sidebar, then click on the template you want to modify.
- Click the Manage menu and choose Edit template.
- Update the desired fields.
- Click Save.
Delete a template
Deleting a template does not remove applications that were created from the template. To remove applications, you must delete the application in Terraform Developer Portal or delete the Terraform resources and the HCP Terraform workspace associated with the application. Refer to Delete an application and Destruction and Deletion for instructions on how to delete applications and workspaces.
To delete a template, complete the following steps:
- Sign in to HCP Terraform and select the organization where you want to delete your template.
- In the navigation menu, click Developer Portal.
- Click Templates in the sidebar, then click on the template you want to delete.
- Click the Manage menu and select Delete.
- In the Delete template dialog, enter "delete" and then click Delete.
Next steps
To learn more about what you can do with Terraform Developer Portal after you created a template, refer to the following topics: