forked from futurice/terraform-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
85 lines (69 loc) · 3.41 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
variable "site_domain" {
description = "Domain on which the static site will be made available (e.g. `\"www.example.com\"`)"
}
variable "name_prefix" {
description = "Name prefix to use for objects that need to be created (only lowercase alphanumeric characters and hyphens allowed, for S3 bucket name compatibility)"
default = "aws-static-site---"
}
variable "comment_prefix" {
description = "This will be included in comments for resources that are created"
default = "Static site: "
}
variable "bucket_override_name" {
description = "When provided, assume a bucket with this name already exists for the site content, instead of creating the bucket automatically (e.g. `\"my-bucket\"`)"
default = ""
}
variable "cloudfront_price_class" {
description = "CloudFront price class to use (`100`, `200` or `\"All\"`, see https://aws.amazon.com/cloudfront/pricing/)"
default = 100
}
variable "viewer_https_only" {
description = "Set this to `false` if you need to support insecure HTTP access for clients, in addition to HTTPS"
default = true
}
variable "cache_ttl_override" {
description = "When >= 0, override the cache behaviour for ALL objects in S3, so that they stay in the CloudFront cache for this amount of seconds"
default = -1
}
variable "default_root_object" {
description = "The object to return when the root URL is requested"
default = "index.html"
}
variable "add_response_headers" {
description = "Map of HTTP headers (if any) to add to outgoing responses before sending them to clients"
type = "map"
default = {
"Strict-Transport-Security" = "max-age=31557600; preload" # i.e. 1 year (in seconds)
}
}
variable "basic_auth_username" {
description = "When non-empty, require this username with HTTP Basic Auth"
default = ""
}
variable "basic_auth_password" {
description = "When non-empty, require this password with HTTP Basic Auth"
default = ""
}
variable "basic_auth_realm" {
description = "When using HTTP Basic Auth, this will be displayed by the browser in the auth prompt"
default = "Authentication Required"
}
variable "basic_auth_body" {
description = "When using HTTP Basic Auth, and authentication has failed, this will be displayed by the browser as the page content"
default = "Unauthorized"
}
variable "lambda_logging_enabled" {
description = "When true, writes information about incoming requests to the Lambda function's CloudWatch group"
default = false
}
variable "tags" {
description = "AWS Tags to add to all resources created (where possible); see https://aws.amazon.com/answers/account-management/aws-tagging-strategies/"
type = "map"
default = {}
}
locals {
prefix_with_domain = "${var.name_prefix}${replace("${var.site_domain}", "/[^a-z0-9-]+/", "-")}" # only lowercase alphanumeric characters and hyphens are allowed in S3 bucket names
bucket_name = "${var.bucket_override_name == "" ? "${local.prefix_with_domain}" : "${var.bucket_override_name}"}" # select between externally-provided or auto-generated bucket names
bucket_domain_name = "${local.bucket_name}.s3-website.${data.aws_region.current.name}.amazonaws.com" # use current region to complete the domain name (we can't use the "aws_s3_bucket" data source because the bucket may not initially exist)
error_ttl = "${var.cache_ttl_override >= 0 ? var.cache_ttl_override : 0}"
}