/
image.ts
272 lines (263 loc) · 10.4 KB
/
image.ts
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
// *** 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! ***
import * as pulumi from "@pulumi/pulumi";
import * as utilities from "./utilities";
/**
* Provides a Linode Image resource. This can be used to create, modify, and delete Linodes Images. Linode Images are snapshots of a Linode Instance Disk which can then be used to provision more Linode Instances. Images can be used across regions.
*
* For more information, see [Linode's documentation on Images](https://www.linode.com/docs/platform/disk-images/linode-images/) and the [Linode APIv4 docs](https://developers.linode.com/api/v4#operation/createImage).
*
* ## Example Usage
*
* The following example shows how one might use this resource to create an Image from a Linode Instance Disk and then deploy a new Linode Instance in another region using that Image.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as linode from "@pulumi/linode";
*
* const foo = new linode.Instance("foo", {
* region: "us-central",
* type: "g6-nanode-1",
* });
* const bar = new linode.Image("bar", {
* description: "Image taken from foo",
* diskId: foo.disks.apply(disks => disks[0].id),
* label: "foo-sda-image",
* linodeId: foo.id,
* });
* const barBased = new linode.Instance("barBased", {
* image: bar.id,
* region: "eu-west",
* type: foo.type,
* });
* ```
*
* ## Attributes
*
* This resource exports the following attributes:
*
* * `id` - The unique ID of this Image. The ID of private images begin with `private/` followed by the numeric identifier of the private image, for example `private/12345`.
*
* * `created` - When this Image was created.
*
* * `createdBy` - The name of the User who created this Image.
*
* * `deprecated` - Whether or not this Image is deprecated. Will only be True for deprecated public Images.
*
* * `isPublic` - True if the Image is public.
*
* * `size` - The minimum size this Image needs to deploy. Size is in MB.
*
* * `type` - How the Image was created. 'Manual' Images can be created at any time. 'Automatic' images are created automatically from a deleted Linode.
*
* * `expiry` - Only Images created automatically (from a deleted Linode; type=automatic) will expire.
*
* * `vendor` - The upstream distribution vendor. Nil for private Images.
*
* > This content is derived from https://github.com/terraform-providers/terraform-provider-linode/blob/master/website/docs/r/image.html.md.
*/
export class Image extends pulumi.CustomResource {
/**
* Get an existing Image resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
*/
public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: ImageState, opts?: pulumi.CustomResourceOptions): Image {
return new Image(name, <any>state, { ...opts, id: id });
}
/** @internal */
public static readonly __pulumiType = 'linode:index/image:Image';
/**
* Returns true if the given object is an instance of Image. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
public static isInstance(obj: any): obj is Image {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === Image.__pulumiType;
}
/**
* When this Image was created.
*/
public /*out*/ readonly created!: pulumi.Output<string>;
/**
* The name of the User who created this Image.
*/
public /*out*/ readonly createdBy!: pulumi.Output<string>;
/**
* Whether or not this Image is deprecated. Will only be True for deprecated public Images.
*/
public /*out*/ readonly deprecated!: pulumi.Output<boolean>;
/**
* A detailed description of this Image.
*/
public readonly description!: pulumi.Output<string | undefined>;
/**
* The ID of the Linode Disk that this Image will be created from.
*/
public readonly diskId!: pulumi.Output<number>;
/**
* Only Images created automatically (from a deleted Linode; type=automatic) will expire.
*/
public /*out*/ readonly expiry!: pulumi.Output<string>;
/**
* True if the Image is public.
*/
public /*out*/ readonly isPublic!: pulumi.Output<boolean>;
/**
* A short description of the Image. Labels cannot contain special characters.
*/
public readonly label!: pulumi.Output<string>;
/**
* The ID of the Linode that this Image will be created from.
*/
public readonly linodeId!: pulumi.Output<number>;
/**
* The minimum size this Image needs to deploy. Size is in MB.
*/
public /*out*/ readonly size!: pulumi.Output<number>;
/**
* How the Image was created. 'Manual' Images can be created at any time. 'Automatic' images are created automatically
* from a deleted Linode.
*/
public /*out*/ readonly type!: pulumi.Output<string>;
/**
* The upstream distribution vendor. Nil for private Images.
*/
public /*out*/ readonly vendor!: pulumi.Output<string>;
/**
* Create a Image resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: ImageArgs, opts?: pulumi.CustomResourceOptions)
constructor(name: string, argsOrState?: ImageArgs | ImageState, opts?: pulumi.CustomResourceOptions) {
let inputs: pulumi.Inputs = {};
if (opts && opts.id) {
const state = argsOrState as ImageState | undefined;
inputs["created"] = state ? state.created : undefined;
inputs["createdBy"] = state ? state.createdBy : undefined;
inputs["deprecated"] = state ? state.deprecated : undefined;
inputs["description"] = state ? state.description : undefined;
inputs["diskId"] = state ? state.diskId : undefined;
inputs["expiry"] = state ? state.expiry : undefined;
inputs["isPublic"] = state ? state.isPublic : undefined;
inputs["label"] = state ? state.label : undefined;
inputs["linodeId"] = state ? state.linodeId : undefined;
inputs["size"] = state ? state.size : undefined;
inputs["type"] = state ? state.type : undefined;
inputs["vendor"] = state ? state.vendor : undefined;
} else {
const args = argsOrState as ImageArgs | undefined;
if (!args || args.diskId === undefined) {
throw new Error("Missing required property 'diskId'");
}
if (!args || args.label === undefined) {
throw new Error("Missing required property 'label'");
}
if (!args || args.linodeId === undefined) {
throw new Error("Missing required property 'linodeId'");
}
inputs["description"] = args ? args.description : undefined;
inputs["diskId"] = args ? args.diskId : undefined;
inputs["label"] = args ? args.label : undefined;
inputs["linodeId"] = args ? args.linodeId : undefined;
inputs["created"] = undefined /*out*/;
inputs["createdBy"] = undefined /*out*/;
inputs["deprecated"] = undefined /*out*/;
inputs["expiry"] = undefined /*out*/;
inputs["isPublic"] = undefined /*out*/;
inputs["size"] = undefined /*out*/;
inputs["type"] = undefined /*out*/;
inputs["vendor"] = undefined /*out*/;
}
if (!opts) {
opts = {}
}
if (!opts.version) {
opts.version = utilities.getVersion();
}
super(Image.__pulumiType, name, inputs, opts);
}
}
/**
* Input properties used for looking up and filtering Image resources.
*/
export interface ImageState {
/**
* When this Image was created.
*/
readonly created?: pulumi.Input<string>;
/**
* The name of the User who created this Image.
*/
readonly createdBy?: pulumi.Input<string>;
/**
* Whether or not this Image is deprecated. Will only be True for deprecated public Images.
*/
readonly deprecated?: pulumi.Input<boolean>;
/**
* A detailed description of this Image.
*/
readonly description?: pulumi.Input<string>;
/**
* The ID of the Linode Disk that this Image will be created from.
*/
readonly diskId?: pulumi.Input<number>;
/**
* Only Images created automatically (from a deleted Linode; type=automatic) will expire.
*/
readonly expiry?: pulumi.Input<string>;
/**
* True if the Image is public.
*/
readonly isPublic?: pulumi.Input<boolean>;
/**
* A short description of the Image. Labels cannot contain special characters.
*/
readonly label?: pulumi.Input<string>;
/**
* The ID of the Linode that this Image will be created from.
*/
readonly linodeId?: pulumi.Input<number>;
/**
* The minimum size this Image needs to deploy. Size is in MB.
*/
readonly size?: pulumi.Input<number>;
/**
* How the Image was created. 'Manual' Images can be created at any time. 'Automatic' images are created automatically
* from a deleted Linode.
*/
readonly type?: pulumi.Input<string>;
/**
* The upstream distribution vendor. Nil for private Images.
*/
readonly vendor?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a Image resource.
*/
export interface ImageArgs {
/**
* A detailed description of this Image.
*/
readonly description?: pulumi.Input<string>;
/**
* The ID of the Linode Disk that this Image will be created from.
*/
readonly diskId: pulumi.Input<number>;
/**
* A short description of the Image. Labels cannot contain special characters.
*/
readonly label: pulumi.Input<string>;
/**
* The ID of the Linode that this Image will be created from.
*/
readonly linodeId: pulumi.Input<number>;
}