forked from cloudposse/terraform-aws-cloudfront-s3-cdn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
453 lines (381 loc) · 14.3 KB
/
variables.tf
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
variable "extra_origin_attributes" {
type = list(string)
default = ["origin"]
description = "Additional attributes to put onto the origin label"
}
variable "extra_logs_attributes" {
type = list(string)
default = ["logs"]
description = "Additional attributes to put onto the log bucket label"
}
variable "acm_certificate_arn" {
type = string
description = "Existing ACM Certificate ARN"
default = ""
}
variable "minimum_protocol_version" {
type = string
description = "Cloudfront TLS minimum protocol version"
default = "TLSv1"
}
variable "aliases" {
type = list(string)
description = "List of FQDN's - Used to set the Alternate Domain Names (CNAMEs) setting on Cloudfront"
default = []
}
variable "use_regional_s3_endpoint" {
type = bool
description = "When set to 'true' the s3 origin_bucket will use the regional endpoint address instead of the global endpoint address"
default = false
}
variable "additional_bucket_policy" {
type = string
default = "{}"
description = "Additional policies for the bucket. If included in the policies, the variables `$${bucket_name}`, `$${origin_path}` and `$${cloudfront_origin_access_identity_iam_arn}` will be substituted. It is also possible to override the default policy statements by providing statements with `S3GetObjectForCloudFront` and `S3ListBucketForCloudFront` sid."
}
variable "override_origin_bucket_policy" {
type = bool
default = true
description = "When using an existing origin bucket (through var.origin_bucket), setting this to 'false' will make it so the existing bucket policy will not be overriden"
}
variable "origin_bucket" {
type = string
default = ""
description = "Origin S3 bucket name"
}
variable "origin_path" {
# http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesOriginPath
type = string
description = "An optional element that causes CloudFront to request your content from a directory in your Amazon S3 bucket or your custom origin. It must begin with a /. Do not add a / at the end of the path."
default = ""
}
variable "origin_force_destroy" {
type = bool
default = false
description = "Delete all objects from the bucket so that the bucket can be destroyed without error (e.g. `true` or `false`)"
}
variable "bucket_domain_format" {
type = string
default = "%s.s3.amazonaws.com"
description = "Format of bucket domain name"
}
variable "compress" {
type = bool
default = false
description = "Compress content for web requests that include Accept-Encoding: gzip in the request header"
}
variable "default_root_object" {
type = string
default = "index.html"
description = "Object that CloudFront return when requests the root URL"
}
variable "comment" {
type = string
default = "Managed by Terraform"
description = "Comment for the origin access identity"
}
variable "logging_enabled" {
type = bool
default = true
description = "When true, access logs will be sent to a newly created s3 bucket"
}
variable "log_versioning_enabled" {
type = bool
default = false
description = "When true, the access logs bucket will be versioned"
}
variable "log_include_cookies" {
type = bool
default = false
description = "Include cookies in access logs"
}
variable "log_prefix" {
type = string
default = ""
description = "Path of logs in S3 bucket"
}
variable "log_standard_transition_days" {
type = number
description = "Number of days to persist in the standard storage tier before moving to the glacier tier"
default = 30
}
variable "log_glacier_transition_days" {
type = number
description = "Number of days after which to move the data to the glacier storage tier"
default = 60
}
variable "log_expiration_days" {
type = number
description = "Number of days after which to expunge the objects"
default = 90
}
variable "forward_query_string" {
type = bool
default = false
description = "Forward query strings to the origin that is associated with this cache behavior"
}
variable "cors_allowed_headers" {
type = list(string)
default = ["*"]
description = "List of allowed headers for S3 bucket"
}
variable "cors_allowed_methods" {
type = list(string)
default = ["GET"]
description = "List of allowed methods (e.g. GET, PUT, POST, DELETE, HEAD) for S3 bucket"
}
variable "cors_allowed_origins" {
type = list(string)
default = []
description = "List of allowed origins (e.g. example.com, test.com) for S3 bucket"
}
variable "cors_expose_headers" {
type = list(string)
default = ["ETag"]
description = "List of expose header in the response for S3 bucket"
}
variable "cors_max_age_seconds" {
type = number
default = 3600
description = "Time in seconds that browser can cache the response for S3 bucket"
}
variable "forward_cookies" {
type = string
default = "none"
description = "Specifies whether you want CloudFront to forward all or no cookies to the origin. Can be 'all' or 'none'"
}
variable "forward_header_values" {
type = list(string)
description = "A list of whitelisted header values to forward to the origin"
default = ["Access-Control-Request-Headers", "Access-Control-Request-Method", "Origin"]
}
variable "price_class" {
type = string
default = "PriceClass_100"
description = "Price class for this distribution: `PriceClass_All`, `PriceClass_200`, `PriceClass_100`"
}
variable "viewer_protocol_policy" {
type = string
description = "allow-all, redirect-to-https"
default = "redirect-to-https"
}
variable "allowed_methods" {
type = list(string)
default = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
description = "List of allowed methods (e.g. GET, PUT, POST, DELETE, HEAD) for AWS CloudFront"
}
variable "cached_methods" {
type = list(string)
default = ["GET", "HEAD"]
description = "List of cached methods (e.g. GET, PUT, POST, DELETE, HEAD)"
}
variable "default_ttl" {
type = number
default = 60
description = "Default amount of time (in seconds) that an object is in a CloudFront cache"
}
variable "min_ttl" {
type = number
default = 0
description = "Minimum amount of time that you want objects to stay in CloudFront caches"
}
variable "max_ttl" {
type = number
default = 31536000
description = "Maximum amount of time (in seconds) that an object is in a CloudFront cache"
}
variable "trusted_signers" {
type = list(string)
default = []
description = "The AWS accounts, if any, that you want to allow to create signed URLs for private content. 'self' is acceptable."
}
variable "geo_restriction_type" {
type = string
# e.g. "whitelist"
default = "none"
description = "Method that use to restrict distribution of your content by country: `none`, `whitelist`, or `blacklist`"
}
variable "geo_restriction_locations" {
type = list(string)
# e.g. ["US", "CA", "GB", "DE"]
default = []
description = "List of country codes for which CloudFront either to distribute content (whitelist) or not distribute your content (blacklist)"
}
variable "parent_zone_id" {
type = string
default = ""
description = "ID of the hosted zone to contain this record (or specify `parent_zone_name`). Requires `dns_alias_enabled` set to true"
}
variable "parent_zone_name" {
type = string
default = ""
description = "Name of the hosted zone to contain this record (or specify `parent_zone_id`). Requires `dns_alias_enabled` set to true"
}
variable "dns_alias_enabled" {
type = bool
default = false
description = "Create a DNS alias for the CDN. Requires `parent_zone_id` or `parent_zone_name`"
}
variable "static_s3_bucket" {
type = string
default = "aws-cli"
description = <<DOC
aws-cli is a bucket owned by amazon that will perminantly exist.
It allows for the data source to be called during the destruction process without failing.
It doesn't get used for anything else, this is a safe workaround for handling the fact that
if a data source like the one `aws_s3_bucket.selected` gets an error, you can't continue the terraform process
which also includes the 'destroy' command, where is doesn't even need this data source!
Don't change this bucket name, it's a variable so that we can provide this description.
And this works around a problem that is an edge case.
DOC
}
variable "custom_error_response" {
# http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html#custom-error-pages-procedure
# https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html#custom-error-response-arguments
type = list(object({
error_caching_min_ttl = string
error_code = string
response_code = string
response_page_path = string
}))
description = "List of one or more custom error response element maps"
default = []
}
variable "lambda_function_association" {
type = list(object({
event_type = string
include_body = bool
lambda_arn = string
}))
description = "A config block that triggers a lambda function with specific actions"
default = []
}
variable "web_acl_id" {
type = string
default = ""
description = "ID of the AWS WAF web ACL that is associated with the distribution"
}
variable "wait_for_deployment" {
type = bool
default = true
description = "When set to 'true' the resource will wait for the distribution status to change from InProgress to Deployed"
}
variable "encryption_enabled" {
type = bool
default = true
description = "When set to 'true' the resource will have aes256 encryption enabled by default"
}
variable "index_document" {
type = string
default = "index.html"
description = "Amazon S3 returns this index document when requests are made to the root domain or any of the subfolders"
}
variable "redirect_all_requests_to" {
type = string
default = ""
description = "A hostname to redirect all website requests for this distribution to. If this is set, it overrides other website settings"
}
variable "error_document" {
type = string
default = ""
description = "An absolute path to the document to return in case of a 4XX error"
}
variable "routing_rules" {
type = string
default = ""
description = "A json array containing routing rules describing redirect behavior and when redirects are applied"
}
variable "ipv6_enabled" {
type = bool
default = true
description = "Set to true to enable an AAAA DNS record to be set as well as the A record"
}
variable "ordered_cache" {
type = list(object({
target_origin_id = string
path_pattern = string
allowed_methods = list(string)
cached_methods = list(string)
compress = bool
viewer_protocol_policy = string
min_ttl = number
default_ttl = number
max_ttl = number
forward_query_string = bool
forward_header_values = list(string)
forward_cookies = string
lambda_function_association = list(object({
event_type = string
include_body = bool
lambda_arn = string
}))
}))
default = []
description = <<DESCRIPTION
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.
The fields can be described by the other variables in this file. For example, the field 'lambda_function_association' in this object has
a description in var.lambda_function_association variable earlier in this file. The only difference is that fields on this object are in ordered caches, whereas the rest
of the vars in this file apply only to the default cache. Put value `""` on field `target_origin_id` to specify default s3 bucket origin.
DESCRIPTION
}
variable "custom_origins" {
type = list(object({
domain_name = string
origin_id = string
origin_path = string
custom_headers = list(object({
name = string
value = string
}))
custom_origin_config = object({
http_port = number
https_port = number
origin_protocol_policy = string
origin_ssl_protocols = list(string)
origin_keepalive_timeout = number
origin_read_timeout = number
})
}))
default = []
description = "One or more custom origins for this distribution (multiples allowed). See documentation for configuration options description https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html#origin-arguments"
}
variable "website_enabled" {
type = bool
default = false
description = "Set to true to use an S3 static website as origin"
}
variable "versioning_enabled" {
type = bool
default = true
description = "When set to 'true' the s3 origin bucket will have versioning enabled"
}
variable "cloudfront_origin_access_identity_iam_arn" {
type = string
default = ""
description = "Existing cloudfront origin access identity iam arn that is supplied in the s3 bucket policy"
}
variable "cloudfront_origin_access_identity_path" {
type = string
default = ""
description = "Existing cloudfront origin access identity path used in the cloudfront distribution's s3_origin_config content"
}
variable "custom_origin_headers" {
type = list(object({ name = string, value = string }))
default = []
description = "A list of origin header parameters that will be sent to origin"
}
variable "origin_ssl_protocols" {
type = list(string)
default = ["TLSv1", "TLSv1.1", "TLSv1.2"]
description = "The SSL/TLS protocols that you want CloudFront to use when communicating with your origin over HTTPS."
}
variable "block_origin_public_access_enabled" {
type = bool
default = false
description = "When set to 'true' the s3 origin bucket will have public access block enabled"
}
variable "access_log_bucket_name" {
type = string
default = ""
description = "Name of the S3 bucket where s3 access log will be sent to"
}