-
Notifications
You must be signed in to change notification settings - Fork 151
/
function.go
348 lines (287 loc) · 11.1 KB
/
function.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
// *** 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 cloudfront
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a CloudFront Function resource. With CloudFront Functions in Amazon CloudFront, you can write lightweight functions in JavaScript for high-scale, latency-sensitive CDN customizations.
//
// See [CloudFront Functions](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-functions.html)
//
// > **NOTE:** You cannot delete a function if it’s associated with a cache behavior. First, update your distributions to remove the function association from all cache behaviors, then delete the function.
//
// ## Example Usage
//
// ## Import
//
// CloudFront Functions can be imported using the `name`, e.g.
//
// ```sh
// $ pulumi import aws:cloudfront/function:Function test my_test_function
// ```
type Function struct {
pulumi.CustomResourceState
// Amazon Resource Name (ARN) identifying your CloudFront Function.
Arn pulumi.StringOutput `pulumi:"arn"`
// Source code of the function
Code pulumi.StringOutput `pulumi:"code"`
// Comment.
Comment pulumi.StringPtrOutput `pulumi:"comment"`
// ETag hash of the function
Etag pulumi.StringOutput `pulumi:"etag"`
// Unique name for your CloudFront Function.
Name pulumi.StringOutput `pulumi:"name"`
// Whether to publish creation/change as Live CloudFront Function Version. Defaults to `true`.
Publish pulumi.BoolPtrOutput `pulumi:"publish"`
// Identifier of the function's runtime. Currently only `cloudfront-js-1.0` is valid.
Runtime pulumi.StringOutput `pulumi:"runtime"`
// Status of the function. Can be `UNPUBLISHED`, `UNASSOCIATED` or `ASSOCIATED`.
Status pulumi.StringOutput `pulumi:"status"`
}
// NewFunction registers a new resource with the given unique name, arguments, and options.
func NewFunction(ctx *pulumi.Context,
name string, args *FunctionArgs, opts ...pulumi.ResourceOption) (*Function, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Code == nil {
return nil, errors.New("invalid value for required argument 'Code'")
}
if args.Runtime == nil {
return nil, errors.New("invalid value for required argument 'Runtime'")
}
var resource Function
err := ctx.RegisterResource("aws:cloudfront/function:Function", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetFunction gets an existing Function 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 GetFunction(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *FunctionState, opts ...pulumi.ResourceOption) (*Function, error) {
var resource Function
err := ctx.ReadResource("aws:cloudfront/function:Function", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Function resources.
type functionState struct {
// Amazon Resource Name (ARN) identifying your CloudFront Function.
Arn *string `pulumi:"arn"`
// Source code of the function
Code *string `pulumi:"code"`
// Comment.
Comment *string `pulumi:"comment"`
// ETag hash of the function
Etag *string `pulumi:"etag"`
// Unique name for your CloudFront Function.
Name *string `pulumi:"name"`
// Whether to publish creation/change as Live CloudFront Function Version. Defaults to `true`.
Publish *bool `pulumi:"publish"`
// Identifier of the function's runtime. Currently only `cloudfront-js-1.0` is valid.
Runtime *string `pulumi:"runtime"`
// Status of the function. Can be `UNPUBLISHED`, `UNASSOCIATED` or `ASSOCIATED`.
Status *string `pulumi:"status"`
}
type FunctionState struct {
// Amazon Resource Name (ARN) identifying your CloudFront Function.
Arn pulumi.StringPtrInput
// Source code of the function
Code pulumi.StringPtrInput
// Comment.
Comment pulumi.StringPtrInput
// ETag hash of the function
Etag pulumi.StringPtrInput
// Unique name for your CloudFront Function.
Name pulumi.StringPtrInput
// Whether to publish creation/change as Live CloudFront Function Version. Defaults to `true`.
Publish pulumi.BoolPtrInput
// Identifier of the function's runtime. Currently only `cloudfront-js-1.0` is valid.
Runtime pulumi.StringPtrInput
// Status of the function. Can be `UNPUBLISHED`, `UNASSOCIATED` or `ASSOCIATED`.
Status pulumi.StringPtrInput
}
func (FunctionState) ElementType() reflect.Type {
return reflect.TypeOf((*functionState)(nil)).Elem()
}
type functionArgs struct {
// Source code of the function
Code string `pulumi:"code"`
// Comment.
Comment *string `pulumi:"comment"`
// Unique name for your CloudFront Function.
Name *string `pulumi:"name"`
// Whether to publish creation/change as Live CloudFront Function Version. Defaults to `true`.
Publish *bool `pulumi:"publish"`
// Identifier of the function's runtime. Currently only `cloudfront-js-1.0` is valid.
Runtime string `pulumi:"runtime"`
}
// The set of arguments for constructing a Function resource.
type FunctionArgs struct {
// Source code of the function
Code pulumi.StringInput
// Comment.
Comment pulumi.StringPtrInput
// Unique name for your CloudFront Function.
Name pulumi.StringPtrInput
// Whether to publish creation/change as Live CloudFront Function Version. Defaults to `true`.
Publish pulumi.BoolPtrInput
// Identifier of the function's runtime. Currently only `cloudfront-js-1.0` is valid.
Runtime pulumi.StringInput
}
func (FunctionArgs) ElementType() reflect.Type {
return reflect.TypeOf((*functionArgs)(nil)).Elem()
}
type FunctionInput interface {
pulumi.Input
ToFunctionOutput() FunctionOutput
ToFunctionOutputWithContext(ctx context.Context) FunctionOutput
}
func (*Function) ElementType() reflect.Type {
return reflect.TypeOf((*Function)(nil))
}
func (i *Function) ToFunctionOutput() FunctionOutput {
return i.ToFunctionOutputWithContext(context.Background())
}
func (i *Function) ToFunctionOutputWithContext(ctx context.Context) FunctionOutput {
return pulumi.ToOutputWithContext(ctx, i).(FunctionOutput)
}
func (i *Function) ToFunctionPtrOutput() FunctionPtrOutput {
return i.ToFunctionPtrOutputWithContext(context.Background())
}
func (i *Function) ToFunctionPtrOutputWithContext(ctx context.Context) FunctionPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(FunctionPtrOutput)
}
type FunctionPtrInput interface {
pulumi.Input
ToFunctionPtrOutput() FunctionPtrOutput
ToFunctionPtrOutputWithContext(ctx context.Context) FunctionPtrOutput
}
type functionPtrType FunctionArgs
func (*functionPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Function)(nil))
}
func (i *functionPtrType) ToFunctionPtrOutput() FunctionPtrOutput {
return i.ToFunctionPtrOutputWithContext(context.Background())
}
func (i *functionPtrType) ToFunctionPtrOutputWithContext(ctx context.Context) FunctionPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(FunctionPtrOutput)
}
// FunctionArrayInput is an input type that accepts FunctionArray and FunctionArrayOutput values.
// You can construct a concrete instance of `FunctionArrayInput` via:
//
// FunctionArray{ FunctionArgs{...} }
type FunctionArrayInput interface {
pulumi.Input
ToFunctionArrayOutput() FunctionArrayOutput
ToFunctionArrayOutputWithContext(context.Context) FunctionArrayOutput
}
type FunctionArray []FunctionInput
func (FunctionArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Function)(nil)).Elem()
}
func (i FunctionArray) ToFunctionArrayOutput() FunctionArrayOutput {
return i.ToFunctionArrayOutputWithContext(context.Background())
}
func (i FunctionArray) ToFunctionArrayOutputWithContext(ctx context.Context) FunctionArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(FunctionArrayOutput)
}
// FunctionMapInput is an input type that accepts FunctionMap and FunctionMapOutput values.
// You can construct a concrete instance of `FunctionMapInput` via:
//
// FunctionMap{ "key": FunctionArgs{...} }
type FunctionMapInput interface {
pulumi.Input
ToFunctionMapOutput() FunctionMapOutput
ToFunctionMapOutputWithContext(context.Context) FunctionMapOutput
}
type FunctionMap map[string]FunctionInput
func (FunctionMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Function)(nil)).Elem()
}
func (i FunctionMap) ToFunctionMapOutput() FunctionMapOutput {
return i.ToFunctionMapOutputWithContext(context.Background())
}
func (i FunctionMap) ToFunctionMapOutputWithContext(ctx context.Context) FunctionMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(FunctionMapOutput)
}
type FunctionOutput struct{ *pulumi.OutputState }
func (FunctionOutput) ElementType() reflect.Type {
return reflect.TypeOf((*Function)(nil))
}
func (o FunctionOutput) ToFunctionOutput() FunctionOutput {
return o
}
func (o FunctionOutput) ToFunctionOutputWithContext(ctx context.Context) FunctionOutput {
return o
}
func (o FunctionOutput) ToFunctionPtrOutput() FunctionPtrOutput {
return o.ToFunctionPtrOutputWithContext(context.Background())
}
func (o FunctionOutput) ToFunctionPtrOutputWithContext(ctx context.Context) FunctionPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v Function) *Function {
return &v
}).(FunctionPtrOutput)
}
type FunctionPtrOutput struct{ *pulumi.OutputState }
func (FunctionPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Function)(nil))
}
func (o FunctionPtrOutput) ToFunctionPtrOutput() FunctionPtrOutput {
return o
}
func (o FunctionPtrOutput) ToFunctionPtrOutputWithContext(ctx context.Context) FunctionPtrOutput {
return o
}
func (o FunctionPtrOutput) Elem() FunctionOutput {
return o.ApplyT(func(v *Function) Function {
if v != nil {
return *v
}
var ret Function
return ret
}).(FunctionOutput)
}
type FunctionArrayOutput struct{ *pulumi.OutputState }
func (FunctionArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]Function)(nil))
}
func (o FunctionArrayOutput) ToFunctionArrayOutput() FunctionArrayOutput {
return o
}
func (o FunctionArrayOutput) ToFunctionArrayOutputWithContext(ctx context.Context) FunctionArrayOutput {
return o
}
func (o FunctionArrayOutput) Index(i pulumi.IntInput) FunctionOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Function {
return vs[0].([]Function)[vs[1].(int)]
}).(FunctionOutput)
}
type FunctionMapOutput struct{ *pulumi.OutputState }
func (FunctionMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]Function)(nil))
}
func (o FunctionMapOutput) ToFunctionMapOutput() FunctionMapOutput {
return o
}
func (o FunctionMapOutput) ToFunctionMapOutputWithContext(ctx context.Context) FunctionMapOutput {
return o
}
func (o FunctionMapOutput) MapIndex(k pulumi.StringInput) FunctionOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Function {
return vs[0].(map[string]Function)[vs[1].(string)]
}).(FunctionOutput)
}
func init() {
pulumi.RegisterOutputType(FunctionOutput{})
pulumi.RegisterOutputType(FunctionPtrOutput{})
pulumi.RegisterOutputType(FunctionArrayOutput{})
pulumi.RegisterOutputType(FunctionMapOutput{})
}