import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Resource for managing Harness Chaos Experiment Templates. Experiment templates define reusable chaos experiments with actions, faults, and probes. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as harness from "@pulumi/harness"; * * // ============================================================================ * // Harness Chaos Experiment Template Resource Examples * // ============================================================================ * // * // Experiment templates define complete chaos experiments with actions, faults, and probes. * // These examples are based on TESTED configurations from the e2e-test suite. * // * // Key Points: * // - Templates combine actions, faults, and probes into workflows * // - Vertices define execution order (workflow graph) * // - Runtime inputs supported: "<+input>" or "<+input>.default('value')" * // - Enterprise features: is_enterprise = true * // ============================================================================ * // ---------------------------------------------------------------------------- * // Example 1: Simple Fault Template (TESTED ✅) * // ---------------------------------------------------------------------------- * // Basic template with single fault * const simpleFault = new harness.chaos.ExperimentTemplate("simple_fault", { * orgId: _this.id, * projectId: thisHarnessPlatformProject.id, * hubIdentity: projectLevel.identity, * identity: "simple-pod-delete", * name: "Simple Pod Delete Experiment", * description: "Basic experiment with single pod delete fault", * tags: [ * "kubernetes", * "pod-delete", * "simple", * ], * spec: { * infraType: "KubernetesV2", * faults: [{ * identity: "pod-delete", * name: "pod-delete-fault", * revision: "v1", * isEnterprise: true, * authEnabled: false, * values: [ * { * name: "TARGET_WORKLOAD_KIND", * value: "deployment", * }, * { * name: "TARGET_WORKLOAD_NAMESPACE", * value: "<+input>.default('default')", * }, * { * name: "TOTAL_CHAOS_DURATION", * value: "<+input>.default('30s')", * }, * ], * }], * vertices: [{ * name: "pod-delete-vertex", * start: { * faults: [{ * name: "pod-delete-fault", * }], * }, * end: {}, * }], * cleanupPolicy: "delete", * }, * }, { * dependsOn: [projectLevel], * }); * // ---------------------------------------------------------------------------- * // Example 2: Template with Action and Fault (TESTED ✅) * // ---------------------------------------------------------------------------- * // Template combining action and fault * const withAction = new harness.chaos.ExperimentTemplate("with_action", { * orgId: _this.id, * projectId: thisHarnessPlatformProject.id, * hubIdentity: projectLevel.identity, * identity: "action-and-fault", * name: "Action and Fault Experiment", * description: "Experiment with action before fault", * tags: [ * "kubernetes", * "action", * "fault", * ], * spec: { * infraType: "KubernetesV2", * actions: [{ * identity: "notification-action", * name: "pre-chaos-notification", * isEnterprise: false, * continueOnCompletion: false, * values: [{ * name: "MESSAGE", * value: "Starting chaos experiment", * }], * }], * faults: [{ * identity: "container-kill", * name: "container-kill-fault", * revision: "v1", * isEnterprise: true, * authEnabled: false, * values: [ * { * name: "TARGET_WORKLOAD_KIND", * value: "deployment", * }, * { * name: "TARGET_WORKLOAD_NAMESPACE", * value: "<+input>", * }, * { * name: "TOTAL_CHAOS_DURATION", * value: "<+input>.default('30s')", * }, * ], * }], * vertices: [ * { * name: "action-vertex", * start: { * actions: [{ * name: "pre-chaos-notification", * }], * }, * end: {}, * }, * { * name: "fault-vertex", * start: { * faults: [{ * name: "container-kill-fault", * }], * }, * end: {}, * }, * ], * cleanupPolicy: "delete", * }, * }, { * dependsOn: [projectLevel], * }); * // ---------------------------------------------------------------------------- * // Example 3: Complex Template with Probes (TESTED ✅) * // ---------------------------------------------------------------------------- * // Complete template with actions, faults, and probes * const complex = new harness.chaos.ExperimentTemplate("complex", { * orgId: _this.id, * projectId: thisHarnessPlatformProject.id, * hubIdentity: projectLevel.identity, * identity: "complex-experiment", * name: "Complex Chaos Experiment", * description: "Complete experiment with actions, faults, and probes", * tags: [ * "kubernetes", * "complex", * "enterprise", * ], * spec: { * infraType: "KubernetesV2", * actions: [{ * identity: "notification-action", * name: "start-notification", * isEnterprise: false, * continueOnCompletion: false, * values: [{ * name: "MESSAGE", * value: "Chaos experiment started", * }], * }], * faults: [ * { * identity: "pod-delete", * name: "pod-delete-fault", * revision: "v1", * isEnterprise: true, * authEnabled: false, * values: [ * { * name: "TARGET_WORKLOAD_KIND", * value: "deployment", * }, * { * name: "TARGET_WORKLOAD_NAMESPACE", * value: "<+input>", * }, * { * name: "TOTAL_CHAOS_DURATION", * value: "<+input>.default('30s')", * }, * ], * }, * { * identity: "pod-network-latency", * name: "network-latency-fault", * revision: "v1", * isEnterprise: true, * authEnabled: false, * values: [ * { * name: "TARGET_WORKLOAD_KIND", * value: "deployment", * }, * { * name: "TARGET_WORKLOAD_NAMESPACE", * value: "<+input>", * }, * { * name: "NETWORK_LATENCY", * value: "<+input>.default('2000')", * }, * ], * }, * ], * probes: [ * { * identity: "pod-status-check", * name: "pod-status-probe", * revision: Number("v1"), * isEnterprise: true, * duration: "30", * weightage: 10, * enableDataCollection: false, * conditions: [ * "onChaosStart", * "duringChaos", * "afterChaos", * ], * values: [{ * name: "TARGET_NAMESPACE", * value: "<+input>", * }], * }, * { * identity: "http-health-check", * name: "http-health-probe", * revision: Number("v1"), * isEnterprise: true, * duration: "30", * weightage: 10, * enableDataCollection: false, * conditions: [ * "duringChaos", * "afterChaos", * ], * values: [{ * name: "URL", * value: "<+input>", * }], * }, * ], * vertices: [ * { * name: "action-stage", * start: { * actions: [{ * name: "start-notification", * }], * }, * end: {}, * }, * { * name: "fault-stage", * start: { * faults: [ * { * name: "pod-delete-fault", * }, * { * name: "network-latency-fault", * }, * ], * probes: [ * { * name: "pod-status-probe", * }, * { * name: "http-health-probe", * }, * ], * }, * end: {}, * }, * { * name: "cleanup-stage", * start: {}, * end: {}, * }, * ], * cleanupPolicy: "delete", * statusCheckTimeouts: { * delay: 5, * timeout: 300, * }, * }, * }, { * dependsOn: [projectLevel], * }); * ``` * * ## Import * * The `pulumi import` command can be used, for example: * * Example 1: Import Project-level Experiment Template * Format: org_id/project_id/hub_identity/template_identity * * ```sh * $ pulumi import harness:chaos/experimentTemplate:ExperimentTemplate simple_fault my_org/my_project/my-chaos-hub/simple-pod-delete-experiment * ``` * * Example 2: Import Org-level Experiment Template * Format: org_id/hub_identity/template_identity * * ```sh * $ pulumi import harness:chaos/experimentTemplate:ExperimentTemplate org_level my_org/org-chaos-hub/org-experiment-template * ``` * * Example 3: Import Account-level Experiment Template * Format: hub_identity/template_identity * * ```sh * $ pulumi import harness:chaos/experimentTemplate:ExperimentTemplate account_level account-chaos-hub/account-experiment-template * ``` * * Example 4: Import Comprehensive Experiment Template * * ```sh * $ pulumi import harness:chaos/experimentTemplate:ExperimentTemplate comprehensive my_org/my_project/my-chaos-hub/comprehensive-experiment * ``` * * Example 5: Import Multi-Fault Experiment Template * * ```sh * $ pulumi import harness:chaos/experimentTemplate:ExperimentTemplate multi_fault my_org/my_project/my-chaos-hub/multi-fault-experiment * ``` */ export declare class ExperimentTemplate extends pulumi.CustomResource { /** * Get an existing ExperimentTemplate 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, state?: ExperimentTemplateState, opts?: pulumi.CustomResourceOptions): ExperimentTemplate; /** * Returns true if the given object is an instance of ExperimentTemplate. 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 ExperimentTemplate; /** * API version of the experiment template */ readonly apiVersion: pulumi.Output; /** * Description of the experiment template */ readonly description: pulumi.Output; /** * Hub identifier where the template is stored */ readonly hubIdentity: pulumi.Output; /** * Unique identifier for the experiment template */ readonly identity: pulumi.Output; /** * Whether this is a default template */ readonly isDefault: pulumi.Output; /** * Kind of the experiment template */ readonly kind: pulumi.Output; /** * Name of the experiment template */ readonly name: pulumi.Output; /** * Organization identifier */ readonly orgId: pulumi.Output; /** * Project identifier */ readonly projectId: pulumi.Output; /** * Revision of the experiment template */ readonly revision: pulumi.Output; /** * Specification of the experiment template */ readonly spec: pulumi.Output; /** * Tags associated with the experiment template */ readonly tags: pulumi.Output; /** * Create a ExperimentTemplate 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: ExperimentTemplateArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering ExperimentTemplate resources. */ export interface ExperimentTemplateState { /** * API version of the experiment template */ apiVersion?: pulumi.Input; /** * Description of the experiment template */ description?: pulumi.Input; /** * Hub identifier where the template is stored */ hubIdentity?: pulumi.Input; /** * Unique identifier for the experiment template */ identity?: pulumi.Input; /** * Whether this is a default template */ isDefault?: pulumi.Input; /** * Kind of the experiment template */ kind?: pulumi.Input; /** * Name of the experiment template */ name?: pulumi.Input; /** * Organization identifier */ orgId?: pulumi.Input; /** * Project identifier */ projectId?: pulumi.Input; /** * Revision of the experiment template */ revision?: pulumi.Input; /** * Specification of the experiment template */ spec?: pulumi.Input; /** * Tags associated with the experiment template */ tags?: pulumi.Input[] | undefined>; } /** * The set of arguments for constructing a ExperimentTemplate resource. */ export interface ExperimentTemplateArgs { /** * Description of the experiment template */ description?: pulumi.Input; /** * Hub identifier where the template is stored */ hubIdentity: pulumi.Input; /** * Unique identifier for the experiment template */ identity: pulumi.Input; /** * Name of the experiment template */ name?: pulumi.Input; /** * Organization identifier */ orgId?: pulumi.Input; /** * Project identifier */ projectId?: pulumi.Input; /** * Specification of the experiment template */ spec: pulumi.Input; /** * Tags associated with the experiment template */ tags?: pulumi.Input[] | undefined>; } //# sourceMappingURL=experimentTemplate.d.ts.map