Skip to content

Commit

Permalink
Add parent_zone_name capability (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
SweetOps authored and const-bon committed Sep 20, 2017
1 parent ea2df8c commit 7626b7a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,29 @@ Terraform Module for Creating S3 backed Websites

## Usage

#### Create s3 website bucket
```terraform
module "website" {
source = "git::https://github.com/cloudposse/tf_s3_website.git?ref=master"
namespace = "${var.namespace}"
stage = "${var.stage}"
name = "${var.name}"
hostname = "${var.hostname}"
dns_zone_id = "${var.dns_zone_id}"
}
```

#### Create S3 Website Bucket with Route53 DNS

* Required one of the `parent_zone_id` or `parent_zone_name`

```terraform
module "website_with_cname" {
source = "git::https://github.com/cloudposse/tf_s3_website.git?ref=master"
namespace = "${var.namespace}"
stage = "${var.stage}"
name = "${var.name}"
hostname = "${var.hostname}"
parent_zone_id = "${var.parent_zone_id}"
}
```

Expand All @@ -30,7 +45,8 @@ module "website" {
| `tags` | `{}` | Additional tags (e.g. `map("BusinessUnit","XYZ")` | No |
| `delimiter` | `-` | Delimiter to be used between `name`, `namespace`, `stage`, `arguments`, etc. | No |
| `hostname` | `[]` | Name of website bucket in `fqdn` format (e.g. `test.example.com`). IMPORTANT! Do not add trailing dot (`.`) | Yes |
| `dns_zone_id` | `` | ID of the hosted zone to contain the record | Yes |
| `parent_zone_id` | `` | ID of the hosted zone to contain the record or specify `parent_zone_name` instead | No |
| `parent_zone_name` | `` | Name of the hosted zone to contain the record or specify `parent_zone_id` instead | No |
| `error_document` | `404.html` | An absolute path to the document to return in case of a 4XX error | No |
| `index_document` | `index.html` | Amazon S3 returns this index document when requests are made to the root domain or any of the subfolders | No |
| `force_destroy` | `` | Delete all objects from the bucket so that the bucket can be destroyed without error (e.g. `true` or `false`) | No |
Expand All @@ -50,7 +66,6 @@ module "website" {
| `logs_glacier_transition_days` | `60` | Number of days after which to move the data to the glacier storage tier | No |
| `logs_expiration_days` | `90` | Number of days after which to expunge the objects | No |


## Outputs

| Name | Description |
Expand Down
11 changes: 6 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ data "aws_iam_policy_document" "default" {
}

module "dns" {
source = "git::https://github.com/cloudposse/tf_vanity.git?ref=tags/0.2.0"
aliases = "${list(var.hostname)}"
parent_zone_id = "${var.dns_zone_id}"
target_dns_name = "${aws_s3_bucket.default.website_domain}"
target_zone_id = "${aws_s3_bucket.default.hosted_zone_id}"
source = "git::https://github.com/cloudposse/tf_vanity.git?ref=tags/0.2.0"
aliases = "${compact(list(signum(length(var.parent_zone_id)) == 1 || signum(length(var.parent_zone_name)) == 1 ? var.hostname : ""))}"
parent_zone_id = "${var.parent_zone_id}"
parent_zone_name = "${var.parent_zone_name}"
target_dns_name = "${aws_s3_bucket.default.website_domain}"
target_zone_id = "${aws_s3_bucket.default.hosted_zone_id}"
}
11 changes: 8 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ variable "delimiter" {
default = "-"
}

variable "hostname" {
}
variable "hostname" {}

variable "dns_zone_id" {
variable "parent_zone_id" {
description = "ID of the hosted zone to contain the record"
default = ""
}

variable "parent_zone_name" {
description = "Name of the hosted zone to contain the record"
default = ""
}

variable "index_document" {
Expand Down

0 comments on commit 7626b7a

Please sign in to comment.