/
association.go
435 lines (389 loc) · 20.9 KB
/
association.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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
// *** 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 ssm
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Associates an SSM Document to an instance or EC2 tag.
//
// ## Example Usage
// ### Create an association for a specific instance
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ssm"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := ssm.NewAssociation(ctx, "example", &ssm.AssociationArgs{
// Targets: ssm.AssociationTargetArray{
// &ssm.AssociationTargetArgs{
// Key: pulumi.String("InstanceIds"),
// Values: pulumi.StringArray{
// pulumi.Any(aws_instance.Example.Id),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// ### Create an association for all managed instances in an AWS account
//
// To target all managed instances in an AWS account, set the `key` as `"InstanceIds"` with `values` set as `["*"]`. This example also illustrates how to use an Amazon owned SSM document named `AmazonCloudWatch-ManageAgent`.
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ssm"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := ssm.NewAssociation(ctx, "example", &ssm.AssociationArgs{
// Targets: ssm.AssociationTargetArray{
// &ssm.AssociationTargetArgs{
// Key: pulumi.String("InstanceIds"),
// Values: pulumi.StringArray{
// pulumi.String("*"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// ### Create an association for a specific tag
//
// This example shows how to target all managed instances that are assigned a tag key of `Environment` and value of `Development`.
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ssm"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := ssm.NewAssociation(ctx, "example", &ssm.AssociationArgs{
// Targets: ssm.AssociationTargetArray{
// &ssm.AssociationTargetArgs{
// Key: pulumi.String("tag:Environment"),
// Values: pulumi.StringArray{
// pulumi.String("Development"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// SSM associations can be imported using the `association_id`, e.g.,
//
// ```sh
// $ pulumi import aws:ssm/association:Association test-association 10abcdef-0abc-1234-5678-90abcdef123456
// ```
type Association struct {
pulumi.CustomResourceState
// By default, when you create a new or update associations, the system runs it immediately and then according to the schedule you specified. Enable this option if you do not want an association to run immediately after you create or update it. This parameter is not supported for rate expressions. Default: `false`.
ApplyOnlyAtCronInterval pulumi.BoolPtrOutput `pulumi:"applyOnlyAtCronInterval"`
// The ID of the SSM association.
AssociationId pulumi.StringOutput `pulumi:"associationId"`
// The descriptive name for the association.
AssociationName pulumi.StringPtrOutput `pulumi:"associationName"`
// Specify the target for the association. This target is required for associations that use an `Automation` document and target resources by using rate controls. This should be set to the SSM document `parameter` that will define how your automation will branch out.
AutomationTargetParameterName pulumi.StringPtrOutput `pulumi:"automationTargetParameterName"`
// The compliance severity for the association. Can be one of the following: `UNSPECIFIED`, `LOW`, `MEDIUM`, `HIGH` or `CRITICAL`
ComplianceSeverity pulumi.StringPtrOutput `pulumi:"complianceSeverity"`
// The document version you want to associate with the target(s). Can be a specific version or the default version.
DocumentVersion pulumi.StringOutput `pulumi:"documentVersion"`
// The instance ID to apply an SSM document to. Use `targets` with key `InstanceIds` for document schema versions 2.0 and above.
InstanceId pulumi.StringPtrOutput `pulumi:"instanceId"`
// The maximum number of targets allowed to run the association at the same time. You can specify a number, for example 10, or a percentage of the target set, for example 10%.
MaxConcurrency pulumi.StringPtrOutput `pulumi:"maxConcurrency"`
// The number of errors that are allowed before the system stops sending requests to run the association on additional targets. You can specify a number, for example 10, or a percentage of the target set, for example 10%.
MaxErrors pulumi.StringPtrOutput `pulumi:"maxErrors"`
// The name of the SSM document to apply.
Name pulumi.StringOutput `pulumi:"name"`
// An output location block. Output Location is documented below.
OutputLocation AssociationOutputLocationPtrOutput `pulumi:"outputLocation"`
// A block of arbitrary string parameters to pass to the SSM document.
Parameters pulumi.StringMapOutput `pulumi:"parameters"`
// A cron expression when the association will be applied to the target(s).
ScheduleExpression pulumi.StringPtrOutput `pulumi:"scheduleExpression"`
// A block containing the targets of the SSM association. Targets are documented below. AWS currently supports a maximum of 5 targets.
Targets AssociationTargetArrayOutput `pulumi:"targets"`
}
// NewAssociation registers a new resource with the given unique name, arguments, and options.
func NewAssociation(ctx *pulumi.Context,
name string, args *AssociationArgs, opts ...pulumi.ResourceOption) (*Association, error) {
if args == nil {
args = &AssociationArgs{}
}
var resource Association
err := ctx.RegisterResource("aws:ssm/association:Association", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetAssociation gets an existing Association 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 GetAssociation(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *AssociationState, opts ...pulumi.ResourceOption) (*Association, error) {
var resource Association
err := ctx.ReadResource("aws:ssm/association:Association", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Association resources.
type associationState struct {
// By default, when you create a new or update associations, the system runs it immediately and then according to the schedule you specified. Enable this option if you do not want an association to run immediately after you create or update it. This parameter is not supported for rate expressions. Default: `false`.
ApplyOnlyAtCronInterval *bool `pulumi:"applyOnlyAtCronInterval"`
// The ID of the SSM association.
AssociationId *string `pulumi:"associationId"`
// The descriptive name for the association.
AssociationName *string `pulumi:"associationName"`
// Specify the target for the association. This target is required for associations that use an `Automation` document and target resources by using rate controls. This should be set to the SSM document `parameter` that will define how your automation will branch out.
AutomationTargetParameterName *string `pulumi:"automationTargetParameterName"`
// The compliance severity for the association. Can be one of the following: `UNSPECIFIED`, `LOW`, `MEDIUM`, `HIGH` or `CRITICAL`
ComplianceSeverity *string `pulumi:"complianceSeverity"`
// The document version you want to associate with the target(s). Can be a specific version or the default version.
DocumentVersion *string `pulumi:"documentVersion"`
// The instance ID to apply an SSM document to. Use `targets` with key `InstanceIds` for document schema versions 2.0 and above.
InstanceId *string `pulumi:"instanceId"`
// The maximum number of targets allowed to run the association at the same time. You can specify a number, for example 10, or a percentage of the target set, for example 10%.
MaxConcurrency *string `pulumi:"maxConcurrency"`
// The number of errors that are allowed before the system stops sending requests to run the association on additional targets. You can specify a number, for example 10, or a percentage of the target set, for example 10%.
MaxErrors *string `pulumi:"maxErrors"`
// The name of the SSM document to apply.
Name *string `pulumi:"name"`
// An output location block. Output Location is documented below.
OutputLocation *AssociationOutputLocation `pulumi:"outputLocation"`
// A block of arbitrary string parameters to pass to the SSM document.
Parameters map[string]string `pulumi:"parameters"`
// A cron expression when the association will be applied to the target(s).
ScheduleExpression *string `pulumi:"scheduleExpression"`
// A block containing the targets of the SSM association. Targets are documented below. AWS currently supports a maximum of 5 targets.
Targets []AssociationTarget `pulumi:"targets"`
}
type AssociationState struct {
// By default, when you create a new or update associations, the system runs it immediately and then according to the schedule you specified. Enable this option if you do not want an association to run immediately after you create or update it. This parameter is not supported for rate expressions. Default: `false`.
ApplyOnlyAtCronInterval pulumi.BoolPtrInput
// The ID of the SSM association.
AssociationId pulumi.StringPtrInput
// The descriptive name for the association.
AssociationName pulumi.StringPtrInput
// Specify the target for the association. This target is required for associations that use an `Automation` document and target resources by using rate controls. This should be set to the SSM document `parameter` that will define how your automation will branch out.
AutomationTargetParameterName pulumi.StringPtrInput
// The compliance severity for the association. Can be one of the following: `UNSPECIFIED`, `LOW`, `MEDIUM`, `HIGH` or `CRITICAL`
ComplianceSeverity pulumi.StringPtrInput
// The document version you want to associate with the target(s). Can be a specific version or the default version.
DocumentVersion pulumi.StringPtrInput
// The instance ID to apply an SSM document to. Use `targets` with key `InstanceIds` for document schema versions 2.0 and above.
InstanceId pulumi.StringPtrInput
// The maximum number of targets allowed to run the association at the same time. You can specify a number, for example 10, or a percentage of the target set, for example 10%.
MaxConcurrency pulumi.StringPtrInput
// The number of errors that are allowed before the system stops sending requests to run the association on additional targets. You can specify a number, for example 10, or a percentage of the target set, for example 10%.
MaxErrors pulumi.StringPtrInput
// The name of the SSM document to apply.
Name pulumi.StringPtrInput
// An output location block. Output Location is documented below.
OutputLocation AssociationOutputLocationPtrInput
// A block of arbitrary string parameters to pass to the SSM document.
Parameters pulumi.StringMapInput
// A cron expression when the association will be applied to the target(s).
ScheduleExpression pulumi.StringPtrInput
// A block containing the targets of the SSM association. Targets are documented below. AWS currently supports a maximum of 5 targets.
Targets AssociationTargetArrayInput
}
func (AssociationState) ElementType() reflect.Type {
return reflect.TypeOf((*associationState)(nil)).Elem()
}
type associationArgs struct {
// By default, when you create a new or update associations, the system runs it immediately and then according to the schedule you specified. Enable this option if you do not want an association to run immediately after you create or update it. This parameter is not supported for rate expressions. Default: `false`.
ApplyOnlyAtCronInterval *bool `pulumi:"applyOnlyAtCronInterval"`
// The descriptive name for the association.
AssociationName *string `pulumi:"associationName"`
// Specify the target for the association. This target is required for associations that use an `Automation` document and target resources by using rate controls. This should be set to the SSM document `parameter` that will define how your automation will branch out.
AutomationTargetParameterName *string `pulumi:"automationTargetParameterName"`
// The compliance severity for the association. Can be one of the following: `UNSPECIFIED`, `LOW`, `MEDIUM`, `HIGH` or `CRITICAL`
ComplianceSeverity *string `pulumi:"complianceSeverity"`
// The document version you want to associate with the target(s). Can be a specific version or the default version.
DocumentVersion *string `pulumi:"documentVersion"`
// The instance ID to apply an SSM document to. Use `targets` with key `InstanceIds` for document schema versions 2.0 and above.
InstanceId *string `pulumi:"instanceId"`
// The maximum number of targets allowed to run the association at the same time. You can specify a number, for example 10, or a percentage of the target set, for example 10%.
MaxConcurrency *string `pulumi:"maxConcurrency"`
// The number of errors that are allowed before the system stops sending requests to run the association on additional targets. You can specify a number, for example 10, or a percentage of the target set, for example 10%.
MaxErrors *string `pulumi:"maxErrors"`
// The name of the SSM document to apply.
Name *string `pulumi:"name"`
// An output location block. Output Location is documented below.
OutputLocation *AssociationOutputLocation `pulumi:"outputLocation"`
// A block of arbitrary string parameters to pass to the SSM document.
Parameters map[string]string `pulumi:"parameters"`
// A cron expression when the association will be applied to the target(s).
ScheduleExpression *string `pulumi:"scheduleExpression"`
// A block containing the targets of the SSM association. Targets are documented below. AWS currently supports a maximum of 5 targets.
Targets []AssociationTarget `pulumi:"targets"`
}
// The set of arguments for constructing a Association resource.
type AssociationArgs struct {
// By default, when you create a new or update associations, the system runs it immediately and then according to the schedule you specified. Enable this option if you do not want an association to run immediately after you create or update it. This parameter is not supported for rate expressions. Default: `false`.
ApplyOnlyAtCronInterval pulumi.BoolPtrInput
// The descriptive name for the association.
AssociationName pulumi.StringPtrInput
// Specify the target for the association. This target is required for associations that use an `Automation` document and target resources by using rate controls. This should be set to the SSM document `parameter` that will define how your automation will branch out.
AutomationTargetParameterName pulumi.StringPtrInput
// The compliance severity for the association. Can be one of the following: `UNSPECIFIED`, `LOW`, `MEDIUM`, `HIGH` or `CRITICAL`
ComplianceSeverity pulumi.StringPtrInput
// The document version you want to associate with the target(s). Can be a specific version or the default version.
DocumentVersion pulumi.StringPtrInput
// The instance ID to apply an SSM document to. Use `targets` with key `InstanceIds` for document schema versions 2.0 and above.
InstanceId pulumi.StringPtrInput
// The maximum number of targets allowed to run the association at the same time. You can specify a number, for example 10, or a percentage of the target set, for example 10%.
MaxConcurrency pulumi.StringPtrInput
// The number of errors that are allowed before the system stops sending requests to run the association on additional targets. You can specify a number, for example 10, or a percentage of the target set, for example 10%.
MaxErrors pulumi.StringPtrInput
// The name of the SSM document to apply.
Name pulumi.StringPtrInput
// An output location block. Output Location is documented below.
OutputLocation AssociationOutputLocationPtrInput
// A block of arbitrary string parameters to pass to the SSM document.
Parameters pulumi.StringMapInput
// A cron expression when the association will be applied to the target(s).
ScheduleExpression pulumi.StringPtrInput
// A block containing the targets of the SSM association. Targets are documented below. AWS currently supports a maximum of 5 targets.
Targets AssociationTargetArrayInput
}
func (AssociationArgs) ElementType() reflect.Type {
return reflect.TypeOf((*associationArgs)(nil)).Elem()
}
type AssociationInput interface {
pulumi.Input
ToAssociationOutput() AssociationOutput
ToAssociationOutputWithContext(ctx context.Context) AssociationOutput
}
func (*Association) ElementType() reflect.Type {
return reflect.TypeOf((**Association)(nil)).Elem()
}
func (i *Association) ToAssociationOutput() AssociationOutput {
return i.ToAssociationOutputWithContext(context.Background())
}
func (i *Association) ToAssociationOutputWithContext(ctx context.Context) AssociationOutput {
return pulumi.ToOutputWithContext(ctx, i).(AssociationOutput)
}
// AssociationArrayInput is an input type that accepts AssociationArray and AssociationArrayOutput values.
// You can construct a concrete instance of `AssociationArrayInput` via:
//
// AssociationArray{ AssociationArgs{...} }
type AssociationArrayInput interface {
pulumi.Input
ToAssociationArrayOutput() AssociationArrayOutput
ToAssociationArrayOutputWithContext(context.Context) AssociationArrayOutput
}
type AssociationArray []AssociationInput
func (AssociationArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Association)(nil)).Elem()
}
func (i AssociationArray) ToAssociationArrayOutput() AssociationArrayOutput {
return i.ToAssociationArrayOutputWithContext(context.Background())
}
func (i AssociationArray) ToAssociationArrayOutputWithContext(ctx context.Context) AssociationArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(AssociationArrayOutput)
}
// AssociationMapInput is an input type that accepts AssociationMap and AssociationMapOutput values.
// You can construct a concrete instance of `AssociationMapInput` via:
//
// AssociationMap{ "key": AssociationArgs{...} }
type AssociationMapInput interface {
pulumi.Input
ToAssociationMapOutput() AssociationMapOutput
ToAssociationMapOutputWithContext(context.Context) AssociationMapOutput
}
type AssociationMap map[string]AssociationInput
func (AssociationMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Association)(nil)).Elem()
}
func (i AssociationMap) ToAssociationMapOutput() AssociationMapOutput {
return i.ToAssociationMapOutputWithContext(context.Background())
}
func (i AssociationMap) ToAssociationMapOutputWithContext(ctx context.Context) AssociationMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(AssociationMapOutput)
}
type AssociationOutput struct{ *pulumi.OutputState }
func (AssociationOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Association)(nil)).Elem()
}
func (o AssociationOutput) ToAssociationOutput() AssociationOutput {
return o
}
func (o AssociationOutput) ToAssociationOutputWithContext(ctx context.Context) AssociationOutput {
return o
}
type AssociationArrayOutput struct{ *pulumi.OutputState }
func (AssociationArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Association)(nil)).Elem()
}
func (o AssociationArrayOutput) ToAssociationArrayOutput() AssociationArrayOutput {
return o
}
func (o AssociationArrayOutput) ToAssociationArrayOutputWithContext(ctx context.Context) AssociationArrayOutput {
return o
}
func (o AssociationArrayOutput) Index(i pulumi.IntInput) AssociationOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Association {
return vs[0].([]*Association)[vs[1].(int)]
}).(AssociationOutput)
}
type AssociationMapOutput struct{ *pulumi.OutputState }
func (AssociationMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Association)(nil)).Elem()
}
func (o AssociationMapOutput) ToAssociationMapOutput() AssociationMapOutput {
return o
}
func (o AssociationMapOutput) ToAssociationMapOutputWithContext(ctx context.Context) AssociationMapOutput {
return o
}
func (o AssociationMapOutput) MapIndex(k pulumi.StringInput) AssociationOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Association {
return vs[0].(map[string]*Association)[vs[1].(string)]
}).(AssociationOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*AssociationInput)(nil)).Elem(), &Association{})
pulumi.RegisterInputType(reflect.TypeOf((*AssociationArrayInput)(nil)).Elem(), AssociationArray{})
pulumi.RegisterInputType(reflect.TypeOf((*AssociationMapInput)(nil)).Elem(), AssociationMap{})
pulumi.RegisterOutputType(AssociationOutput{})
pulumi.RegisterOutputType(AssociationArrayOutput{})
pulumi.RegisterOutputType(AssociationMapOutput{})
}