Resource Hierarchy
Create resources at the account, organization, or project scope.
When creating flexible templates, resources can exist at the account, organization, or project scope.
To do this, you must do three things:
Have the user specify the location where the template should be placed
Place the resource [using the terraform code] at the target location
Dynamically give the users links to the created resources
This can be achieved using the following pattern in your catalog and terraform code.
Specify location
You can use the following template section in your catalog to ask the user where the resource should be placed.
parameters:
- title: Template Location
description: Where should this be placed?
required:
- template_location
properties:
template_location:
title: Template Location
type: string
description: Where should we place the template?
enum:
- Account
- Organization
- Project
dependencies:
template_location:
oneOf:
- properties:
template_location:
enum:
- Account
- properties:
template_location:
enum:
- Organization
org_id:
title: Org Identifier
description: Harness Organization Identifier
type: string
ui:field: HarnessOrgPicker
required:
- org_id
- properties:
template_location:
enum:
- Project
project_id:
title: Project Identifier
description: Harness Project Identifier
type: string
ui:field: HarnessProjectPicker
org_id:
title: Org Identifier
description: Harness Organization Identifier
type: string
ui:field: HarnessOrgPicker
required:
- project_id
- org_idYou can then pass the org and project IDs to your terraform based on the values selected:
Use location
Now in your terraform, you need to define variables for the org and project IDs, and use them in your resource definition.
Data sources validate that the locations exist before Terraform tries to create them, turning a confusing apply failure into a clear plan failure.
The data sources can then be used to place the resources being created at whatever level the user specified.
Return resource links
Finally, give the user handy links in their template so they can easily navigate to the created resource. The resource URL is crafted based on the org or project specified. This may change based on the resource you are linking to; the following is an example for some of the common resources.
Last updated
Was this helpful?