Skip to content

Commit b3e86c7

Browse files
committed
feat: Update example
1 parent aaaa014 commit b3e86c7

File tree

7 files changed

+332
-282
lines changed

7 files changed

+332
-282
lines changed

README.md

Lines changed: 13 additions & 49 deletions
Large diffs are not rendered by default.

docs/UPGRADE-6.0.md

Lines changed: 115 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@ If you find a bug, please open an issue with supporting configuration to reprodu
55

66
## List of backwards incompatible changes
77

8-
- AWS provider `v6.0` is now minimum supported version
8+
- AWS provider `v6.20` is now minimum supported version
99
- Support for `aws_cloudfront_origin_access_identity` has been removed in favor of `aws_cloudfront_origin_access_control`
1010

1111
## Additional changes
1212

1313
### Added
1414

15-
- Support for `region` parameter to specify the AWS region for the resources created if different from the provider region.
15+
- None
1616

1717
### Modified
1818

19-
- Variable definitions now contain detailed `object` types in place of the previously used any type.
20-
- `is_ipv6_enabled` now defaults to `true` if not specified.
19+
- Variable definitions now contain detailed `object` types in place of the previously used any type
20+
- `is_ipv6_enabled` now defaults to `true` if not specified
21+
- `default_cache_behavior.compress` and `ordered_cache_behavior.compress` now default to `true`
22+
- `origin.origin_ssl_protocols` now defaults to `["TLSv1.2"]`
23+
- `vpc_origin.origin_ssl_protocols.items` now defaults to `["TLSv1.2"]`
24+
- `vpc_origin_timeouts` is now embedded under `vpc_origin`
25+
- `viewer_certificate.minimum_protocol_version` now defaults to `"TLSv1.2_2025"`
26+
- See the the `Before vs After` examples below for more details on variable type definition changes
2127

2228
### Variable and output changes
2329

@@ -50,7 +56,7 @@ If you find a bug, please open an issue with supporting configuration to reprodu
5056

5157
5. Renamed outputs:
5258

53-
-
59+
- None
5460

5561
6. Added outputs:
5662

@@ -67,6 +73,58 @@ module "cloudfront" {
6773
6874
# Truncated for brevity ...
6975
76+
create_vpc_origin = true
77+
vpc_origin = {
78+
ec2 = {
79+
arn = module.ec2.arn
80+
http_port = 80
81+
https_port = 443
82+
origin_protocol_policy = "http-only"
83+
origin_ssl_protocols = {
84+
items = ["TLSv1.2"]
85+
quantity = 1
86+
}
87+
}
88+
}
89+
90+
vpc_origin_timeouts = {
91+
create = "20m"
92+
update = "20m"
93+
delete = "20m"
94+
}
95+
96+
origin = {
97+
s3 = {
98+
domain_name = module.s3.bucket_regional_domain_name
99+
s3_origin_config = {
100+
origin_access_identity = "s3_bucket_one"
101+
}
102+
103+
custom_header = [
104+
{
105+
name = "X-Forwarded-Scheme"
106+
value = "https"
107+
},
108+
{
109+
name = "X-Frame-Options"
110+
value = "SAMEORIGIN"
111+
}
112+
]
113+
}
114+
}
115+
116+
origin_group = {
117+
group_one = {
118+
failover_status_codes = [403, 404, 500, 502]
119+
primary_member_origin_id = "appsync" # Not shown
120+
secondary_member_origin_id = "s3"
121+
}
122+
}
123+
124+
geo_restriction = {
125+
restriction_type = "whitelist"
126+
locations = ["NO", "UA", "US", "GB"]
127+
}
70128
}
71129
```
72130

@@ -79,9 +137,60 @@ module "cloudfront" {
79137
80138
# Truncated for brevity ...
81139
140+
vpc_origin = {
141+
ec2 = {
142+
arn = module.ec2.arn
143+
http_port = 80
144+
https_port = 443
145+
origin_protocol_policy = "http-only"
146+
origin_ssl_protocols = {
147+
items = ["TLSv1.2"]
148+
quantity = 1
149+
}
150+
151+
timeouts = {
152+
create = "20m"
153+
update = "20m"
154+
delete = "20m"
155+
}
156+
}
157+
}
158+
159+
origin = {
160+
s3 = {
161+
domain_name = module.s3.bucket_regional_domain_name
162+
s3_origin_config = {
163+
origin_access_control_key = "s3_bucket_one"
164+
}
165+
166+
custom_header = {
167+
"X-Forwarded-Scheme" = "https"
168+
"X-Frame-Options" = "SAMEORIGIN"
169+
}
170+
}
171+
}
172+
173+
origin_group = {
174+
group-one = {
175+
failover_criteria = {
176+
status_codes = [403, 404, 500, 502]
177+
}
178+
member = [
179+
{ origin_id = "appsync" }, # Not shown
180+
{ origin_id = "s3" }
181+
]
182+
}
183+
}
184+
185+
restrictions = {
186+
geo_restriction = {
187+
restriction_type = "whitelist"
188+
locations = ["NO", "UA", "US", "GB"]
189+
}
190+
}
82191
}
83192
```
84193

85194
### State Changes
86195

87-
TBD
196+
None

examples/complete/README.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
# Complete CloudFront Distribution
22

3-
Configuration in this directory creates CloudFront distribution which demos such capabilities:
4-
5-
- access logging
6-
- origins and origin groups
7-
- caching behaviours
8-
- Origin Access Identities (with S3 bucket policy)
9-
- Origin Access Control (recommended over OAI)
10-
- Lambda@Edge
11-
- CloudFront Functions
12-
- Response Headers Policies
13-
- ACM certificate
14-
- Route53 record
15-
- VPC Origins
3+
Configuration in this directory creates CloudFront distribution which demonstrates nearly all features supported by this module.
164

175
## Usage
186

@@ -34,15 +22,13 @@ Note that this example may create resources which cost money. Run `terraform des
3422
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
3523
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.20 |
3624
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |
37-
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
3825

3926
## Providers
4027

4128
| Name | Version |
4229
|------|---------|
4330
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.20 |
4431
| <a name="provider_null"></a> [null](#provider\_null) | >= 2.0 |
45-
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.0 |
4632

4733
## Modules
4834

@@ -54,16 +40,16 @@ Note that this example may create resources which cost money. Run `terraform des
5440
| <a name="module_lambda_function"></a> [lambda\_function](#module\_lambda\_function) | terraform-aws-modules/lambda/aws | ~> 8.0 |
5541
| <a name="module_log_bucket"></a> [log\_bucket](#module\_log\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 5.0 |
5642
| <a name="module_records"></a> [records](#module\_records) | terraform-aws-modules/route53/aws//modules/records | ~> 5.0 |
57-
| <a name="module_s3_one"></a> [s3\_one](#module\_s3\_one) | terraform-aws-modules/s3-bucket/aws | ~> 5.0 |
43+
| <a name="module_s3"></a> [s3](#module\_s3) | terraform-aws-modules/s3-bucket/aws | ~> 5.0 |
44+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 6.0 |
5845

5946
## Resources
6047

6148
| Name | Type |
6249
|------|------|
6350
| [aws_cloudfront_function.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_function) | resource |
64-
| [aws_s3_bucket_policy.bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
6551
| [null_resource.download_package](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
66-
| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |
52+
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
6753
| [aws_canonical_user_id.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/canonical_user_id) | data source |
6854
| [aws_cloudfront_log_delivery_canonical_user_id.cloudfront](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/cloudfront_log_delivery_canonical_user_id) | data source |
6955
| [aws_iam_policy_document.s3_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |

0 commit comments

Comments
 (0)