UNPKG

@lbrlabs/pulumi-harness

Version:

A Pulumi package for creating and managing Harness resources.

1,008 lines (1,007 loc) 30.9 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Resource for creating a Template. Description field is deprecated * * ## Remote Pipeline template * * resource "harness.platform.Template" "pipelineTemplateRemote" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * gitDetails { * branchName = "main" * commitMessage = "Commit" * filePath = "filePath" * connectorRef = "account.connector_ref" * storeType = "REMOTE" * repoName = "repoName" * } * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: Pipeline * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * stages: * - stage: * identifier: dvvdvd * name: dvvdvd * description: "" * type: Deployment * spec: * deploymentType: Kubernetes * service: * serviceRef: <+input> * serviceInputs: <+input> * environment: * environmentRef: <+input> * deployToAll: false * environmentInputs: <+input> * serviceOverrideInputs: <+input> * infrastructureDefinitions: <+input> * execution: * steps: * - step: * name: Rollout Deployment * identifier: rolloutDeployment * type: K8sRollingDeploy * timeout: 10m * spec: * skipDryRun: false * pruningEnabled: false * rollbackSteps: * - step: * name: Rollback Rollout Deployment * identifier: rollbackRolloutDeployment * type: K8sRollingRollback * timeout: 10m * spec: * pruningEnabled: false * tags: {} * failureStrategies: * - onFailure: * errors: * - AllErrors * action: * type: StageRollback * * EOT * } * * ## Remote Pipeline template to create new branch from existing base branch * * resource "harness.platform.Template" "pipelineTemplateRemote" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * gitDetails { * branchName = "newBranch" * commitMessage = "Commit" * filePath = "filePath" * connectorRef = "account.connector_ref" * storeType = "REMOTE" * repoName = "repoName" * baseBranch = "main" * } * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: Pipeline * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * stages: * - stage: * identifier: dvvdvd * name: dvvdvd * description: "" * type: Deployment * spec: * deploymentType: Kubernetes * service: * serviceRef: <+input> * serviceInputs: <+input> * environment: * environmentRef: <+input> * deployToAll: false * environmentInputs: <+input> * serviceOverrideInputs: <+input> * infrastructureDefinitions: <+input> * execution: * steps: * - step: * name: Rollout Deployment * identifier: rolloutDeployment * type: K8sRollingDeploy * timeout: 10m * spec: * skipDryRun: false * pruningEnabled: false * rollbackSteps: * - step: * name: Rollback Rollout Deployment * identifier: rollbackRolloutDeployment * type: K8sRollingRollback * timeout: 10m * spec: * pruningEnabled: false * tags: {} * failureStrategies: * - onFailure: * errors: * - AllErrors * action: * type: StageRollback * * EOT * } * * ## Inline Pipeline template * * resource "harness.platform.Template" "pipelineTemplateInline" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: Pipeline * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * stages: * - stage: * identifier: dvvdvd * name: dvvdvd * description: "" * type: Deployment * spec: * deploymentType: Kubernetes * service: * serviceRef: <+input> * serviceInputs: <+input> * environment: * environmentRef: <+input> * deployToAll: false * environmentInputs: <+input> * serviceOverrideInputs: <+input> * infrastructureDefinitions: <+input> * execution: * steps: * - step: * name: Rollout Deployment * identifier: rolloutDeployment * type: K8sRollingDeploy * timeout: 10m * spec: * skipDryRun: false * pruningEnabled: false * rollbackSteps: * - step: * name: Rollback Rollout Deployment * identifier: rollbackRolloutDeployment * type: K8sRollingRollback * timeout: 10m * spec: * pruningEnabled: false * tags: {} * failureStrategies: * - onFailure: * errors: * - AllErrors * action: * type: StageRollback * * EOT * } * * ## Inline Step template * * resource "harness.platform.Template" "stepTemplateInline" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: Step * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * timeout: 10m * type: ShellScript * spec: * shell: Bash * onDelegate: true * source: * type: Inline * spec: * script: <+input> * environmentVariables: [] * outputVariables: [] * * EOT * } * * ## Remote Step template * * resource "harness.platform.Template" "stepTemplateRemote" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * gitDetails { * branchName = "main" * commitMessage = "Commit" * filePath = "filePath" * connectorRef = "account.connector_ref" * storeType = "REMOTE" * repoName = "repoName" * } * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: Step * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * timeout: 10m * type: ShellScript * spec: * shell: Bash * onDelegate: true * source: * type: Inline * spec: * script: <+input> * environmentVariables: [] * outputVariables: [] * * EOT * } * * ## Remote Step template to create new branch from existing branch * * resource "harness.platform.Template" "stepTemplateRemote" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * gitDetails { * branchName = "newBranch" * commitMessage = "Commit" * filePath = "filePath" * connectorRef = "account.connector_ref" * storeType = "REMOTE" * repoName = "repoName" * baseBranch = "main" * } * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: Step * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * timeout: 10m * type: ShellScript * spec: * shell: Bash * onDelegate: true * source: * type: Inline * spec: * script: <+input> * environmentVariables: [] * outputVariables: [] * * EOT * } * * ## Inline Stage template * * resource "harness.platform.Template" "stageTemplateInline" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: Stage * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * type: Deployment * spec: * deploymentType: Kubernetes * service: * serviceRef: <+input> * serviceInputs: <+input> * environment: * environmentRef: <+input> * deployToAll: false * environmentInputs: <+input> * infrastructureDefinitions: <+input> * execution: * steps: * - step: * type: ShellScript * name: Shell Script_1 * identifier: ShellScript_1 * spec: * shell: Bash * onDelegate: true * source: * type: Inline * spec: * script: <+input> * environmentVariables: [] * outputVariables: [] * timeout: <+input> * rollbackSteps: [] * failureStrategies: * - onFailure: * errors: * - AllErrors * action: * type: StageRollback * * EOT * } * * ## Remote Stage template * * resource "harness.platform.Template" "stageTemplateRemote" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * gitDetails { * branchName = "main" * commitMessage = "Commit" * filePath = "filePath" * connectorRef = "account.connector_ref" * storeType = "REMOTE" * repoName = "repoName" * } * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: Stage * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * type: Deployment * spec: * deploymentType: Kubernetes * service: * serviceRef: <+input> * serviceInputs: <+input> * environment: * environmentRef: <+input> * deployToAll: false * environmentInputs: <+input> * infrastructureDefinitions: <+input> * execution: * steps: * - step: * type: ShellScript * name: Shell Script_1 * identifier: ShellScript_1 * spec: * shell: Bash * onDelegate: true * source: * type: Inline * spec: * script: <+input> * environmentVariables: [] * outputVariables: [] * timeout: <+input> * rollbackSteps: [] * failureStrategies: * - onFailure: * errors: * - AllErrors * action: * type: StageRollback * * EOT * } * * ## Remote Stage template to create new branch from existing branch * * resource "harness.platform.Template" "stageTemplateRemote" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * gitDetails { * branchName = "newBranch" * commitMessage = "Commit" * filePath = "filePath" * connectorRef = "account.connector_ref" * storeType = "REMOTE" * repoName = "repoName" * baseBranch = "main" * } * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: Stage * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * type: Deployment * spec: * deploymentType: Kubernetes * service: * serviceRef: <+input> * serviceInputs: <+input> * environment: * environmentRef: <+input> * deployToAll: false * environmentInputs: <+input> * infrastructureDefinitions: <+input> * execution: * steps: * - step: * type: ShellScript * name: Shell Script_1 * identifier: ShellScript_1 * spec: * shell: Bash * onDelegate: true * source: * type: Inline * spec: * script: <+input> * environmentVariables: [] * outputVariables: [] * timeout: <+input> * rollbackSteps: [] * failureStrategies: * - onFailure: * errors: * - AllErrors * action: * type: StageRollback * * EOT * } * * ## Inline StepGroup template * * resource "harness.platform.Template" "stepgroupTemplateInline" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: StepGroup * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * stageType: Deployment * steps: * - step: * type: ShellScript * name: Shell Script_1 * identifier: ShellScript_1 * spec: * shell: Bash * onDelegate: true * source: * type: Inline * spec: * script: <+input> * environmentVariables: [] * outputVariables: [] * timeout: 10m * * EOT * } * * ## Remote StepGroup template * * resource "harness.platform.Template" "stepgroupTemplateRemote" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * gitDetails { * branchName = "main" * commitMessage = "Commit" * filePath = "filePath" * connectorRef = "account.connector_ref" * storeType = "REMOTE" * repoName = "repoName" * } * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: StepGroup * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * stageType: Deployment * steps: * - step: * type: ShellScript * name: Shell Script_1 * identifier: ShellScript_1 * spec: * shell: Bash * onDelegate: true * source: * type: Inline * spec: * script: <+input> * environmentVariables: [] * outputVariables: [] * timeout: 10m * * EOT * } * * ## Remote StepGroup template to create new branch from existing branch * * resource "harness.platform.Template" "stepgroupTemplateRemote" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * gitDetails { * branchName = "newBranch" * commitMessage = "Commit" * filePath = "filePath" * connectorRef = "account.connector_ref" * storeType = "REMOTE" * repoName = "repoName" * baseBranch = "main" * } * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: StepGroup * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * stageType: Deployment * steps: * - step: * type: ShellScript * name: Shell Script_1 * identifier: ShellScript_1 * spec: * shell: Bash * onDelegate: true * source: * type: Inline * spec: * script: <+input> * environmentVariables: [] * outputVariables: [] * timeout: 10m * * EOT * } * * ## Inline Monitered Service template * * resource "harness.platform.Template" "moniteredServiceTemplateInline" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: MonitoredService * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * serviceRef: <+input> * environmentRef: <+input> * type: Application * sources: * changeSources: * - name: Harness CD Next Gen * identifier: harnessCdNextGen * type: HarnessCDNextGen * enabled: true * category: Deployment * spec: {} * healthSources: * - name: health * identifier: health * type: AppDynamics * spec: * applicationName: <+input> * tierName: <+input> * metricData: * Errors: true * Performance: true * metricDefinitions: [] * feature: Application Monitoring * connectorRef: <+input> * metricPacks: * - identifier: Errors * - identifier: Performance * * EOT * } * * ## Artifact Source template * * resource "harness.platform.Template" "artifactSourceTemplate" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: ArtifactSource * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * type: DockerRegistry * spec: * imagePath: library/nginx * tag: <+input> * connectorRef: account.Harness_DockerHub * * EOT * } * * ## Deployment template * * resource "harness.platform.Template" "deploymentTemplate" { * identifier = "identifier" * orgId = harness_platform_project.test.org_id * projectId = harness_platform_project.test.id * name = "name" * comments = "comments" * version = "ab" * isStable = true * templateYaml = <<-EOT * template: * name: "name" * identifier: "identifier" * versionLabel: "ab" * type: CustomDeployment * projectIdentifier: ${harness_platform_project.test.id} * orgIdentifier: ${harness_platform_project.test.org_id} * tags: {} * spec: * infrastructure: * variables: * - name: kubeConnector * type: Connector * value: <+input> * description: "" * fetchInstancesScript: * store: * type: Inline * spec: * content: | * # * # Script is expected to query Infrastructure and dump json * # in $INSTANCE_OUTPUT_PATH file path * # * # Harness is expected to initialize ${INSTANCE_OUTPUT_PATH} * # environment variable - a random unique file path on delegate, * # so script execution can save the result. * # * /opt/harness-delegate/client-tools/kubectl/v1.19.2/kubectl get pods --namespace=harness-delegate-ng -o json > $INSTANCE_OUTPUT_PATH * instanceAttributes: * - name: instancename * jsonPath: metadata.name * description: "" * instancesListPath: items * execution: * stepTemplateRefs: [] * * EOT * } * * ## Import * * Import account level template * * ```sh * $ pulumi import harness:platform/template:Template example <template_id> * ``` * * Import org level template * * ```sh * $ pulumi import harness:platform/template:Template example <ord_id>/<template_id> * ``` * * Import project level template * * ```sh * $ pulumi import harness:platform/template:Template example <org_id>/<project_id>/<template_id> * ``` */ export declare class Template extends pulumi.CustomResource { /** * Get an existing Template resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input<pulumi.ID>, state?: TemplateState, opts?: pulumi.CustomResourceOptions): Template; /** * Returns true if the given object is an instance of Template. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is Template; /** * Specify comment with respect to changes. */ readonly comments: pulumi.Output<string | undefined>; /** * Description of the entity. Description field is deprecated * * @deprecated description field is deprecated */ readonly description: pulumi.Output<string | undefined>; /** * Enable this flag for force deletion of template */ readonly forceDelete: pulumi.Output<string>; /** * Contains parameters related to creating an Entity for Git Experience. */ readonly gitDetails: pulumi.Output<outputs.platform.TemplateGitDetails>; /** * Unique identifier of the resource */ readonly identifier: pulumi.Output<string>; /** * True if given version for template to be set as stable. */ readonly isStable: pulumi.Output<boolean | undefined>; /** * Name of the Variable */ readonly name: pulumi.Output<string>; /** * Organization Identifier for the Entity */ readonly orgId: pulumi.Output<string | undefined>; /** * Project Identifier for the Entity */ readonly projectId: pulumi.Output<string | undefined>; /** * Tags to associate with the resource. */ readonly tags: pulumi.Output<string[] | undefined>; /** * Yaml for creating new Template. In YAML, to reference an entity at the organization scope, prefix 'org' to the expression: org.{identifier}. To reference an entity at the account scope, prefix 'account` to the expression: account.{identifier}. For eg, to reference a connector with identifier 'connectorId' at the organization scope in a stage mention it as connectorRef: org.connectorId. */ readonly templateYaml: pulumi.Output<string>; /** * Version Label for Template. */ readonly version: pulumi.Output<string>; /** * Create a Template resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: TemplateArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Template resources. */ export interface TemplateState { /** * Specify comment with respect to changes. */ comments?: pulumi.Input<string>; /** * Description of the entity. Description field is deprecated * * @deprecated description field is deprecated */ description?: pulumi.Input<string>; /** * Enable this flag for force deletion of template */ forceDelete?: pulumi.Input<string>; /** * Contains parameters related to creating an Entity for Git Experience. */ gitDetails?: pulumi.Input<inputs.platform.TemplateGitDetails>; /** * Unique identifier of the resource */ identifier?: pulumi.Input<string>; /** * True if given version for template to be set as stable. */ isStable?: pulumi.Input<boolean>; /** * Name of the Variable */ name?: pulumi.Input<string>; /** * Organization Identifier for the Entity */ orgId?: pulumi.Input<string>; /** * Project Identifier for the Entity */ projectId?: pulumi.Input<string>; /** * Tags to associate with the resource. */ tags?: pulumi.Input<pulumi.Input<string>[]>; /** * Yaml for creating new Template. In YAML, to reference an entity at the organization scope, prefix 'org' to the expression: org.{identifier}. To reference an entity at the account scope, prefix 'account` to the expression: account.{identifier}. For eg, to reference a connector with identifier 'connectorId' at the organization scope in a stage mention it as connectorRef: org.connectorId. */ templateYaml?: pulumi.Input<string>; /** * Version Label for Template. */ version?: pulumi.Input<string>; } /** * The set of arguments for constructing a Template resource. */ export interface TemplateArgs { /** * Specify comment with respect to changes. */ comments?: pulumi.Input<string>; /** * Description of the entity. Description field is deprecated * * @deprecated description field is deprecated */ description?: pulumi.Input<string>; /** * Enable this flag for force deletion of template */ forceDelete?: pulumi.Input<string>; /** * Contains parameters related to creating an Entity for Git Experience. */ gitDetails?: pulumi.Input<inputs.platform.TemplateGitDetails>; /** * Unique identifier of the resource */ identifier: pulumi.Input<string>; /** * True if given version for template to be set as stable. */ isStable?: pulumi.Input<boolean>; /** * Name of the Variable */ name?: pulumi.Input<string>; /** * Organization Identifier for the Entity */ orgId?: pulumi.Input<string>; /** * Project Identifier for the Entity */ projectId?: pulumi.Input<string>; /** * Tags to associate with the resource. */ tags?: pulumi.Input<pulumi.Input<string>[]>; /** * Yaml for creating new Template. In YAML, to reference an entity at the organization scope, prefix 'org' to the expression: org.{identifier}. To reference an entity at the account scope, prefix 'account` to the expression: account.{identifier}. For eg, to reference a connector with identifier 'connectorId' at the organization scope in a stage mention it as connectorRef: org.connectorId. */ templateYaml: pulumi.Input<string>; /** * Version Label for Template. */ version: pulumi.Input<string>; }