diff --git a/.gitignore b/.gitignore index 9804399..408848f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ .terraform .idea *.iml + +.build-harness +build-harness \ No newline at end of file diff --git a/Makefile b/Makefile index d002c7d..655f630 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +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 + $(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate \ No newline at end of file diff --git a/README.md b/README.md index bab9ea1..226eafa 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,27 @@ -# terraform-aws-s3-website [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-s3-website.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-s3-website) + + +[![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com) + +# terraform-aws-s3-website [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-s3-website.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-s3-website) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-s3-website.svg)](https://github.com/cloudposse/terraform-aws-s3-website/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) + Terraform module to provision S3-backed Websites -## Further Reading +--- + +This project is part of our comprehensive ["SweetOps"](https://docs.cloudposse.com) approach towards DevOps. + + +It's 100% Open Source and licensed under the [APACHE2](LICENSE). + + + + + + + -* http://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html ## Usage @@ -30,7 +46,7 @@ module "website" { #### Create S3 website bucket with Route53 DNS -* Required one of the `parent_zone_id` or `parent_zone_name` +Required one of the `parent_zone_id` or `parent_zone_name` ```hcl module "website_with_cname" { @@ -44,61 +60,116 @@ module "website_with_cname" { ``` -## Variables - -| Name | Default | Description | Required | -|:------------------------------------|:--------------:|:----------------------------------------------------------------------------------------------------------------|:--------:| -| `namespace` | `` | Namespace (e.g. `cp` or `cloudposse`) | Yes | -| `stage` | `` | Stage (e.g. `prod`, `dev`, `staging`) | Yes | -| `name` | `` | Name (e.g. `app`) | Yes | -| `attributes` | `[]` | Additional attributes (e.g. `1`) | No | -| `tags` | `{}` | Additional tags (e.g. `map("BusinessUnit","XYZ")` | No | -| `delimiter` | `-` | Delimiter to be used between `namespace`, `stage`, `name` and `attributes` | No | -| `hostname` | `[]` | Name of website bucket in `fqdn` format (e.g. `test.example.com`). IMPORTANT! Do not add trailing dot (`.`) | 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 | -| `lifecycle_rule_enabled` | `` | Lifecycle rule status (e.g. `true` or `false`) | No | -| `noncurrent_version_transition_days`| `30` | Number of days to persist in the standard storage tier before moving to the glacier tier infrequent access tier | No | -| `noncurrent_version_expiration_days`| `90` | Specifies when noncurrent object versions expire | No | -| `cors_allowed_headers` | `["*"]` | List of allowed headers | No | -| `cors_allowed_methods` | `["GET"]` | List of allowed methods (e.g. ` GET, PUT, POST, DELETE, HEAD`) | No | -| `cors_allowed_origins` | `["*"]` | List of allowed origins (e.g. ` example.com, test.com`) | No | -| `cors_max_age_seconds` | `3600` | Time in seconds that browser can cache the response | No | -| `cors_expose_headers` | `["ETag"]` | List of expose header in the response | No | -| `prefix` | `` | Prefix identifying one or more objects to which the rule applies | No | -| `region` | `` | AWS region this bucket should reside in | No | -| `routing_rules` | `` | A json array containing routing rules describing redirect behavior and when redirects are applied | No | -| `versioning_enabled` | `` | State of versioning (e.g. `true` or `false`) | No | -| `logs_standard_transition_days` | `30` | Number of days to persist in the standard storage tier before moving to the glacier tier | No | -| `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 | -| `replication_source_principal_arns` | `[]` | List of principal ARNs to grant replication access from different AWS accounts | No | -| `deployment_arns` | `{}` | Map of deployment ARNs to lists of S3 path prefixes to grant `deployment_actions` permissions | No | -| `deployment_actions` | read/write/ls | List of actions to permit deployment ARNs to perform | No | + + +## Makefile Targets +``` +Available targets: + + help This help screen + help/all Display help for all targets + lint Lint terraform code + +``` + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| attributes | Additional attributes (e.g. `policy` or `role`) | list | `` | no | +| cors_allowed_headers | List of allowed headers | list | `` | no | +| cors_allowed_methods | List of allowed methods (e.g. ` GET, PUT, POST, DELETE, HEAD`) | list | `` | no | +| cors_allowed_origins | List of allowed origins (e.g. ` example.com, test.com`) | list | `` | no | +| cors_expose_headers | List of expose header in the response | list | `` | no | +| cors_max_age_seconds | Time in seconds that browser can cache the response | string | `3600` | no | +| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no | +| deployment_actions | List of actions to permit deployment ARNs to perform | list | `` | no | +| deployment_arns | (Optional) Map of deployment ARNs to lists of S3 path prefixes to grant `deployment_actions` permissions | map | `` | no | +| error_document | An absolute path to the document to return in case of a 4XX error | string | `404.html` | no | +| force_destroy | Delete all objects from the bucket so that the bucket can be destroyed without error (e.g. `true` or `false`) | string | `` | no | +| hostname | Name of website bucket in `fqdn` format (e.g. `test.example.com`). IMPORTANT! Do not add trailing dot (`.`) | string | - | yes | +| index_document | Amazon S3 returns this index document when requests are made to the root domain or any of the subfolders | string | `index.html` | no | +| lifecycle_rule_enabled | Lifecycle rule status (e.g. `true` or `false`) | string | `` | no | +| logs_expiration_days | Number of days after which to expunge the objects | string | `90` | no | +| logs_glacier_transition_days | Number of days after which to move the data to the glacier storage tier | string | `60` | no | +| logs_standard_transition_days | Number of days to persist in the standard storage tier before moving to the glacier tier | string | `30` | no | +| name | The Name of the application or solution (e.g. `bastion` or `portal`) | string | - | yes | +| namespace | Namespace (e.g. `cp` or `cloudposse`) | string | - | yes | +| noncurrent_version_expiration_days | Specifies when noncurrent object versions expire | string | `90` | no | +| noncurrent_version_transition_days | Number of days to persist in the standard storage tier before moving to the glacier tier infrequent access tier | string | `30` | no | +| parent_zone_id | ID of the hosted zone to contain the record | string | `` | no | +| parent_zone_name | Name of the hosted zone to contain the record | string | `` | no | +| prefix | Prefix identifying one or more objects to which the rule applies | string | `` | no | +| region | AWS region this bucket should reside in | string | `` | no | +| replication_source_principal_arns | (Optional) List of principal ARNs to grant replication access from different AWS accounts | list | `` | no | +| routing_rules | A json array containing routing rules describing redirect behavior and when redirects are applied | string | `` | no | +| stage | Stage (e.g. `prod`, `dev`, `staging`) | string | - | yes | +| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')`) | map | `` | no | +| versioning_enabled | State of versioning (e.g. `true` or `false`) | string | `` | no | + ## Outputs -| Name | Description | -|:------------------------------ |:------------------------------------------------------------| -| `hostname` | Bucket hostname | -| `s3_bucket_domain_name` | DNS record of website bucket | -| `s3_bucket_name` | Name of of website bucket | -| `s3_bucket_arn` | Name of of website bucket | -| `s3_bucket_website_endpoint` | The website endpoint URL | -| `s3_bucket_website_domain` | The domain of the website endpoint | -| `s3_bucket_hosted_zone_id` | The Route 53 Hosted Zone ID for this bucket's region | +| Name | Description | +|------|-------------| +| hostname | Bucket hostname | +| s3_bucket_arn | Name of of website bucket | +| s3_bucket_domain_name | Name of of website bucket | +| s3_bucket_hosted_zone_id | The Route 53 Hosted Zone ID for this bucket's region | +| s3_bucket_name | DNS record of website bucket | +| s3_bucket_website_domain | The domain of the website endpoint | +| s3_bucket_website_endpoint | The website endpoint URL | + + + + +## Related Projects + +Check out these related projects. + +- [terraform-aws-cloudfront-s3-cdn](https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn) - Terraform module to easily provision CloudFront CDN backed by an S3 origin +- [terraform-aws-s3-log-storage](https://github.com/cloudposse/terraform-aws-s3-log-storage) - This module creates an S3 bucket suitable for receiving logs from other AWS services such as S3, CloudFront, and CloudTrail +- [terraform-aws-user-data-s3-backend](https://github.com/cloudposse/terraform-aws-user-data-s3-backend) - Terraform Module to Offload User Data to S3 +- [terraform-aws-s3-logs-athena-query](https://github.com/cloudposse/terraform-aws-s3-logs-athena-query) - A Terraform module that creates an Athena Database and Structure for querying S3 access logs +- [terraform-aws-lb-s3-bucket](https://github.com/cloudposse/terraform-aws-lb-s3-bucket) - Terraform module to provision an S3 bucket with built in IAM policy to allow AWS Load Balancers to ship access logs + + + + +## References + +For additional context, refer to some of these links. + +- [Hosting Websites on Amazon S3](http://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html) - Example: setting up a Static Website Using a Custom Domain ## Help **Got a question?** -File a GitHub [issue](https://github.com/cloudposse/terraform-aws-s3-website/issues), send us an [email](mailto:hello@cloudposse.com) or reach out to us on [Gitter](https://gitter.im/cloudposse/). +File a GitHub [issue](https://github.com/cloudposse/terraform-aws-s3-website/issues), send us an [email][email] or join our [Slack Community][slack]. + +## Commercial Support + +Work directly with our team of DevOps experts via email, slack, and video conferencing. +We provide [*commercial support*][commercial_support] for all of our [Open Source][github] projects. As a *Dedicated Support* customer, you have access to our team of subject matter experts at a fraction of the cost of a full-time engineer. + +[![E-Mail](https://img.shields.io/badge/email-hello@cloudposse.com-blue.svg)](mailto:hello@cloudposse.com) + +- **Questions.** We'll use a Shared Slack channel between your team and ours. +- **Troubleshooting.** We'll help you triage why things aren't working. +- **Code Reviews.** We'll review your Pull Requests and provide constructive feedback. +- **Bug Fixes.** We'll rapidly work to fix any bugs in our projects. +- **Build New Terraform Modules.** We'll develop original modules to provision infrastructure. +- **Cloud Architecture.** We'll assist with your cloud strategy and design. +- **Implementation.** We'll provide hands-on support to implement our reference architectures. + + +## Community Forum + +Get access to our [Open Source Community Forum][slack] on Slack. It's **FREE** to join for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build *sweet* infrastructure. ## Contributing @@ -108,7 +179,7 @@ Please use the [issue tracker](https://github.com/cloudposse/terraform-aws-s3-we ### Developing -If you are interested in being a contributor and want to get involved in developing `terraform-aws-s3-website`, we would love to hear from you! Shoot us an [email](mailto:hello@cloudposse.com). +If you are interested in being a contributor and want to get involved in developing this project or [help out](https://github.com/orgs/cloudposse/projects/3) with our other projects, we would love to hear from you! Shoot us an [email](mailto:hello@cloudposse.com). In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. @@ -116,14 +187,20 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. 2. **Clone** the project to your own machine 3. **Commit** changes to your own branch 4. **Push** your work back up to your fork - 5. Submit a **Pull request** so that we can review your changes + 5. Submit a **Pull Request** so that we can review your changes + +**NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request! + -**NOTE:** Be sure to merge the latest from "upstream" before making a pull request! +## Copyright +Copyright © 2017-2018 [Cloud Posse, LLC](https://cloudposse.com) -## License -[APACHE 2.0](LICENSE) © 2017-2018 [Cloud Posse, LLC](https://cloudposse.com) + +## License + +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) See [LICENSE](LICENSE) for full details. @@ -135,7 +212,7 @@ See [LICENSE](LICENSE) for full details. "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an @@ -145,33 +222,51 @@ See [LICENSE](LICENSE) for full details. under the License. -## About -`terraform-aws-s3-website` is maintained and funded by [Cloud Posse, LLC][website]. -![Cloud Posse](https://cloudposse.com/logo-300x69.png) -Like it? Please let us know at -We love [Open Source Software](https://github.com/cloudposse/)! -See [our other projects][community] -or [hire us][hire] to help build your next cloud platform. +## Trademarks + +All other trademarks referenced herein are the property of their respective owners. + +## About + +This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know at + +[![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com) + +We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We love [Open Source Software](https://github.com/cloudposse/)! + +We offer paid support on all of our projects. + +Check out [our other projects][github], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation. + + [docs]: https://docs.cloudposse.com/ [website]: https://cloudposse.com/ - [community]: https://github.com/cloudposse/ + [github]: https://github.com/cloudposse/ + [commercial_support]: https://github.com/orgs/cloudposse/projects + [jobs]: https://cloudposse.com/jobs/ [hire]: https://cloudposse.com/contact/ + [slack]: https://slack.cloudposse.com/ + [linkedin]: https://www.linkedin.com/company/cloudposse + [twitter]: https://twitter.com/cloudposse/ + [email]: mailto:hello@cloudposse.com + + +### Contributors +| [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]
[Andriy Knysh][aknysh_homepage] | [![Vladimir][SweetOps_avatar]][SweetOps_homepage]
[Vladimir][SweetOps_homepage] | +|---|---|---| -## Contributors + [osterman_homepage]: https://github.com/osterman + [osterman_avatar]: https://github.com/osterman.png?size=150 + [aknysh_homepage]: https://github.com/aknysh + [aknysh_avatar]: https://github.com/aknysh.png?size=150 + [SweetOps_homepage]: https://github.com/SweetOps + [SweetOps_avatar]: https://github.com/SweetOps.png?size=150 -| [![Erik Osterman][erik_img]][erik_web]
[Erik Osterman][erik_web] | [![Andriy Knysh][andriy_img]][andriy_web]
[Andriy Knysh][andriy_web] |[![Igor Rodionov][igor_img]][igor_web]
[Igor Rodionov][igor_img] -|-------------------------------------------------------|------------------------------------------------------------------|------------------------------------------------------------------| -[erik_img]: http://s.gravatar.com/avatar/88c480d4f73b813904e00a5695a454cb?s=144 -[erik_web]: https://github.com/osterman/ -[andriy_img]: https://avatars0.githubusercontent.com/u/7356997?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 -[andriy_web]: https://github.com/aknysh/ -[igor_img]: http://s.gravatar.com/avatar/bc70834d32ed4517568a1feb0b9be7e2?s=144 -[igor_web]: https://github.com/goruha/ diff --git a/README.yaml b/README.yaml new file mode 100644 index 0000000..2359840 --- /dev/null +++ b/README.yaml @@ -0,0 +1,102 @@ +--- +# +# This is the canonical configuration for the `README.md` +# Run `make readme` to rebuild the `README.md` +# + +# Name of this project +name: terraform-aws-s3-website + +# Logo for this project +#logo: docs/logo.png + +# License of this project +license: "APACHE2" + +# Canonical GitHub repo +github_repo: cloudposse/terraform-aws-s3-website + +# Badges to display +badges: + - name: "Build Status" + image: "https://travis-ci.org/cloudposse/terraform-aws-s3-website.svg?branch=master" + url: "https://travis-ci.org/cloudposse/terraform-aws-s3-website" + - name: "Latest Release" + image: "https://img.shields.io/github/release/cloudposse/terraform-aws-s3-website.svg" + url: "https://github.com/cloudposse/terraform-aws-s3-website/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-user-data-s3-backend" + description: "Terraform Module to Offload User Data to S3" + url: "https://github.com/cloudposse/terraform-aws-user-data-s3-backend" + - name: "terraform-aws-s3-logs-athena-query" + description: "A Terraform module that creates an Athena Database and Structure for querying S3 access logs" + url: "https://github.com/cloudposse/terraform-aws-s3-logs-athena-query" + - name: "terraform-aws-lb-s3-bucket" + description: "Terraform module to provision an S3 bucket with built in IAM policy to allow AWS Load Balancers to ship access logs" + url: "https://github.com/cloudposse/terraform-aws-lb-s3-bucket" + +# Short description of this project +description: |- + Terraform module to provision S3-backed Websites + +# How to use this project +usage: |- + #### Create s3 website bucket + + ```hcl + module "website" { + source = "git::https://github.com/cloudposse/terraform-aws-s3-website.git?ref=master" + namespace = "cp" + stage = "prod" + name = "app" + hostname = "docs.prod.cloudposse.org" + + deployment_arns = { + "arn:aws:s3:::principal1" = ["/prefix1", "/prefix2"] + "arn:aws:s3:::principal2" = [""] + } + } + ``` + + + #### Create S3 website bucket with Route53 DNS + + Required one of the `parent_zone_id` or `parent_zone_name` + + ```hcl + module "website_with_cname" { + source = "git::https://github.com/cloudposse/terraform-aws-s3-website.git?ref=master" + namespace = "cp" + stage = "prod" + name = "app" + hostname = "docs.prod.cloudposse.org" + parent_zone_id = "XXXXXXXXXXXX" + } + ``` +references: + - name: "Hosting Websites on Amazon S3" + description: "Example: setting up a Static Website Using a Custom Domain" + url: "http://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html" + +include: + - "docs/targets.md" + - "docs/terraform.md" + +# Contributors to this project +contributors: + - name: "Erik Osterman" + github: "osterman" + - name: "Andriy Knysh" + github: "aknysh" + - name: "Vladimir" + github: "SweetOps" \ No newline at end of file diff --git a/docs/targets.md b/docs/targets.md new file mode 100644 index 0000000..09c39cd --- /dev/null +++ b/docs/targets.md @@ -0,0 +1,9 @@ +## Makefile Targets +``` +Available targets: + + help This help screen + help/all Display help for all targets + lint Lint terraform code + +``` diff --git a/docs/terraform.md b/docs/terraform.md new file mode 100644 index 0000000..c081113 --- /dev/null +++ b/docs/terraform.md @@ -0,0 +1,48 @@ + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| attributes | Additional attributes (e.g. `policy` or `role`) | list | `` | no | +| cors_allowed_headers | List of allowed headers | list | `` | no | +| cors_allowed_methods | List of allowed methods (e.g. ` GET, PUT, POST, DELETE, HEAD`) | list | `` | no | +| cors_allowed_origins | List of allowed origins (e.g. ` example.com, test.com`) | list | `` | no | +| cors_expose_headers | List of expose header in the response | list | `` | no | +| cors_max_age_seconds | Time in seconds that browser can cache the response | string | `3600` | no | +| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no | +| deployment_actions | List of actions to permit deployment ARNs to perform | list | `` | no | +| deployment_arns | (Optional) Map of deployment ARNs to lists of S3 path prefixes to grant `deployment_actions` permissions | map | `` | no | +| error_document | An absolute path to the document to return in case of a 4XX error | string | `404.html` | no | +| force_destroy | Delete all objects from the bucket so that the bucket can be destroyed without error (e.g. `true` or `false`) | string | `` | no | +| hostname | Name of website bucket in `fqdn` format (e.g. `test.example.com`). IMPORTANT! Do not add trailing dot (`.`) | string | - | yes | +| index_document | Amazon S3 returns this index document when requests are made to the root domain or any of the subfolders | string | `index.html` | no | +| lifecycle_rule_enabled | Lifecycle rule status (e.g. `true` or `false`) | string | `` | no | +| logs_expiration_days | Number of days after which to expunge the objects | string | `90` | no | +| logs_glacier_transition_days | Number of days after which to move the data to the glacier storage tier | string | `60` | no | +| logs_standard_transition_days | Number of days to persist in the standard storage tier before moving to the glacier tier | string | `30` | no | +| name | The Name of the application or solution (e.g. `bastion` or `portal`) | string | - | yes | +| namespace | Namespace (e.g. `cp` or `cloudposse`) | string | - | yes | +| noncurrent_version_expiration_days | Specifies when noncurrent object versions expire | string | `90` | no | +| noncurrent_version_transition_days | Number of days to persist in the standard storage tier before moving to the glacier tier infrequent access tier | string | `30` | no | +| parent_zone_id | ID of the hosted zone to contain the record | string | `` | no | +| parent_zone_name | Name of the hosted zone to contain the record | string | `` | no | +| prefix | Prefix identifying one or more objects to which the rule applies | string | `` | no | +| region | AWS region this bucket should reside in | string | `` | no | +| replication_source_principal_arns | (Optional) List of principal ARNs to grant replication access from different AWS accounts | list | `` | no | +| routing_rules | A json array containing routing rules describing redirect behavior and when redirects are applied | string | `` | no | +| stage | Stage (e.g. `prod`, `dev`, `staging`) | string | - | yes | +| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')`) | map | `` | no | +| versioning_enabled | State of versioning (e.g. `true` or `false`) | string | `` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| hostname | Bucket hostname | +| s3_bucket_arn | Name of of website bucket | +| s3_bucket_domain_name | Name of of website bucket | +| s3_bucket_hosted_zone_id | The Route 53 Hosted Zone ID for this bucket's region | +| s3_bucket_name | DNS record of website bucket | +| s3_bucket_website_domain | The domain of the website endpoint | +| s3_bucket_website_endpoint | The website endpoint URL | + diff --git a/output.tf b/output.tf index 66b3bbc..83cd4f8 100644 --- a/output.tf +++ b/output.tf @@ -1,27 +1,34 @@ output "hostname" { - value = "${var.hostname}" + value = "${var.hostname}" + description = "Bucket hostname" } output "s3_bucket_name" { - value = "${aws_s3_bucket.default.id}" + value = "${aws_s3_bucket.default.id}" + description = "DNS record of website bucket" } output "s3_bucket_domain_name" { - value = "${aws_s3_bucket.default.bucket_domain_name}" + value = "${aws_s3_bucket.default.bucket_domain_name}" + description = "Name of of website bucket" } output "s3_bucket_arn" { - value = "${aws_s3_bucket.default.arn}" + value = "${aws_s3_bucket.default.arn}" + description = "Name of of website bucket" } output "s3_bucket_website_endpoint" { - value = "${aws_s3_bucket.default.website_endpoint}" + value = "${aws_s3_bucket.default.website_endpoint}" + description = "The website endpoint URL" } output "s3_bucket_website_domain" { - value = "${aws_s3_bucket.default.website_domain}" + value = "${aws_s3_bucket.default.website_domain}" + description = "The domain of the website endpoint" } output "s3_bucket_hosted_zone_id" { - value = "${aws_s3_bucket.default.hosted_zone_id}" + value = "${aws_s3_bucket.default.hosted_zone_id}" + description = "The Route 53 Hosted Zone ID for this bucket's region" } diff --git a/variables.tf b/variables.tf index a8dad50..c969a13 100644 --- a/variables.tf +++ b/variables.tf @@ -1,24 +1,36 @@ -variable "name" {} +variable "name" { + description = "The Name of the application or solution (e.g. `bastion` or `portal`)" +} -variable "namespace" {} +variable "namespace" { + description = "Namespace (e.g. `cp` or `cloudposse`)" +} -variable "stage" {} +variable "stage" { + description = "Stage (e.g. `prod`, `dev`, `staging`)" +} variable "attributes" { - type = "list" - default = [] + type = "list" + default = [] + description = "Additional attributes (e.g. `policy` or `role`)" } variable "tags" { - type = "map" - default = {} + type = "map" + default = {} + description = "Additional tags (e.g. `map('BusinessUnit','XYZ')`)" } variable "delimiter" { - default = "-" + type = "string" + default = "-" + description = "Delimiter to be used between `name`, `namespace`, `stage`, etc." } -variable "hostname" {} +variable "hostname" { + description = "Name of website bucket in `fqdn` format (e.g. `test.example.com`). IMPORTANT! Do not add trailing dot (`.`)" +} variable "parent_zone_id" { description = "ID of the hosted zone to contain the record" @@ -31,39 +43,47 @@ variable "parent_zone_name" { } variable "index_document" { - default = "index.html" + default = "index.html" + description = "Amazon S3 returns this index document when requests are made to the root domain or any of the subfolders" } variable "error_document" { - default = "404.html" + default = "404.html" + description = "An absolute path to the document to return in case of a 4XX error" } variable "routing_rules" { - default = "" + default = "" + description = "A json array containing routing rules describing redirect behavior and when redirects are applied" } variable "cors_allowed_headers" { - type = "list" - default = ["*"] + type = "list" + default = ["*"] + description = "List of allowed headers" } variable "cors_allowed_methods" { - type = "list" - default = ["GET"] + type = "list" + default = ["GET"] + description = "List of allowed methods (e.g. ` GET, PUT, POST, DELETE, HEAD`) " } variable "cors_allowed_origins" { - type = "list" - default = ["*"] + type = "list" + default = ["*"] + description = "List of allowed origins (e.g. ` example.com, test.com`)" } variable "cors_expose_headers" { - type = "list" - default = ["ETag"] + type = "list" + default = ["ETag"] + description = "List of expose header in the response" } variable "cors_max_age_seconds" { - default = "3600" + default = "3600" + description = "Time in seconds that browser can cache the response" } variable "logs_standard_transition_days" { @@ -82,31 +102,38 @@ variable "logs_expiration_days" { } variable "lifecycle_rule_enabled" { - default = "" + default = "" + description = "Lifecycle rule status (e.g. `true` or `false`)" } variable "prefix" { - default = "" + default = "" + description = "Prefix identifying one or more objects to which the rule applies" } variable "noncurrent_version_transition_days" { - default = "30" + default = "30" + description = "Number of days to persist in the standard storage tier before moving to the glacier tier infrequent access tier" } variable "noncurrent_version_expiration_days" { - default = "90" + default = "90" + description = "Specifies when noncurrent object versions expire" } variable "region" { - default = "" + default = "" + description = "AWS region this bucket should reside in" } variable "versioning_enabled" { - default = "" + default = "" + description = "State of versioning (e.g. `true` or `false`)" } variable "force_destroy" { - default = "" + default = "" + description = "Delete all objects from the bucket so that the bucket can be destroyed without error (e.g. `true` or `false`)" } variable "replication_source_principal_arns" {