How to Customize an Existing Template Using Custom Harness Template Library
This tutorial will go through how to make changes to a template in Custom Harness Template Library
For the purpose of this tutorial we will be focusing on customizing the project creation workflow but this can be done for any workflow.
Any workspaces that are created with the custom template library will now be configured with the source:custom tag, and have the appropriate connectors, branch and repos.
Add a variable
Add a variable into the project creation workflow.
Navigate to the Terraform Harness Documentation
Under Next Gen find
harness_platform_variablesGo into your code editor and open up
custom-harness-template-library/harness-projectAdd in file harness_variables.tf and paste in declaration from the Terraform docs
Change org_id to
data.harness_platform_organization.selected.idYou could use a variable but this was pulled from the others where the data object already exists.
Change project_id to
data.harness_platform_project.selected.idYou could use a variable but this was pulled from the others where the data object already exists.
Change fixed_value to
var.application_id
Add in the application_id variable into variables.tf
Add the variable to catalog_template.yaml. This will tell the user what to do and pass the information.
If you wanted to add in validations you can add this in here and add in things like patterns, minLength, and maxLength.
All new builds must have this field, so add it into required.
Note: the default value covers all pre-existing builds
Scroll down to configure_workspace and under RESOURCE_VARS add
application_id: ${{ parameters.application_id }}This will pass in the application ID into workspace creation.
Save, commit and push
Run the
Register Custom IDP Templatespipeline since changes were made to the workflow.
Workflows are registered using APIs not git experience therefore the change would only take effect if it is reloaded back in.
Add a new group
Create a new file under groups
The name of the file is very important as it is going to determine the identifier
As an example, create a Security Champions group by creating the Security_Champions.yaml file that looks like this:
Save, commit and push
Last updated
Was this helpful?