@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
232 lines • 8.54 kB
JavaScript
// *** 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, { ...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?.actions;
resourceInputs["description"] = state?.description;
resourceInputs["experimentOptions"] = state?.experimentOptions;
resourceInputs["experimentReportConfiguration"] = state?.experimentReportConfiguration;
resourceInputs["logConfiguration"] = state?.logConfiguration;
resourceInputs["region"] = state?.region;
resourceInputs["roleArn"] = state?.roleArn;
resourceInputs["stopConditions"] = state?.stopConditions;
resourceInputs["tags"] = state?.tags;
resourceInputs["tagsAll"] = state?.tagsAll;
resourceInputs["targets"] = state?.targets;
}
else {
const args = argsOrState;
if (args?.actions === undefined && !opts.urn) {
throw new Error("Missing required property 'actions'");
}
if (args?.description === undefined && !opts.urn) {
throw new Error("Missing required property 'description'");
}
if (args?.roleArn === undefined && !opts.urn) {
throw new Error("Missing required property 'roleArn'");
}
if (args?.stopConditions === undefined && !opts.urn) {
throw new Error("Missing required property 'stopConditions'");
}
resourceInputs["actions"] = args?.actions;
resourceInputs["description"] = args?.description;
resourceInputs["experimentOptions"] = args?.experimentOptions;
resourceInputs["experimentReportConfiguration"] = args?.experimentReportConfiguration;
resourceInputs["logConfiguration"] = args?.logConfiguration;
resourceInputs["region"] = args?.region;
resourceInputs["roleArn"] = args?.roleArn;
resourceInputs["stopConditions"] = args?.stopConditions;
resourceInputs["tags"] = args?.tags;
resourceInputs["targets"] = args?.targets;
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
;