1. Packages
  2. AWS Native
  3. API Docs
  4. fis
  5. ExperimentTemplate

AWS Native is in preview. AWS Classic is fully supported.

AWS Native v0.103.0 published on Monday, Apr 22, 2024 by Pulumi

aws-native.fis.ExperimentTemplate

Explore with Pulumi AI

aws-native logo

AWS Native is in preview. AWS Classic is fully supported.

AWS Native v0.103.0 published on Monday, Apr 22, 2024 by Pulumi

    Resource schema for AWS::FIS::ExperimentTemplate

    Example Usage

    Example

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AwsNative = Pulumi.AwsNative;
    
    return await Deployment.RunAsync(() => 
    {
        var fisRole = new AwsNative.Iam.Role("fisRole", new()
        {
            AssumeRolePolicyDocument = new Dictionary<string, object?>
            {
                ["version"] = "2012-10-17",
                ["statement"] = new[]
                {
                    new Dictionary<string, object?>
                    {
                        ["effect"] = "Allow",
                        ["principal"] = new Dictionary<string, object?>
                        {
                            ["service"] = "fis.amazonaws.com",
                        },
                        ["action"] = "sts:AssumeRole",
                    },
                },
            },
            Policies = new[]
            {
                new AwsNative.Iam.Inputs.RolePolicyArgs
                {
                    PolicyName = "FISRoleEC2Actions",
                    PolicyDocument = new Dictionary<string, object?>
                    {
                        ["version"] = "2012-10-17",
                        ["statement"] = new[]
                        {
                            new Dictionary<string, object?>
                            {
                                ["effect"] = "Allow",
                                ["action"] = new[]
                                {
                                    "ec2:RebootInstances",
                                    "ec2:StopInstances",
                                    "ec2:StartInstances",
                                    "ec2:TerminateInstances",
                                },
                                ["resource"] = "arn:aws:ec2:*:*:instance/*",
                            },
                        },
                    },
                },
            },
        });
    
        var experimentTemplate = new AwsNative.Fis.ExperimentTemplate("experimentTemplate", new()
        {
            Description = "stop an instance based on a tag",
            Actions = 
            {
                { "stopInstances", new AwsNative.Fis.Inputs.ExperimentTemplateActionArgs
                {
                    ActionId = "aws:ec2:stop-instances",
                    Parameters = 
                    {
                        { "startInstancesAfterDuration", "PT2M" },
                    },
                    Targets = 
                    {
                        { "instances", "oneRandomInstance" },
                    },
                } },
            },
            Targets = 
            {
                { "oneRandomInstance", new AwsNative.Fis.Inputs.ExperimentTemplateTargetArgs
                {
                    ResourceTags = 
                    {
                        { "env", "prod" },
                    },
                    ResourceType = "aws:ec2:instance",
                    SelectionMode = "COUNT(1)",
                } },
            },
            StopConditions = new[]
            {
                new AwsNative.Fis.Inputs.ExperimentTemplateStopConditionArgs
                {
                    Source = "none",
                },
            },
            Tags = 
            {
                { "name", "fisStopInstances" },
            },
            RoleArn = fisRole.Arn,
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws-native/sdk/go/aws/fis"
    	"github.com/pulumi/pulumi-aws-native/sdk/go/aws/iam"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		fisRole, err := iam.NewRole(ctx, "fisRole", &iam.RoleArgs{
    			AssumeRolePolicyDocument: pulumi.Any(map[string]interface{}{
    				"version": "2012-10-17",
    				"statement": []map[string]interface{}{
    					map[string]interface{}{
    						"effect": "Allow",
    						"principal": map[string]interface{}{
    							"service": "fis.amazonaws.com",
    						},
    						"action": "sts:AssumeRole",
    					},
    				},
    			}),
    			Policies: iam.RolePolicyTypeArray{
    				&iam.RolePolicyTypeArgs{
    					PolicyName: pulumi.String("FISRoleEC2Actions"),
    					PolicyDocument: pulumi.Any(map[string]interface{}{
    						"version": "2012-10-17",
    						"statement": []map[string]interface{}{
    							map[string]interface{}{
    								"effect": "Allow",
    								"action": []string{
    									"ec2:RebootInstances",
    									"ec2:StopInstances",
    									"ec2:StartInstances",
    									"ec2:TerminateInstances",
    								},
    								"resource": "arn:aws:ec2:*:*:instance/*",
    							},
    						},
    					}),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = fis.NewExperimentTemplate(ctx, "experimentTemplate", &fis.ExperimentTemplateArgs{
    			Description: pulumi.String("stop an instance based on a tag"),
    			Actions: fis.ExperimentTemplateActionMap{
    				"stopInstances": &fis.ExperimentTemplateActionArgs{
    					ActionId: pulumi.String("aws:ec2:stop-instances"),
    					Parameters: pulumi.StringMap{
    						"startInstancesAfterDuration": pulumi.String("PT2M"),
    					},
    					Targets: pulumi.StringMap{
    						"instances": pulumi.String("oneRandomInstance"),
    					},
    				},
    			},
    			Targets: fis.ExperimentTemplateTargetMap{
    				"oneRandomInstance": &fis.ExperimentTemplateTargetArgs{
    					ResourceTags: pulumi.StringMap{
    						"env": pulumi.String("prod"),
    					},
    					ResourceType:  pulumi.String("aws:ec2:instance"),
    					SelectionMode: pulumi.String("COUNT(1)"),
    				},
    			},
    			StopConditions: fis.ExperimentTemplateStopConditionArray{
    				&fis.ExperimentTemplateStopConditionArgs{
    					Source: pulumi.String("none"),
    				},
    			},
    			Tags: pulumi.StringMap{
    				"name": pulumi.String("fisStopInstances"),
    			},
    			RoleArn: fisRole.Arn,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    

    Coming soon!

    import pulumi
    import pulumi_aws_native as aws_native
    
    fis_role = aws_native.iam.Role("fisRole",
        assume_role_policy_document={
            "version": "2012-10-17",
            "statement": [{
                "effect": "Allow",
                "principal": {
                    "service": "fis.amazonaws.com",
                },
                "action": "sts:AssumeRole",
            }],
        },
        policies=[aws_native.iam.RolePolicyArgs(
            policy_name="FISRoleEC2Actions",
            policy_document={
                "version": "2012-10-17",
                "statement": [{
                    "effect": "Allow",
                    "action": [
                        "ec2:RebootInstances",
                        "ec2:StopInstances",
                        "ec2:StartInstances",
                        "ec2:TerminateInstances",
                    ],
                    "resource": "arn:aws:ec2:*:*:instance/*",
                }],
            },
        )])
    experiment_template = aws_native.fis.ExperimentTemplate("experimentTemplate",
        description="stop an instance based on a tag",
        actions={
            "stopInstances": aws_native.fis.ExperimentTemplateActionArgs(
                action_id="aws:ec2:stop-instances",
                parameters={
                    "startInstancesAfterDuration": "PT2M",
                },
                targets={
                    "instances": "oneRandomInstance",
                },
            ),
        },
        targets={
            "oneRandomInstance": aws_native.fis.ExperimentTemplateTargetArgs(
                resource_tags={
                    "env": "prod",
                },
                resource_type="aws:ec2:instance",
                selection_mode="COUNT(1)",
            ),
        },
        stop_conditions=[aws_native.fis.ExperimentTemplateStopConditionArgs(
            source="none",
        )],
        tags={
            "name": "fisStopInstances",
        },
        role_arn=fis_role.arn)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws_native from "@pulumi/aws-native";
    
    const fisRole = new aws_native.iam.Role("fisRole", {
        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/*",
                }],
            },
        }],
    });
    const experimentTemplate = new aws_native.fis.ExperimentTemplate("experimentTemplate", {
        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: fisRole.arn,
    });
    

    Coming soon!

    Create ExperimentTemplate Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new ExperimentTemplate(name: string, args: ExperimentTemplateArgs, opts?: CustomResourceOptions);
    @overload
    def ExperimentTemplate(resource_name: str,
                           args: ExperimentTemplateArgs,
                           opts: Optional[ResourceOptions] = None)
    
    @overload
    def ExperimentTemplate(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           description: Optional[str] = None,
                           role_arn: Optional[str] = None,
                           stop_conditions: Optional[Sequence[ExperimentTemplateStopConditionArgs]] = None,
                           tags: Optional[Mapping[str, str]] = None,
                           targets: Optional[Mapping[str, ExperimentTemplateTargetArgs]] = None,
                           actions: Optional[Mapping[str, ExperimentTemplateActionArgs]] = None,
                           experiment_options: Optional[ExperimentTemplateExperimentOptionsArgs] = None,
                           log_configuration: Optional[ExperimentTemplateLogConfigurationArgs] = None)
    func NewExperimentTemplate(ctx *Context, name string, args ExperimentTemplateArgs, opts ...ResourceOption) (*ExperimentTemplate, error)
    public ExperimentTemplate(string name, ExperimentTemplateArgs args, CustomResourceOptions? opts = null)
    public ExperimentTemplate(String name, ExperimentTemplateArgs args)
    public ExperimentTemplate(String name, ExperimentTemplateArgs args, CustomResourceOptions options)
    
    type: aws-native:fis:ExperimentTemplate
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args ExperimentTemplateArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ExperimentTemplateArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ExperimentTemplateArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ExperimentTemplateArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ExperimentTemplateArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    Coming soon!
    
    Coming soon!
    
    Coming soon!
    
    Coming soon!
    
    const experimentTemplateResource = new aws_native.fis.ExperimentTemplate("experimentTemplateResource", {
        description: "string",
        roleArn: "string",
        stopConditions: [{
            source: "string",
            value: "string",
        }],
        tags: {
            string: "string",
        },
        targets: {
            string: {
                resourceType: "string",
                selectionMode: "string",
                filters: [{
                    path: "string",
                    values: ["string"],
                }],
                parameters: {
                    string: "string",
                },
                resourceArns: ["string"],
                resourceTags: {
                    string: "string",
                },
            },
        },
        actions: {
            string: {
                actionId: "string",
                description: "string",
                parameters: {
                    string: "string",
                },
                startAfter: ["string"],
                targets: {
                    string: "string",
                },
            },
        },
        experimentOptions: {
            accountTargeting: aws_native.fis.ExperimentTemplateExperimentOptionsAccountTargeting.MultiAccount,
            emptyTargetResolutionMode: aws_native.fis.ExperimentTemplateExperimentOptionsEmptyTargetResolutionMode.Fail,
        },
        logConfiguration: {
            logSchemaVersion: 0,
            cloudWatchLogsConfiguration: {
                logGroupArn: "string",
            },
            s3Configuration: {
                bucketName: "string",
                prefix: "string",
            },
        },
    });
    
    Coming soon!
    

    ExperimentTemplate Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The ExperimentTemplate resource accepts the following input properties:

    Description string
    RoleArn string
    StopConditions List<Pulumi.AwsNative.Fis.Inputs.ExperimentTemplateStopCondition>
    Tags Dictionary<string, string>
    Targets Dictionary<string, Pulumi.AwsNative.Fis.Inputs.ExperimentTemplateTargetArgs>
    Actions Dictionary<string, Pulumi.AwsNative.Fis.Inputs.ExperimentTemplateActionArgs>
    ExperimentOptions Pulumi.AwsNative.Fis.Inputs.ExperimentTemplateExperimentOptions
    LogConfiguration Pulumi.AwsNative.Fis.Inputs.ExperimentTemplateLogConfiguration
    description string
    roleArn string
    stopConditions ExperimentTemplateStopCondition[]
    tags {[key: string]: string}
    targets {[key: string]: ExperimentTemplateTargetArgs}
    actions {[key: string]: ExperimentTemplateActionArgs}
    experimentOptions ExperimentTemplateExperimentOptions
    logConfiguration ExperimentTemplateLogConfiguration

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ExperimentTemplate resource produces the following output properties:

    AwsId string
    Id string
    The provider-assigned unique ID for this managed resource.
    AwsId string
    Id string
    The provider-assigned unique ID for this managed resource.
    awsId String
    id String
    The provider-assigned unique ID for this managed resource.
    awsId string
    id string
    The provider-assigned unique ID for this managed resource.
    aws_id str
    id str
    The provider-assigned unique ID for this managed resource.
    awsId String
    id String
    The provider-assigned unique ID for this managed resource.

    Supporting Types

    ExperimentTemplateAction, ExperimentTemplateActionArgs

    ActionId string
    Description string
    Parameters Dictionary<string, string>
    The parameters for the action, if applicable.
    StartAfter List<string>
    Targets Dictionary<string, string>
    One or more targets for the action.
    ActionId string
    Description string
    Parameters map[string]string
    The parameters for the action, if applicable.
    StartAfter []string
    Targets map[string]string
    One or more targets for the action.
    actionId String
    description String
    parameters Map<String,String>
    The parameters for the action, if applicable.
    startAfter List<String>
    targets Map<String,String>
    One or more targets for the action.
    actionId string
    description string
    parameters {[key: string]: string}
    The parameters for the action, if applicable.
    startAfter string[]
    targets {[key: string]: string}
    One or more targets for the action.
    action_id str
    description str
    parameters Mapping[str, str]
    The parameters for the action, if applicable.
    start_after Sequence[str]
    targets Mapping[str, str]
    One or more targets for the action.
    actionId String
    description String
    parameters Map<String>
    The parameters for the action, if applicable.
    startAfter List<String>
    targets Map<String>
    One or more targets for the action.

    ExperimentTemplateExperimentOptions, ExperimentTemplateExperimentOptionsArgs

    AccountTargeting ExperimentTemplateExperimentOptionsAccountTargeting
    The account targeting setting for the experiment template.
    EmptyTargetResolutionMode ExperimentTemplateExperimentOptionsEmptyTargetResolutionMode
    The target resolution failure mode for the experiment template.
    accountTargeting ExperimentTemplateExperimentOptionsAccountTargeting
    The account targeting setting for the experiment template.
    emptyTargetResolutionMode ExperimentTemplateExperimentOptionsEmptyTargetResolutionMode
    The target resolution failure mode for the experiment template.
    accountTargeting ExperimentTemplateExperimentOptionsAccountTargeting
    The account targeting setting for the experiment template.
    emptyTargetResolutionMode ExperimentTemplateExperimentOptionsEmptyTargetResolutionMode
    The target resolution failure mode for the experiment template.
    account_targeting ExperimentTemplateExperimentOptionsAccountTargeting
    The account targeting setting for the experiment template.
    empty_target_resolution_mode ExperimentTemplateExperimentOptionsEmptyTargetResolutionMode
    The target resolution failure mode for the experiment template.
    accountTargeting "multi-account" | "single-account"
    The account targeting setting for the experiment template.
    emptyTargetResolutionMode "fail" | "skip"
    The target resolution failure mode for the experiment template.

    ExperimentTemplateExperimentOptionsAccountTargeting, ExperimentTemplateExperimentOptionsAccountTargetingArgs

    MultiAccount
    multi-account
    SingleAccount
    single-account
    ExperimentTemplateExperimentOptionsAccountTargetingMultiAccount
    multi-account
    ExperimentTemplateExperimentOptionsAccountTargetingSingleAccount
    single-account
    MultiAccount
    multi-account
    SingleAccount
    single-account
    MultiAccount
    multi-account
    SingleAccount
    single-account
    MULTI_ACCOUNT
    multi-account
    SINGLE_ACCOUNT
    single-account
    "multi-account"
    multi-account
    "single-account"
    single-account

    ExperimentTemplateExperimentOptionsEmptyTargetResolutionMode, ExperimentTemplateExperimentOptionsEmptyTargetResolutionModeArgs

    Fail
    fail
    Skip
    skip
    ExperimentTemplateExperimentOptionsEmptyTargetResolutionModeFail
    fail
    ExperimentTemplateExperimentOptionsEmptyTargetResolutionModeSkip
    skip
    Fail
    fail
    Skip
    skip
    Fail
    fail
    Skip
    skip
    FAIL
    fail
    SKIP
    skip
    "fail"
    fail
    "skip"
    skip

    ExperimentTemplateLogConfiguration, ExperimentTemplateLogConfigurationArgs

    ExperimentTemplateLogConfigurationCloudWatchLogsConfigurationProperties, ExperimentTemplateLogConfigurationCloudWatchLogsConfigurationPropertiesArgs

    ExperimentTemplateLogConfigurationS3ConfigurationProperties, ExperimentTemplateLogConfigurationS3ConfigurationPropertiesArgs

    BucketName string
    Prefix string
    BucketName string
    Prefix string
    bucketName String
    prefix String
    bucketName string
    prefix string
    bucketName String
    prefix String

    ExperimentTemplateStopCondition, ExperimentTemplateStopConditionArgs

    Source string
    Value string
    Source string
    Value string
    source String
    value String
    source string
    value string
    source str
    value str
    source String
    value String

    ExperimentTemplateTarget, ExperimentTemplateTargetArgs

    resourceType string
    selectionMode string
    filters ExperimentTemplateTargetFilter[]
    parameters {[key: string]: string}
    resourceArns string[]
    resourceTags {[key: string]: string}

    ExperimentTemplateTargetFilter, ExperimentTemplateTargetFilterArgs

    Path string
    Values List<string>
    Path string
    Values []string
    path String
    values List<String>
    path string
    values string[]
    path str
    values Sequence[str]
    path String
    values List<String>

    Package Details

    Repository
    AWS Native pulumi/pulumi-aws-native
    License
    Apache-2.0
    aws-native logo

    AWS Native is in preview. AWS Classic is fully supported.

    AWS Native v0.103.0 published on Monday, Apr 22, 2024 by Pulumi