ExperimentTemplate class

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 for more information.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.fis.ExperimentTemplate("example", {
    actions: [{
        target: {
            key: "Instances",
            value: "example-target",
        },
        name: "example-action",
        actionId: "aws:ec2:terminate-instances",
    }],
    stopConditions: [{
        source: "none",
    }],
    targets: [{
        resourceTags: [{
            key: "env",
            value: "example",
        }],
        name: "example-target",
        resourceType: "aws:ec2:instance",
        selectionMode: "COUNT(1)",
    }],
    description: "example",
    roleArn: exampleAwsIamRole.arn,
});
import pulumi
import pulumi_aws as aws

example = aws.fis.ExperimentTemplate("example",
    actions=[{
        "target": {
            "key": "Instances",
            "value": "example-target",
        },
        "name": "example-action",
        "action_id": "aws:ec2:terminate-instances",
    }],
    stop_conditions=[{
        "source": "none",
    }],
    targets=[{
        "resource_tags": [{
            "key": "env",
            "value": "example",
        }],
        "name": "example-target",
        "resource_type": "aws:ec2:instance",
        "selection_mode": "COUNT(1)",
    }],
    description="example",
    role_arn=example_aws_iam_role["arn"])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.Fis.ExperimentTemplate("example", new()
    {
        Actions = new[]
        {
            new Aws.Fis.Inputs.ExperimentTemplateActionArgs
            {
                Target = new Aws.Fis.Inputs.ExperimentTemplateActionTargetArgs
                {
                    Key = "Instances",
                    Value = "example-target",
                },
                Name = "example-action",
                ActionId = "aws:ec2:terminate-instances",
            },
        },
        StopConditions = new[]
        {
            new Aws.Fis.Inputs.ExperimentTemplateStopConditionArgs
            {
                Source = "none",
            },
        },
        Targets = new[]
        {
            new Aws.Fis.Inputs.ExperimentTemplateTargetArgs
            {
                ResourceTags = new[]
                {
                    new Aws.Fis.Inputs.ExperimentTemplateTargetResourceTagArgs
                    {
                        Key = "env",
                        Value = "example",
                    },
                },
                Name = "example-target",
                ResourceType = "aws:ec2:instance",
                SelectionMode = "COUNT(1)",
            },
        },
        Description = "example",
        RoleArn = exampleAwsIamRole.Arn,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/fis"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := fis.NewExperimentTemplate(ctx, "example", &fis.ExperimentTemplateArgs{
			Actions: fis.ExperimentTemplateActionArray{
				&fis.ExperimentTemplateActionArgs{
					Target: &fis.ExperimentTemplateActionTargetArgs{
						Key:   pulumi.String("Instances"),
						Value: pulumi.String("example-target"),
					},
					Name:     pulumi.String("example-action"),
					ActionId: pulumi.String("aws:ec2:terminate-instances"),
				},
			},
			StopConditions: fis.ExperimentTemplateStopConditionArray{
				&fis.ExperimentTemplateStopConditionArgs{
					Source: pulumi.String("none"),
				},
			},
			Targets: fis.ExperimentTemplateTargetArray{
				&fis.ExperimentTemplateTargetArgs{
					ResourceTags: fis.ExperimentTemplateTargetResourceTagArray{
						&fis.ExperimentTemplateTargetResourceTagArgs{
							Key:   pulumi.String("env"),
							Value: pulumi.String("example"),
						},
					},
					Name:          pulumi.String("example-target"),
					ResourceType:  pulumi.String("aws:ec2:instance"),
					SelectionMode: pulumi.String("COUNT(1)"),
				},
			},
			Description: pulumi.String("example"),
			RoleArn:     pulumi.Any(exampleAwsIamRole.Arn),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_fis_experimenttemplate" "example" {
  actions {
    target = {
      key   = "Instances"
      value = "example-target"
    }
    name      = "example-action"
    action_id = "aws:ec2:terminate-instances"
  }
  stop_conditions {
    source = "none"
  }
  targets {
    resource_tags {
      key   = "env"
      value = "example"
    }
    name           = "example-target"
    resource_type  = "aws:ec2:instance"
    selection_mode = "COUNT(1)"
  }
  description = "example"
  role_arn    = exampleAwsIamRole.arn
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.fis.ExperimentTemplate;
import com.pulumi.aws.fis.ExperimentTemplateArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateActionArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateActionTargetArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateStopConditionArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateTargetArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateTargetResourceTagArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new ExperimentTemplate("example", ExperimentTemplateArgs.builder()
            .actions(ExperimentTemplateActionArgs.builder()
                .target(ExperimentTemplateActionTargetArgs.builder()
                    .key("Instances")
                    .value("example-target")
                    .build())
                .name("example-action")
                .actionId("aws:ec2:terminate-instances")
                .build())
            .stopConditions(ExperimentTemplateStopConditionArgs.builder()
                .source("none")
                .build())
            .targets(ExperimentTemplateTargetArgs.builder()
                .resourceTags(ExperimentTemplateTargetResourceTagArgs.builder()
                    .key("env")
                    .value("example")
                    .build())
                .name("example-target")
                .resourceType("aws:ec2:instance")
                .selectionMode("COUNT(1)")
                .build())
            .description("example")
            .roleArn(exampleAwsIamRole.arn())
            .build());

    }
}
resources:
  example:
    type: aws:fis:ExperimentTemplate
    properties:
      actions:
        - target:
            key: Instances
            value: example-target
          name: example-action
          actionId: aws:ec2:terminate-instances
      stopConditions:
        - source: none
      targets:
        - resourceTags:
            - key: env
              value: example
          name: example-target
          resourceType: aws:ec2:instance
          selectionMode: COUNT(1)
      description: example
      roleArn: ${exampleAwsIamRole.arn}

Example Usage with Report Configuration

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({
    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: ["*"],
        },
    ],
    version: "2012-10-17",
});
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", {
    experimentReportConfiguration: {
        dataSources: {
            cloudwatchDashboards: [{
                dashboardArn: exampleAwsCloudwatchDashboard.dashboardArn,
            }],
        },
        outputs: {
            s3Configuration: {
                bucketName: exampleAwsS3Bucket.bucket,
                prefix: "fis-example-reports",
            },
        },
        postExperimentDuration: "PT10M",
        preExperimentDuration: "PT10M",
    },
    actions: [{
        target: {
            key: "Instances",
            value: "example-target",
        },
        name: "example-action",
        actionId: "aws:ec2:terminate-instances",
    }],
    stopConditions: [{
        source: "none",
    }],
    targets: [{
        resourceTags: [{
            key: "env",
            value: "example",
        }],
        name: "example-target",
        resourceType: "aws:ec2:instance",
        selectionMode: "COUNT(1)",
    }],
    description: "example",
    roleArn: example.arn,
    tags: {
        Name: "example",
    },
});
import pulumi
import json
import pulumi_aws as aws

current = aws.get_partition()
example = aws.iam.Role("example",
    name="example",
    assume_role_policy=json.dumps({
        "Statement": [{
            "Action": "sts:AssumeRole",
            "Effect": "Allow",
            "Principal": {
                "Service": [f"fis.{current.dns_suffix}"],
            },
        }],
        "Version": "2012-10-17",
    }))
report_access = aws.iam.get_policy_document(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": ["*"],
        },
    ],
    version="2012-10-17")
report_access_policy = aws.iam.Policy("report_access",
    name="report_access",
    policy=report_access.json)
report_access_role_policy_attachment = aws.iam.RolePolicyAttachment("report_access",
    role=test["name"],
    policy_arn=report_access_policy.arn)
example_experiment_template = aws.fis.ExperimentTemplate("example",
    experiment_report_configuration={
        "data_sources": {
            "cloudwatch_dashboards": [{
                "dashboard_arn": example_aws_cloudwatch_dashboard["dashboardArn"],
            }],
        },
        "outputs": {
            "s3_configuration": {
                "bucket_name": example_aws_s3_bucket["bucket"],
                "prefix": "fis-example-reports",
            },
        },
        "post_experiment_duration": "PT10M",
        "pre_experiment_duration": "PT10M",
    },
    actions=[{
        "target": {
            "key": "Instances",
            "value": "example-target",
        },
        "name": "example-action",
        "action_id": "aws:ec2:terminate-instances",
    }],
    stop_conditions=[{
        "source": "none",
    }],
    targets=[{
        "resource_tags": [{
            "key": "env",
            "value": "example",
        }],
        "name": "example-target",
        "resource_type": "aws:ec2:instance",
        "selection_mode": "COUNT(1)",
    }],
    description="example",
    role_arn=example.arn,
    tags={
        "Name": "example",
    })
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var current = Aws.GetPartition.Invoke();

    var example = new Aws.Iam.Role("example", new()
    {
        Name = "example",
        AssumeRolePolicy = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["Statement"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["Action"] = "sts:AssumeRole",
                    ["Effect"] = "Allow",
                    ["Principal"] = new Dictionary<string, object?>
                    {
                        ["Service"] = new[]
                        {
                            $"fis.{current.Apply(getPartitionResult => getPartitionResult.DnsSuffix)}",
                        },
                    },
                },
            },
            ["Version"] = "2012-10-17",
        }),
    });

    var reportAccess = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Sid = "logsDelivery",
                Effect = "Allow",
                Actions = new[]
                {
                    "logs:CreateLogDelivery",
                },
                Resources = new[]
                {
                    "*",
                },
            },
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Sid = "ReportsBucket",
                Effect = "Allow",
                Actions = new[]
                {
                    "s3:PutObject",
                    "s3:GetObject",
                },
                Resources = new[]
                {
                    "*",
                },
            },
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Sid = "GetDashboard",
                Effect = "Allow",
                Actions = new[]
                {
                    "cloudwatch:GetDashboard",
                },
                Resources = new[]
                {
                    "*",
                },
            },
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Sid = "GetDashboardData",
                Effect = "Allow",
                Actions = new[]
                {
                    "cloudwatch:getMetricWidgetImage",
                },
                Resources = new[]
                {
                    "*",
                },
            },
        },
        Version = "2012-10-17",
    });

    var reportAccessPolicy = new Aws.Iam.Policy("report_access", new()
    {
        Name = "report_access",
        PolicyDocument = reportAccess.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

    var reportAccessRolePolicyAttachment = new Aws.Iam.RolePolicyAttachment("report_access", new()
    {
        Role = test.Name,
        PolicyArn = reportAccessPolicy.Arn,
    });

    var exampleExperimentTemplate = new Aws.Fis.ExperimentTemplate("example", new()
    {
        ExperimentReportConfiguration = new Aws.Fis.Inputs.ExperimentTemplateExperimentReportConfigurationArgs
        {
            DataSources = new Aws.Fis.Inputs.ExperimentTemplateExperimentReportConfigurationDataSourcesArgs
            {
                CloudwatchDashboards = new[]
                {
                    new Aws.Fis.Inputs.ExperimentTemplateExperimentReportConfigurationDataSourcesCloudwatchDashboardArgs
                    {
                        DashboardArn = exampleAwsCloudwatchDashboard.DashboardArn,
                    },
                },
            },
            Outputs = new Aws.Fis.Inputs.ExperimentTemplateExperimentReportConfigurationOutputsArgs
            {
                S3Configuration = new Aws.Fis.Inputs.ExperimentTemplateExperimentReportConfigurationOutputsS3ConfigurationArgs
                {
                    BucketName = exampleAwsS3Bucket.Bucket,
                    Prefix = "fis-example-reports",
                },
            },
            PostExperimentDuration = "PT10M",
            PreExperimentDuration = "PT10M",
        },
        Actions = new[]
        {
            new Aws.Fis.Inputs.ExperimentTemplateActionArgs
            {
                Target = new Aws.Fis.Inputs.ExperimentTemplateActionTargetArgs
                {
                    Key = "Instances",
                    Value = "example-target",
                },
                Name = "example-action",
                ActionId = "aws:ec2:terminate-instances",
            },
        },
        StopConditions = new[]
        {
            new Aws.Fis.Inputs.ExperimentTemplateStopConditionArgs
            {
                Source = "none",
            },
        },
        Targets = new[]
        {
            new Aws.Fis.Inputs.ExperimentTemplateTargetArgs
            {
                ResourceTags = new[]
                {
                    new Aws.Fis.Inputs.ExperimentTemplateTargetResourceTagArgs
                    {
                        Key = "env",
                        Value = "example",
                    },
                },
                Name = "example-target",
                ResourceType = "aws:ec2:instance",
                SelectionMode = "COUNT(1)",
            },
        },
        Description = "example",
        RoleArn = example.Arn,
        Tags =
        {
            { "Name", "example" },
        },
    });

});
package main

import (
	"encoding/json"
	"fmt"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/fis"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		current, err := aws.GetPartition(ctx, &aws.GetPartitionArgs{}, nil)
		if err != nil {
			return err
		}
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"Statement": []map[string]interface{}{
				map[string]interface{}{
					"Action": "sts:AssumeRole",
					"Effect": "Allow",
					"Principal": map[string][]string{
						"Service": []string{
							fmt.Sprintf("fis.%v", current.DnsSuffix),
						},
					},
				},
			},
			"Version": "2012-10-17",
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		example, err := iam.NewRole(ctx, "example", &iam.RoleArgs{
			Name:             pulumi.String("example"),
			AssumeRolePolicy: json0,
		})
		if err != nil {
			return err
		}
		reportAccess, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Sid:    pulumi.StringRef("logsDelivery"),
					Effect: pulumi.StringRef("Allow"),
					Actions: []string{
						"logs:CreateLogDelivery",
					},
					Resources: []string{
						"*",
					},
				},
				{
					Sid:    pulumi.StringRef("ReportsBucket"),
					Effect: pulumi.StringRef("Allow"),
					Actions: []string{
						"s3:PutObject",
						"s3:GetObject",
					},
					Resources: []string{
						"*",
					},
				},
				{
					Sid:    pulumi.StringRef("GetDashboard"),
					Effect: pulumi.StringRef("Allow"),
					Actions: []string{
						"cloudwatch:GetDashboard",
					},
					Resources: []string{
						"*",
					},
				},
				{
					Sid:    pulumi.StringRef("GetDashboardData"),
					Effect: pulumi.StringRef("Allow"),
					Actions: []string{
						"cloudwatch:getMetricWidgetImage",
					},
					Resources: []string{
						"*",
					},
				},
			},
			Version: pulumi.StringRef("2012-10-17"),
		}, nil)
		if err != nil {
			return err
		}
		reportAccessPolicy, err := iam.NewPolicy(ctx, "report_access", &iam.PolicyArgs{
			Name:   pulumi.String("report_access"),
			Policy: pulumi.String(reportAccess.Json),
		})
		if err != nil {
			return err
		}
		_, err = iam.NewRolePolicyAttachment(ctx, "report_access", &iam.RolePolicyAttachmentArgs{
			Role:      pulumi.Any(test.Name),
			PolicyArn: reportAccessPolicy.Arn,
		})
		if err != nil {
			return err
		}
		_, err = fis.NewExperimentTemplate(ctx, "example", &fis.ExperimentTemplateArgs{
			ExperimentReportConfiguration: &fis.ExperimentTemplateExperimentReportConfigurationArgs{
				DataSources: &fis.ExperimentTemplateExperimentReportConfigurationDataSourcesArgs{
					CloudwatchDashboards: fis.ExperimentTemplateExperimentReportConfigurationDataSourcesCloudwatchDashboardArray{
						&fis.ExperimentTemplateExperimentReportConfigurationDataSourcesCloudwatchDashboardArgs{
							DashboardArn: pulumi.Any(exampleAwsCloudwatchDashboard.DashboardArn),
						},
					},
				},
				Outputs: &fis.ExperimentTemplateExperimentReportConfigurationOutputsArgs{
					S3Configuration: &fis.ExperimentTemplateExperimentReportConfigurationOutputsS3ConfigurationArgs{
						BucketName: pulumi.Any(exampleAwsS3Bucket.Bucket),
						Prefix:     pulumi.String("fis-example-reports"),
					},
				},
				PostExperimentDuration: pulumi.String("PT10M"),
				PreExperimentDuration:  pulumi.String("PT10M"),
			},
			Actions: fis.ExperimentTemplateActionArray{
				&fis.ExperimentTemplateActionArgs{
					Target: &fis.ExperimentTemplateActionTargetArgs{
						Key:   pulumi.String("Instances"),
						Value: pulumi.String("example-target"),
					},
					Name:     pulumi.String("example-action"),
					ActionId: pulumi.String("aws:ec2:terminate-instances"),
				},
			},
			StopConditions: fis.ExperimentTemplateStopConditionArray{
				&fis.ExperimentTemplateStopConditionArgs{
					Source: pulumi.String("none"),
				},
			},
			Targets: fis.ExperimentTemplateTargetArray{
				&fis.ExperimentTemplateTargetArgs{
					ResourceTags: fis.ExperimentTemplateTargetResourceTagArray{
						&fis.ExperimentTemplateTargetResourceTagArgs{
							Key:   pulumi.String("env"),
							Value: pulumi.String("example"),
						},
					},
					Name:          pulumi.String("example-target"),
					ResourceType:  pulumi.String("aws:ec2:instance"),
					SelectionMode: pulumi.String("COUNT(1)"),
				},
			},
			Description: pulumi.String("example"),
			RoleArn:     example.Arn,
			Tags: pulumi.StringMap{
				"Name": pulumi.String("example"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_getpartition" "current" {
}
data "aws_iam_getpolicydocument" "reportAccess" {
  statements {
    sid       = "logsDelivery"
    effect    = "Allow"
    actions   = ["logs:CreateLogDelivery"]
    resources = ["*"]
  }
  statements {
    sid       = "ReportsBucket"
    effect    = "Allow"
    actions   = ["s3:PutObject", "s3:GetObject"]
    resources = ["*"]
  }
  statements {
    sid       = "GetDashboard"
    effect    = "Allow"
    actions   = ["cloudwatch:GetDashboard"]
    resources = ["*"]
  }
  statements {
    sid       = "GetDashboardData"
    effect    = "Allow"
    actions   = ["cloudwatch:getMetricWidgetImage"]
    resources = ["*"]
  }
  version = "2012-10-17"
}

resource "aws_iam_role" "example" {
  name = "example"
  assume_role_policy = jsonencode({
    "Statement" = [{
      "Action" = "sts:AssumeRole"
      "Effect" = "Allow"
      "Principal" = {
        "Service" = ["fis.${data.aws_getpartition.current.dns_suffix}"]
      }
    }]
    "Version" = "2012-10-17"
  })
}
resource "aws_iam_policy" "report_access" {
  name   = "report_access"
  policy = data.aws_iam_getpolicydocument.reportAccess.json
}
resource "aws_iam_rolepolicyattachment" "report_access" {
  role       = test.name
  policy_arn = aws_iam_policy.report_access.arn
}
resource "aws_fis_experimenttemplate" "example" {
  experiment_report_configuration = {
    data_sources = {
      cloudwatch_dashboards = [{
        "dashboardArn" = exampleAwsCloudwatchDashboard.dashboardArn
      }]
    }
    outputs = {
      s3_configuration = {
        bucket_name = exampleAwsS3Bucket.bucket
        prefix      = "fis-example-reports"
      }
    }
    post_experiment_duration = "PT10M"
    pre_experiment_duration  = "PT10M"
  }
  actions {
    target = {
      key   = "Instances"
      value = "example-target"
    }
    name      = "example-action"
    action_id = "aws:ec2:terminate-instances"
  }
  stop_conditions {
    source = "none"
  }
  targets {
    resource_tags {
      key   = "env"
      value = "example"
    }
    name           = "example-target"
    resource_type  = "aws:ec2:instance"
    selection_mode = "COUNT(1)"
  }
  description = "example"
  role_arn    = aws_iam_role.example.arn
  tags = {
    "Name" = "example"
  }
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.AwsFunctions;
import com.pulumi.aws.inputs.GetPartitionArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.Policy;
import com.pulumi.aws.iam.PolicyArgs;
import com.pulumi.aws.iam.RolePolicyAttachment;
import com.pulumi.aws.iam.RolePolicyAttachmentArgs;
import com.pulumi.aws.fis.ExperimentTemplate;
import com.pulumi.aws.fis.ExperimentTemplateArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateExperimentReportConfigurationArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateExperimentReportConfigurationDataSourcesArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateExperimentReportConfigurationDataSourcesCloudwatchDashboardArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateExperimentReportConfigurationOutputsArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateExperimentReportConfigurationOutputsS3ConfigurationArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateActionArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateActionTargetArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateStopConditionArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateTargetArgs;
import com.pulumi.aws.fis.inputs.ExperimentTemplateTargetResourceTagArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var current = AwsFunctions.getPartition(GetPartitionArgs.builder()
            .build());

        var example = new Role("example", RoleArgs.builder()
            .name("example")
            .assumeRolePolicy(serializeJson(
                jsonObject(
                    jsonProperty("Statement", jsonArray(jsonObject(
                        jsonProperty("Action", "sts:AssumeRole"),
                        jsonProperty("Effect", "Allow"),
                        jsonProperty("Principal", jsonObject(
                            jsonProperty("Service", jsonArray(String.format("fis.%s", current.dnsSuffix())))
                        ))
                    ))),
                    jsonProperty("Version", "2012-10-17")
                )))
            .build());

        final var reportAccess = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(
                GetPolicyDocumentStatementArgs.builder()
                    .sid("logsDelivery")
                    .effect("Allow")
                    .actions("logs:CreateLogDelivery")
                    .resources("*")
                    .build(),
                GetPolicyDocumentStatementArgs.builder()
                    .sid("ReportsBucket")
                    .effect("Allow")
                    .actions(
                        "s3:PutObject",
                        "s3:GetObject")
                    .resources("*")
                    .build(),
                GetPolicyDocumentStatementArgs.builder()
                    .sid("GetDashboard")
                    .effect("Allow")
                    .actions("cloudwatch:GetDashboard")
                    .resources("*")
                    .build(),
                GetPolicyDocumentStatementArgs.builder()
                    .sid("GetDashboardData")
                    .effect("Allow")
                    .actions("cloudwatch:getMetricWidgetImage")
                    .resources("*")
                    .build())
            .version("2012-10-17")
            .build());

        var reportAccessPolicy = new Policy("reportAccessPolicy", PolicyArgs.builder()
            .name("report_access")
            .policy(reportAccess.json())
            .build());

        var reportAccessRolePolicyAttachment = new RolePolicyAttachment("reportAccessRolePolicyAttachment", RolePolicyAttachmentArgs.builder()
            .role(test.name())
            .policyArn(reportAccessPolicy.arn())
            .build());

        var exampleExperimentTemplate = new ExperimentTemplate("exampleExperimentTemplate", ExperimentTemplateArgs.builder()
            .experimentReportConfiguration(ExperimentTemplateExperimentReportConfigurationArgs.builder()
                .dataSources(ExperimentTemplateExperimentReportConfigurationDataSourcesArgs.builder()
                    .cloudwatchDashboards(ExperimentTemplateExperimentReportConfigurationDataSourcesCloudwatchDashboardArgs.builder()
                        .dashboardArn(exampleAwsCloudwatchDashboard.dashboardArn())
                        .build())
                    .build())
                .outputs(ExperimentTemplateExperimentReportConfigurationOutputsArgs.builder()
                    .s3Configuration(ExperimentTemplateExperimentReportConfigurationOutputsS3ConfigurationArgs.builder()
                        .bucketName(exampleAwsS3Bucket.bucket())
                        .prefix("fis-example-reports")
                        .build())
                    .build())
                .postExperimentDuration("PT10M")
                .preExperimentDuration("PT10M")
                .build())
            .actions(ExperimentTemplateActionArgs.builder()
                .target(ExperimentTemplateActionTargetArgs.builder()
                    .key("Instances")
                    .value("example-target")
                    .build())
                .name("example-action")
                .actionId("aws:ec2:terminate-instances")
                .build())
            .stopConditions(ExperimentTemplateStopConditionArgs.builder()
                .source("none")
                .build())
            .targets(ExperimentTemplateTargetArgs.builder()
                .resourceTags(ExperimentTemplateTargetResourceTagArgs.builder()
                    .key("env")
                    .value("example")
                    .build())
                .name("example-target")
                .resourceType("aws:ec2:instance")
                .selectionMode("COUNT(1)")
                .build())
            .description("example")
            .roleArn(example.arn())
            .tags(Map.of("Name", "example"))
            .build());

    }
}
resources:
  example:
    type: aws:iam:Role
    properties:
      name: example
      assumeRolePolicy:
        fn::toJSON:
          Statement:
            - Action: sts:AssumeRole
              Effect: Allow
              Principal:
                Service:
                  - fis.${current.dnsSuffix}
          Version: 2012-10-17
  reportAccessPolicy:
    type: aws:iam:Policy
    name: report_access
    properties:
      name: report_access
      policy: ${reportAccess.json}
  reportAccessRolePolicyAttachment:
    type: aws:iam:RolePolicyAttachment
    name: report_access
    properties:
      role: ${test.name}
      policyArn: ${reportAccessPolicy.arn}
  exampleExperimentTemplate:
    type: aws:fis:ExperimentTemplate
    name: example
    properties:
      experimentReportConfiguration:
        dataSources:
          cloudwatchDashboards:
            - dashboardArn: ${exampleAwsCloudwatchDashboard.dashboardArn}
        outputs:
          s3Configuration:
            bucketName: ${exampleAwsS3Bucket.bucket}
            prefix: fis-example-reports
        postExperimentDuration: PT10M
        preExperimentDuration: PT10M
      actions:
        - target:
            key: Instances
            value: example-target
          name: example-action
          actionId: aws:ec2:terminate-instances
      stopConditions:
        - source: none
      targets:
        - resourceTags:
            - key: env
              value: example
          name: example-target
          resourceType: aws:ec2:instance
          selectionMode: COUNT(1)
      description: example
      roleArn: ${example.arn}
      tags:
        Name: example
variables:
  current:
    fn::invoke:
      function: aws:getPartition
      arguments: {}
  reportAccess:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        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:
              - '*'
        version: 2012-10-17

Import

Using pulumi import, import FIS Experiment Templates using the id. For example:

$ pulumi import aws:fis/experimentTemplate:ExperimentTemplate template EXT123AbCdEfGhIjK

Constructors

ExperimentTemplate(String name, {ExperimentTemplateArgs? args, CustomResourceOptions? options})
Creates a new ExperimentTemplate. name The Pulumi resource name. args Arguments used to configure this ExperimentTemplate. The set of arguments for ExperimentTemplate. options Resource options controlling this resource's behavior.
ExperimentTemplate.reference(String urn)
Creates a typed reference to an existing ExperimentTemplate resource.

Properties

actions ↔ Output<List<ExperimentTemplateAction>>
Action to be performed during an experiment. See below.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
description ↔ Output<String>
Description for the experiment template.
latefinal
experimentOptions ↔ Output<ExperimentTemplateExperimentOptions>
Experiment options for the experiment template. See experimentOptions below for more details!
latefinal
experimentReportConfiguration ↔ Output<ExperimentTemplateExperimentReportConfiguration?>
Configuration for experiment reporting. See below.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
logConfiguration ↔ Output<ExperimentTemplateLogConfiguration?>
Configuration for experiment logging. See below.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
roleArn ↔ Output<String>
ARN of an IAM role that grants the AWS FIS service permission to perform service actions on your behalf.
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
stopConditions ↔ Output<List<ExperimentTemplateStopCondition>>
When an ongoing experiment should be stopped. See below.
latefinal
tags ↔ Output<Map<String, String>?>
Key-value mapping of tags. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
latefinal
tagsAll ↔ Output<Map<String, String>>
latefinal
targets ↔ Output<List<ExperimentTemplateTarget>?>
Target of an action. See below.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {ExperimentTemplateState? state, CustomResourceOptions? options}) → ExperimentTemplate
Gets an existing ExperimentTemplate resource's state with the given name and id.