github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/fis/experimentTemplate.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package fis
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Provides an FIS Experiment Template, which can be used to run an experiment.
    16  // An experiment template contains one or more actions to run on specified targets during an experiment.
    17  // It also contains the stop conditions that prevent the experiment from going out of bounds.
    18  // See [Amazon Fault Injection Simulator](https://docs.aws.amazon.com/fis/index.html)
    19  // for more information.
    20  //
    21  // ## Example Usage
    22  //
    23  // <!--Start PulumiCodeChooser -->
    24  // ```go
    25  // package main
    26  //
    27  // import (
    28  //
    29  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/fis"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			_, err := fis.NewExperimentTemplate(ctx, "example", &fis.ExperimentTemplateArgs{
    37  //				Description: pulumi.String("example"),
    38  //				RoleArn:     pulumi.Any(exampleAwsIamRole.Arn),
    39  //				StopConditions: fis.ExperimentTemplateStopConditionArray{
    40  //					&fis.ExperimentTemplateStopConditionArgs{
    41  //						Source: pulumi.String("none"),
    42  //					},
    43  //				},
    44  //				Actions: fis.ExperimentTemplateActionArray{
    45  //					&fis.ExperimentTemplateActionArgs{
    46  //						Name:     pulumi.String("example-action"),
    47  //						ActionId: pulumi.String("aws:ec2:terminate-instances"),
    48  //						Target: &fis.ExperimentTemplateActionTargetArgs{
    49  //							Key:   pulumi.String("Instances"),
    50  //							Value: pulumi.String("example-target"),
    51  //						},
    52  //					},
    53  //				},
    54  //				Targets: fis.ExperimentTemplateTargetArray{
    55  //					&fis.ExperimentTemplateTargetArgs{
    56  //						Name:          pulumi.String("example-target"),
    57  //						ResourceType:  pulumi.String("aws:ec2:instance"),
    58  //						SelectionMode: pulumi.String("COUNT(1)"),
    59  //						ResourceTags: fis.ExperimentTemplateTargetResourceTagArray{
    60  //							&fis.ExperimentTemplateTargetResourceTagArgs{
    61  //								Key:   pulumi.String("env"),
    62  //								Value: pulumi.String("example"),
    63  //							},
    64  //						},
    65  //					},
    66  //				},
    67  //			})
    68  //			if err != nil {
    69  //				return err
    70  //			}
    71  //			return nil
    72  //		})
    73  //	}
    74  //
    75  // ```
    76  // <!--End PulumiCodeChooser -->
    77  //
    78  // ## Import
    79  //
    80  // Using `pulumi import`, import FIS Experiment Templates using the `id`. For example:
    81  //
    82  // ```sh
    83  // $ pulumi import aws:fis/experimentTemplate:ExperimentTemplate template EXT123AbCdEfGhIjK
    84  // ```
    85  type ExperimentTemplate struct {
    86  	pulumi.CustomResourceState
    87  
    88  	// Action to be performed during an experiment. See below.
    89  	Actions ExperimentTemplateActionArrayOutput `pulumi:"actions"`
    90  	// Description for the experiment template.
    91  	Description pulumi.StringOutput `pulumi:"description"`
    92  	// The configuration for experiment logging. See below.
    93  	LogConfiguration ExperimentTemplateLogConfigurationPtrOutput `pulumi:"logConfiguration"`
    94  	// ARN of an IAM role that grants the AWS FIS service permission to perform service actions on your behalf.
    95  	RoleArn pulumi.StringOutput `pulumi:"roleArn"`
    96  	// When an ongoing experiment should be stopped. See below.
    97  	//
    98  	// The following arguments are optional:
    99  	StopConditions ExperimentTemplateStopConditionArrayOutput `pulumi:"stopConditions"`
   100  	// 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.
   101  	Tags pulumi.StringMapOutput `pulumi:"tags"`
   102  	// Deprecated: Please use `tags` instead.
   103  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
   104  	// Target of an action. See below.
   105  	Targets ExperimentTemplateTargetArrayOutput `pulumi:"targets"`
   106  }
   107  
   108  // NewExperimentTemplate registers a new resource with the given unique name, arguments, and options.
   109  func NewExperimentTemplate(ctx *pulumi.Context,
   110  	name string, args *ExperimentTemplateArgs, opts ...pulumi.ResourceOption) (*ExperimentTemplate, error) {
   111  	if args == nil {
   112  		return nil, errors.New("missing one or more required arguments")
   113  	}
   114  
   115  	if args.Actions == nil {
   116  		return nil, errors.New("invalid value for required argument 'Actions'")
   117  	}
   118  	if args.Description == nil {
   119  		return nil, errors.New("invalid value for required argument 'Description'")
   120  	}
   121  	if args.RoleArn == nil {
   122  		return nil, errors.New("invalid value for required argument 'RoleArn'")
   123  	}
   124  	if args.StopConditions == nil {
   125  		return nil, errors.New("invalid value for required argument 'StopConditions'")
   126  	}
   127  	opts = internal.PkgResourceDefaultOpts(opts)
   128  	var resource ExperimentTemplate
   129  	err := ctx.RegisterResource("aws:fis/experimentTemplate:ExperimentTemplate", name, args, &resource, opts...)
   130  	if err != nil {
   131  		return nil, err
   132  	}
   133  	return &resource, nil
   134  }
   135  
   136  // GetExperimentTemplate gets an existing ExperimentTemplate resource's state with the given name, ID, and optional
   137  // state properties that are used to uniquely qualify the lookup (nil if not required).
   138  func GetExperimentTemplate(ctx *pulumi.Context,
   139  	name string, id pulumi.IDInput, state *ExperimentTemplateState, opts ...pulumi.ResourceOption) (*ExperimentTemplate, error) {
   140  	var resource ExperimentTemplate
   141  	err := ctx.ReadResource("aws:fis/experimentTemplate:ExperimentTemplate", name, id, state, &resource, opts...)
   142  	if err != nil {
   143  		return nil, err
   144  	}
   145  	return &resource, nil
   146  }
   147  
   148  // Input properties used for looking up and filtering ExperimentTemplate resources.
   149  type experimentTemplateState struct {
   150  	// Action to be performed during an experiment. See below.
   151  	Actions []ExperimentTemplateAction `pulumi:"actions"`
   152  	// Description for the experiment template.
   153  	Description *string `pulumi:"description"`
   154  	// The configuration for experiment logging. See below.
   155  	LogConfiguration *ExperimentTemplateLogConfiguration `pulumi:"logConfiguration"`
   156  	// ARN of an IAM role that grants the AWS FIS service permission to perform service actions on your behalf.
   157  	RoleArn *string `pulumi:"roleArn"`
   158  	// When an ongoing experiment should be stopped. See below.
   159  	//
   160  	// The following arguments are optional:
   161  	StopConditions []ExperimentTemplateStopCondition `pulumi:"stopConditions"`
   162  	// 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.
   163  	Tags map[string]string `pulumi:"tags"`
   164  	// Deprecated: Please use `tags` instead.
   165  	TagsAll map[string]string `pulumi:"tagsAll"`
   166  	// Target of an action. See below.
   167  	Targets []ExperimentTemplateTarget `pulumi:"targets"`
   168  }
   169  
   170  type ExperimentTemplateState struct {
   171  	// Action to be performed during an experiment. See below.
   172  	Actions ExperimentTemplateActionArrayInput
   173  	// Description for the experiment template.
   174  	Description pulumi.StringPtrInput
   175  	// The configuration for experiment logging. See below.
   176  	LogConfiguration ExperimentTemplateLogConfigurationPtrInput
   177  	// ARN of an IAM role that grants the AWS FIS service permission to perform service actions on your behalf.
   178  	RoleArn pulumi.StringPtrInput
   179  	// When an ongoing experiment should be stopped. See below.
   180  	//
   181  	// The following arguments are optional:
   182  	StopConditions ExperimentTemplateStopConditionArrayInput
   183  	// 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.
   184  	Tags pulumi.StringMapInput
   185  	// Deprecated: Please use `tags` instead.
   186  	TagsAll pulumi.StringMapInput
   187  	// Target of an action. See below.
   188  	Targets ExperimentTemplateTargetArrayInput
   189  }
   190  
   191  func (ExperimentTemplateState) ElementType() reflect.Type {
   192  	return reflect.TypeOf((*experimentTemplateState)(nil)).Elem()
   193  }
   194  
   195  type experimentTemplateArgs struct {
   196  	// Action to be performed during an experiment. See below.
   197  	Actions []ExperimentTemplateAction `pulumi:"actions"`
   198  	// Description for the experiment template.
   199  	Description string `pulumi:"description"`
   200  	// The configuration for experiment logging. See below.
   201  	LogConfiguration *ExperimentTemplateLogConfiguration `pulumi:"logConfiguration"`
   202  	// ARN of an IAM role that grants the AWS FIS service permission to perform service actions on your behalf.
   203  	RoleArn string `pulumi:"roleArn"`
   204  	// When an ongoing experiment should be stopped. See below.
   205  	//
   206  	// The following arguments are optional:
   207  	StopConditions []ExperimentTemplateStopCondition `pulumi:"stopConditions"`
   208  	// 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.
   209  	Tags map[string]string `pulumi:"tags"`
   210  	// Target of an action. See below.
   211  	Targets []ExperimentTemplateTarget `pulumi:"targets"`
   212  }
   213  
   214  // The set of arguments for constructing a ExperimentTemplate resource.
   215  type ExperimentTemplateArgs struct {
   216  	// Action to be performed during an experiment. See below.
   217  	Actions ExperimentTemplateActionArrayInput
   218  	// Description for the experiment template.
   219  	Description pulumi.StringInput
   220  	// The configuration for experiment logging. See below.
   221  	LogConfiguration ExperimentTemplateLogConfigurationPtrInput
   222  	// ARN of an IAM role that grants the AWS FIS service permission to perform service actions on your behalf.
   223  	RoleArn pulumi.StringInput
   224  	// When an ongoing experiment should be stopped. See below.
   225  	//
   226  	// The following arguments are optional:
   227  	StopConditions ExperimentTemplateStopConditionArrayInput
   228  	// 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.
   229  	Tags pulumi.StringMapInput
   230  	// Target of an action. See below.
   231  	Targets ExperimentTemplateTargetArrayInput
   232  }
   233  
   234  func (ExperimentTemplateArgs) ElementType() reflect.Type {
   235  	return reflect.TypeOf((*experimentTemplateArgs)(nil)).Elem()
   236  }
   237  
   238  type ExperimentTemplateInput interface {
   239  	pulumi.Input
   240  
   241  	ToExperimentTemplateOutput() ExperimentTemplateOutput
   242  	ToExperimentTemplateOutputWithContext(ctx context.Context) ExperimentTemplateOutput
   243  }
   244  
   245  func (*ExperimentTemplate) ElementType() reflect.Type {
   246  	return reflect.TypeOf((**ExperimentTemplate)(nil)).Elem()
   247  }
   248  
   249  func (i *ExperimentTemplate) ToExperimentTemplateOutput() ExperimentTemplateOutput {
   250  	return i.ToExperimentTemplateOutputWithContext(context.Background())
   251  }
   252  
   253  func (i *ExperimentTemplate) ToExperimentTemplateOutputWithContext(ctx context.Context) ExperimentTemplateOutput {
   254  	return pulumi.ToOutputWithContext(ctx, i).(ExperimentTemplateOutput)
   255  }
   256  
   257  // ExperimentTemplateArrayInput is an input type that accepts ExperimentTemplateArray and ExperimentTemplateArrayOutput values.
   258  // You can construct a concrete instance of `ExperimentTemplateArrayInput` via:
   259  //
   260  //	ExperimentTemplateArray{ ExperimentTemplateArgs{...} }
   261  type ExperimentTemplateArrayInput interface {
   262  	pulumi.Input
   263  
   264  	ToExperimentTemplateArrayOutput() ExperimentTemplateArrayOutput
   265  	ToExperimentTemplateArrayOutputWithContext(context.Context) ExperimentTemplateArrayOutput
   266  }
   267  
   268  type ExperimentTemplateArray []ExperimentTemplateInput
   269  
   270  func (ExperimentTemplateArray) ElementType() reflect.Type {
   271  	return reflect.TypeOf((*[]*ExperimentTemplate)(nil)).Elem()
   272  }
   273  
   274  func (i ExperimentTemplateArray) ToExperimentTemplateArrayOutput() ExperimentTemplateArrayOutput {
   275  	return i.ToExperimentTemplateArrayOutputWithContext(context.Background())
   276  }
   277  
   278  func (i ExperimentTemplateArray) ToExperimentTemplateArrayOutputWithContext(ctx context.Context) ExperimentTemplateArrayOutput {
   279  	return pulumi.ToOutputWithContext(ctx, i).(ExperimentTemplateArrayOutput)
   280  }
   281  
   282  // ExperimentTemplateMapInput is an input type that accepts ExperimentTemplateMap and ExperimentTemplateMapOutput values.
   283  // You can construct a concrete instance of `ExperimentTemplateMapInput` via:
   284  //
   285  //	ExperimentTemplateMap{ "key": ExperimentTemplateArgs{...} }
   286  type ExperimentTemplateMapInput interface {
   287  	pulumi.Input
   288  
   289  	ToExperimentTemplateMapOutput() ExperimentTemplateMapOutput
   290  	ToExperimentTemplateMapOutputWithContext(context.Context) ExperimentTemplateMapOutput
   291  }
   292  
   293  type ExperimentTemplateMap map[string]ExperimentTemplateInput
   294  
   295  func (ExperimentTemplateMap) ElementType() reflect.Type {
   296  	return reflect.TypeOf((*map[string]*ExperimentTemplate)(nil)).Elem()
   297  }
   298  
   299  func (i ExperimentTemplateMap) ToExperimentTemplateMapOutput() ExperimentTemplateMapOutput {
   300  	return i.ToExperimentTemplateMapOutputWithContext(context.Background())
   301  }
   302  
   303  func (i ExperimentTemplateMap) ToExperimentTemplateMapOutputWithContext(ctx context.Context) ExperimentTemplateMapOutput {
   304  	return pulumi.ToOutputWithContext(ctx, i).(ExperimentTemplateMapOutput)
   305  }
   306  
   307  type ExperimentTemplateOutput struct{ *pulumi.OutputState }
   308  
   309  func (ExperimentTemplateOutput) ElementType() reflect.Type {
   310  	return reflect.TypeOf((**ExperimentTemplate)(nil)).Elem()
   311  }
   312  
   313  func (o ExperimentTemplateOutput) ToExperimentTemplateOutput() ExperimentTemplateOutput {
   314  	return o
   315  }
   316  
   317  func (o ExperimentTemplateOutput) ToExperimentTemplateOutputWithContext(ctx context.Context) ExperimentTemplateOutput {
   318  	return o
   319  }
   320  
   321  // Action to be performed during an experiment. See below.
   322  func (o ExperimentTemplateOutput) Actions() ExperimentTemplateActionArrayOutput {
   323  	return o.ApplyT(func(v *ExperimentTemplate) ExperimentTemplateActionArrayOutput { return v.Actions }).(ExperimentTemplateActionArrayOutput)
   324  }
   325  
   326  // Description for the experiment template.
   327  func (o ExperimentTemplateOutput) Description() pulumi.StringOutput {
   328  	return o.ApplyT(func(v *ExperimentTemplate) pulumi.StringOutput { return v.Description }).(pulumi.StringOutput)
   329  }
   330  
   331  // The configuration for experiment logging. See below.
   332  func (o ExperimentTemplateOutput) LogConfiguration() ExperimentTemplateLogConfigurationPtrOutput {
   333  	return o.ApplyT(func(v *ExperimentTemplate) ExperimentTemplateLogConfigurationPtrOutput { return v.LogConfiguration }).(ExperimentTemplateLogConfigurationPtrOutput)
   334  }
   335  
   336  // ARN of an IAM role that grants the AWS FIS service permission to perform service actions on your behalf.
   337  func (o ExperimentTemplateOutput) RoleArn() pulumi.StringOutput {
   338  	return o.ApplyT(func(v *ExperimentTemplate) pulumi.StringOutput { return v.RoleArn }).(pulumi.StringOutput)
   339  }
   340  
   341  // When an ongoing experiment should be stopped. See below.
   342  //
   343  // The following arguments are optional:
   344  func (o ExperimentTemplateOutput) StopConditions() ExperimentTemplateStopConditionArrayOutput {
   345  	return o.ApplyT(func(v *ExperimentTemplate) ExperimentTemplateStopConditionArrayOutput { return v.StopConditions }).(ExperimentTemplateStopConditionArrayOutput)
   346  }
   347  
   348  // 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.
   349  func (o ExperimentTemplateOutput) Tags() pulumi.StringMapOutput {
   350  	return o.ApplyT(func(v *ExperimentTemplate) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   351  }
   352  
   353  // Deprecated: Please use `tags` instead.
   354  func (o ExperimentTemplateOutput) TagsAll() pulumi.StringMapOutput {
   355  	return o.ApplyT(func(v *ExperimentTemplate) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   356  }
   357  
   358  // Target of an action. See below.
   359  func (o ExperimentTemplateOutput) Targets() ExperimentTemplateTargetArrayOutput {
   360  	return o.ApplyT(func(v *ExperimentTemplate) ExperimentTemplateTargetArrayOutput { return v.Targets }).(ExperimentTemplateTargetArrayOutput)
   361  }
   362  
   363  type ExperimentTemplateArrayOutput struct{ *pulumi.OutputState }
   364  
   365  func (ExperimentTemplateArrayOutput) ElementType() reflect.Type {
   366  	return reflect.TypeOf((*[]*ExperimentTemplate)(nil)).Elem()
   367  }
   368  
   369  func (o ExperimentTemplateArrayOutput) ToExperimentTemplateArrayOutput() ExperimentTemplateArrayOutput {
   370  	return o
   371  }
   372  
   373  func (o ExperimentTemplateArrayOutput) ToExperimentTemplateArrayOutputWithContext(ctx context.Context) ExperimentTemplateArrayOutput {
   374  	return o
   375  }
   376  
   377  func (o ExperimentTemplateArrayOutput) Index(i pulumi.IntInput) ExperimentTemplateOutput {
   378  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ExperimentTemplate {
   379  		return vs[0].([]*ExperimentTemplate)[vs[1].(int)]
   380  	}).(ExperimentTemplateOutput)
   381  }
   382  
   383  type ExperimentTemplateMapOutput struct{ *pulumi.OutputState }
   384  
   385  func (ExperimentTemplateMapOutput) ElementType() reflect.Type {
   386  	return reflect.TypeOf((*map[string]*ExperimentTemplate)(nil)).Elem()
   387  }
   388  
   389  func (o ExperimentTemplateMapOutput) ToExperimentTemplateMapOutput() ExperimentTemplateMapOutput {
   390  	return o
   391  }
   392  
   393  func (o ExperimentTemplateMapOutput) ToExperimentTemplateMapOutputWithContext(ctx context.Context) ExperimentTemplateMapOutput {
   394  	return o
   395  }
   396  
   397  func (o ExperimentTemplateMapOutput) MapIndex(k pulumi.StringInput) ExperimentTemplateOutput {
   398  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ExperimentTemplate {
   399  		return vs[0].(map[string]*ExperimentTemplate)[vs[1].(string)]
   400  	}).(ExperimentTemplateOutput)
   401  }
   402  
   403  func init() {
   404  	pulumi.RegisterInputType(reflect.TypeOf((*ExperimentTemplateInput)(nil)).Elem(), &ExperimentTemplate{})
   405  	pulumi.RegisterInputType(reflect.TypeOf((*ExperimentTemplateArrayInput)(nil)).Elem(), ExperimentTemplateArray{})
   406  	pulumi.RegisterInputType(reflect.TypeOf((*ExperimentTemplateMapInput)(nil)).Elem(), ExperimentTemplateMap{})
   407  	pulumi.RegisterOutputType(ExperimentTemplateOutput{})
   408  	pulumi.RegisterOutputType(ExperimentTemplateArrayOutput{})
   409  	pulumi.RegisterOutputType(ExperimentTemplateMapOutput{})
   410  }