/
distribution.go
489 lines (476 loc) · 22.4 KB
/
distribution.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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
// *** 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 (
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/go/pulumi"
)
// Creates an Amazon CloudFront web distribution.
//
// For information about CloudFront distributions, see the
// [Amazon CloudFront Developer Guide][1]. For specific information about creating
// CloudFront web distributions, see the [POST Distribution][2] page in the Amazon
// CloudFront API Reference.
//
// > **NOTE:** CloudFront distributions take about 15 minutes to a deployed state
// after creation or modification. During this time, deletes to resources will be
// blocked. If you need to delete a distribution that is enabled and you do not
// want to wait, you need to use the `retainOnDelete` flag.
type Distribution struct {
pulumi.CustomResourceState
// The key pair IDs that CloudFront is aware of for
// each trusted signer, if the distribution is set up to serve private content
// with signed URLs.
ActiveTrustedSigners pulumi.MapOutput `pulumi:"activeTrustedSigners"`
// Extra CNAMEs (alternate domain names), if any, for
// this distribution.
Aliases pulumi.StringArrayOutput `pulumi:"aliases"`
// The ARN (Amazon Resource Name) for the distribution. For example: arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5, where 123456789012 is your AWS account ID.
Arn pulumi.StringOutput `pulumi:"arn"`
// Internal value used by CloudFront to allow future
// updates to the distribution configuration.
CallerReference pulumi.StringOutput `pulumi:"callerReference"`
// Any comments you want to include about the
// distribution.
Comment pulumi.StringPtrOutput `pulumi:"comment"`
// One or more custom error response elements (multiples allowed).
CustomErrorResponses DistributionCustomErrorResponseArrayOutput `pulumi:"customErrorResponses"`
// The default cache behavior for this distribution (maximum
// one).
DefaultCacheBehavior DistributionDefaultCacheBehaviorOutput `pulumi:"defaultCacheBehavior"`
// The object that you want CloudFront to
// return (for example, index.html) when an end user requests the root URL.
DefaultRootObject pulumi.StringPtrOutput `pulumi:"defaultRootObject"`
// The DNS domain name of either the S3 bucket, or
// web site of your custom origin.
DomainName pulumi.StringOutput `pulumi:"domainName"`
// Whether the distribution is enabled to accept end
// user requests for content.
Enabled pulumi.BoolOutput `pulumi:"enabled"`
// The current version of the distribution's information. For example:
// `E2QWRUHAPOMQZL`.
Etag pulumi.StringOutput `pulumi:"etag"`
// The CloudFront Route 53 zone ID that can be used to
// route an [Alias Resource Record Set][7] to. This attribute is simply an
// alias for the zone ID `Z2FDTNDATAQYW2`.
HostedZoneId pulumi.StringOutput `pulumi:"hostedZoneId"`
// The maximum HTTP version to support on the
// distribution. Allowed values are `http1.1` and `http2`. The default is
// `http2`.
HttpVersion pulumi.StringPtrOutput `pulumi:"httpVersion"`
// The number of invalidation batches
// currently in progress.
InProgressValidationBatches pulumi.IntOutput `pulumi:"inProgressValidationBatches"`
// Whether the IPv6 is enabled for the distribution.
IsIpv6Enabled pulumi.BoolPtrOutput `pulumi:"isIpv6Enabled"`
// The date and time the distribution was last modified.
LastModifiedTime pulumi.StringOutput `pulumi:"lastModifiedTime"`
// The logging
// configuration that controls how logs are written
// to your distribution (maximum one).
LoggingConfig DistributionLoggingConfigPtrOutput `pulumi:"loggingConfig"`
// An ordered list of cache behaviors
// resource for this distribution. List from top to bottom
// in order of precedence. The topmost cache behavior will have precedence 0.
OrderedCacheBehaviors DistributionOrderedCacheBehaviorArrayOutput `pulumi:"orderedCacheBehaviors"`
// One or more originGroup for this
// distribution (multiples allowed).
OriginGroups DistributionOriginGroupArrayOutput `pulumi:"originGroups"`
// One or more origins for this
// distribution (multiples allowed).
Origins DistributionOriginArrayOutput `pulumi:"origins"`
// The price class for this distribution. One of
// `PriceClass_All`, `PriceClass_200`, `PriceClass_100`
PriceClass pulumi.StringPtrOutput `pulumi:"priceClass"`
// The restriction
// configuration for this distribution (maximum one).
Restrictions DistributionRestrictionsOutput `pulumi:"restrictions"`
// Disables the distribution instead of
// deleting it when destroying the resource. If this is set,
// the distribution needs to be deleted manually afterwards. Default: `false`.
RetainOnDelete pulumi.BoolPtrOutput `pulumi:"retainOnDelete"`
// The current status of the distribution. `Deployed` if the
// distribution's information is fully propagated throughout the Amazon
// CloudFront system.
Status pulumi.StringOutput `pulumi:"status"`
// A mapping of tags to assign to the resource.
Tags pulumi.MapOutput `pulumi:"tags"`
// The SSL
// configuration for this distribution (maximum
// one).
ViewerCertificate DistributionViewerCertificateOutput `pulumi:"viewerCertificate"`
// If enabled, the resource will wait for
// the distribution status to change from `InProgress` to `Deployed`. Setting
// this to`false` will skip the process. Default: `true`.
WaitForDeployment pulumi.BoolPtrOutput `pulumi:"waitForDeployment"`
// If you're using AWS WAF to filter CloudFront
// requests, the Id of the AWS WAF web ACL that is associated with the
// distribution. The WAF Web ACL must exist in the WAF Global (CloudFront)
// region and the credentials configuring this argument must have
// `waf:GetWebACL` permissions assigned.
WebAclId pulumi.StringPtrOutput `pulumi:"webAclId"`
}
// NewDistribution registers a new resource with the given unique name, arguments, and options.
func NewDistribution(ctx *pulumi.Context,
name string, args *DistributionArgs, opts ...pulumi.ResourceOption) (*Distribution, error) {
if args == nil || args.DefaultCacheBehavior == nil {
return nil, errors.New("missing required argument 'DefaultCacheBehavior'")
}
if args == nil || args.Enabled == nil {
return nil, errors.New("missing required argument 'Enabled'")
}
if args == nil || args.Origins == nil {
return nil, errors.New("missing required argument 'Origins'")
}
if args == nil || args.Restrictions == nil {
return nil, errors.New("missing required argument 'Restrictions'")
}
if args == nil || args.ViewerCertificate == nil {
return nil, errors.New("missing required argument 'ViewerCertificate'")
}
if args == nil {
args = &DistributionArgs{}
}
var resource Distribution
err := ctx.RegisterResource("aws:cloudfront/distribution:Distribution", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetDistribution gets an existing Distribution 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 GetDistribution(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *DistributionState, opts ...pulumi.ResourceOption) (*Distribution, error) {
var resource Distribution
err := ctx.ReadResource("aws:cloudfront/distribution:Distribution", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Distribution resources.
type distributionState struct {
// The key pair IDs that CloudFront is aware of for
// each trusted signer, if the distribution is set up to serve private content
// with signed URLs.
ActiveTrustedSigners map[string]interface{} `pulumi:"activeTrustedSigners"`
// Extra CNAMEs (alternate domain names), if any, for
// this distribution.
Aliases []string `pulumi:"aliases"`
// The ARN (Amazon Resource Name) for the distribution. For example: arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5, where 123456789012 is your AWS account ID.
Arn *string `pulumi:"arn"`
// Internal value used by CloudFront to allow future
// updates to the distribution configuration.
CallerReference *string `pulumi:"callerReference"`
// Any comments you want to include about the
// distribution.
Comment *string `pulumi:"comment"`
// One or more custom error response elements (multiples allowed).
CustomErrorResponses []DistributionCustomErrorResponse `pulumi:"customErrorResponses"`
// The default cache behavior for this distribution (maximum
// one).
DefaultCacheBehavior *DistributionDefaultCacheBehavior `pulumi:"defaultCacheBehavior"`
// The object that you want CloudFront to
// return (for example, index.html) when an end user requests the root URL.
DefaultRootObject *string `pulumi:"defaultRootObject"`
// The DNS domain name of either the S3 bucket, or
// web site of your custom origin.
DomainName *string `pulumi:"domainName"`
// Whether the distribution is enabled to accept end
// user requests for content.
Enabled *bool `pulumi:"enabled"`
// The current version of the distribution's information. For example:
// `E2QWRUHAPOMQZL`.
Etag *string `pulumi:"etag"`
// The CloudFront Route 53 zone ID that can be used to
// route an [Alias Resource Record Set][7] to. This attribute is simply an
// alias for the zone ID `Z2FDTNDATAQYW2`.
HostedZoneId *string `pulumi:"hostedZoneId"`
// The maximum HTTP version to support on the
// distribution. Allowed values are `http1.1` and `http2`. The default is
// `http2`.
HttpVersion *string `pulumi:"httpVersion"`
// The number of invalidation batches
// currently in progress.
InProgressValidationBatches *int `pulumi:"inProgressValidationBatches"`
// Whether the IPv6 is enabled for the distribution.
IsIpv6Enabled *bool `pulumi:"isIpv6Enabled"`
// The date and time the distribution was last modified.
LastModifiedTime *string `pulumi:"lastModifiedTime"`
// The logging
// configuration that controls how logs are written
// to your distribution (maximum one).
LoggingConfig *DistributionLoggingConfig `pulumi:"loggingConfig"`
// An ordered list of cache behaviors
// resource for this distribution. List from top to bottom
// in order of precedence. The topmost cache behavior will have precedence 0.
OrderedCacheBehaviors []DistributionOrderedCacheBehavior `pulumi:"orderedCacheBehaviors"`
// One or more originGroup for this
// distribution (multiples allowed).
OriginGroups []DistributionOriginGroup `pulumi:"originGroups"`
// One or more origins for this
// distribution (multiples allowed).
Origins []DistributionOrigin `pulumi:"origins"`
// The price class for this distribution. One of
// `PriceClass_All`, `PriceClass_200`, `PriceClass_100`
PriceClass *string `pulumi:"priceClass"`
// The restriction
// configuration for this distribution (maximum one).
Restrictions *DistributionRestrictions `pulumi:"restrictions"`
// Disables the distribution instead of
// deleting it when destroying the resource. If this is set,
// the distribution needs to be deleted manually afterwards. Default: `false`.
RetainOnDelete *bool `pulumi:"retainOnDelete"`
// The current status of the distribution. `Deployed` if the
// distribution's information is fully propagated throughout the Amazon
// CloudFront system.
Status *string `pulumi:"status"`
// A mapping of tags to assign to the resource.
Tags map[string]interface{} `pulumi:"tags"`
// The SSL
// configuration for this distribution (maximum
// one).
ViewerCertificate *DistributionViewerCertificate `pulumi:"viewerCertificate"`
// If enabled, the resource will wait for
// the distribution status to change from `InProgress` to `Deployed`. Setting
// this to`false` will skip the process. Default: `true`.
WaitForDeployment *bool `pulumi:"waitForDeployment"`
// If you're using AWS WAF to filter CloudFront
// requests, the Id of the AWS WAF web ACL that is associated with the
// distribution. The WAF Web ACL must exist in the WAF Global (CloudFront)
// region and the credentials configuring this argument must have
// `waf:GetWebACL` permissions assigned.
WebAclId *string `pulumi:"webAclId"`
}
type DistributionState struct {
// The key pair IDs that CloudFront is aware of for
// each trusted signer, if the distribution is set up to serve private content
// with signed URLs.
ActiveTrustedSigners pulumi.MapInput
// Extra CNAMEs (alternate domain names), if any, for
// this distribution.
Aliases pulumi.StringArrayInput
// The ARN (Amazon Resource Name) for the distribution. For example: arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5, where 123456789012 is your AWS account ID.
Arn pulumi.StringPtrInput
// Internal value used by CloudFront to allow future
// updates to the distribution configuration.
CallerReference pulumi.StringPtrInput
// Any comments you want to include about the
// distribution.
Comment pulumi.StringPtrInput
// One or more custom error response elements (multiples allowed).
CustomErrorResponses DistributionCustomErrorResponseArrayInput
// The default cache behavior for this distribution (maximum
// one).
DefaultCacheBehavior DistributionDefaultCacheBehaviorPtrInput
// The object that you want CloudFront to
// return (for example, index.html) when an end user requests the root URL.
DefaultRootObject pulumi.StringPtrInput
// The DNS domain name of either the S3 bucket, or
// web site of your custom origin.
DomainName pulumi.StringPtrInput
// Whether the distribution is enabled to accept end
// user requests for content.
Enabled pulumi.BoolPtrInput
// The current version of the distribution's information. For example:
// `E2QWRUHAPOMQZL`.
Etag pulumi.StringPtrInput
// The CloudFront Route 53 zone ID that can be used to
// route an [Alias Resource Record Set][7] to. This attribute is simply an
// alias for the zone ID `Z2FDTNDATAQYW2`.
HostedZoneId pulumi.StringPtrInput
// The maximum HTTP version to support on the
// distribution. Allowed values are `http1.1` and `http2`. The default is
// `http2`.
HttpVersion pulumi.StringPtrInput
// The number of invalidation batches
// currently in progress.
InProgressValidationBatches pulumi.IntPtrInput
// Whether the IPv6 is enabled for the distribution.
IsIpv6Enabled pulumi.BoolPtrInput
// The date and time the distribution was last modified.
LastModifiedTime pulumi.StringPtrInput
// The logging
// configuration that controls how logs are written
// to your distribution (maximum one).
LoggingConfig DistributionLoggingConfigPtrInput
// An ordered list of cache behaviors
// resource for this distribution. List from top to bottom
// in order of precedence. The topmost cache behavior will have precedence 0.
OrderedCacheBehaviors DistributionOrderedCacheBehaviorArrayInput
// One or more originGroup for this
// distribution (multiples allowed).
OriginGroups DistributionOriginGroupArrayInput
// One or more origins for this
// distribution (multiples allowed).
Origins DistributionOriginArrayInput
// The price class for this distribution. One of
// `PriceClass_All`, `PriceClass_200`, `PriceClass_100`
PriceClass pulumi.StringPtrInput
// The restriction
// configuration for this distribution (maximum one).
Restrictions DistributionRestrictionsPtrInput
// Disables the distribution instead of
// deleting it when destroying the resource. If this is set,
// the distribution needs to be deleted manually afterwards. Default: `false`.
RetainOnDelete pulumi.BoolPtrInput
// The current status of the distribution. `Deployed` if the
// distribution's information is fully propagated throughout the Amazon
// CloudFront system.
Status pulumi.StringPtrInput
// A mapping of tags to assign to the resource.
Tags pulumi.MapInput
// The SSL
// configuration for this distribution (maximum
// one).
ViewerCertificate DistributionViewerCertificatePtrInput
// If enabled, the resource will wait for
// the distribution status to change from `InProgress` to `Deployed`. Setting
// this to`false` will skip the process. Default: `true`.
WaitForDeployment pulumi.BoolPtrInput
// If you're using AWS WAF to filter CloudFront
// requests, the Id of the AWS WAF web ACL that is associated with the
// distribution. The WAF Web ACL must exist in the WAF Global (CloudFront)
// region and the credentials configuring this argument must have
// `waf:GetWebACL` permissions assigned.
WebAclId pulumi.StringPtrInput
}
func (DistributionState) ElementType() reflect.Type {
return reflect.TypeOf((*distributionState)(nil)).Elem()
}
type distributionArgs struct {
// Extra CNAMEs (alternate domain names), if any, for
// this distribution.
Aliases []string `pulumi:"aliases"`
// Any comments you want to include about the
// distribution.
Comment *string `pulumi:"comment"`
// One or more custom error response elements (multiples allowed).
CustomErrorResponses []DistributionCustomErrorResponse `pulumi:"customErrorResponses"`
// The default cache behavior for this distribution (maximum
// one).
DefaultCacheBehavior DistributionDefaultCacheBehavior `pulumi:"defaultCacheBehavior"`
// The object that you want CloudFront to
// return (for example, index.html) when an end user requests the root URL.
DefaultRootObject *string `pulumi:"defaultRootObject"`
// Whether the distribution is enabled to accept end
// user requests for content.
Enabled bool `pulumi:"enabled"`
// The maximum HTTP version to support on the
// distribution. Allowed values are `http1.1` and `http2`. The default is
// `http2`.
HttpVersion *string `pulumi:"httpVersion"`
// Whether the IPv6 is enabled for the distribution.
IsIpv6Enabled *bool `pulumi:"isIpv6Enabled"`
// The logging
// configuration that controls how logs are written
// to your distribution (maximum one).
LoggingConfig *DistributionLoggingConfig `pulumi:"loggingConfig"`
// An ordered list of cache behaviors
// resource for this distribution. List from top to bottom
// in order of precedence. The topmost cache behavior will have precedence 0.
OrderedCacheBehaviors []DistributionOrderedCacheBehavior `pulumi:"orderedCacheBehaviors"`
// One or more originGroup for this
// distribution (multiples allowed).
OriginGroups []DistributionOriginGroup `pulumi:"originGroups"`
// One or more origins for this
// distribution (multiples allowed).
Origins []DistributionOrigin `pulumi:"origins"`
// The price class for this distribution. One of
// `PriceClass_All`, `PriceClass_200`, `PriceClass_100`
PriceClass *string `pulumi:"priceClass"`
// The restriction
// configuration for this distribution (maximum one).
Restrictions DistributionRestrictions `pulumi:"restrictions"`
// Disables the distribution instead of
// deleting it when destroying the resource. If this is set,
// the distribution needs to be deleted manually afterwards. Default: `false`.
RetainOnDelete *bool `pulumi:"retainOnDelete"`
// A mapping of tags to assign to the resource.
Tags map[string]interface{} `pulumi:"tags"`
// The SSL
// configuration for this distribution (maximum
// one).
ViewerCertificate DistributionViewerCertificate `pulumi:"viewerCertificate"`
// If enabled, the resource will wait for
// the distribution status to change from `InProgress` to `Deployed`. Setting
// this to`false` will skip the process. Default: `true`.
WaitForDeployment *bool `pulumi:"waitForDeployment"`
// If you're using AWS WAF to filter CloudFront
// requests, the Id of the AWS WAF web ACL that is associated with the
// distribution. The WAF Web ACL must exist in the WAF Global (CloudFront)
// region and the credentials configuring this argument must have
// `waf:GetWebACL` permissions assigned.
WebAclId *string `pulumi:"webAclId"`
}
// The set of arguments for constructing a Distribution resource.
type DistributionArgs struct {
// Extra CNAMEs (alternate domain names), if any, for
// this distribution.
Aliases pulumi.StringArrayInput
// Any comments you want to include about the
// distribution.
Comment pulumi.StringPtrInput
// One or more custom error response elements (multiples allowed).
CustomErrorResponses DistributionCustomErrorResponseArrayInput
// The default cache behavior for this distribution (maximum
// one).
DefaultCacheBehavior DistributionDefaultCacheBehaviorInput
// The object that you want CloudFront to
// return (for example, index.html) when an end user requests the root URL.
DefaultRootObject pulumi.StringPtrInput
// Whether the distribution is enabled to accept end
// user requests for content.
Enabled pulumi.BoolInput
// The maximum HTTP version to support on the
// distribution. Allowed values are `http1.1` and `http2`. The default is
// `http2`.
HttpVersion pulumi.StringPtrInput
// Whether the IPv6 is enabled for the distribution.
IsIpv6Enabled pulumi.BoolPtrInput
// The logging
// configuration that controls how logs are written
// to your distribution (maximum one).
LoggingConfig DistributionLoggingConfigPtrInput
// An ordered list of cache behaviors
// resource for this distribution. List from top to bottom
// in order of precedence. The topmost cache behavior will have precedence 0.
OrderedCacheBehaviors DistributionOrderedCacheBehaviorArrayInput
// One or more originGroup for this
// distribution (multiples allowed).
OriginGroups DistributionOriginGroupArrayInput
// One or more origins for this
// distribution (multiples allowed).
Origins DistributionOriginArrayInput
// The price class for this distribution. One of
// `PriceClass_All`, `PriceClass_200`, `PriceClass_100`
PriceClass pulumi.StringPtrInput
// The restriction
// configuration for this distribution (maximum one).
Restrictions DistributionRestrictionsInput
// Disables the distribution instead of
// deleting it when destroying the resource. If this is set,
// the distribution needs to be deleted manually afterwards. Default: `false`.
RetainOnDelete pulumi.BoolPtrInput
// A mapping of tags to assign to the resource.
Tags pulumi.MapInput
// The SSL
// configuration for this distribution (maximum
// one).
ViewerCertificate DistributionViewerCertificateInput
// If enabled, the resource will wait for
// the distribution status to change from `InProgress` to `Deployed`. Setting
// this to`false` will skip the process. Default: `true`.
WaitForDeployment pulumi.BoolPtrInput
// If you're using AWS WAF to filter CloudFront
// requests, the Id of the AWS WAF web ACL that is associated with the
// distribution. The WAF Web ACL must exist in the WAF Global (CloudFront)
// region and the credentials configuring this argument must have
// `waf:GetWebACL` permissions assigned.
WebAclId pulumi.StringPtrInput
}
func (DistributionArgs) ElementType() reflect.Type {
return reflect.TypeOf((*distributionArgs)(nil)).Elem()
}