For the complete documentation index, see llms.txt. This page is also available as Markdown.

Provision Infrastructure using IDP and IaCM

Create a basic infrastructure provisioning pipeline using Harness IDP

This tutorial is designed to help a platform engineer to get started with Harness IDP. We will create a basic infrastructure provisioning pipeline using IaCM that takes input from software template and provisions an ec2 instance for a developer. After you create the software template, developers can choose the template on the Workflow page and enter details such as a the owner user-group and the Git repository. The IaCM pipeline handles change management by creating a JIRA ticket followed by the IaCM stage containing the terraform scripts. Once the infra is provisioned we do the Governance Management using the OPA.

Users (developers) must perform a sequence of tasks to provision the infrastructure. First, they interact with a software template. A software template is a form that collects a user's requirements. After a user submits the form, IDP executes a Harness IaCM pipeline that provisions the new ec2 instance.

Before you begin

Before you begin this tutorial, make sure that you have completed the following requirements:

  • Enable Harness IDP and Harness IaCM for your account.

  • Make sure you are assigned the IDP Admin Role or another role that has full access to all IDP resources along with the IACM Workspace.

  • Create a Service Now and JIRA connector with access to the projects where you want to create the tickets for provisioning the pipeline.

  • Create a Workspace using the AWS Connector created above. Also use the following repository for the workspace and add the branch as master and file path as .

Create a pipeline

Begin by creating a pipeline for provisioning infrastructure

To create a Developer Portal stage, perform the following steps:

  1. Go to Configure section under IDP, select Projects, and then select a project.

You can also create a new project for the service onboarding pipelines. Eventually, all the users in your account should have permissions to execute the pipelines in this project. For information about creating a project, go to Create organizations and projects.

  1. Then select Create a Pipeline, add a name for the pipeline and select the type as Inline

  2. The YAML below defines an IaCM stage with a number of steps as described here that will perform the actions provision the infrastructure. Copy the YAML below, then in the Harness Pipeline Studio go to the YAML view and paste below the existing YAML.

You need to have completed all the steps under PreRequisites for the below given YAML to work properly

Update the connectorRef: <the_connector_name_you_created_under_prerequisites> for all the steps it is used.

  1. Now Save the pipeline.

All inputs, except for pipeline input as variables, must be of fixed value.

Create a workflow

Now that our pipeline is ready to execute when a project name and a GitHub repository name are provided, let us create the UI counterpart of it in IDP. Create a workflow.yaml file anywhere in your Git repository.

In the following workflow.yaml we have added few enums to choose from the available list of options like for the instance_type, ami, subnet and vpc. Team responsible for infrastructure provisioning is expected to fill this enums with available possibilities for the ease of developers to just select form the available options.

Replace the YOUR PIPELINE URL HERE with the pipeline URL that you created.

This YAML code is governed by Backstage. You can change the name and description of the software template.

Authenticate the request to the pipeline

The Workflow contains a single action which is designed to trigger the pipeline you created via an API call. Since the API call requires authentication, Harness has created a custom component to authenticate based of the logged-in user's credentials.

The following YAML snippet under spec.parameters.properties automatically creates a token field without exposing it to the end user.

The token property we use to fetch Harness Auth Token is hidden on the Review Step using ui:widget: password, but for this to work the token property needs to be mentioned under the first page in case you have multiple pages.

That token is then used as part of steps as apikey

Register the workflow in IDP

Use the URL to the workflow.yaml created above and register it by using the same process for registering a new software component.

Use the self service workflows

Now navigate to the Workflows page in IDP. You will see the newly created Workflow appear. Click on Choose, fill in the form, click Next Step, then Create to trigger the automated pipeline. Once complete, you should be able to see the EC2 instance provisioned.

Last updated

Was this helpful?