AWS::FIS::ExperimentTemplate - Amazon CloudFormation
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

AWS::FIS::ExperimentTemplate

Specifies an experiment template.

An experiment template includes the following components:

  • Targets: A target can be a specific resource in your Amazon environment, or one or more resources that match criteria that you specify, for example, resources that have specific tags.

  • Actions: The actions to carry out on the target. You can specify multiple actions, the duration of each action, and when to start each action during an experiment.

  • Stop conditions: If a stop condition is triggered while an experiment is running, the experiment is automatically stopped. You can define a stop condition as a CloudWatch alarm.

For more information, see Experiment templates in the Amazon Fault Injection Service User Guide.

Syntax

To declare this entity in your Amazon CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::FIS::ExperimentTemplate", "Properties" : { "Actions" : {Key: Value, ...}, "Description" : String, "ExperimentOptions" : ExperimentTemplateExperimentOptions, "LogConfiguration" : ExperimentTemplateLogConfiguration, "RoleArn" : String, "StopConditions" : [ ExperimentTemplateStopCondition, ... ], "Tags" : {Key: Value, ...}, "Targets" : {Key: Value, ...} } }

Properties

Actions

The actions for the experiment.

Required: No

Type: Object of ExperimentTemplateAction

Update requires: No interruption

Description

The description for the experiment template.

Required: Yes

Type: String

Maximum: 512

Update requires: No interruption

ExperimentOptions

The experiment options for an experiment template.

Required: No

Type: ExperimentTemplateExperimentOptions

Update requires: No interruption

LogConfiguration

The configuration for experiment logging.

Required: No

Type: ExperimentTemplateLogConfiguration

Update requires: No interruption

RoleArn

The Amazon Resource Name (ARN) of an IAM role.

Required: Yes

Type: String

Maximum: 1224

Update requires: No interruption

StopConditions

The stop conditions for the experiment.

Required: Yes

Type: Array of ExperimentTemplateStopCondition

Update requires: No interruption

Tags

The tags for the experiment template.

Required: Yes

Type: Object of String

Pattern: .{1,128}

Maximum: 256

Update requires: Replacement

Targets

The targets for the experiment.

Required: Yes

Type: Object of ExperimentTemplateTarget

Update requires: No interruption

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the experiment template ID.

For more information about using the Ref function, see Ref.

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

Examples

The following example creates an experiment template that stops and starts one instance with the tag env=prod, chosen at random.

YAML

Resources: ExperimentTemplate: Type: 'AWS::FIS::ExperimentTemplate' Properties: Description: 'stop an instance based on a tag' Actions: stopInstances: ActionId: 'aws:ec2:stop-instances' Parameters: startInstancesAfterDuration: 'PT2M' Targets: Instances: oneRandomInstance Targets: oneRandomInstance: ResourceTags: 'env': 'prod' ResourceType: 'aws:ec2:instance' SelectionMode: 'COUNT(1)' StopConditions: - Source: 'none' Tags: Name: 'fisStopInstances' RoleArn: !GetAtt FISRole.Arn FISRole: Type: 'AWS::IAM::Role' Properties: AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Principal: Service: 'fis.amazonaws.com' Action: 'sts:AssumeRole' Policies: - PolicyName: 'FISRoleEC2Actions' PolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Action: - 'ec2:RebootInstances' - 'ec2:StopInstances' - 'ec2:StartInstances' - 'ec2:TerminateInstances' Resource: 'arn:aws:ec2:*:*:instance/*'

JSON

{ "Resources": { "ExperimentTemplate": { "Type": "AWS::FIS::ExperimentTemplate", "DeletionPolicy": "Retain", "Properties": { "Description": "stop an instance based on a tag", "Actions": { "stopInstances": { "ActionId": "aws:ec2:stop-instances", "Parameters": { "startInstancesAfterDuration": "PT2M" }, "Targets": { "Instances": "oneRandomInstance" } } }, "Targets": { "oneRandomInstance": { "ResourceTags": { "env": "prod" }, "ResourceType": "aws:ec2:instance", "SelectionMode": "COUNT(1)" } }, "StopConditions": [ { "Source": "none" } ], "Tags": { "Name": "fisStopInstancesJson" }, "RoleArn": { "Fn::GetAtt": ["FISRole", "Arn"] } } }, "FISRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "fis.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }, "Policies": [ { "PolicyName": "FISRoleEC2Actions", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:RebootInstances", "ec2:StopInstances", "ec2:StartInstances", "ec2:TerminateInstances" ], "Resource": "arn:aws:ec2:*:*:instance/*" } ] } } ] } } } }