Skip to content

Commit 7c9db75

Browse files
authored
Convert to TF 0.12. Add tests. Add Codefresh test pipeline (#45)
* Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline
1 parent cfa9964 commit 7c9db75

26 files changed

+791
-400
lines changed

.travis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2017-2018 Cloud Posse, LLC
189+
Copyright 2017-2019 Cloud Posse, LLC
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[![Cloud Posse][logo]](https://cpco.io/homepage)
55

6-
# terraform-aws-cloudfront-s3-cdn [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-cloudfront-s3-cdn.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-cloudfront-s3-cdn) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-cloudfront-s3-cdn.svg)](https://travis-ci.org/cloudposse/terraform-aws-cloudfront-s3-cdn/releases) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
6+
# terraform-aws-cloudfront-s3-cdn [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-cloudfront-s3-cdn?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d169121757962ff25679794) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-cloudfront-s3-cdn.svg)](https://travis-ci.org/cloudposse/terraform-aws-cloudfront-s3-cdn/releases) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
77

88

99
Terraform module to provision an AWS CloudFront CDN with an S3 origin.
@@ -42,6 +42,11 @@ We literally have [*hundreds of terraform modules*][terraform_modules] that are
4242

4343
## Usage
4444

45+
46+
**IMPORTANT:** The `master` branch is used in `source` just as an example. In your code, do not pin to `master` because there may be breaking changes between releases.
47+
Instead pin to the release tag (e.g. `?ref=tags/x.y.z`) of one of our [latest releases](https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn/releases).
48+
49+
4550
```hcl
4651
module "cdn" {
4752
source = "git::https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn.git?ref=master"
@@ -100,54 +105,54 @@ Available targets:
100105
| Name | Description | Type | Default | Required |
101106
|------|-------------|:----:|:-----:|:-----:|
102107
| acm_certificate_arn | Existing ACM Certificate ARN | string | `` | no |
103-
| aliases | List of FQDN's - Used to set the Alternate Domain Names (CNAMEs) setting on Cloudfront | list | `<list>` | no |
104-
| allowed_methods | List of allowed methods (e.g. GET, PUT, POST, DELETE, HEAD) for AWS CloudFront | list | `<list>` | no |
105-
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
108+
| aliases | List of FQDN's - Used to set the Alternate Domain Names (CNAMEs) setting on Cloudfront | list(string) | `<list>` | no |
109+
| allowed_methods | List of allowed methods (e.g. GET, PUT, POST, DELETE, HEAD) for AWS CloudFront | list(string) | `<list>` | no |
110+
| attributes | Additional attributes (e.g. `1`) | list(string) | `<list>` | no |
106111
| bucket_domain_format | Format of bucket domain name | string | `%s.s3.amazonaws.com` | no |
107-
| cached_methods | List of cached methods (e.g. GET, PUT, POST, DELETE, HEAD) | list | `<list>` | no |
112+
| cached_methods | List of cached methods (e.g. GET, PUT, POST, DELETE, HEAD) | list(string) | `<list>` | no |
108113
| comment | Comment for the origin access identity | string | `Managed by Terraform` | no |
109-
| compress | Compress content for web requests that include Accept-Encoding: gzip in the request header | string | `false` | no |
110-
| cors_allowed_headers | List of allowed headers for S3 bucket | list | `<list>` | no |
111-
| cors_allowed_methods | List of allowed methods (e.g. GET, PUT, POST, DELETE, HEAD) for S3 bucket | list | `<list>` | no |
112-
| cors_allowed_origins | List of allowed origins (e.g. example.com, test.com) for S3 bucket | list | `<list>` | no |
113-
| cors_expose_headers | List of expose header in the response for S3 bucket | list | `<list>` | no |
114+
| compress | Compress content for web requests that include Accept-Encoding: gzip in the request header | bool | `false` | no |
115+
| cors_allowed_headers | List of allowed headers for S3 bucket | list(string) | `<list>` | no |
116+
| cors_allowed_methods | List of allowed methods (e.g. GET, PUT, POST, DELETE, HEAD) for S3 bucket | list(string) | `<list>` | no |
117+
| cors_allowed_origins | List of allowed origins (e.g. example.com, test.com) for S3 bucket | list(string) | `<list>` | no |
118+
| cors_expose_headers | List of expose header in the response for S3 bucket | list(string) | `<list>` | no |
114119
| cors_max_age_seconds | Time in seconds that browser can cache the response for S3 bucket | string | `3600` | no |
115-
| custom_error_response | List of one or more custom error response element maps | list | `<list>` | no |
120+
| custom_error_response | List of one or more custom error response element maps | object | `<list>` | no |
116121
| default_root_object | Object that CloudFront return when requests the root URL | string | `index.html` | no |
117122
| default_ttl | Default amount of time (in seconds) that an object is in a CloudFront cache | string | `60` | no |
118123
| delimiter | Delimiter to be used between `namespace`, `stage`, `name` and `attributes` | string | `-` | no |
119-
| enabled | Select Enabled if you want CloudFront to begin processing requests as soon as the distribution is created, or select Disabled if you do not want CloudFront to begin processing requests after the distribution is created. | string | `true` | no |
124+
| enabled | Select Enabled if you want CloudFront to begin processing requests as soon as the distribution is created, or select Disabled if you do not want CloudFront to begin processing requests after the distribution is created. | bool | `true` | no |
120125
| forward_cookies | Time in seconds that browser can cache the response for S3 bucket | string | `none` | no |
121-
| forward_header_values | A list of whitelisted header values to forward to the origin | list | `<list>` | no |
122-
| forward_query_string | Forward query strings to the origin that is associated with this cache behavior | string | `false` | no |
123-
| geo_restriction_locations | List of country codes for which CloudFront either to distribute content (whitelist) or not distribute your content (blacklist) | list | `<list>` | no |
126+
| forward_header_values | A list of whitelisted header values to forward to the origin | list(string) | `<list>` | no |
127+
| forward_query_string | Forward query strings to the origin that is associated with this cache behavior | bool | `false` | no |
128+
| geo_restriction_locations | List of country codes for which CloudFront either to distribute content (whitelist) or not distribute your content (blacklist) | list(string) | `<list>` | no |
124129
| geo_restriction_type | Method that use to restrict distribution of your content by country: `none`, `whitelist`, or `blacklist` | string | `none` | no |
125-
| is_ipv6_enabled | State of CloudFront IPv6 | string | `true` | no |
126-
| lambda_function_association | A config block that triggers a lambda function with specific actions | list | `<list>` | no |
130+
| is_ipv6_enabled | State of CloudFront IPv6 | bool | `true` | no |
131+
| lambda_function_association | A config block that triggers a lambda function with specific actions | object | `<list>` | no |
127132
| log_expiration_days | Number of days after which to expunge the objects | string | `90` | no |
128133
| log_glacier_transition_days | Number of days after which to move the data to the glacier storage tier | string | `60` | no |
129-
| log_include_cookies | Include cookies in access logs | string | `false` | no |
134+
| log_include_cookies | Include cookies in access logs | bool | `false` | no |
130135
| log_prefix | Path of logs in S3 bucket | string | `` | no |
131136
| log_standard_transition_days | Number of days to persist in the standard storage tier before moving to the glacier tier | string | `30` | no |
132137
| max_ttl | Maximum amount of time (in seconds) that an object is in a CloudFront cache | string | `31536000` | no |
133138
| min_ttl | Minimum amount of time that you want objects to stay in CloudFront caches | string | `0` | no |
134139
| minimum_protocol_version | Cloudfront TLS minimum protocol version | string | `TLSv1` | no |
135140
| name | Name (e.g. `bastion` or `app`) | string | - | yes |
136-
| namespace | Namespace (e.g. `eg` or `cp`) | string | - | yes |
141+
| namespace | Namespace (e.g. `eg` or `cp`) | string | `` | no |
137142
| null | an empty string | string | `` | no |
138-
| origin_bucket | Name of S3 bucket | string | `` | no |
139-
| origin_force_destroy | Delete all objects from the bucket so that the bucket can be destroyed without error (e.g. `true` or `false`) | string | `false` | no |
143+
| origin_bucket | Origin S3 bucket name | string | `` | no |
144+
| origin_force_destroy | Delete all objects from the bucket so that the bucket can be destroyed without error (e.g. `true` or `false`) | bool | `false` | no |
140145
| origin_path | 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. | string | `` | no |
141146
| parent_zone_id | ID of the hosted zone to contain this record (or specify `parent_zone_name`) | string | `` | no |
142147
| parent_zone_name | Name of the hosted zone to contain this record (or specify `parent_zone_id`) | string | `` | no |
143148
| price_class | Price class for this distribution: `PriceClass_All`, `PriceClass_200`, `PriceClass_100` | string | `PriceClass_100` | no |
144-
| stage | Stage (e.g. `prod`, `dev`, `staging`) | string | - | yes |
149+
| stage | Stage (e.g. `prod`, `dev`, `staging`) | string | `` | no |
145150
| static_s3_bucket | 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. | string | `aws-cli` | no |
146-
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`) | map | `<map>` | no |
147-
| trusted_signers | The AWS accounts, if any, that you want to allow to create signed URLs for private content. 'self' is acceptable. | list | `<list>` | no |
148-
| use_regional_s3_endpoint | When set to 'true' the s3 origin_bucket will use the regional endpoint address instead of the global endpoint address | string | `false` | no |
151+
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`) | map(string) | `<map>` | no |
152+
| trusted_signers | The AWS accounts, if any, that you want to allow to create signed URLs for private content. 'self' is acceptable. | list(string) | `<list>` | no |
153+
| use_regional_s3_endpoint | When set to 'true' the s3 origin_bucket will use the regional endpoint address instead of the global endpoint address | bool | `false` | no |
149154
| viewer_protocol_policy | allow-all, redirect-to-https | string | `redirect-to-https` | no |
150-
| wait_for_deployment | When set to 'true' the resource will wait for the distribution status to change from InProgress to Deployed | string | `true` | no |
155+
| wait_for_deployment | When set to 'true' the resource will wait for the distribution status to change from InProgress to Deployed | bool | `true` | no |
151156
| web_acl_id | ID of the AWS WAF web ACL that is associated with the distribution | string | `` | no |
152157

153158
## Outputs

README.yaml

Lines changed: 110 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,110 @@
1-
---
2-
#
3-
# This is the canonical configuration for the `README.md`
4-
# Run `make readme` to rebuild the `README.md`
5-
#
6-
7-
# Name of this project
8-
name: terraform-aws-cloudfront-s3-cdn
9-
10-
# Tags of this project
11-
tags:
12-
- aws
13-
- terraform
14-
- terraform-modules
15-
- cdn
16-
- cloudfront
17-
- cloudfront-logs
18-
- s3
19-
20-
# Categories of this project
21-
categories:
22-
- terraform-modules/cdn
23-
24-
# Logo for this project
25-
#logo: docs/logo.png
26-
27-
# License of this project
28-
license: "APACHE2"
29-
30-
# Canonical GitHub repo
31-
github_repo: cloudposse/terraform-aws-cloudfront-s3-cdn
32-
33-
# Badges to display
34-
badges:
35-
- name: "Build Status"
36-
image: "https://travis-ci.org/cloudposse/terraform-aws-cloudfront-s3-cdn.svg?branch=master"
37-
url: "https://travis-ci.org/cloudposse/terraform-aws-cloudfront-s3-cdn"
38-
- name: "Latest Release"
39-
image: "https://img.shields.io/github/release/cloudposse/terraform-aws-cloudfront-s3-cdn.svg"
40-
url: "https://travis-ci.org/cloudposse/terraform-aws-cloudfront-s3-cdn/releases"
41-
- name: "Slack Community"
42-
image: "https://slack.cloudposse.com/badge.svg"
43-
url: "https://slack.cloudposse.com"
44-
45-
related:
46-
- name: "terraform-aws-cloudfront-cdn"
47-
description: "Terraform Module that implements a CloudFront Distribution (CDN) for a custom origin."
48-
url: "https://github.com/cloudposse/terraform-aws-cloudfront-cdn"
49-
- name: "terraform-aws-s3-log-storage"
50-
description: "S3 bucket with built in IAM policy to allow CloudTrail logs"
51-
url: "https://github.com/cloudposse/terraform-aws-s3-log-storage"
52-
53-
# Short description of this project
54-
description: |-
55-
Terraform module to provision an AWS CloudFront CDN with an S3 origin.
56-
57-
# How to use this project
58-
usage: |-
59-
```hcl
60-
module "cdn" {
61-
source = "git::https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn.git?ref=master"
62-
namespace = "eg"
63-
stage = "prod"
64-
name = "app"
65-
aliases = ["assets.cloudposse.com"]
66-
parent_zone_name = "cloudposse.com"
67-
}
68-
```
69-
70-
Full working example can be found in [example](./example) folder.
71-
72-
### Generating ACM Certificate
73-
74-
Use the AWS cli to [request new ACM certifiates](http://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request.html) (requires email validation)
75-
```
76-
aws acm request-certificate --domain-name example.com --subject-alternative-names a.example.com b.example.com *.c.example.com
77-
```
78-
79-
80-
81-
__NOTE__:
82-
83-
Although AWS Certificate Manager is supported in many AWS regions, to use an SSL certificate with CloudFront, it should be requested only in US East (N. Virginia) region.
84-
85-
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cnames-and-https-requirements.html
86-
> If you want to require HTTPS between viewers and CloudFront, you must change the AWS region to US East (N. Virginia) in the AWS Certificate Manager console before you request or import a certificate.
87-
88-
https://docs.aws.amazon.com/acm/latest/userguide/acm-regions.html
89-
> To use an ACM Certificate with Amazon CloudFront, you must request or import the certificate in the US East (N. Virginia) region. ACM Certificates in this region that are associated with a CloudFront distribution are distributed to all the geographic locations configured for that distribution.
90-
91-
This is a fundamental requirement of CloudFront, and you will need to request the certificate in `us-east-1` region.
92-
93-
If there are warnings around the outputs when destroying using this module.
94-
Then you can use this method for supressing the superfluous errors.
95-
`TF_WARN_OUTPUT_ERRORS=1 terraform destroy`
96-
97-
include:
98-
- "docs/targets.md"
99-
- "docs/terraform.md"
100-
101-
# Contributors to this project
102-
contributors:
103-
- name: "Erik Osterman"
104-
github: "osterman"
105-
- name: "Andriy Knysh"
106-
github: "aknysh"
107-
- name: "Jamie Nelson"
108-
github: "Jamie-BitFlight"
109-
- name: "Clive Zagno"
110-
github: "cliveza"
1+
---
2+
#
3+
# This is the canonical configuration for the `README.md`
4+
# Run `make readme` to rebuild the `README.md`
5+
#
6+
7+
# Name of this project
8+
name: terraform-aws-cloudfront-s3-cdn
9+
10+
# Tags of this project
11+
tags:
12+
- aws
13+
- terraform
14+
- terraform-modules
15+
- cdn
16+
- cloudfront
17+
- cloudfront-logs
18+
- s3
19+
20+
# Categories of this project
21+
categories:
22+
- terraform-modules/cdn
23+
24+
# Logo for this project
25+
#logo: docs/logo.png
26+
27+
# License of this project
28+
license: "APACHE2"
29+
30+
# Canonical GitHub repo
31+
github_repo: cloudposse/terraform-aws-cloudfront-s3-cdn
32+
33+
# Badges to display
34+
badges:
35+
- name: "Codefresh Build Status"
36+
image: "https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-cloudfront-s3-cdn?type=cf-1"
37+
url: "https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d169121757962ff25679794"
38+
- name: "Latest Release"
39+
image: "https://img.shields.io/github/release/cloudposse/terraform-aws-cloudfront-s3-cdn.svg"
40+
url: "https://travis-ci.org/cloudposse/terraform-aws-cloudfront-s3-cdn/releases"
41+
- name: "Slack Community"
42+
image: "https://slack.cloudposse.com/badge.svg"
43+
url: "https://slack.cloudposse.com"
44+
45+
related:
46+
- name: "terraform-aws-cloudfront-cdn"
47+
description: "Terraform Module that implements a CloudFront Distribution (CDN) for a custom origin."
48+
url: "https://github.com/cloudposse/terraform-aws-cloudfront-cdn"
49+
- name: "terraform-aws-s3-log-storage"
50+
description: "S3 bucket with built in IAM policy to allow CloudTrail logs"
51+
url: "https://github.com/cloudposse/terraform-aws-s3-log-storage"
52+
53+
# Short description of this project
54+
description: |-
55+
Terraform module to provision an AWS CloudFront CDN with an S3 origin.
56+
57+
# How to use this project
58+
usage: |-
59+
```hcl
60+
module "cdn" {
61+
source = "git::https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn.git?ref=master"
62+
namespace = "eg"
63+
stage = "prod"
64+
name = "app"
65+
aliases = ["assets.cloudposse.com"]
66+
parent_zone_name = "cloudposse.com"
67+
}
68+
```
69+
70+
Full working example can be found in [example](./example) folder.
71+
72+
### Generating ACM Certificate
73+
74+
Use the AWS cli to [request new ACM certifiates](http://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request.html) (requires email validation)
75+
```
76+
aws acm request-certificate --domain-name example.com --subject-alternative-names a.example.com b.example.com *.c.example.com
77+
```
78+
79+
80+
81+
__NOTE__:
82+
83+
Although AWS Certificate Manager is supported in many AWS regions, to use an SSL certificate with CloudFront, it should be requested only in US East (N. Virginia) region.
84+
85+
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cnames-and-https-requirements.html
86+
> If you want to require HTTPS between viewers and CloudFront, you must change the AWS region to US East (N. Virginia) in the AWS Certificate Manager console before you request or import a certificate.
87+
88+
https://docs.aws.amazon.com/acm/latest/userguide/acm-regions.html
89+
> To use an ACM Certificate with Amazon CloudFront, you must request or import the certificate in the US East (N. Virginia) region. ACM Certificates in this region that are associated with a CloudFront distribution are distributed to all the geographic locations configured for that distribution.
90+
91+
This is a fundamental requirement of CloudFront, and you will need to request the certificate in `us-east-1` region.
92+
93+
If there are warnings around the outputs when destroying using this module.
94+
Then you can use this method for supressing the superfluous errors.
95+
`TF_WARN_OUTPUT_ERRORS=1 terraform destroy`
96+
97+
include:
98+
- "docs/targets.md"
99+
- "docs/terraform.md"
100+
101+
# Contributors to this project
102+
contributors:
103+
- name: "Erik Osterman"
104+
github: "osterman"
105+
- name: "Andriy Knysh"
106+
github: "aknysh"
107+
- name: "Jamie Nelson"
108+
github: "Jamie-BitFlight"
109+
- name: "Clive Zagno"
110+
github: "cliveza"

0 commit comments

Comments
 (0)