Developer Environment Setup
This document will guide the user through the creation of new Terraform templates to be included in the Harness Template Library. The goal will be to guide the user through adding a new local development branch and base scaffold necessary to build a new Terraform Template.
Prerequisites
This document assumes that your local development environment has followed the steps outline in the Developer Environment Setup guide. Please review those requirements to ensure that you have all the tools necessary to proceed.
Walk-thru
STOP: Before you proceed, make sure you review the Naming Standards guide to ensure your new template will adhere to the project standards
- Open this repository in your local IDE tool
- Open a terminal in this local path to this directory
- Choose a new name for this template. Don't forget to review Naming Standards guide
- Create a new branch for your enhancement using the pattern -
feature/<name-for-template>
- Run the command
make generate type=terraform name=<name-for-template>
Replace<name-for-template>
with the name for the resource
Next Steps
Once you add the new scaffold, it is time to start building the resources. The scaffold adds the following files to the repository:
- main.tf - Should contain core resource declarations and data resources used throughout the template. Additional
.tf
files can be added to further organize the resources by grouping them together. - locals.tf - Local variable declarations and configurations
- outputs.tf - All output variables should be declared along with their descriptions
- providers.tf - Contains the Harness provider configuration block and should include any other provider configuration blocks required
- terraform.tf - Terraform settings and provider version details
- terraform.tfvars.example - Example file leveraged by end-users to generate custom
terraform.tfvars
files - variables.tf - All user-defined variables should be placed within this file
- templates (directory) - Any Terraform
template_file
source material - e.g. Yaml template files used to define a pipeline - Makefile - Standard Makefile included which can be used to execute standard automation
- README.md - Fully documented user guide for the new template
README
To help generate the resources
, inputs
, and outputs
section of the README you can use the terraform-docs tool to generate this for you: terraform-docs markdown table --anchor=false .
terraform.tfvars.example
This file should include all the variables from your project, their description, and their defaults, so users can easily use this to bootstrap your template. You can again use terraform-docs to bootstrap this: terraform-docs tfvars hcl .