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