Skip to content

Commit

Permalink
Migrate readme yaml (#13)
Browse files Browse the repository at this point in the history
* Migrate readme yaml

* Update related section

* Fix related project name

* Regenerate README.md

* Add travis.yaml

* Update module versions
  • Loading branch information
vadim-gleif authored and aknysh committed Jul 27, 2018
1 parent 44120cc commit 12f64bd
Show file tree
Hide file tree
Showing 11 changed files with 504 additions and 102 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
.terraform/
.idea
*.iml

.build-harness
build-harness
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
addons:
apt:
packages:
- git
- make
- curl

install:
- make init

script:
- make terraform/install
- make terraform/get-plugins
- make terraform/get-modules
- make terraform/lint
- make terraform/validate
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2017 Cloud Posse, LLC
Copyright 2017-2018 Cloud Posse, LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SHELL := /bin/bash

# List of targets the `readme` target should call before generating the readme
export README_DEPS ?= docs/targets.md docs/terraform.md

-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)

## Lint terraform code
lint:
$(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate
292 changes: 232 additions & 60 deletions README.md

Large diffs are not rendered by default.

94 changes: 94 additions & 0 deletions README.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
#
# This is the canonical configuration for the `README.md`
# Run `make readme` to rebuild the `README.md`
#

# Name of this project
name: terraform-aws-cloudfront-cdn

# Logo for this project
#logo: docs/logo.png

# License of this project
license: "APACHE2"

# Canonical GitHub repo
github_repo: cloudposse/terraform-aws-cloudfront-cdn

# Badges to display
badges:
- name: "Build Status"
image: "https://travis-ci.org/cloudposse/terraform-aws-cloudfront-cdn.svg?branch=master"
url: "https://travis-ci.org/cloudposse/terraform-aws-cloudfront-cdn"
- name: "Latest Release"
image: "https://img.shields.io/github/release/cloudposse/terraform-aws-cloudfront-cdn.svg"
url: "https://github.com/cloudposse/terraform-aws-cloudfront-cdn/releases/latest"
- name: "Slack Community"
image: "https://slack.cloudposse.com/badge.svg"
url: "https://slack.cloudposse.com"

related:
- name: "terraform-aws-cloudfront-s3-cdn"
description: "Terraform module to easily provision CloudFront CDN backed by an S3 origin"
url: "https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn"
- name: "terraform-aws-s3-log-storage"
description: "This module creates an S3 bucket suitable for receiving logs from other AWS services such as S3, CloudFront, and CloudTrail"
url: "https://github.com/cloudposse/terraform-aws-s3-log-storage"
- name: "terraform-aws-cloudtrail"
description: "Terraform module to provision an AWS CloudTrail and an encrypted S3 bucket with versioning to store CloudTrail logs"
url: "https://github.com/cloudposse/terraform-aws-cloudtrail"
- name: "terraform-aws-s3-website"
description: "Terraform module to provision S3-backed Websites"
url: "https://github.com/cloudposse/terraform-aws-s3-website"
- name: "terraform-root-modules/aws/docs"
description: "Reference implementation combining `terraform-aws-s3-website` with `terraform-aws-cdn`"
url: "https://github.com/cloudposse/terraform-root-modules/tree/master/aws/docs"

# Short description of this project
description: |-
Terraform Module that implements a CloudFront Distribution (CDN) for a custom origin (e.g. website) and [ships logs to a bucket](https://github.com/cloudposse/terraform-aws-log-storage).
If you need to accelerate an S3 bucket, we suggest using [`terraform-aws-cloudfront-s3-cdn`](https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn) instead.
# How to use this project
usage: |-
Basic usage:
```hcl
module "cdn" {
source = "git::https://github.com/cloudposse/terraform-aws-cloudfront-cdn.git?ref=master"
namespace = "cp"
stage = "prod"
name = "app"
aliases = ["cloudposse.com", "www.cloudposse.com"]
parent_zone_name = "cloudposse.com"
origin_domain_name = "origin.cloudposse.com"
}
```
Complete example of setting up CloudFront Distribution with Cache Behaviors for a WordPress site: [`examples/wordpress`](examples/wordpress/main.tf)
### Generating ACM Certificate
Use the AWS cli to [request new ACM certifiates](http://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request.html) (requires email validation)
```
aws acm request-certificate --domain-name example.com --subject-alternative-names a.example.com b.example.com *.c.example.com
```
include:
- "docs/targets.md"
- "docs/terraform.md"

# Contributors to this project
contributors:
- name: "Erik Osterman"
github: "osterman"
- name: "Igor Rodionov"
github: "goruha"
- name: "Andriy Knysh"
github: "aknysh"
- name: "Justin Burnham"
github: "jburnham"
9 changes: 9 additions & 0 deletions docs/targets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Makefile Targets
```
Available targets:
help This help screen
help/all Display help for all targets
lint Lint terraform code
```
63 changes: 63 additions & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| acm_certificate_arn | Existing ACM Certificate ARN | string | `` | no |
| aliases | List of aliases. CAUTION! Names MUSTN'T contain trailing `.` | list | `<list>` | no |
| allowed_methods | List of allowed methods (e.g. ` GET, PUT, POST, DELETE, HEAD`) for AWS CloudFront | list | `<list>` | no |
| attributes | Additional attributes (e.g. `policy` or `role`) | list | `<list>` | no |
| cache_behavior | List of cache behaviors to implement | list | `<list>` | no |
| cached_methods | List of cached methods (e.g. ` GET, PUT, POST, DELETE, HEAD`) | list | `<list>` | no |
| comment | Comment for the origin access identity | string | `Managed by Terraform` | no |
| compress | (Optional) Whether you want CloudFront to automatically compress content for web requests that include Accept-Encoding: gzip in the request header (default: false) | string | `false` | no |
| custom_error_response | (Optional) - List of one or more custom error response element maps | list | `<list>` | no |
| default_root_object | Object that CloudFront return when requests the root URL | string | `index.html` | no |
| default_ttl | Default amount of time (in seconds) that an object is in a CloudFront cache | string | `60` | no |
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no |
| enabled | Set to false to prevent the module from creating any resources | string | `true` | no |
| forward_cookies | Specifies whether you want CloudFront to forward cookies to the origin. Valid options are all, none or whitelist | string | `none` | no |
| forward_cookies_whitelisted_names | List of forwarded cookie names | list | `<list>` | no |
| forward_headers | Specifies the Headers, if any, that you want CloudFront to vary upon for this cache behavior. Specify `*` to include all headers. | list | `<list>` | no |
| forward_query_string | Forward query strings to the origin that is associated with this cache behavior | string | `false` | no |
| geo_restriction_locations | List of country codes for which CloudFront either to distribute content (whitelist) or not distribute your content (blacklist) | list | `<list>` | no |
| geo_restriction_type | Method that use to restrict distribution of your content by country: `none`, `whitelist`, or `blacklist` | string | `none` | no |
| is_ipv6_enabled | State of CloudFront IPv6 | string | `true` | no |
| log_expiration_days | Number of days after which to expunge the objects | string | `90` | no |
| log_glacier_transition_days | Number of days after which to move the data to the glacier storage tier | string | `60` | no |
| log_include_cookies | Include cookies in access logs | string | `false` | no |
| log_prefix | Path of logs in S3 bucket | string | `` | no |
| log_standard_transition_days | Number of days to persist in the standard storage tier before moving to the glacier tier | string | `30` | no |
| max_ttl | Maximum amount of time (in seconds) that an object is in a CloudFront cache | string | `31536000` | no |
| min_ttl | Minimum amount of time that you want objects to stay in CloudFront caches | string | `0` | no |
| name | Name (e.g. `bastion` or `db`) | string | - | yes |
| namespace | Namespace (e.g. `cp` or `cloudposse`) | string | - | yes |
| origin_domain_name | (Required) - The DNS domain name of your custom origin (e.g. website) | string | `` | no |
| origin_http_port | (Required) - The HTTP port the custom origin listens on | string | `80` | no |
| origin_https_port | (Required) - The HTTPS port the custom origin listens on | string | `443` | no |
| origin_keepalive_timeout | (Optional) The Custom KeepAlive timeout, in seconds. By default, AWS enforces a limit of 60. But you can request an increase. | string | `60` | no |
| origin_path | (Optional) - An optional element that causes CloudFront to request your content from a directory in your Amazon S3 bucket or your custom origin | string | `` | no |
| origin_protocol_policy | (Required) - The origin protocol policy to apply to your origin. One of http-only, https-only, or match-viewer | string | `match-viewer` | no |
| origin_read_timeout | (Optional) The Custom Read timeout, in seconds. By default, AWS enforces a limit of 60. But you can request an increase. | string | `60` | no |
| origin_ssl_protocols | (Required) - The SSL/TLS protocols that you want CloudFront to use when communicating with your origin over HTTPS | list | `<list>` | no |
| parent_zone_id | ID of the hosted zone to contain this record (or specify `parent_zone_name`) | string | `` | no |
| parent_zone_name | Name of the hosted zone to contain this record (or specify `parent_zone_id`) | string | `` | no |
| price_class | Price class for this distribution: `PriceClass_All`, `PriceClass_200`, `PriceClass_100` | string | `PriceClass_100` | no |
| stage | Stage (e.g. `prod`, `dev`, `staging`) | string | - | yes |
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')`) | map | `<map>` | no |
| viewer_minimum_protocol_version | (Optional) The minimum version of the SSL protocol that you want CloudFront to use for HTTPS connections. | string | `TLSv1` | no |
| viewer_protocol_policy | allow-all, redirect-to-https | string | `redirect-to-https` | no |

## Outputs

| Name | Description |
|------|-------------|
| cf_aliases | Extra CNAMEs of AWS CloudFront |
| cf_arn | ID of AWS CloudFront distribution |
| cf_domain_name | Domain name corresponding to the distribution |
| cf_etag | Current version of the distribution's information |
| cf_hosted_zone_id | CloudFront Route 53 zone ID |
| cf_id | ID of AWS CloudFront distribution |
| cf_origin_access_identity | A shortcut to the full path for the origin access identity to use in CloudFront |
| cf_status | Current status of the distribution |

8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "origin_label" {
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.1"
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.7"
namespace = "${var.namespace}"
stage = "${var.stage}"
name = "${var.name}"
Expand All @@ -13,7 +13,7 @@ resource "aws_cloudfront_origin_access_identity" "default" {
}

module "logs" {
source = "git::https://github.com/cloudposse/terraform-aws-log-storage.git?ref=tags/0.1.2"
source = "git::https://github.com/cloudposse/terraform-aws-log-storage.git?ref=tags/0.2.2"
namespace = "${var.namespace}"
stage = "${var.stage}"
name = "${var.name}"
Expand All @@ -27,7 +27,7 @@ module "logs" {
}

module "distribution_label" {
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.1"
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.7"
namespace = "${var.namespace}"
stage = "${var.stage}"
name = "${var.name}"
Expand Down Expand Up @@ -111,7 +111,7 @@ resource "aws_cloudfront_distribution" "default" {
}

module "dns" {
source = "git::https://github.com/cloudposse/terraform-aws-route53-alias.git?ref=tags/0.2.2"
source = "git::https://github.com/cloudposse/terraform-aws-route53-alias.git?ref=tags/0.2.4"
aliases = "${var.aliases}"
parent_zone_id = "${var.parent_zone_id}"
parent_zone_name = "${var.parent_zone_name}"
Expand Down
24 changes: 16 additions & 8 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
output "cf_id" {
value = "${aws_cloudfront_distribution.default.id}"
value = "${aws_cloudfront_distribution.default.id}"
description = "ID of AWS CloudFront distribution"
}

output "cf_arn" {
value = "${aws_cloudfront_distribution.default.arn}"
value = "${aws_cloudfront_distribution.default.arn}"
description = "ID of AWS CloudFront distribution"
}

output "cf_aliases" {
value = "${aws_cloudfront_distribution.default.aliases}"
value = "${aws_cloudfront_distribution.default.aliases}"
description = "Extra CNAMEs of AWS CloudFront"
}

output "cf_status" {
value = "${aws_cloudfront_distribution.default.status}"
value = "${aws_cloudfront_distribution.default.status}"
description = "Current status of the distribution"
}

output "cf_domain_name" {
value = "${aws_cloudfront_distribution.default.domain_name}"
value = "${aws_cloudfront_distribution.default.domain_name}"
description = "Domain name corresponding to the distribution"
}

output "cf_etag" {
value = "${aws_cloudfront_distribution.default.etag}"
value = "${aws_cloudfront_distribution.default.etag}"
description = "Current version of the distribution's information"
}

output "cf_hosted_zone_id" {
value = "${aws_cloudfront_distribution.default.hosted_zone_id}"
value = "${aws_cloudfront_distribution.default.hosted_zone_id}"
description = "CloudFront Route 53 zone ID"
}

output "cf_origin_access_identity" {
value = "${aws_cloudfront_origin_access_identity.default.cloudfront_access_identity_path}"
value = "${aws_cloudfront_origin_access_identity.default.cloudfront_access_identity_path}"
description = "A shortcut to the full path for the origin access identity to use in CloudFront"
}
Loading

0 comments on commit 12f64bd

Please sign in to comment.