/
document.go
476 lines (430 loc) · 21.7 KB
/
document.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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
// *** 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/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides an SSM Document resource
//
// > **NOTE on updating SSM documents:** Only documents with a schema version of 2.0
// or greater can update their content once created, see [SSM Schema Features](http://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-ssm-docs.html#document-schemas-features). To update a document with an older schema version you must recreate the resource. Not all document types support a schema version of 2.0 or greater. Refer to [SSM document schema features and examples](https://docs.aws.amazon.com/systems-manager/latest/userguide/document-schemas-features.html) for information about which schema versions are supported for the respective `documentType`.
//
// ## Example Usage
// ### Create an ssm document in JSON format
//
// ```go
// package main
//
// import (
// "fmt"
//
// "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.NewDocument(ctx, "foo", &ssm.DocumentArgs{
// Content: pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v", " {\n", " \"schemaVersion\": \"1.2\",\n", " \"description\": \"Check ip configuration of a Linux instance.\",\n", " \"parameters\": {\n", "\n", " },\n", " \"runtimeConfig\": {\n", " \"aws:runShellScript\": {\n", " \"properties\": [\n", " {\n", " \"id\": \"0.aws:runShellScript\",\n", " \"runCommand\": [\"ifconfig\"]\n", " }\n", " ]\n", " }\n", " }\n", " }\n", "\n")),
// DocumentType: pulumi.String("Command"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// ### Create an ssm document in YAML format
//
// ```go
// package main
//
// import (
// "fmt"
//
// "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.NewDocument(ctx, "foo", &ssm.DocumentArgs{
// Content: pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v", "schemaVersion: '1.2'\n", "description: Check ip configuration of a Linux instance.\n", "parameters: {}\n", "runtimeConfig:\n", " 'aws:runShellScript':\n", " properties:\n", " - id: '0.aws:runShellScript'\n", " runCommand:\n", " - ifconfig\n", "\n")),
// DocumentFormat: pulumi.String("YAML"),
// DocumentType: pulumi.String("Command"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// ## Permissions
//
// The permissions attribute specifies how you want to share the document. If you share a document privately,
// you must specify the AWS user account IDs for those people who can use the document. If you share a document
// publicly, you must specify All as the account ID.
//
// The permissions mapping supports the following:
//
// * `type` - The permission type for the document. The permission type can be `Share`.
// * `accountIds` - The AWS user accounts that should have access to the document. The account IDs can either be a group of account IDs or `All`.
//
// ## Import
//
// SSM Documents can be imported using the name, e.g.,
//
// ```sh
// $ pulumi import aws:ssm/document:Document example example
// ```
//
// The `attachments_source` argument does not have an SSM API method for reading the attachment information detail after creation. If the argument is set in the provider configuration on an imported resource, this provider will always show a difference. To workaround this behavior, either omit the argument from the configuration or use [`ignoreChanges`](https://www.pulumi.com/docs/intro/concepts/programming-model/#ignorechanges) to hide the difference, e.g. terraform resource "aws_ssm_document" "test" {
//
// name
//
// = "test_document"
//
// document_type = "Package"
//
// attachments_source {
//
// key
//
// = "SourceUrl"
//
// values = ["s3://${aws_s3_bucket.object_bucket.bucket}/test.zip"]
//
// }
//
// # There is no AWS SSM API for reading attachments_source info directly
//
// lifecycle {
//
// ignore_changes = [attachments_source]
//
// } }
type Document struct {
pulumi.CustomResourceState
Arn pulumi.StringOutput `pulumi:"arn"`
// One or more configuration blocks describing attachments sources to a version of a document. Defined below.
AttachmentsSources DocumentAttachmentsSourceArrayOutput `pulumi:"attachmentsSources"`
// The JSON or YAML content of the document.
Content pulumi.StringOutput `pulumi:"content"`
// The date the document was created.
CreatedDate pulumi.StringOutput `pulumi:"createdDate"`
// The default version of the document.
DefaultVersion pulumi.StringOutput `pulumi:"defaultVersion"`
// The description of the document.
Description pulumi.StringOutput `pulumi:"description"`
// The format of the document. Valid document types include: `JSON` and `YAML`
DocumentFormat pulumi.StringPtrOutput `pulumi:"documentFormat"`
// The type of the document. Valid document types include: `Automation`, `Command`, `Package`, `Policy`, and `Session`
DocumentType pulumi.StringOutput `pulumi:"documentType"`
// The document version.
DocumentVersion pulumi.StringOutput `pulumi:"documentVersion"`
// The sha1 or sha256 of the document content
Hash pulumi.StringOutput `pulumi:"hash"`
// "Sha1" "Sha256". The hashing algorithm used when hashing the content.
HashType pulumi.StringOutput `pulumi:"hashType"`
// The latest version of the document.
LatestVersion pulumi.StringOutput `pulumi:"latestVersion"`
// The name of the document.
Name pulumi.StringOutput `pulumi:"name"`
// The AWS user account of the person who created the document.
Owner pulumi.StringOutput `pulumi:"owner"`
// The parameters that are available to this document.
Parameters DocumentParameterArrayOutput `pulumi:"parameters"`
// Additional Permissions to attach to the document. See Permissions below for details.
Permissions pulumi.StringMapOutput `pulumi:"permissions"`
// A list of OS platforms compatible with this SSM document, either "Windows" or "Linux".
PlatformTypes pulumi.StringArrayOutput `pulumi:"platformTypes"`
// The schema version of the document.
SchemaVersion pulumi.StringOutput `pulumi:"schemaVersion"`
// "Creating", "Active" or "Deleting". The current status of the document.
Status pulumi.StringOutput `pulumi:"status"`
// A map of tags to assign to the object. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags pulumi.StringMapOutput `pulumi:"tags"`
// A map of tags assigned to the resource, including those inherited from the provider .
TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
// The target type which defines the kinds of resources the document can run on. For example, /AWS::EC2::Instance. For a list of valid resource types, see AWS Resource Types Reference (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)
TargetType pulumi.StringPtrOutput `pulumi:"targetType"`
// A field specifying the version of the artifact you are creating with the document. For example, "Release 12, Update 6". This value is unique across all versions of a document and cannot be changed for an existing document version.
VersionName pulumi.StringPtrOutput `pulumi:"versionName"`
}
// NewDocument registers a new resource with the given unique name, arguments, and options.
func NewDocument(ctx *pulumi.Context,
name string, args *DocumentArgs, opts ...pulumi.ResourceOption) (*Document, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Content == nil {
return nil, errors.New("invalid value for required argument 'Content'")
}
if args.DocumentType == nil {
return nil, errors.New("invalid value for required argument 'DocumentType'")
}
var resource Document
err := ctx.RegisterResource("aws:ssm/document:Document", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetDocument gets an existing Document 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 GetDocument(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *DocumentState, opts ...pulumi.ResourceOption) (*Document, error) {
var resource Document
err := ctx.ReadResource("aws:ssm/document:Document", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Document resources.
type documentState struct {
Arn *string `pulumi:"arn"`
// One or more configuration blocks describing attachments sources to a version of a document. Defined below.
AttachmentsSources []DocumentAttachmentsSource `pulumi:"attachmentsSources"`
// The JSON or YAML content of the document.
Content *string `pulumi:"content"`
// The date the document was created.
CreatedDate *string `pulumi:"createdDate"`
// The default version of the document.
DefaultVersion *string `pulumi:"defaultVersion"`
// The description of the document.
Description *string `pulumi:"description"`
// The format of the document. Valid document types include: `JSON` and `YAML`
DocumentFormat *string `pulumi:"documentFormat"`
// The type of the document. Valid document types include: `Automation`, `Command`, `Package`, `Policy`, and `Session`
DocumentType *string `pulumi:"documentType"`
// The document version.
DocumentVersion *string `pulumi:"documentVersion"`
// The sha1 or sha256 of the document content
Hash *string `pulumi:"hash"`
// "Sha1" "Sha256". The hashing algorithm used when hashing the content.
HashType *string `pulumi:"hashType"`
// The latest version of the document.
LatestVersion *string `pulumi:"latestVersion"`
// The name of the document.
Name *string `pulumi:"name"`
// The AWS user account of the person who created the document.
Owner *string `pulumi:"owner"`
// The parameters that are available to this document.
Parameters []DocumentParameter `pulumi:"parameters"`
// Additional Permissions to attach to the document. See Permissions below for details.
Permissions map[string]string `pulumi:"permissions"`
// A list of OS platforms compatible with this SSM document, either "Windows" or "Linux".
PlatformTypes []string `pulumi:"platformTypes"`
// The schema version of the document.
SchemaVersion *string `pulumi:"schemaVersion"`
// "Creating", "Active" or "Deleting". The current status of the document.
Status *string `pulumi:"status"`
// A map of tags to assign to the object. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags map[string]string `pulumi:"tags"`
// A map of tags assigned to the resource, including those inherited from the provider .
TagsAll map[string]string `pulumi:"tagsAll"`
// The target type which defines the kinds of resources the document can run on. For example, /AWS::EC2::Instance. For a list of valid resource types, see AWS Resource Types Reference (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)
TargetType *string `pulumi:"targetType"`
// A field specifying the version of the artifact you are creating with the document. For example, "Release 12, Update 6". This value is unique across all versions of a document and cannot be changed for an existing document version.
VersionName *string `pulumi:"versionName"`
}
type DocumentState struct {
Arn pulumi.StringPtrInput
// One or more configuration blocks describing attachments sources to a version of a document. Defined below.
AttachmentsSources DocumentAttachmentsSourceArrayInput
// The JSON or YAML content of the document.
Content pulumi.StringPtrInput
// The date the document was created.
CreatedDate pulumi.StringPtrInput
// The default version of the document.
DefaultVersion pulumi.StringPtrInput
// The description of the document.
Description pulumi.StringPtrInput
// The format of the document. Valid document types include: `JSON` and `YAML`
DocumentFormat pulumi.StringPtrInput
// The type of the document. Valid document types include: `Automation`, `Command`, `Package`, `Policy`, and `Session`
DocumentType pulumi.StringPtrInput
// The document version.
DocumentVersion pulumi.StringPtrInput
// The sha1 or sha256 of the document content
Hash pulumi.StringPtrInput
// "Sha1" "Sha256". The hashing algorithm used when hashing the content.
HashType pulumi.StringPtrInput
// The latest version of the document.
LatestVersion pulumi.StringPtrInput
// The name of the document.
Name pulumi.StringPtrInput
// The AWS user account of the person who created the document.
Owner pulumi.StringPtrInput
// The parameters that are available to this document.
Parameters DocumentParameterArrayInput
// Additional Permissions to attach to the document. See Permissions below for details.
Permissions pulumi.StringMapInput
// A list of OS platforms compatible with this SSM document, either "Windows" or "Linux".
PlatformTypes pulumi.StringArrayInput
// The schema version of the document.
SchemaVersion pulumi.StringPtrInput
// "Creating", "Active" or "Deleting". The current status of the document.
Status pulumi.StringPtrInput
// A map of tags to assign to the object. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags pulumi.StringMapInput
// A map of tags assigned to the resource, including those inherited from the provider .
TagsAll pulumi.StringMapInput
// The target type which defines the kinds of resources the document can run on. For example, /AWS::EC2::Instance. For a list of valid resource types, see AWS Resource Types Reference (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)
TargetType pulumi.StringPtrInput
// A field specifying the version of the artifact you are creating with the document. For example, "Release 12, Update 6". This value is unique across all versions of a document and cannot be changed for an existing document version.
VersionName pulumi.StringPtrInput
}
func (DocumentState) ElementType() reflect.Type {
return reflect.TypeOf((*documentState)(nil)).Elem()
}
type documentArgs struct {
// One or more configuration blocks describing attachments sources to a version of a document. Defined below.
AttachmentsSources []DocumentAttachmentsSource `pulumi:"attachmentsSources"`
// The JSON or YAML content of the document.
Content string `pulumi:"content"`
// The format of the document. Valid document types include: `JSON` and `YAML`
DocumentFormat *string `pulumi:"documentFormat"`
// The type of the document. Valid document types include: `Automation`, `Command`, `Package`, `Policy`, and `Session`
DocumentType string `pulumi:"documentType"`
// The name of the document.
Name *string `pulumi:"name"`
// Additional Permissions to attach to the document. See Permissions below for details.
Permissions map[string]string `pulumi:"permissions"`
// A map of tags to assign to the object. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags map[string]string `pulumi:"tags"`
// The target type which defines the kinds of resources the document can run on. For example, /AWS::EC2::Instance. For a list of valid resource types, see AWS Resource Types Reference (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)
TargetType *string `pulumi:"targetType"`
// A field specifying the version of the artifact you are creating with the document. For example, "Release 12, Update 6". This value is unique across all versions of a document and cannot be changed for an existing document version.
VersionName *string `pulumi:"versionName"`
}
// The set of arguments for constructing a Document resource.
type DocumentArgs struct {
// One or more configuration blocks describing attachments sources to a version of a document. Defined below.
AttachmentsSources DocumentAttachmentsSourceArrayInput
// The JSON or YAML content of the document.
Content pulumi.StringInput
// The format of the document. Valid document types include: `JSON` and `YAML`
DocumentFormat pulumi.StringPtrInput
// The type of the document. Valid document types include: `Automation`, `Command`, `Package`, `Policy`, and `Session`
DocumentType pulumi.StringInput
// The name of the document.
Name pulumi.StringPtrInput
// Additional Permissions to attach to the document. See Permissions below for details.
Permissions pulumi.StringMapInput
// A map of tags to assign to the object. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags pulumi.StringMapInput
// The target type which defines the kinds of resources the document can run on. For example, /AWS::EC2::Instance. For a list of valid resource types, see AWS Resource Types Reference (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)
TargetType pulumi.StringPtrInput
// A field specifying the version of the artifact you are creating with the document. For example, "Release 12, Update 6". This value is unique across all versions of a document and cannot be changed for an existing document version.
VersionName pulumi.StringPtrInput
}
func (DocumentArgs) ElementType() reflect.Type {
return reflect.TypeOf((*documentArgs)(nil)).Elem()
}
type DocumentInput interface {
pulumi.Input
ToDocumentOutput() DocumentOutput
ToDocumentOutputWithContext(ctx context.Context) DocumentOutput
}
func (*Document) ElementType() reflect.Type {
return reflect.TypeOf((**Document)(nil)).Elem()
}
func (i *Document) ToDocumentOutput() DocumentOutput {
return i.ToDocumentOutputWithContext(context.Background())
}
func (i *Document) ToDocumentOutputWithContext(ctx context.Context) DocumentOutput {
return pulumi.ToOutputWithContext(ctx, i).(DocumentOutput)
}
// DocumentArrayInput is an input type that accepts DocumentArray and DocumentArrayOutput values.
// You can construct a concrete instance of `DocumentArrayInput` via:
//
// DocumentArray{ DocumentArgs{...} }
type DocumentArrayInput interface {
pulumi.Input
ToDocumentArrayOutput() DocumentArrayOutput
ToDocumentArrayOutputWithContext(context.Context) DocumentArrayOutput
}
type DocumentArray []DocumentInput
func (DocumentArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Document)(nil)).Elem()
}
func (i DocumentArray) ToDocumentArrayOutput() DocumentArrayOutput {
return i.ToDocumentArrayOutputWithContext(context.Background())
}
func (i DocumentArray) ToDocumentArrayOutputWithContext(ctx context.Context) DocumentArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(DocumentArrayOutput)
}
// DocumentMapInput is an input type that accepts DocumentMap and DocumentMapOutput values.
// You can construct a concrete instance of `DocumentMapInput` via:
//
// DocumentMap{ "key": DocumentArgs{...} }
type DocumentMapInput interface {
pulumi.Input
ToDocumentMapOutput() DocumentMapOutput
ToDocumentMapOutputWithContext(context.Context) DocumentMapOutput
}
type DocumentMap map[string]DocumentInput
func (DocumentMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Document)(nil)).Elem()
}
func (i DocumentMap) ToDocumentMapOutput() DocumentMapOutput {
return i.ToDocumentMapOutputWithContext(context.Background())
}
func (i DocumentMap) ToDocumentMapOutputWithContext(ctx context.Context) DocumentMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(DocumentMapOutput)
}
type DocumentOutput struct{ *pulumi.OutputState }
func (DocumentOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Document)(nil)).Elem()
}
func (o DocumentOutput) ToDocumentOutput() DocumentOutput {
return o
}
func (o DocumentOutput) ToDocumentOutputWithContext(ctx context.Context) DocumentOutput {
return o
}
type DocumentArrayOutput struct{ *pulumi.OutputState }
func (DocumentArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Document)(nil)).Elem()
}
func (o DocumentArrayOutput) ToDocumentArrayOutput() DocumentArrayOutput {
return o
}
func (o DocumentArrayOutput) ToDocumentArrayOutputWithContext(ctx context.Context) DocumentArrayOutput {
return o
}
func (o DocumentArrayOutput) Index(i pulumi.IntInput) DocumentOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Document {
return vs[0].([]*Document)[vs[1].(int)]
}).(DocumentOutput)
}
type DocumentMapOutput struct{ *pulumi.OutputState }
func (DocumentMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Document)(nil)).Elem()
}
func (o DocumentMapOutput) ToDocumentMapOutput() DocumentMapOutput {
return o
}
func (o DocumentMapOutput) ToDocumentMapOutputWithContext(ctx context.Context) DocumentMapOutput {
return o
}
func (o DocumentMapOutput) MapIndex(k pulumi.StringInput) DocumentOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Document {
return vs[0].(map[string]*Document)[vs[1].(string)]
}).(DocumentOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*DocumentInput)(nil)).Elem(), &Document{})
pulumi.RegisterInputType(reflect.TypeOf((*DocumentArrayInput)(nil)).Elem(), DocumentArray{})
pulumi.RegisterInputType(reflect.TypeOf((*DocumentMapInput)(nil)).Elem(), DocumentMap{})
pulumi.RegisterOutputType(DocumentOutput{})
pulumi.RegisterOutputType(DocumentArrayOutput{})
pulumi.RegisterOutputType(DocumentMapOutput{})
}