github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2transitgateway/instanceState.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 ec2transitgateway
     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 EC2 instance state resource. This allows managing an instance power state.
    16  //
    17  // > **NOTE on Instance State Management:** AWS does not currently have an EC2 API operation to determine an instance has finished processing user data. As a result, this resource can interfere with user data processing. For example, this resource may stop an instance while the user data script is in mid run.
    18  //
    19  // ## Example Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    28  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2transitgateway"
    29  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    30  //
    31  // )
    32  //
    33  //	func main() {
    34  //		pulumi.Run(func(ctx *pulumi.Context) error {
    35  //			ubuntu, err := ec2.LookupAmi(ctx, &ec2.LookupAmiArgs{
    36  //				MostRecent: pulumi.BoolRef(true),
    37  //				Filters: []ec2.GetAmiFilter{
    38  //					{
    39  //						Name: "name",
    40  //						Values: []string{
    41  //							"ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*",
    42  //						},
    43  //					},
    44  //					{
    45  //						Name: "virtualization-type",
    46  //						Values: []string{
    47  //							"hvm",
    48  //						},
    49  //					},
    50  //				},
    51  //				Owners: []string{
    52  //					"099720109477",
    53  //				},
    54  //			}, nil)
    55  //			if err != nil {
    56  //				return err
    57  //			}
    58  //			test, err := ec2.NewInstance(ctx, "test", &ec2.InstanceArgs{
    59  //				Ami:          pulumi.String(ubuntu.Id),
    60  //				InstanceType: pulumi.String(ec2.InstanceType_T3_Micro),
    61  //				Tags: pulumi.StringMap{
    62  //					"Name": pulumi.String("HelloWorld"),
    63  //				},
    64  //			})
    65  //			if err != nil {
    66  //				return err
    67  //			}
    68  //			_, err = ec2transitgateway.NewInstanceState(ctx, "test", &ec2transitgateway.InstanceStateArgs{
    69  //				InstanceId: test.ID(),
    70  //				State:      pulumi.String("stopped"),
    71  //			})
    72  //			if err != nil {
    73  //				return err
    74  //			}
    75  //			return nil
    76  //		})
    77  //	}
    78  //
    79  // ```
    80  // <!--End PulumiCodeChooser -->
    81  //
    82  // ## Import
    83  //
    84  // Using `pulumi import`, import `aws_ec2_instance_state` using the `instance_id` attribute. For example:
    85  //
    86  // ```sh
    87  // $ pulumi import aws:ec2transitgateway/instanceState:InstanceState test i-02cae6557dfcf2f96
    88  // ```
    89  type InstanceState struct {
    90  	pulumi.CustomResourceState
    91  
    92  	// Whether to request a forced stop when `state` is `stopped`. Otherwise (_i.e._, `state` is `running`), ignored. When an instance is forced to stop, it does not flush file system caches or file system metadata, and you must subsequently perform file system check and repair. Not recommended for Windows instances. Defaults to `false`.
    93  	Force pulumi.BoolPtrOutput `pulumi:"force"`
    94  	// ID of the instance.
    95  	InstanceId pulumi.StringOutput `pulumi:"instanceId"`
    96  	// State of the instance. Valid values are `stopped`, `running`.
    97  	//
    98  	// The following arguments are optional:
    99  	State pulumi.StringOutput `pulumi:"state"`
   100  }
   101  
   102  // NewInstanceState registers a new resource with the given unique name, arguments, and options.
   103  func NewInstanceState(ctx *pulumi.Context,
   104  	name string, args *InstanceStateArgs, opts ...pulumi.ResourceOption) (*InstanceState, error) {
   105  	if args == nil {
   106  		return nil, errors.New("missing one or more required arguments")
   107  	}
   108  
   109  	if args.InstanceId == nil {
   110  		return nil, errors.New("invalid value for required argument 'InstanceId'")
   111  	}
   112  	if args.State == nil {
   113  		return nil, errors.New("invalid value for required argument 'State'")
   114  	}
   115  	opts = internal.PkgResourceDefaultOpts(opts)
   116  	var resource InstanceState
   117  	err := ctx.RegisterResource("aws:ec2transitgateway/instanceState:InstanceState", name, args, &resource, opts...)
   118  	if err != nil {
   119  		return nil, err
   120  	}
   121  	return &resource, nil
   122  }
   123  
   124  // GetInstanceState gets an existing InstanceState resource's state with the given name, ID, and optional
   125  // state properties that are used to uniquely qualify the lookup (nil if not required).
   126  func GetInstanceState(ctx *pulumi.Context,
   127  	name string, id pulumi.IDInput, state *InstanceStateState, opts ...pulumi.ResourceOption) (*InstanceState, error) {
   128  	var resource InstanceState
   129  	err := ctx.ReadResource("aws:ec2transitgateway/instanceState:InstanceState", name, id, state, &resource, opts...)
   130  	if err != nil {
   131  		return nil, err
   132  	}
   133  	return &resource, nil
   134  }
   135  
   136  // Input properties used for looking up and filtering InstanceState resources.
   137  type instanceStateState struct {
   138  	// Whether to request a forced stop when `state` is `stopped`. Otherwise (_i.e._, `state` is `running`), ignored. When an instance is forced to stop, it does not flush file system caches or file system metadata, and you must subsequently perform file system check and repair. Not recommended for Windows instances. Defaults to `false`.
   139  	Force *bool `pulumi:"force"`
   140  	// ID of the instance.
   141  	InstanceId *string `pulumi:"instanceId"`
   142  	// State of the instance. Valid values are `stopped`, `running`.
   143  	//
   144  	// The following arguments are optional:
   145  	State *string `pulumi:"state"`
   146  }
   147  
   148  type InstanceStateState struct {
   149  	// Whether to request a forced stop when `state` is `stopped`. Otherwise (_i.e._, `state` is `running`), ignored. When an instance is forced to stop, it does not flush file system caches or file system metadata, and you must subsequently perform file system check and repair. Not recommended for Windows instances. Defaults to `false`.
   150  	Force pulumi.BoolPtrInput
   151  	// ID of the instance.
   152  	InstanceId pulumi.StringPtrInput
   153  	// State of the instance. Valid values are `stopped`, `running`.
   154  	//
   155  	// The following arguments are optional:
   156  	State pulumi.StringPtrInput
   157  }
   158  
   159  func (InstanceStateState) ElementType() reflect.Type {
   160  	return reflect.TypeOf((*instanceStateState)(nil)).Elem()
   161  }
   162  
   163  type instanceStateArgs struct {
   164  	// Whether to request a forced stop when `state` is `stopped`. Otherwise (_i.e._, `state` is `running`), ignored. When an instance is forced to stop, it does not flush file system caches or file system metadata, and you must subsequently perform file system check and repair. Not recommended for Windows instances. Defaults to `false`.
   165  	Force *bool `pulumi:"force"`
   166  	// ID of the instance.
   167  	InstanceId string `pulumi:"instanceId"`
   168  	// State of the instance. Valid values are `stopped`, `running`.
   169  	//
   170  	// The following arguments are optional:
   171  	State string `pulumi:"state"`
   172  }
   173  
   174  // The set of arguments for constructing a InstanceState resource.
   175  type InstanceStateArgs struct {
   176  	// Whether to request a forced stop when `state` is `stopped`. Otherwise (_i.e._, `state` is `running`), ignored. When an instance is forced to stop, it does not flush file system caches or file system metadata, and you must subsequently perform file system check and repair. Not recommended for Windows instances. Defaults to `false`.
   177  	Force pulumi.BoolPtrInput
   178  	// ID of the instance.
   179  	InstanceId pulumi.StringInput
   180  	// State of the instance. Valid values are `stopped`, `running`.
   181  	//
   182  	// The following arguments are optional:
   183  	State pulumi.StringInput
   184  }
   185  
   186  func (InstanceStateArgs) ElementType() reflect.Type {
   187  	return reflect.TypeOf((*instanceStateArgs)(nil)).Elem()
   188  }
   189  
   190  type InstanceStateInput interface {
   191  	pulumi.Input
   192  
   193  	ToInstanceStateOutput() InstanceStateOutput
   194  	ToInstanceStateOutputWithContext(ctx context.Context) InstanceStateOutput
   195  }
   196  
   197  func (*InstanceState) ElementType() reflect.Type {
   198  	return reflect.TypeOf((**InstanceState)(nil)).Elem()
   199  }
   200  
   201  func (i *InstanceState) ToInstanceStateOutput() InstanceStateOutput {
   202  	return i.ToInstanceStateOutputWithContext(context.Background())
   203  }
   204  
   205  func (i *InstanceState) ToInstanceStateOutputWithContext(ctx context.Context) InstanceStateOutput {
   206  	return pulumi.ToOutputWithContext(ctx, i).(InstanceStateOutput)
   207  }
   208  
   209  // InstanceStateArrayInput is an input type that accepts InstanceStateArray and InstanceStateArrayOutput values.
   210  // You can construct a concrete instance of `InstanceStateArrayInput` via:
   211  //
   212  //	InstanceStateArray{ InstanceStateArgs{...} }
   213  type InstanceStateArrayInput interface {
   214  	pulumi.Input
   215  
   216  	ToInstanceStateArrayOutput() InstanceStateArrayOutput
   217  	ToInstanceStateArrayOutputWithContext(context.Context) InstanceStateArrayOutput
   218  }
   219  
   220  type InstanceStateArray []InstanceStateInput
   221  
   222  func (InstanceStateArray) ElementType() reflect.Type {
   223  	return reflect.TypeOf((*[]*InstanceState)(nil)).Elem()
   224  }
   225  
   226  func (i InstanceStateArray) ToInstanceStateArrayOutput() InstanceStateArrayOutput {
   227  	return i.ToInstanceStateArrayOutputWithContext(context.Background())
   228  }
   229  
   230  func (i InstanceStateArray) ToInstanceStateArrayOutputWithContext(ctx context.Context) InstanceStateArrayOutput {
   231  	return pulumi.ToOutputWithContext(ctx, i).(InstanceStateArrayOutput)
   232  }
   233  
   234  // InstanceStateMapInput is an input type that accepts InstanceStateMap and InstanceStateMapOutput values.
   235  // You can construct a concrete instance of `InstanceStateMapInput` via:
   236  //
   237  //	InstanceStateMap{ "key": InstanceStateArgs{...} }
   238  type InstanceStateMapInput interface {
   239  	pulumi.Input
   240  
   241  	ToInstanceStateMapOutput() InstanceStateMapOutput
   242  	ToInstanceStateMapOutputWithContext(context.Context) InstanceStateMapOutput
   243  }
   244  
   245  type InstanceStateMap map[string]InstanceStateInput
   246  
   247  func (InstanceStateMap) ElementType() reflect.Type {
   248  	return reflect.TypeOf((*map[string]*InstanceState)(nil)).Elem()
   249  }
   250  
   251  func (i InstanceStateMap) ToInstanceStateMapOutput() InstanceStateMapOutput {
   252  	return i.ToInstanceStateMapOutputWithContext(context.Background())
   253  }
   254  
   255  func (i InstanceStateMap) ToInstanceStateMapOutputWithContext(ctx context.Context) InstanceStateMapOutput {
   256  	return pulumi.ToOutputWithContext(ctx, i).(InstanceStateMapOutput)
   257  }
   258  
   259  type InstanceStateOutput struct{ *pulumi.OutputState }
   260  
   261  func (InstanceStateOutput) ElementType() reflect.Type {
   262  	return reflect.TypeOf((**InstanceState)(nil)).Elem()
   263  }
   264  
   265  func (o InstanceStateOutput) ToInstanceStateOutput() InstanceStateOutput {
   266  	return o
   267  }
   268  
   269  func (o InstanceStateOutput) ToInstanceStateOutputWithContext(ctx context.Context) InstanceStateOutput {
   270  	return o
   271  }
   272  
   273  // Whether to request a forced stop when `state` is `stopped`. Otherwise (_i.e._, `state` is `running`), ignored. When an instance is forced to stop, it does not flush file system caches or file system metadata, and you must subsequently perform file system check and repair. Not recommended for Windows instances. Defaults to `false`.
   274  func (o InstanceStateOutput) Force() pulumi.BoolPtrOutput {
   275  	return o.ApplyT(func(v *InstanceState) pulumi.BoolPtrOutput { return v.Force }).(pulumi.BoolPtrOutput)
   276  }
   277  
   278  // ID of the instance.
   279  func (o InstanceStateOutput) InstanceId() pulumi.StringOutput {
   280  	return o.ApplyT(func(v *InstanceState) pulumi.StringOutput { return v.InstanceId }).(pulumi.StringOutput)
   281  }
   282  
   283  // State of the instance. Valid values are `stopped`, `running`.
   284  //
   285  // The following arguments are optional:
   286  func (o InstanceStateOutput) State() pulumi.StringOutput {
   287  	return o.ApplyT(func(v *InstanceState) pulumi.StringOutput { return v.State }).(pulumi.StringOutput)
   288  }
   289  
   290  type InstanceStateArrayOutput struct{ *pulumi.OutputState }
   291  
   292  func (InstanceStateArrayOutput) ElementType() reflect.Type {
   293  	return reflect.TypeOf((*[]*InstanceState)(nil)).Elem()
   294  }
   295  
   296  func (o InstanceStateArrayOutput) ToInstanceStateArrayOutput() InstanceStateArrayOutput {
   297  	return o
   298  }
   299  
   300  func (o InstanceStateArrayOutput) ToInstanceStateArrayOutputWithContext(ctx context.Context) InstanceStateArrayOutput {
   301  	return o
   302  }
   303  
   304  func (o InstanceStateArrayOutput) Index(i pulumi.IntInput) InstanceStateOutput {
   305  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *InstanceState {
   306  		return vs[0].([]*InstanceState)[vs[1].(int)]
   307  	}).(InstanceStateOutput)
   308  }
   309  
   310  type InstanceStateMapOutput struct{ *pulumi.OutputState }
   311  
   312  func (InstanceStateMapOutput) ElementType() reflect.Type {
   313  	return reflect.TypeOf((*map[string]*InstanceState)(nil)).Elem()
   314  }
   315  
   316  func (o InstanceStateMapOutput) ToInstanceStateMapOutput() InstanceStateMapOutput {
   317  	return o
   318  }
   319  
   320  func (o InstanceStateMapOutput) ToInstanceStateMapOutputWithContext(ctx context.Context) InstanceStateMapOutput {
   321  	return o
   322  }
   323  
   324  func (o InstanceStateMapOutput) MapIndex(k pulumi.StringInput) InstanceStateOutput {
   325  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *InstanceState {
   326  		return vs[0].(map[string]*InstanceState)[vs[1].(string)]
   327  	}).(InstanceStateOutput)
   328  }
   329  
   330  func init() {
   331  	pulumi.RegisterInputType(reflect.TypeOf((*InstanceStateInput)(nil)).Elem(), &InstanceState{})
   332  	pulumi.RegisterInputType(reflect.TypeOf((*InstanceStateArrayInput)(nil)).Elem(), InstanceStateArray{})
   333  	pulumi.RegisterInputType(reflect.TypeOf((*InstanceStateMapInput)(nil)).Elem(), InstanceStateMap{})
   334  	pulumi.RegisterOutputType(InstanceStateOutput{})
   335  	pulumi.RegisterOutputType(InstanceStateArrayOutput{})
   336  	pulumi.RegisterOutputType(InstanceStateMapOutput{})
   337  }