-
Notifications
You must be signed in to change notification settings - Fork 151
/
cachePolicy.go
393 lines (332 loc) · 15.9 KB
/
cachePolicy.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
// *** 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/pulumi/pulumi/sdk/v3/go/pulumi"
)
// ## Example Usage
//
// The following example below creates a CloudFront cache policy.
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/cloudfront"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := cloudfront.NewCachePolicy(ctx, "example", &cloudfront.CachePolicyArgs{
// Comment: pulumi.String("test comment"),
// DefaultTtl: pulumi.Int(50),
// MaxTtl: pulumi.Int(100),
// MinTtl: pulumi.Int(1),
// ParametersInCacheKeyAndForwardedToOrigin: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginArgs{
// CookiesConfig: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigArgs{
// CookieBehavior: pulumi.String("whitelist"),
// Cookies: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookiesArgs{
// Items: pulumi.StringArray{
// pulumi.String("example"),
// },
// },
// },
// HeadersConfig: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigArgs{
// HeaderBehavior: pulumi.String("whitelist"),
// Headers: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeadersArgs{
// Items: pulumi.StringArray{
// pulumi.String("example"),
// },
// },
// },
// QueryStringsConfig: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigArgs{
// QueryStringBehavior: pulumi.String("whitelist"),
// QueryStrings: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStringsArgs{
// Items: pulumi.StringArray{
// pulumi.String("example"),
// },
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Cloudfront Cache Policies can be imported using the `id`, e.g.
//
// ```sh
// $ pulumi import aws:cloudfront/cachePolicy:CachePolicy policy 658327ea-f89d-4fab-a63d-7e88639e58f6
// ```
type CachePolicy struct {
pulumi.CustomResourceState
// A comment to describe the cache policy.
Comment pulumi.StringPtrOutput `pulumi:"comment"`
// The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
DefaultTtl pulumi.IntPtrOutput `pulumi:"defaultTtl"`
// The current version of the cache policy.
Etag pulumi.StringOutput `pulumi:"etag"`
// The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
MaxTtl pulumi.IntPtrOutput `pulumi:"maxTtl"`
// The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
MinTtl pulumi.IntPtrOutput `pulumi:"minTtl"`
// A unique name to identify the cache policy.
Name pulumi.StringOutput `pulumi:"name"`
// The HTTP headers, cookies, and URL query strings to include in the cache key. See Parameters In Cache Key And Forwarded To Origin for more information.
ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOriginPtrOutput `pulumi:"parametersInCacheKeyAndForwardedToOrigin"`
}
// NewCachePolicy registers a new resource with the given unique name, arguments, and options.
func NewCachePolicy(ctx *pulumi.Context,
name string, args *CachePolicyArgs, opts ...pulumi.ResourceOption) (*CachePolicy, error) {
if args == nil {
args = &CachePolicyArgs{}
}
var resource CachePolicy
err := ctx.RegisterResource("aws:cloudfront/cachePolicy:CachePolicy", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetCachePolicy gets an existing CachePolicy 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 GetCachePolicy(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *CachePolicyState, opts ...pulumi.ResourceOption) (*CachePolicy, error) {
var resource CachePolicy
err := ctx.ReadResource("aws:cloudfront/cachePolicy:CachePolicy", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering CachePolicy resources.
type cachePolicyState struct {
// A comment to describe the cache policy.
Comment *string `pulumi:"comment"`
// The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
DefaultTtl *int `pulumi:"defaultTtl"`
// The current version of the cache policy.
Etag *string `pulumi:"etag"`
// The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
MaxTtl *int `pulumi:"maxTtl"`
// The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
MinTtl *int `pulumi:"minTtl"`
// A unique name to identify the cache policy.
Name *string `pulumi:"name"`
// The HTTP headers, cookies, and URL query strings to include in the cache key. See Parameters In Cache Key And Forwarded To Origin for more information.
ParametersInCacheKeyAndForwardedToOrigin *CachePolicyParametersInCacheKeyAndForwardedToOrigin `pulumi:"parametersInCacheKeyAndForwardedToOrigin"`
}
type CachePolicyState struct {
// A comment to describe the cache policy.
Comment pulumi.StringPtrInput
// The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
DefaultTtl pulumi.IntPtrInput
// The current version of the cache policy.
Etag pulumi.StringPtrInput
// The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
MaxTtl pulumi.IntPtrInput
// The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
MinTtl pulumi.IntPtrInput
// A unique name to identify the cache policy.
Name pulumi.StringPtrInput
// The HTTP headers, cookies, and URL query strings to include in the cache key. See Parameters In Cache Key And Forwarded To Origin for more information.
ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOriginPtrInput
}
func (CachePolicyState) ElementType() reflect.Type {
return reflect.TypeOf((*cachePolicyState)(nil)).Elem()
}
type cachePolicyArgs struct {
// A comment to describe the cache policy.
Comment *string `pulumi:"comment"`
// The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
DefaultTtl *int `pulumi:"defaultTtl"`
// The current version of the cache policy.
Etag *string `pulumi:"etag"`
// The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
MaxTtl *int `pulumi:"maxTtl"`
// The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
MinTtl *int `pulumi:"minTtl"`
// A unique name to identify the cache policy.
Name *string `pulumi:"name"`
// The HTTP headers, cookies, and URL query strings to include in the cache key. See Parameters In Cache Key And Forwarded To Origin for more information.
ParametersInCacheKeyAndForwardedToOrigin *CachePolicyParametersInCacheKeyAndForwardedToOrigin `pulumi:"parametersInCacheKeyAndForwardedToOrigin"`
}
// The set of arguments for constructing a CachePolicy resource.
type CachePolicyArgs struct {
// A comment to describe the cache policy.
Comment pulumi.StringPtrInput
// The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
DefaultTtl pulumi.IntPtrInput
// The current version of the cache policy.
Etag pulumi.StringPtrInput
// The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
MaxTtl pulumi.IntPtrInput
// The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
MinTtl pulumi.IntPtrInput
// A unique name to identify the cache policy.
Name pulumi.StringPtrInput
// The HTTP headers, cookies, and URL query strings to include in the cache key. See Parameters In Cache Key And Forwarded To Origin for more information.
ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOriginPtrInput
}
func (CachePolicyArgs) ElementType() reflect.Type {
return reflect.TypeOf((*cachePolicyArgs)(nil)).Elem()
}
type CachePolicyInput interface {
pulumi.Input
ToCachePolicyOutput() CachePolicyOutput
ToCachePolicyOutputWithContext(ctx context.Context) CachePolicyOutput
}
func (*CachePolicy) ElementType() reflect.Type {
return reflect.TypeOf((*CachePolicy)(nil))
}
func (i *CachePolicy) ToCachePolicyOutput() CachePolicyOutput {
return i.ToCachePolicyOutputWithContext(context.Background())
}
func (i *CachePolicy) ToCachePolicyOutputWithContext(ctx context.Context) CachePolicyOutput {
return pulumi.ToOutputWithContext(ctx, i).(CachePolicyOutput)
}
func (i *CachePolicy) ToCachePolicyPtrOutput() CachePolicyPtrOutput {
return i.ToCachePolicyPtrOutputWithContext(context.Background())
}
func (i *CachePolicy) ToCachePolicyPtrOutputWithContext(ctx context.Context) CachePolicyPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(CachePolicyPtrOutput)
}
type CachePolicyPtrInput interface {
pulumi.Input
ToCachePolicyPtrOutput() CachePolicyPtrOutput
ToCachePolicyPtrOutputWithContext(ctx context.Context) CachePolicyPtrOutput
}
type cachePolicyPtrType CachePolicyArgs
func (*cachePolicyPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**CachePolicy)(nil))
}
func (i *cachePolicyPtrType) ToCachePolicyPtrOutput() CachePolicyPtrOutput {
return i.ToCachePolicyPtrOutputWithContext(context.Background())
}
func (i *cachePolicyPtrType) ToCachePolicyPtrOutputWithContext(ctx context.Context) CachePolicyPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(CachePolicyPtrOutput)
}
// CachePolicyArrayInput is an input type that accepts CachePolicyArray and CachePolicyArrayOutput values.
// You can construct a concrete instance of `CachePolicyArrayInput` via:
//
// CachePolicyArray{ CachePolicyArgs{...} }
type CachePolicyArrayInput interface {
pulumi.Input
ToCachePolicyArrayOutput() CachePolicyArrayOutput
ToCachePolicyArrayOutputWithContext(context.Context) CachePolicyArrayOutput
}
type CachePolicyArray []CachePolicyInput
func (CachePolicyArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*CachePolicy)(nil)).Elem()
}
func (i CachePolicyArray) ToCachePolicyArrayOutput() CachePolicyArrayOutput {
return i.ToCachePolicyArrayOutputWithContext(context.Background())
}
func (i CachePolicyArray) ToCachePolicyArrayOutputWithContext(ctx context.Context) CachePolicyArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(CachePolicyArrayOutput)
}
// CachePolicyMapInput is an input type that accepts CachePolicyMap and CachePolicyMapOutput values.
// You can construct a concrete instance of `CachePolicyMapInput` via:
//
// CachePolicyMap{ "key": CachePolicyArgs{...} }
type CachePolicyMapInput interface {
pulumi.Input
ToCachePolicyMapOutput() CachePolicyMapOutput
ToCachePolicyMapOutputWithContext(context.Context) CachePolicyMapOutput
}
type CachePolicyMap map[string]CachePolicyInput
func (CachePolicyMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*CachePolicy)(nil)).Elem()
}
func (i CachePolicyMap) ToCachePolicyMapOutput() CachePolicyMapOutput {
return i.ToCachePolicyMapOutputWithContext(context.Background())
}
func (i CachePolicyMap) ToCachePolicyMapOutputWithContext(ctx context.Context) CachePolicyMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(CachePolicyMapOutput)
}
type CachePolicyOutput struct{ *pulumi.OutputState }
func (CachePolicyOutput) ElementType() reflect.Type {
return reflect.TypeOf((*CachePolicy)(nil))
}
func (o CachePolicyOutput) ToCachePolicyOutput() CachePolicyOutput {
return o
}
func (o CachePolicyOutput) ToCachePolicyOutputWithContext(ctx context.Context) CachePolicyOutput {
return o
}
func (o CachePolicyOutput) ToCachePolicyPtrOutput() CachePolicyPtrOutput {
return o.ToCachePolicyPtrOutputWithContext(context.Background())
}
func (o CachePolicyOutput) ToCachePolicyPtrOutputWithContext(ctx context.Context) CachePolicyPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v CachePolicy) *CachePolicy {
return &v
}).(CachePolicyPtrOutput)
}
type CachePolicyPtrOutput struct{ *pulumi.OutputState }
func (CachePolicyPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**CachePolicy)(nil))
}
func (o CachePolicyPtrOutput) ToCachePolicyPtrOutput() CachePolicyPtrOutput {
return o
}
func (o CachePolicyPtrOutput) ToCachePolicyPtrOutputWithContext(ctx context.Context) CachePolicyPtrOutput {
return o
}
func (o CachePolicyPtrOutput) Elem() CachePolicyOutput {
return o.ApplyT(func(v *CachePolicy) CachePolicy {
if v != nil {
return *v
}
var ret CachePolicy
return ret
}).(CachePolicyOutput)
}
type CachePolicyArrayOutput struct{ *pulumi.OutputState }
func (CachePolicyArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]CachePolicy)(nil))
}
func (o CachePolicyArrayOutput) ToCachePolicyArrayOutput() CachePolicyArrayOutput {
return o
}
func (o CachePolicyArrayOutput) ToCachePolicyArrayOutputWithContext(ctx context.Context) CachePolicyArrayOutput {
return o
}
func (o CachePolicyArrayOutput) Index(i pulumi.IntInput) CachePolicyOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) CachePolicy {
return vs[0].([]CachePolicy)[vs[1].(int)]
}).(CachePolicyOutput)
}
type CachePolicyMapOutput struct{ *pulumi.OutputState }
func (CachePolicyMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]CachePolicy)(nil))
}
func (o CachePolicyMapOutput) ToCachePolicyMapOutput() CachePolicyMapOutput {
return o
}
func (o CachePolicyMapOutput) ToCachePolicyMapOutputWithContext(ctx context.Context) CachePolicyMapOutput {
return o
}
func (o CachePolicyMapOutput) MapIndex(k pulumi.StringInput) CachePolicyOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) CachePolicy {
return vs[0].(map[string]CachePolicy)[vs[1].(string)]
}).(CachePolicyOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*CachePolicyInput)(nil)).Elem(), &CachePolicy{})
pulumi.RegisterInputType(reflect.TypeOf((*CachePolicyPtrInput)(nil)).Elem(), &CachePolicy{})
pulumi.RegisterInputType(reflect.TypeOf((*CachePolicyArrayInput)(nil)).Elem(), CachePolicyArray{})
pulumi.RegisterInputType(reflect.TypeOf((*CachePolicyMapInput)(nil)).Elem(), CachePolicyMap{})
pulumi.RegisterOutputType(CachePolicyOutput{})
pulumi.RegisterOutputType(CachePolicyPtrOutput{})
pulumi.RegisterOutputType(CachePolicyArrayOutput{})
pulumi.RegisterOutputType(CachePolicyMapOutput{})
}