AWS::FIS::ExperimentTemplate
Specifies an experiment template.
An experiment template includes the following components:
-
Targets: A target can be a specific resource in your AWS 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 AWS Fault Injection Simulator User Guide.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::FIS::ExperimentTemplate", "Properties" : { "Actions" :
{
, "Description" :Key
:Value
, ...}String
, "LogConfiguration" :ExperimentTemplateLogConfiguration
, "RoleArn" :String
, "StopConditions" :[ ExperimentTemplateStopCondition, ... ]
, "Tags" :{
, "Targets" :Key
:Value
, ...}{
} }Key
:Value
, ...}
YAML
Type: AWS::FIS::ExperimentTemplate Properties: Actions:
Description:
Key
:Value
String
LogConfiguration:ExperimentTemplateLogConfiguration
RoleArn:String
StopConditions:- ExperimentTemplateStopCondition
Tags:Targets:
Key
:Value
Key
:Value
Properties
Actions
-
The actions for the experiment.
Required: No
Type: Map of ExperimentTemplateAction
Update requires: No interruption
Description
-
A description for the experiment template.
Required: Yes
Type: String
Maximum:
512
Pattern:
[\s\S]+
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 that grants the AWS FIS service permission to perform service actions on your behalf.
Required: Yes
Type: String
Minimum:
20
Maximum:
2048
Pattern:
[\S]+
Update requires: No interruption
StopConditions
-
The stop conditions.
Required: Yes
Type: List of ExperimentTemplateStopCondition
Update requires: No interruption
Tags
-
The tags to apply to the experiment template.
Required: Yes
Type: Map of String
Update requires: Replacement
Targets
-
The targets for the experiment.
Required: Yes
Type: Map 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/*" } ] } } ] } } } }