/
instanceGroup.go
400 lines (339 loc) · 17.7 KB
/
instanceGroup.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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package emr
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides an Elastic MapReduce Cluster Instance Group configuration.
// See [Amazon Elastic MapReduce Documentation](https://aws.amazon.com/documentation/emr/) for more information.
//
// > **NOTE:** At this time, Instance Groups cannot be destroyed through the API nor
// web interface. Instance Groups are destroyed when the EMR Cluster is destroyed.
// this provider will resize any Instance Group to zero when destroying the resource.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/emr"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := emr.NewInstanceGroup(ctx, "task", &emr.InstanceGroupArgs{
// ClusterId: pulumi.Any(aws_emr_cluster.Tf - test - cluster.Id),
// InstanceCount: pulumi.Int(1),
// InstanceType: pulumi.String("m5.xlarge"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// EMR task instance group can be imported using their EMR Cluster id and Instance Group id separated by a forward-slash `/`, e.g.
//
// ```sh
// $ pulumi import aws:emr/instanceGroup:InstanceGroup task_greoup j-123456ABCDEF/ig-15EK4O09RZLNR
// ```
type InstanceGroup struct {
pulumi.CustomResourceState
// The autoscaling policy document. This is a JSON formatted string. See [EMR Auto Scaling](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-automatic-scaling.html)
AutoscalingPolicy pulumi.StringPtrOutput `pulumi:"autoscalingPolicy"`
// If set, the bid price for each EC2 instance in the instance group, expressed in USD. By setting this attribute, the instance group is being declared as a Spot Instance, and will implicitly create a Spot request. Leave this blank to use On-Demand Instances.
BidPrice pulumi.StringPtrOutput `pulumi:"bidPrice"`
// ID of the EMR Cluster to attach to. Changing this forces a new resource to be created.
ClusterId pulumi.StringOutput `pulumi:"clusterId"`
// A JSON string for supplying list of configurations specific to the EMR instance group. Note that this can only be changed when using EMR release 5.21 or later.
ConfigurationsJson pulumi.StringPtrOutput `pulumi:"configurationsJson"`
// One or more `ebsConfig` blocks as defined below. Changing this forces a new resource to be created.
EbsConfigs InstanceGroupEbsConfigArrayOutput `pulumi:"ebsConfigs"`
// Indicates whether an Amazon EBS volume is EBS-optimized. Changing this forces a new resource to be created.
EbsOptimized pulumi.BoolPtrOutput `pulumi:"ebsOptimized"`
// target number of instances for the instance group. defaults to 0.
InstanceCount pulumi.IntPtrOutput `pulumi:"instanceCount"`
// The EC2 instance type for all instances in the instance group. Changing this forces a new resource to be created.
InstanceType pulumi.StringOutput `pulumi:"instanceType"`
// Human friendly name given to the instance group. Changing this forces a new resource to be created.
Name pulumi.StringOutput `pulumi:"name"`
RunningInstanceCount pulumi.IntOutput `pulumi:"runningInstanceCount"`
Status pulumi.StringOutput `pulumi:"status"`
}
// NewInstanceGroup registers a new resource with the given unique name, arguments, and options.
func NewInstanceGroup(ctx *pulumi.Context,
name string, args *InstanceGroupArgs, opts ...pulumi.ResourceOption) (*InstanceGroup, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.ClusterId == nil {
return nil, errors.New("invalid value for required argument 'ClusterId'")
}
if args.InstanceType == nil {
return nil, errors.New("invalid value for required argument 'InstanceType'")
}
var resource InstanceGroup
err := ctx.RegisterResource("aws:emr/instanceGroup:InstanceGroup", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetInstanceGroup gets an existing InstanceGroup 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 GetInstanceGroup(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *InstanceGroupState, opts ...pulumi.ResourceOption) (*InstanceGroup, error) {
var resource InstanceGroup
err := ctx.ReadResource("aws:emr/instanceGroup:InstanceGroup", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering InstanceGroup resources.
type instanceGroupState struct {
// The autoscaling policy document. This is a JSON formatted string. See [EMR Auto Scaling](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-automatic-scaling.html)
AutoscalingPolicy *string `pulumi:"autoscalingPolicy"`
// If set, the bid price for each EC2 instance in the instance group, expressed in USD. By setting this attribute, the instance group is being declared as a Spot Instance, and will implicitly create a Spot request. Leave this blank to use On-Demand Instances.
BidPrice *string `pulumi:"bidPrice"`
// ID of the EMR Cluster to attach to. Changing this forces a new resource to be created.
ClusterId *string `pulumi:"clusterId"`
// A JSON string for supplying list of configurations specific to the EMR instance group. Note that this can only be changed when using EMR release 5.21 or later.
ConfigurationsJson *string `pulumi:"configurationsJson"`
// One or more `ebsConfig` blocks as defined below. Changing this forces a new resource to be created.
EbsConfigs []InstanceGroupEbsConfig `pulumi:"ebsConfigs"`
// Indicates whether an Amazon EBS volume is EBS-optimized. Changing this forces a new resource to be created.
EbsOptimized *bool `pulumi:"ebsOptimized"`
// target number of instances for the instance group. defaults to 0.
InstanceCount *int `pulumi:"instanceCount"`
// The EC2 instance type for all instances in the instance group. Changing this forces a new resource to be created.
InstanceType *string `pulumi:"instanceType"`
// Human friendly name given to the instance group. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
RunningInstanceCount *int `pulumi:"runningInstanceCount"`
Status *string `pulumi:"status"`
}
type InstanceGroupState struct {
// The autoscaling policy document. This is a JSON formatted string. See [EMR Auto Scaling](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-automatic-scaling.html)
AutoscalingPolicy pulumi.StringPtrInput
// If set, the bid price for each EC2 instance in the instance group, expressed in USD. By setting this attribute, the instance group is being declared as a Spot Instance, and will implicitly create a Spot request. Leave this blank to use On-Demand Instances.
BidPrice pulumi.StringPtrInput
// ID of the EMR Cluster to attach to. Changing this forces a new resource to be created.
ClusterId pulumi.StringPtrInput
// A JSON string for supplying list of configurations specific to the EMR instance group. Note that this can only be changed when using EMR release 5.21 or later.
ConfigurationsJson pulumi.StringPtrInput
// One or more `ebsConfig` blocks as defined below. Changing this forces a new resource to be created.
EbsConfigs InstanceGroupEbsConfigArrayInput
// Indicates whether an Amazon EBS volume is EBS-optimized. Changing this forces a new resource to be created.
EbsOptimized pulumi.BoolPtrInput
// target number of instances for the instance group. defaults to 0.
InstanceCount pulumi.IntPtrInput
// The EC2 instance type for all instances in the instance group. Changing this forces a new resource to be created.
InstanceType pulumi.StringPtrInput
// Human friendly name given to the instance group. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
RunningInstanceCount pulumi.IntPtrInput
Status pulumi.StringPtrInput
}
func (InstanceGroupState) ElementType() reflect.Type {
return reflect.TypeOf((*instanceGroupState)(nil)).Elem()
}
type instanceGroupArgs struct {
// The autoscaling policy document. This is a JSON formatted string. See [EMR Auto Scaling](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-automatic-scaling.html)
AutoscalingPolicy *string `pulumi:"autoscalingPolicy"`
// If set, the bid price for each EC2 instance in the instance group, expressed in USD. By setting this attribute, the instance group is being declared as a Spot Instance, and will implicitly create a Spot request. Leave this blank to use On-Demand Instances.
BidPrice *string `pulumi:"bidPrice"`
// ID of the EMR Cluster to attach to. Changing this forces a new resource to be created.
ClusterId string `pulumi:"clusterId"`
// A JSON string for supplying list of configurations specific to the EMR instance group. Note that this can only be changed when using EMR release 5.21 or later.
ConfigurationsJson *string `pulumi:"configurationsJson"`
// One or more `ebsConfig` blocks as defined below. Changing this forces a new resource to be created.
EbsConfigs []InstanceGroupEbsConfig `pulumi:"ebsConfigs"`
// Indicates whether an Amazon EBS volume is EBS-optimized. Changing this forces a new resource to be created.
EbsOptimized *bool `pulumi:"ebsOptimized"`
// target number of instances for the instance group. defaults to 0.
InstanceCount *int `pulumi:"instanceCount"`
// The EC2 instance type for all instances in the instance group. Changing this forces a new resource to be created.
InstanceType string `pulumi:"instanceType"`
// Human friendly name given to the instance group. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
}
// The set of arguments for constructing a InstanceGroup resource.
type InstanceGroupArgs struct {
// The autoscaling policy document. This is a JSON formatted string. See [EMR Auto Scaling](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-automatic-scaling.html)
AutoscalingPolicy pulumi.StringPtrInput
// If set, the bid price for each EC2 instance in the instance group, expressed in USD. By setting this attribute, the instance group is being declared as a Spot Instance, and will implicitly create a Spot request. Leave this blank to use On-Demand Instances.
BidPrice pulumi.StringPtrInput
// ID of the EMR Cluster to attach to. Changing this forces a new resource to be created.
ClusterId pulumi.StringInput
// A JSON string for supplying list of configurations specific to the EMR instance group. Note that this can only be changed when using EMR release 5.21 or later.
ConfigurationsJson pulumi.StringPtrInput
// One or more `ebsConfig` blocks as defined below. Changing this forces a new resource to be created.
EbsConfigs InstanceGroupEbsConfigArrayInput
// Indicates whether an Amazon EBS volume is EBS-optimized. Changing this forces a new resource to be created.
EbsOptimized pulumi.BoolPtrInput
// target number of instances for the instance group. defaults to 0.
InstanceCount pulumi.IntPtrInput
// The EC2 instance type for all instances in the instance group. Changing this forces a new resource to be created.
InstanceType pulumi.StringInput
// Human friendly name given to the instance group. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
}
func (InstanceGroupArgs) ElementType() reflect.Type {
return reflect.TypeOf((*instanceGroupArgs)(nil)).Elem()
}
type InstanceGroupInput interface {
pulumi.Input
ToInstanceGroupOutput() InstanceGroupOutput
ToInstanceGroupOutputWithContext(ctx context.Context) InstanceGroupOutput
}
func (*InstanceGroup) ElementType() reflect.Type {
return reflect.TypeOf((*InstanceGroup)(nil))
}
func (i *InstanceGroup) ToInstanceGroupOutput() InstanceGroupOutput {
return i.ToInstanceGroupOutputWithContext(context.Background())
}
func (i *InstanceGroup) ToInstanceGroupOutputWithContext(ctx context.Context) InstanceGroupOutput {
return pulumi.ToOutputWithContext(ctx, i).(InstanceGroupOutput)
}
func (i *InstanceGroup) ToInstanceGroupPtrOutput() InstanceGroupPtrOutput {
return i.ToInstanceGroupPtrOutputWithContext(context.Background())
}
func (i *InstanceGroup) ToInstanceGroupPtrOutputWithContext(ctx context.Context) InstanceGroupPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(InstanceGroupPtrOutput)
}
type InstanceGroupPtrInput interface {
pulumi.Input
ToInstanceGroupPtrOutput() InstanceGroupPtrOutput
ToInstanceGroupPtrOutputWithContext(ctx context.Context) InstanceGroupPtrOutput
}
type instanceGroupPtrType InstanceGroupArgs
func (*instanceGroupPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**InstanceGroup)(nil))
}
func (i *instanceGroupPtrType) ToInstanceGroupPtrOutput() InstanceGroupPtrOutput {
return i.ToInstanceGroupPtrOutputWithContext(context.Background())
}
func (i *instanceGroupPtrType) ToInstanceGroupPtrOutputWithContext(ctx context.Context) InstanceGroupPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(InstanceGroupPtrOutput)
}
// InstanceGroupArrayInput is an input type that accepts InstanceGroupArray and InstanceGroupArrayOutput values.
// You can construct a concrete instance of `InstanceGroupArrayInput` via:
//
// InstanceGroupArray{ InstanceGroupArgs{...} }
type InstanceGroupArrayInput interface {
pulumi.Input
ToInstanceGroupArrayOutput() InstanceGroupArrayOutput
ToInstanceGroupArrayOutputWithContext(context.Context) InstanceGroupArrayOutput
}
type InstanceGroupArray []InstanceGroupInput
func (InstanceGroupArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*InstanceGroup)(nil)).Elem()
}
func (i InstanceGroupArray) ToInstanceGroupArrayOutput() InstanceGroupArrayOutput {
return i.ToInstanceGroupArrayOutputWithContext(context.Background())
}
func (i InstanceGroupArray) ToInstanceGroupArrayOutputWithContext(ctx context.Context) InstanceGroupArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(InstanceGroupArrayOutput)
}
// InstanceGroupMapInput is an input type that accepts InstanceGroupMap and InstanceGroupMapOutput values.
// You can construct a concrete instance of `InstanceGroupMapInput` via:
//
// InstanceGroupMap{ "key": InstanceGroupArgs{...} }
type InstanceGroupMapInput interface {
pulumi.Input
ToInstanceGroupMapOutput() InstanceGroupMapOutput
ToInstanceGroupMapOutputWithContext(context.Context) InstanceGroupMapOutput
}
type InstanceGroupMap map[string]InstanceGroupInput
func (InstanceGroupMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*InstanceGroup)(nil)).Elem()
}
func (i InstanceGroupMap) ToInstanceGroupMapOutput() InstanceGroupMapOutput {
return i.ToInstanceGroupMapOutputWithContext(context.Background())
}
func (i InstanceGroupMap) ToInstanceGroupMapOutputWithContext(ctx context.Context) InstanceGroupMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(InstanceGroupMapOutput)
}
type InstanceGroupOutput struct{ *pulumi.OutputState }
func (InstanceGroupOutput) ElementType() reflect.Type {
return reflect.TypeOf((*InstanceGroup)(nil))
}
func (o InstanceGroupOutput) ToInstanceGroupOutput() InstanceGroupOutput {
return o
}
func (o InstanceGroupOutput) ToInstanceGroupOutputWithContext(ctx context.Context) InstanceGroupOutput {
return o
}
func (o InstanceGroupOutput) ToInstanceGroupPtrOutput() InstanceGroupPtrOutput {
return o.ToInstanceGroupPtrOutputWithContext(context.Background())
}
func (o InstanceGroupOutput) ToInstanceGroupPtrOutputWithContext(ctx context.Context) InstanceGroupPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v InstanceGroup) *InstanceGroup {
return &v
}).(InstanceGroupPtrOutput)
}
type InstanceGroupPtrOutput struct{ *pulumi.OutputState }
func (InstanceGroupPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**InstanceGroup)(nil))
}
func (o InstanceGroupPtrOutput) ToInstanceGroupPtrOutput() InstanceGroupPtrOutput {
return o
}
func (o InstanceGroupPtrOutput) ToInstanceGroupPtrOutputWithContext(ctx context.Context) InstanceGroupPtrOutput {
return o
}
func (o InstanceGroupPtrOutput) Elem() InstanceGroupOutput {
return o.ApplyT(func(v *InstanceGroup) InstanceGroup {
if v != nil {
return *v
}
var ret InstanceGroup
return ret
}).(InstanceGroupOutput)
}
type InstanceGroupArrayOutput struct{ *pulumi.OutputState }
func (InstanceGroupArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]InstanceGroup)(nil))
}
func (o InstanceGroupArrayOutput) ToInstanceGroupArrayOutput() InstanceGroupArrayOutput {
return o
}
func (o InstanceGroupArrayOutput) ToInstanceGroupArrayOutputWithContext(ctx context.Context) InstanceGroupArrayOutput {
return o
}
func (o InstanceGroupArrayOutput) Index(i pulumi.IntInput) InstanceGroupOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) InstanceGroup {
return vs[0].([]InstanceGroup)[vs[1].(int)]
}).(InstanceGroupOutput)
}
type InstanceGroupMapOutput struct{ *pulumi.OutputState }
func (InstanceGroupMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]InstanceGroup)(nil))
}
func (o InstanceGroupMapOutput) ToInstanceGroupMapOutput() InstanceGroupMapOutput {
return o
}
func (o InstanceGroupMapOutput) ToInstanceGroupMapOutputWithContext(ctx context.Context) InstanceGroupMapOutput {
return o
}
func (o InstanceGroupMapOutput) MapIndex(k pulumi.StringInput) InstanceGroupOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) InstanceGroup {
return vs[0].(map[string]InstanceGroup)[vs[1].(string)]
}).(InstanceGroupOutput)
}
func init() {
pulumi.RegisterOutputType(InstanceGroupOutput{})
pulumi.RegisterOutputType(InstanceGroupPtrOutput{})
pulumi.RegisterOutputType(InstanceGroupArrayOutput{})
pulumi.RegisterOutputType(InstanceGroupMapOutput{})
}