Skip to content

Commit c422848

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

File tree

7 files changed

+324
-280
lines changed

7 files changed

+324
-280
lines changed

README.md

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

docs/UPGRADE-6.0.md

Lines changed: 107 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ 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

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

5151
5. Renamed outputs:
5252

53-
-
53+
- None
5454

5555
6. Added outputs:
5656

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

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

85188
### State Changes
86189

87-
TBD
190+
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)