Get started with Terraform Developer Portal
Terraform Developer Portal is an internal developer platform that allows platform teams to define golden patterns and workflows that enable a self-service experience for developers.
First, platform engineers create shared templates and add-on definitions for common services and publish them to Terraform Developer Portal. Then, developers use the templates and add-ons to deploy applications and the underlying infrastructure.
Templates are starting points for application developers. Templates standardize many aspects of the main infrastructure that support developers' applications. For example, a template can create a code repository from a standardized template already configured with your organizations standard libraries and best practices.
Add-ons are building blocks that capture generic, reusable infrastructure configuration. When a developer uses a template to deploy infrastructure, they can attach add-ons to that provision optional resources for their application, such as a database or a cache.
Shared templates and add-on definitions codify the requirements from stakeholders across the organization, including security, compliance, and finance. Refer to the Create and manage templates and Create and manage add-on definitions documentation for more information.
Developers can use the assets published to Terraform Developer Portal to create applications without waiting for input or approval from the platform engineering team.
The tutorials in this collection will teach you how to complete the following tasks:
- Set up and configure an HCP Terraform project and variable set
- Publish no-code modules for a template and add-on
- Create definitions for a template and add-on
- Create an application from a template
- Install an add-on to an application
- Clean up the resources and infrastructure you created
In this tutorial, you will set up a project and variable set in HCP Terraform that you will use to deploy your application and add-on.
Prerequisites
For this tutorial, you will need the following:
- A GitHub account.
- An HCP Terraform account, permission to manage projects and no-code modules, and organization on the Standard edition or higher. Refer to HCP Terraform pricing for more information.
- A GitHub VCS provider configured in your HCP Terraform organization. Refer to Set up the GitHub.com VCS provider for more information.
- An AWS account, as well as credentials to authenticate to the account.
Create GitHub access token
The example in this tutorial creates a new GitHub repository that contains starting code for a new application. To create this repository, you must provide a GitHub token with access to create repositories and commit files. Complete the following steps to create a new GitHub token.
- Login to GitHub, click your profile picture in the top-right, then click Settings.
- Click Developer settings in the left navigation panel.
- Click Personal access tokens in the left navigation panel, then click Fine-grained tokens.
- Click Generate new token.
- In the Token name field, enter
Terraform Developer Portal. - Optionally, choose a Resource owner. This is the owner for every repository this token creates. This defaults to your personal account.
- Under Repository access, choose All repositories. This setting is required to create new repositories.
- Click Add permissions.
- Choose Administration and select Read and write access. GitHub requires this permission to create new repositories. Note that GitHub automatically adds the Metadata permission as well. GitHub requires this permission to read information about your repositories.
- Click Add permissions.
- Choose Contents and select Read and write access. GitHub requires this permission to write content to repositories.
- Click Generate token.
- GitHub displays a summary of the token that you chose to create. Click Generate token to confirm.
GitHub only displays your new GitHub token once. Copy this and store it somewhere secure. You will use this token later in this tutorial.
Create a project
Create a project to deploy your application and add-on to. Every Terraform Developer Portal application maps to an HCP Terraform workspace, and when you deploy an application you must choose a project to create the workspace in. Complete the following steps to create a new workspace in HCP Terraform:
- Login to HCP Terraform and choose your organization.
- In the left navigation panel, click Projects.
- Click the New Project button.
- In the Project name textbox, enter
Developer Portal. - In the Project description textbox, enter
Get Started with Terraform Developer Portal. - Click Create.
HCP Terraform automatically takes you to the overview page for your new project.
Create a variable set
You can use project-scoped variable sets to apply values for Terraform variables and environment variables to every workspace in a project. For this tutorial, complete the following steps to create a new project-scoped variable set with your AWS credentials:
In the project overview page, click Settings in the left navigation panel.
Click Variable sets.
Click Create project variable set.
In the Name textbox, name the variable set
Developer Portal AWS.In the Description textbox, enter
AWS credentials for Developer Portal deployments.In the Variable set scope section, choose Apply to the entire project.
Click Add variable to create a new environment variable. Repeat this step for each environment variable in the following table:
Category Key Value Sensitive Environment AWS_ACCESS_KEY_IDThe access key ID from your AWS key pair False Environment AWS_SECRET_ACCESS_KEYThe secret access key from your AWS key pair True Environment GITHUB_TOKENYour GitHub token created earlier True After you added the required variables, click Create variable set.
To learn more about variable sets in HCP Terraform, refer to the Variable sets documentation.
Next steps
In this tutorial, you learned about Terraform Developer Portal and how to set up your HCP organization to start using Terraform Developer Portal.
In the next tutorial, you will create a template from a no-code module and use it to create an application.