/
cachePolicy.go
373 lines (320 loc) · 16.3 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
// 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 cloudfront
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// ## Example Usage
//
// Use the `cloudfront.CachePolicy` resource to create a cache policy for CloudFront.
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v6/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{
// Name: pulumi.String("example-policy"),
// 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
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// Using `pulumi import`, import CloudFront cache policies using the `id` of the cache policy. For example:
//
// ```sh
// $ pulumi import aws:cloudfront/cachePolicy:CachePolicy policy 658327ea-f89d-4fab-a63d-7e88639e58f6
// ```
type CachePolicy struct {
pulumi.CustomResourceState
// Description for the cache policy.
Comment pulumi.StringPtrOutput `pulumi:"comment"`
// Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
DefaultTtl pulumi.IntPtrOutput `pulumi:"defaultTtl"`
// Current version of the cache policy.
Etag pulumi.StringOutput `pulumi:"etag"`
// 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"`
// Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
MinTtl pulumi.IntPtrOutput `pulumi:"minTtl"`
// Unique name used to identify the cache policy.
Name pulumi.StringOutput `pulumi:"name"`
// Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOriginOutput `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 {
return nil, errors.New("missing one or more required arguments")
}
if args.ParametersInCacheKeyAndForwardedToOrigin == nil {
return nil, errors.New("invalid value for required argument 'ParametersInCacheKeyAndForwardedToOrigin'")
}
opts = internal.PkgResourceDefaultOpts(opts)
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 {
// Description for the cache policy.
Comment *string `pulumi:"comment"`
// Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
DefaultTtl *int `pulumi:"defaultTtl"`
// Current version of the cache policy.
Etag *string `pulumi:"etag"`
// 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"`
// Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
MinTtl *int `pulumi:"minTtl"`
// Unique name used to identify the cache policy.
Name *string `pulumi:"name"`
// Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
ParametersInCacheKeyAndForwardedToOrigin *CachePolicyParametersInCacheKeyAndForwardedToOrigin `pulumi:"parametersInCacheKeyAndForwardedToOrigin"`
}
type CachePolicyState struct {
// Description for the cache policy.
Comment pulumi.StringPtrInput
// Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
DefaultTtl pulumi.IntPtrInput
// Current version of the cache policy.
Etag pulumi.StringPtrInput
// 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
// Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
MinTtl pulumi.IntPtrInput
// Unique name used to identify the cache policy.
Name pulumi.StringPtrInput
// Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOriginPtrInput
}
func (CachePolicyState) ElementType() reflect.Type {
return reflect.TypeOf((*cachePolicyState)(nil)).Elem()
}
type cachePolicyArgs struct {
// Description for the cache policy.
Comment *string `pulumi:"comment"`
// Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
DefaultTtl *int `pulumi:"defaultTtl"`
// 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"`
// Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
MinTtl *int `pulumi:"minTtl"`
// Unique name used to identify the cache policy.
Name *string `pulumi:"name"`
// Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOrigin `pulumi:"parametersInCacheKeyAndForwardedToOrigin"`
}
// The set of arguments for constructing a CachePolicy resource.
type CachePolicyArgs struct {
// Description for the cache policy.
Comment pulumi.StringPtrInput
// Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
DefaultTtl pulumi.IntPtrInput
// 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
// Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
MinTtl pulumi.IntPtrInput
// Unique name used to identify the cache policy.
Name pulumi.StringPtrInput
// Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOriginInput
}
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)).Elem()
}
func (i *CachePolicy) ToCachePolicyOutput() CachePolicyOutput {
return i.ToCachePolicyOutputWithContext(context.Background())
}
func (i *CachePolicy) ToCachePolicyOutputWithContext(ctx context.Context) CachePolicyOutput {
return pulumi.ToOutputWithContext(ctx, i).(CachePolicyOutput)
}
// 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)).Elem()
}
func (o CachePolicyOutput) ToCachePolicyOutput() CachePolicyOutput {
return o
}
func (o CachePolicyOutput) ToCachePolicyOutputWithContext(ctx context.Context) CachePolicyOutput {
return o
}
// Description for the cache policy.
func (o CachePolicyOutput) Comment() pulumi.StringPtrOutput {
return o.ApplyT(func(v *CachePolicy) pulumi.StringPtrOutput { return v.Comment }).(pulumi.StringPtrOutput)
}
// Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated.
func (o CachePolicyOutput) DefaultTtl() pulumi.IntPtrOutput {
return o.ApplyT(func(v *CachePolicy) pulumi.IntPtrOutput { return v.DefaultTtl }).(pulumi.IntPtrOutput)
}
// Current version of the cache policy.
func (o CachePolicyOutput) Etag() pulumi.StringOutput {
return o.ApplyT(func(v *CachePolicy) pulumi.StringOutput { return v.Etag }).(pulumi.StringOutput)
}
// 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.
func (o CachePolicyOutput) MaxTtl() pulumi.IntPtrOutput {
return o.ApplyT(func(v *CachePolicy) pulumi.IntPtrOutput { return v.MaxTtl }).(pulumi.IntPtrOutput)
}
// Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates.
func (o CachePolicyOutput) MinTtl() pulumi.IntPtrOutput {
return o.ApplyT(func(v *CachePolicy) pulumi.IntPtrOutput { return v.MinTtl }).(pulumi.IntPtrOutput)
}
// Unique name used to identify the cache policy.
func (o CachePolicyOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *CachePolicy) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section.
func (o CachePolicyOutput) ParametersInCacheKeyAndForwardedToOrigin() CachePolicyParametersInCacheKeyAndForwardedToOriginOutput {
return o.ApplyT(func(v *CachePolicy) CachePolicyParametersInCacheKeyAndForwardedToOriginOutput {
return v.ParametersInCacheKeyAndForwardedToOrigin
}).(CachePolicyParametersInCacheKeyAndForwardedToOriginOutput)
}
type CachePolicyArrayOutput struct{ *pulumi.OutputState }
func (CachePolicyArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*CachePolicy)(nil)).Elem()
}
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)).Elem()
}
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((*CachePolicyArrayInput)(nil)).Elem(), CachePolicyArray{})
pulumi.RegisterInputType(reflect.TypeOf((*CachePolicyMapInput)(nil)).Elem(), CachePolicyMap{})
pulumi.RegisterOutputType(CachePolicyOutput{})
pulumi.RegisterOutputType(CachePolicyArrayOutput{})
pulumi.RegisterOutputType(CachePolicyMapOutput{})
}