generated from pulumi/pulumi-tf-provider-boilerplate
/
image.go
437 lines (379 loc) · 21.5 KB
/
image.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
// 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 ecs
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Creates a custom image. You can then use a custom image to create ECS instances (RunInstances) or change the system disk for an existing instance (ReplaceSystemDisk).
//
// > **NOTE:** If you want to create a template from an ECS instance, you can specify the instance ID (InstanceId) to create a custom image. You must make sure that the status of the specified instance is Running or Stopped. After a successful invocation, each disk of the specified instance has a new snapshot created.
//
// > **NOTE:** If you want to create a custom image based on the system disk of your ECS instance, you can specify one of the system disk snapshots (SnapshotId) to create a custom image. However, the specified snapshot cannot be created on or before July 15, 2013.
//
// > **NOTE:** If you want to combine snapshots of multiple disks into an image template, you can specify DiskDeviceMapping to create a custom image.
//
// > **NOTE:** Available in 1.64.0+
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/rhysmdnz/pulumi-alicloud/sdk/go/alicloud/ecs"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := ecs.NewImage(ctx, "default", &ecs.ImageArgs{
// Architecture: pulumi.String("x86_64"),
// Description: pulumi.String("test-image"),
// ImageName: pulumi.String("test-image"),
// InstanceId: pulumi.String("i-bp1g6zv0ce8oghu7k***"),
// Platform: pulumi.String("CentOS"),
// ResourceGroupId: pulumi.String("rg-bp67acfmxazb4ph***"),
// Tags: pulumi.AnyMap{
// "FinanceDept": pulumi.Any("FinanceDeptJoshua"),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// image can be imported using the id, e.g.
//
// ```sh
//
// $ pulumi import alicloud:ecs/image:Image default m-uf66871ape***yg1q***
//
// ```
type Image struct {
pulumi.CustomResourceState
// Specifies the architecture of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: `i386` , Default is `x8664`.
Architecture pulumi.StringPtrOutput `pulumi:"architecture"`
DeleteAutoSnapshot pulumi.BoolPtrOutput `pulumi:"deleteAutoSnapshot"`
// The description of the image. It must be 2 to 256 characters in length and must not start with http:// or https://. Default value: null.
Description pulumi.StringPtrOutput `pulumi:"description"`
// Description of the system with disks and snapshots under the image.
DiskDeviceMappings ImageDiskDeviceMappingArrayOutput `pulumi:"diskDeviceMappings"`
// Indicates whether to force delete the custom image, Default is `false`.
// - true:Force deletes the custom image, regardless of whether the image is currently being used by other instances.
// - false:Verifies that the image is not currently in use by any other instances before deleting the image.
Force pulumi.BoolPtrOutput `pulumi:"force"`
// The image name. It must be 2 to 128 characters in length, and must begin with a letter or Chinese character (beginning with http:// or https:// is not allowed). It can contain digits, colons (:), underscores (_), or hyphens (-). Default value: null.
ImageName pulumi.StringOutput `pulumi:"imageName"`
// The instance ID.
InstanceId pulumi.StringPtrOutput `pulumi:"instanceId"`
// Deprecated: Attribute 'name' has been deprecated from version 1.69.0. Use `image_name` instead.
Name pulumi.StringOutput `pulumi:"name"`
// Specifies the operating system platform of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: `CentOS`, `Ubuntu`, `SUSE`, `OpenSUSE`, `RedHat`, `Debian`, `CoreOS`, `Aliyun Linux`, `Windows Server 2003`, `Windows Server 2008`, `Windows Server 2012`, `Windows 7`, Default is `Others Linux`.
Platform pulumi.StringPtrOutput `pulumi:"platform"`
// The ID of the enterprise resource group to which a custom image belongs
ResourceGroupId pulumi.StringPtrOutput `pulumi:"resourceGroupId"`
// Specifies a snapshot that is used to create a combined custom image.
SnapshotId pulumi.StringPtrOutput `pulumi:"snapshotId"`
// The tag value of an image. The value of N ranges from 1 to 20.
Tags pulumi.MapOutput `pulumi:"tags"`
}
// NewImage registers a new resource with the given unique name, arguments, and options.
func NewImage(ctx *pulumi.Context,
name string, args *ImageArgs, opts ...pulumi.ResourceOption) (*Image, error) {
if args == nil {
args = &ImageArgs{}
}
opts = pkgResourceDefaultOpts(opts)
var resource Image
err := ctx.RegisterResource("alicloud:ecs/image:Image", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetImage gets an existing Image 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 GetImage(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ImageState, opts ...pulumi.ResourceOption) (*Image, error) {
var resource Image
err := ctx.ReadResource("alicloud:ecs/image:Image", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Image resources.
type imageState struct {
// Specifies the architecture of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: `i386` , Default is `x8664`.
Architecture *string `pulumi:"architecture"`
DeleteAutoSnapshot *bool `pulumi:"deleteAutoSnapshot"`
// The description of the image. It must be 2 to 256 characters in length and must not start with http:// or https://. Default value: null.
Description *string `pulumi:"description"`
// Description of the system with disks and snapshots under the image.
DiskDeviceMappings []ImageDiskDeviceMapping `pulumi:"diskDeviceMappings"`
// Indicates whether to force delete the custom image, Default is `false`.
// - true:Force deletes the custom image, regardless of whether the image is currently being used by other instances.
// - false:Verifies that the image is not currently in use by any other instances before deleting the image.
Force *bool `pulumi:"force"`
// The image name. It must be 2 to 128 characters in length, and must begin with a letter or Chinese character (beginning with http:// or https:// is not allowed). It can contain digits, colons (:), underscores (_), or hyphens (-). Default value: null.
ImageName *string `pulumi:"imageName"`
// The instance ID.
InstanceId *string `pulumi:"instanceId"`
// Deprecated: Attribute 'name' has been deprecated from version 1.69.0. Use `image_name` instead.
Name *string `pulumi:"name"`
// Specifies the operating system platform of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: `CentOS`, `Ubuntu`, `SUSE`, `OpenSUSE`, `RedHat`, `Debian`, `CoreOS`, `Aliyun Linux`, `Windows Server 2003`, `Windows Server 2008`, `Windows Server 2012`, `Windows 7`, Default is `Others Linux`.
Platform *string `pulumi:"platform"`
// The ID of the enterprise resource group to which a custom image belongs
ResourceGroupId *string `pulumi:"resourceGroupId"`
// Specifies a snapshot that is used to create a combined custom image.
SnapshotId *string `pulumi:"snapshotId"`
// The tag value of an image. The value of N ranges from 1 to 20.
Tags map[string]interface{} `pulumi:"tags"`
}
type ImageState struct {
// Specifies the architecture of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: `i386` , Default is `x8664`.
Architecture pulumi.StringPtrInput
DeleteAutoSnapshot pulumi.BoolPtrInput
// The description of the image. It must be 2 to 256 characters in length and must not start with http:// or https://. Default value: null.
Description pulumi.StringPtrInput
// Description of the system with disks and snapshots under the image.
DiskDeviceMappings ImageDiskDeviceMappingArrayInput
// Indicates whether to force delete the custom image, Default is `false`.
// - true:Force deletes the custom image, regardless of whether the image is currently being used by other instances.
// - false:Verifies that the image is not currently in use by any other instances before deleting the image.
Force pulumi.BoolPtrInput
// The image name. It must be 2 to 128 characters in length, and must begin with a letter or Chinese character (beginning with http:// or https:// is not allowed). It can contain digits, colons (:), underscores (_), or hyphens (-). Default value: null.
ImageName pulumi.StringPtrInput
// The instance ID.
InstanceId pulumi.StringPtrInput
// Deprecated: Attribute 'name' has been deprecated from version 1.69.0. Use `image_name` instead.
Name pulumi.StringPtrInput
// Specifies the operating system platform of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: `CentOS`, `Ubuntu`, `SUSE`, `OpenSUSE`, `RedHat`, `Debian`, `CoreOS`, `Aliyun Linux`, `Windows Server 2003`, `Windows Server 2008`, `Windows Server 2012`, `Windows 7`, Default is `Others Linux`.
Platform pulumi.StringPtrInput
// The ID of the enterprise resource group to which a custom image belongs
ResourceGroupId pulumi.StringPtrInput
// Specifies a snapshot that is used to create a combined custom image.
SnapshotId pulumi.StringPtrInput
// The tag value of an image. The value of N ranges from 1 to 20.
Tags pulumi.MapInput
}
func (ImageState) ElementType() reflect.Type {
return reflect.TypeOf((*imageState)(nil)).Elem()
}
type imageArgs struct {
// Specifies the architecture of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: `i386` , Default is `x8664`.
Architecture *string `pulumi:"architecture"`
DeleteAutoSnapshot *bool `pulumi:"deleteAutoSnapshot"`
// The description of the image. It must be 2 to 256 characters in length and must not start with http:// or https://. Default value: null.
Description *string `pulumi:"description"`
// Description of the system with disks and snapshots under the image.
DiskDeviceMappings []ImageDiskDeviceMapping `pulumi:"diskDeviceMappings"`
// Indicates whether to force delete the custom image, Default is `false`.
// - true:Force deletes the custom image, regardless of whether the image is currently being used by other instances.
// - false:Verifies that the image is not currently in use by any other instances before deleting the image.
Force *bool `pulumi:"force"`
// The image name. It must be 2 to 128 characters in length, and must begin with a letter or Chinese character (beginning with http:// or https:// is not allowed). It can contain digits, colons (:), underscores (_), or hyphens (-). Default value: null.
ImageName *string `pulumi:"imageName"`
// The instance ID.
InstanceId *string `pulumi:"instanceId"`
// Deprecated: Attribute 'name' has been deprecated from version 1.69.0. Use `image_name` instead.
Name *string `pulumi:"name"`
// Specifies the operating system platform of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: `CentOS`, `Ubuntu`, `SUSE`, `OpenSUSE`, `RedHat`, `Debian`, `CoreOS`, `Aliyun Linux`, `Windows Server 2003`, `Windows Server 2008`, `Windows Server 2012`, `Windows 7`, Default is `Others Linux`.
Platform *string `pulumi:"platform"`
// The ID of the enterprise resource group to which a custom image belongs
ResourceGroupId *string `pulumi:"resourceGroupId"`
// Specifies a snapshot that is used to create a combined custom image.
SnapshotId *string `pulumi:"snapshotId"`
// The tag value of an image. The value of N ranges from 1 to 20.
Tags map[string]interface{} `pulumi:"tags"`
}
// The set of arguments for constructing a Image resource.
type ImageArgs struct {
// Specifies the architecture of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: `i386` , Default is `x8664`.
Architecture pulumi.StringPtrInput
DeleteAutoSnapshot pulumi.BoolPtrInput
// The description of the image. It must be 2 to 256 characters in length and must not start with http:// or https://. Default value: null.
Description pulumi.StringPtrInput
// Description of the system with disks and snapshots under the image.
DiskDeviceMappings ImageDiskDeviceMappingArrayInput
// Indicates whether to force delete the custom image, Default is `false`.
// - true:Force deletes the custom image, regardless of whether the image is currently being used by other instances.
// - false:Verifies that the image is not currently in use by any other instances before deleting the image.
Force pulumi.BoolPtrInput
// The image name. It must be 2 to 128 characters in length, and must begin with a letter or Chinese character (beginning with http:// or https:// is not allowed). It can contain digits, colons (:), underscores (_), or hyphens (-). Default value: null.
ImageName pulumi.StringPtrInput
// The instance ID.
InstanceId pulumi.StringPtrInput
// Deprecated: Attribute 'name' has been deprecated from version 1.69.0. Use `image_name` instead.
Name pulumi.StringPtrInput
// Specifies the operating system platform of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: `CentOS`, `Ubuntu`, `SUSE`, `OpenSUSE`, `RedHat`, `Debian`, `CoreOS`, `Aliyun Linux`, `Windows Server 2003`, `Windows Server 2008`, `Windows Server 2012`, `Windows 7`, Default is `Others Linux`.
Platform pulumi.StringPtrInput
// The ID of the enterprise resource group to which a custom image belongs
ResourceGroupId pulumi.StringPtrInput
// Specifies a snapshot that is used to create a combined custom image.
SnapshotId pulumi.StringPtrInput
// The tag value of an image. The value of N ranges from 1 to 20.
Tags pulumi.MapInput
}
func (ImageArgs) ElementType() reflect.Type {
return reflect.TypeOf((*imageArgs)(nil)).Elem()
}
type ImageInput interface {
pulumi.Input
ToImageOutput() ImageOutput
ToImageOutputWithContext(ctx context.Context) ImageOutput
}
func (*Image) ElementType() reflect.Type {
return reflect.TypeOf((**Image)(nil)).Elem()
}
func (i *Image) ToImageOutput() ImageOutput {
return i.ToImageOutputWithContext(context.Background())
}
func (i *Image) ToImageOutputWithContext(ctx context.Context) ImageOutput {
return pulumi.ToOutputWithContext(ctx, i).(ImageOutput)
}
// ImageArrayInput is an input type that accepts ImageArray and ImageArrayOutput values.
// You can construct a concrete instance of `ImageArrayInput` via:
//
// ImageArray{ ImageArgs{...} }
type ImageArrayInput interface {
pulumi.Input
ToImageArrayOutput() ImageArrayOutput
ToImageArrayOutputWithContext(context.Context) ImageArrayOutput
}
type ImageArray []ImageInput
func (ImageArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Image)(nil)).Elem()
}
func (i ImageArray) ToImageArrayOutput() ImageArrayOutput {
return i.ToImageArrayOutputWithContext(context.Background())
}
func (i ImageArray) ToImageArrayOutputWithContext(ctx context.Context) ImageArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ImageArrayOutput)
}
// ImageMapInput is an input type that accepts ImageMap and ImageMapOutput values.
// You can construct a concrete instance of `ImageMapInput` via:
//
// ImageMap{ "key": ImageArgs{...} }
type ImageMapInput interface {
pulumi.Input
ToImageMapOutput() ImageMapOutput
ToImageMapOutputWithContext(context.Context) ImageMapOutput
}
type ImageMap map[string]ImageInput
func (ImageMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Image)(nil)).Elem()
}
func (i ImageMap) ToImageMapOutput() ImageMapOutput {
return i.ToImageMapOutputWithContext(context.Background())
}
func (i ImageMap) ToImageMapOutputWithContext(ctx context.Context) ImageMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ImageMapOutput)
}
type ImageOutput struct{ *pulumi.OutputState }
func (ImageOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Image)(nil)).Elem()
}
func (o ImageOutput) ToImageOutput() ImageOutput {
return o
}
func (o ImageOutput) ToImageOutputWithContext(ctx context.Context) ImageOutput {
return o
}
// Specifies the architecture of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: `i386` , Default is `x8664`.
func (o ImageOutput) Architecture() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Image) pulumi.StringPtrOutput { return v.Architecture }).(pulumi.StringPtrOutput)
}
func (o ImageOutput) DeleteAutoSnapshot() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *Image) pulumi.BoolPtrOutput { return v.DeleteAutoSnapshot }).(pulumi.BoolPtrOutput)
}
// The description of the image. It must be 2 to 256 characters in length and must not start with http:// or https://. Default value: null.
func (o ImageOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Image) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// Description of the system with disks and snapshots under the image.
func (o ImageOutput) DiskDeviceMappings() ImageDiskDeviceMappingArrayOutput {
return o.ApplyT(func(v *Image) ImageDiskDeviceMappingArrayOutput { return v.DiskDeviceMappings }).(ImageDiskDeviceMappingArrayOutput)
}
// Indicates whether to force delete the custom image, Default is `false`.
// - true:Force deletes the custom image, regardless of whether the image is currently being used by other instances.
// - false:Verifies that the image is not currently in use by any other instances before deleting the image.
func (o ImageOutput) Force() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *Image) pulumi.BoolPtrOutput { return v.Force }).(pulumi.BoolPtrOutput)
}
// The image name. It must be 2 to 128 characters in length, and must begin with a letter or Chinese character (beginning with http:// or https:// is not allowed). It can contain digits, colons (:), underscores (_), or hyphens (-). Default value: null.
func (o ImageOutput) ImageName() pulumi.StringOutput {
return o.ApplyT(func(v *Image) pulumi.StringOutput { return v.ImageName }).(pulumi.StringOutput)
}
// The instance ID.
func (o ImageOutput) InstanceId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Image) pulumi.StringPtrOutput { return v.InstanceId }).(pulumi.StringPtrOutput)
}
// Deprecated: Attribute 'name' has been deprecated from version 1.69.0. Use `image_name` instead.
func (o ImageOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *Image) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Specifies the operating system platform of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: `CentOS`, `Ubuntu`, `SUSE`, `OpenSUSE`, `RedHat`, `Debian`, `CoreOS`, `Aliyun Linux`, `Windows Server 2003`, `Windows Server 2008`, `Windows Server 2012`, `Windows 7`, Default is `Others Linux`.
func (o ImageOutput) Platform() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Image) pulumi.StringPtrOutput { return v.Platform }).(pulumi.StringPtrOutput)
}
// The ID of the enterprise resource group to which a custom image belongs
func (o ImageOutput) ResourceGroupId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Image) pulumi.StringPtrOutput { return v.ResourceGroupId }).(pulumi.StringPtrOutput)
}
// Specifies a snapshot that is used to create a combined custom image.
func (o ImageOutput) SnapshotId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Image) pulumi.StringPtrOutput { return v.SnapshotId }).(pulumi.StringPtrOutput)
}
// The tag value of an image. The value of N ranges from 1 to 20.
func (o ImageOutput) Tags() pulumi.MapOutput {
return o.ApplyT(func(v *Image) pulumi.MapOutput { return v.Tags }).(pulumi.MapOutput)
}
type ImageArrayOutput struct{ *pulumi.OutputState }
func (ImageArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Image)(nil)).Elem()
}
func (o ImageArrayOutput) ToImageArrayOutput() ImageArrayOutput {
return o
}
func (o ImageArrayOutput) ToImageArrayOutputWithContext(ctx context.Context) ImageArrayOutput {
return o
}
func (o ImageArrayOutput) Index(i pulumi.IntInput) ImageOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Image {
return vs[0].([]*Image)[vs[1].(int)]
}).(ImageOutput)
}
type ImageMapOutput struct{ *pulumi.OutputState }
func (ImageMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Image)(nil)).Elem()
}
func (o ImageMapOutput) ToImageMapOutput() ImageMapOutput {
return o
}
func (o ImageMapOutput) ToImageMapOutputWithContext(ctx context.Context) ImageMapOutput {
return o
}
func (o ImageMapOutput) MapIndex(k pulumi.StringInput) ImageOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Image {
return vs[0].(map[string]*Image)[vs[1].(string)]
}).(ImageOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ImageInput)(nil)).Elem(), &Image{})
pulumi.RegisterInputType(reflect.TypeOf((*ImageArrayInput)(nil)).Elem(), ImageArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ImageMapInput)(nil)).Elem(), ImageMap{})
pulumi.RegisterOutputType(ImageOutput{})
pulumi.RegisterOutputType(ImageArrayOutput{})
pulumi.RegisterOutputType(ImageMapOutput{})
}