Skip to content

Commit

Permalink
Convert to TF 0.12/0.13. Update to context.tf. Update GitHub Actions.…
Browse files Browse the repository at this point in the history
… Use `go` modules (#40)

* Convert to TF 0.12

* Update to context.tf. Update GitHub Actions. Use `go` modules

* Update to context.tf. Update GitHub Actions. Use `go` modules

* Update to context.tf. Update GitHub Actions. Use `go` modules

* Update to context.tf. Update GitHub Actions. Use `go` modules

* Update to context.tf. Update GitHub Actions. Use `go` modules
  • Loading branch information
aknysh authored Oct 16, 2020
1 parent c364464 commit a387a57
Show file tree
Hide file tree
Showing 26 changed files with 1,510 additions and 392 deletions.
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

256 changes: 136 additions & 120 deletions README.md

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ 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"
Expand All @@ -52,36 +49,39 @@ related:
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"
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).
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:
For a complete example, see [examples/complete](examples/complete).
For automated tests of the complete example using [bats](https://github.com/bats-core/bats-core)
and [Terratest](https://github.com/gruntwork-io/terratest) (which tests and deploys the example on AWS), see [test](test).
```hcl
module "cdn" {
source = "git::https://github.com/cloudposse/terraform-aws-cloudfront-cdn.git?ref=master"
namespace = "cp"
namespace = "eg"
stage = "prod"
name = "app"
aliases = ["cloudposse.com", "www.cloudposse.com"]
parent_zone_name = "cloudposse.com"
origin_domain_name = "origin.cloudposse.com"
aliases = ["www.example.net"]
origin_domain_name = "origin.example.com"
parent_zone_name = "example.net"
}
```
Complete example of setting up CloudFront Distribution with Cache Behaviors for a WordPress site: [`examples/wordpress`](examples/wordpress/main.tf)
Complete example of setting up CloudFront Distribution with Cache Behaviors for a WordPress site: [`examples/wordpress`](examples/wordpress)
### Generating ACM Certificate
Expand All @@ -104,4 +104,4 @@ contributors:
- name: "Andriy Knysh"
github: "aknysh"
- name: "Justin Burnham"
github: "jburnham"
github: "jburnham"
167 changes: 167 additions & 0 deletions context.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#
# ONLY EDIT THIS FILE IN github.com/cloudposse/terraform-null-label
# All other instances of this file should be a copy of that one
#
#
# Copy this file from https://github.com/cloudposse/terraform-null-label/blob/master/exports/context.tf
# and then place it in your Terraform module to automatically get
# Cloud Posse's standard configuration inputs suitable for passing
# to Cloud Posse modules.
#
# Modules should access the whole context as `module.this.context`
# to get the input variables with nulls for defaults,
# for example `context = module.this.context`,
# and access individual variables as `module.this.<var>`,
# with final values filled in.
#
# For example, when using defaults, `module.this.context.delimiter`
# will be null, and `module.this.delimiter` will be `-` (hyphen).
#

module "this" {
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.19.2"

enabled = var.enabled
namespace = var.namespace
environment = var.environment
stage = var.stage
name = var.name
delimiter = var.delimiter
attributes = var.attributes
tags = var.tags
additional_tag_map = var.additional_tag_map
label_order = var.label_order
regex_replace_chars = var.regex_replace_chars
id_length_limit = var.id_length_limit

context = var.context
}

# Copy contents of cloudposse/terraform-null-label/variables.tf here

variable "context" {
type = object({
enabled = bool
namespace = string
environment = string
stage = string
name = string
delimiter = string
attributes = list(string)
tags = map(string)
additional_tag_map = map(string)
regex_replace_chars = string
label_order = list(string)
id_length_limit = number
})
default = {
enabled = true
namespace = null
environment = null
stage = null
name = null
delimiter = null
attributes = []
tags = {}
additional_tag_map = {}
regex_replace_chars = null
label_order = []
id_length_limit = null
}
description = <<-EOT
Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
EOT
}

variable "enabled" {
type = bool
default = null
description = "Set to false to prevent the module from creating any resources"
}

variable "namespace" {
type = string
default = null
description = "Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp'"
}

variable "environment" {
type = string
default = null
description = "Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT'"
}

variable "stage" {
type = string
default = null
description = "Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release'"
}

variable "name" {
type = string
default = null
description = "Solution name, e.g. 'app' or 'jenkins'"
}

variable "delimiter" {
type = string
default = null
description = <<-EOT
Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all.
EOT
}

variable "attributes" {
type = list(string)
default = []
description = "Additional attributes (e.g. `1`)"
}

variable "tags" {
type = map(string)
default = {}
description = "Additional tags (e.g. `map('BusinessUnit','XYZ')`"
}

variable "additional_tag_map" {
type = map(string)
default = {}
description = "Additional tags for appending to tags_as_list_of_maps. Not added to `tags`."
}

variable "label_order" {
type = list(string)
default = null
description = <<-EOT
The naming order of the id output and Name tag.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 5 elements, but at least one must be present.
EOT
}

variable "regex_replace_chars" {
type = string
default = null
description = <<-EOT
Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits.
EOT
}

variable "id_length_limit" {
type = number
default = null
description = <<-EOT
Limit `id` to this many characters.
Set to `0` for unlimited length.
Set to `null` for default, which is `0`.
Does not affect `id_full`.
EOT
}

#### End of copy of cloudposse/terraform-null-label/variables.tf
4 changes: 3 additions & 1 deletion docs/targets.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- markdownlint-disable -->
## Makefile Targets
```
```text
Available targets:
help Help screen
Expand All @@ -8,3 +9,4 @@ Available targets:
lint Lint terraform code
```
<!-- markdownlint-restore -->
Loading

0 comments on commit a387a57

Please sign in to comment.