UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

232 lines • 9 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.ExperimentTemplate = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Provides an FIS Experiment Template, which can be used to run an experiment. * An experiment template contains one or more actions to run on specified targets during an experiment. * It also contains the stop conditions that prevent the experiment from going out of bounds. * See [Amazon Fault Injection Simulator](https://docs.aws.amazon.com/fis/index.html) * for more information. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.fis.ExperimentTemplate("example", { * description: "example", * roleArn: exampleAwsIamRole.arn, * stopConditions: [{ * source: "none", * }], * actions: [{ * name: "example-action", * actionId: "aws:ec2:terminate-instances", * target: { * key: "Instances", * value: "example-target", * }, * }], * targets: [{ * name: "example-target", * resourceType: "aws:ec2:instance", * selectionMode: "COUNT(1)", * resourceTags: [{ * key: "env", * value: "example", * }], * }], * }); * ``` * * ### With Report Configuration * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const current = aws.getPartition({}); * const example = new aws.iam.Role("example", { * name: "example", * assumeRolePolicy: JSON.stringify({ * Statement: [{ * Action: "sts:AssumeRole", * Effect: "Allow", * Principal: { * Service: [current.then(current => `fis.${current.dnsSuffix}`)], * }, * }], * Version: "2012-10-17", * }), * }); * const reportAccess = aws.iam.getPolicyDocument({ * version: "2012-10-17", * statements: [ * { * sid: "logsDelivery", * effect: "Allow", * actions: ["logs:CreateLogDelivery"], * resources: ["*"], * }, * { * sid: "ReportsBucket", * effect: "Allow", * actions: [ * "s3:PutObject", * "s3:GetObject", * ], * resources: ["*"], * }, * { * sid: "GetDashboard", * effect: "Allow", * actions: ["cloudwatch:GetDashboard"], * resources: ["*"], * }, * { * sid: "GetDashboardData", * effect: "Allow", * actions: ["cloudwatch:getMetricWidgetImage"], * resources: ["*"], * }, * ], * }); * const reportAccessPolicy = new aws.iam.Policy("report_access", { * name: "report_access", * policy: reportAccess.then(reportAccess => reportAccess.json), * }); * const reportAccessRolePolicyAttachment = new aws.iam.RolePolicyAttachment("report_access", { * role: test.name, * policyArn: reportAccessPolicy.arn, * }); * const exampleExperimentTemplate = new aws.fis.ExperimentTemplate("example", { * description: "example", * roleArn: example.arn, * stopConditions: [{ * source: "none", * }], * actions: [{ * name: "example-action", * actionId: "aws:ec2:terminate-instances", * target: { * key: "Instances", * value: "example-target", * }, * }], * targets: [{ * name: "example-target", * resourceType: "aws:ec2:instance", * selectionMode: "COUNT(1)", * resourceTags: [{ * key: "env", * value: "example", * }], * }], * experimentReportConfiguration: { * dataSources: { * cloudwatchDashboards: [{ * dashboardArn: exampleAwsCloudwatchDashboard.dashboardArn, * }], * }, * outputs: { * s3Configuration: { * bucketName: exampleAwsS3Bucket.bucket, * prefix: "fis-example-reports", * }, * }, * postExperimentDuration: "PT10M", * preExperimentDuration: "PT10M", * }, * tags: { * Name: "example", * }, * }); * ``` * * ## Import * * Using `pulumi import`, import FIS Experiment Templates using the `id`. For example: * * ```sh * $ pulumi import aws:fis/experimentTemplate:ExperimentTemplate template EXT123AbCdEfGhIjK * ``` */ 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, id, state, opts) { return new ExperimentTemplate(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === ExperimentTemplate.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["actions"] = state ? state.actions : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["experimentOptions"] = state ? state.experimentOptions : undefined; resourceInputs["experimentReportConfiguration"] = state ? state.experimentReportConfiguration : undefined; resourceInputs["logConfiguration"] = state ? state.logConfiguration : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["roleArn"] = state ? state.roleArn : undefined; resourceInputs["stopConditions"] = state ? state.stopConditions : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["tagsAll"] = state ? state.tagsAll : undefined; resourceInputs["targets"] = state ? state.targets : undefined; } else { const args = argsOrState; if ((!args || args.actions === undefined) && !opts.urn) { throw new Error("Missing required property 'actions'"); } if ((!args || args.description === undefined) && !opts.urn) { throw new Error("Missing required property 'description'"); } if ((!args || args.roleArn === undefined) && !opts.urn) { throw new Error("Missing required property 'roleArn'"); } if ((!args || args.stopConditions === undefined) && !opts.urn) { throw new Error("Missing required property 'stopConditions'"); } resourceInputs["actions"] = args ? args.actions : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["experimentOptions"] = args ? args.experimentOptions : undefined; resourceInputs["experimentReportConfiguration"] = args ? args.experimentReportConfiguration : undefined; resourceInputs["logConfiguration"] = args ? args.logConfiguration : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["roleArn"] = args ? args.roleArn : undefined; resourceInputs["stopConditions"] = args ? args.stopConditions : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["targets"] = args ? args.targets : undefined; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(ExperimentTemplate.__pulumiType, name, resourceInputs, opts); } } exports.ExperimentTemplate = ExperimentTemplate; /** @internal */ ExperimentTemplate.__pulumiType = 'aws:fis/experimentTemplate:ExperimentTemplate'; //# sourceMappingURL=experimentTemplate.js.map