Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme improvements #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ This module provisions the infrasructure required for a static website hosted on
- [CloudFront Distribution](https://aws.amazon.com/cloudfront/) to serve the website at edge locations at a low cost and high performance.
- [Route 53](https://aws.amazon.com/route53/) A records to utilise custom domain on website.
- Security First - S3 Bucket is private with IAM policies to provide permissions to CloudFront.
- Utilises aws S3 sync command to upload website content to S3 Bucket.
- Utilises `aws S3 sync` command to upload website content to S3 Bucket.

![image](https://raw.githubusercontent.com/DevOpsNavy/terraform-aws-s3-cloudfront-static-website/v0.0.0/diagrams/Architecture.drawio.png)

## Pre-quisites

- Domain Name
- [Route 53 Hosted zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-working-with.html) which is the DNS provider for the domain. [Making Amazon Route 53 the DNS service for an existing domain](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/MigratingDNS.html). Note: the hosted zone only needs to manage the DNS service, domain registration does not need to be migrated!
- [A second aws porovider configured in us-east-1](https://www.terraform.io/language/providers/configuration) as CloudFront and SSL certificates are only available in us-east-1.
- [A second aws provider configured in us-east-1](https://www.terraform.io/language/providers/configuration) as CloudFront and SSL certificates are only available in `us-east-1`.

For syncronisation of the website content with a local directory, the following is required:
- [AWS CLI](https://aws.amazon.com/cli/) installed locally - [installation instructions](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
- [Configure a named profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) using `aws configure --profile NAME` command. This is used for the aws s3 sync command which is executed locally. Profiles are preferred over keys and secrets.
- [Configure a named profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) using `aws configure --profile NAME` command. This is used for the `aws s3 sync` command which is executed locally. Profiles are preferred over keys and secrets.


## Usage
[Example available here](https://github.com/DevOpsNavy/s3-cloudfront-static-website/tree/main/examples/static_website_with_sync)

```javascript
```hcl
terraform {
required_providers {
aws = {
Expand All @@ -50,7 +50,6 @@ provider "aws" {
}

module "website" {

source = "XXX"

resource_uid = "DevOpsNavy"
Expand Down Expand Up @@ -124,11 +123,11 @@ No modules.
| <a name="input_default_cache_methods"></a> [default\_cache\_methods](#input\_default\_cache\_methods) | Controls whether CloudFront caches the response to requests using the specified HTTP methods. | `list(string)` | <pre>[<br> "GET",<br> "HEAD",<br> "OPTIONS"<br>]</pre> | no |
| <a name="input_default_cache_min_ttl"></a> [default\_cache\_min\_ttl](#input\_default\_cache\_min\_ttl) | The minimum amount of time that you want objects to stay in CloudFront caches before CloudFront queries your origin to see whether the object has been updated. | `number` | `0` | no |
| <a name="input_default_cache_viewer_protocol_policy"></a> [default\_cache\_viewer\_protocol\_policy](#input\_default\_cache\_viewer\_protocol\_policy) | Use this element to specify the protocol that users can use to access the files in the origin specified by TargetOriginId when a request matches the path pattern in PathPattern. One of allow-all, https-only, or redirect-to-https. | `string` | `"redirect-to-https"` | no |
| <a name="input_default_root_object"></a> [default\_root\_object](#input\_default\_root\_object) | The object that you want CloudFront to return (for example, index.html) when an end user requests the root URL. | `string` | `"index.html"` | no |
| <a name="input_default_root_object"></a> [default\_root\_object](#input\_default\_root\_object) | The object that you want CloudFront to return (for example, `index.html`) when an end user requests the root URL. | `string` | `"index.html"` | no |
| <a name="input_domain_name"></a> [domain\_name](#input\_domain\_name) | The domain name for the website. | `string` | n/a | yes |
| <a name="input_enable_cloudfront_distribution"></a> [enable\_cloudfront\_distribution](#input\_enable\_cloudfront\_distribution) | Whether the distribution is enabled to accept end user requests for content. | `bool` | `true` | no |
| <a name="input_hosted_zone_id"></a> [hosted\_zone\_id](#input\_hosted\_zone\_id) | The Hosted Zone ID. This is automatically generated and can be referenced by zone records. | `string` | n/a | yes |
| <a name="input_profile"></a> [profile](#input\_profile) | Credentials profile to use for aws s3 sync command | `string` | n/a | yes |
| <a name="input_profile"></a> [profile](#input\_profile) | Credentials profile to use for `aws s3 sync command` | `string` | n/a | yes |
| <a name="input_resource_uid"></a> [resource\_uid](#input\_resource\_uid) | UID which will be prepended to resources created by this module | `string` | n/a | yes |
| <a name="input_sync_directories"></a> [sync\_directories](#input\_sync\_directories) | Directories to sync with S3 | <pre>list(object({<br> local_source_directory = string<br> s3_target_directory = string<br> }))</pre> | `[]` | no |

Expand All @@ -140,31 +139,31 @@ No modules.
| <a name="output_acm_certificate_domain_name"></a> [acm\_certificate\_domain\_name](#output\_acm\_certificate\_domain\_name) | The domain name for which the certificate is issued |
| <a name="output_acm_certificate_status"></a> [acm\_certificate\_status](#output\_acm\_certificate\_status) | Status of the certificate. |
| <a name="output_acm_certificate_validation_id"></a> [acm\_certificate\_validation\_id](#output\_acm\_certificate\_validation\_id) | The time at which the certificate was issued |
| <a name="output_cloudfront_distribution_arn"></a> [cloudfront\_distribution\_arn](#output\_cloudfront\_distribution\_arn) | The ARN (Amazon Resource Name) for the distribution. For example: arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5, where 123456789012 is your AWS account ID. |
| <a name="output_cloudfront_distribution_arn"></a> [cloudfront\_distribution\_arn](#output\_cloudfront\_distribution\_arn) | The ARN (Amazon Resource Name) for the distribution. For example: `arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5`, where 123456789012 is your AWS account ID. |
| <a name="output_cloudfront_distribution_caller_reference"></a> [cloudfront\_distribution\_caller\_reference](#output\_cloudfront\_distribution\_caller\_reference) | Internal value used by CloudFront to allow future updates to the distribution configuration. |
| <a name="output_cloudfront_distribution_domain_name"></a> [cloudfront\_distribution\_domain\_name](#output\_cloudfront\_distribution\_domain\_name) | The domain name corresponding to the distribution. For example: d604721fxaaqy9.cloudfront.net. |
| <a name="output_cloudfront_distribution_etag"></a> [cloudfront\_distribution\_etag](#output\_cloudfront\_distribution\_etag) | The current version of the distribution's information. For example: E2QWRUHAPOMQZL. |
| <a name="output_cloudfront_distribution_hosted_zone_id"></a> [cloudfront\_distribution\_hosted\_zone\_id](#output\_cloudfront\_distribution\_hosted\_zone\_id) | The CloudFront Route 53 zone ID that can be used to route an Alias Resource Record Set to. This attribute is simply an alias for the zone ID Z2FDTNDATAQYW2. |
| <a name="output_cloudfront_distribution_id"></a> [cloudfront\_distribution\_id](#output\_cloudfront\_distribution\_id) | The identifier for the distribution. For example: EDFDVBD632BHDS5. |
| <a name="output_cloudfront_distribution_domain_name"></a> [cloudfront\_distribution\_domain\_name](#output\_cloudfront\_distribution\_domain\_name) | The domain name corresponding to the distribution. For example: `d604721fxaaqy9.cloudfront.net`. |
| <a name="output_cloudfront_distribution_etag"></a> [cloudfront\_distribution\_etag](#output\_cloudfront\_distribution\_etag) | The current version of the distribution's information. For example: `E2QWRUHAPOMQZL`. |
| <a name="output_cloudfront_distribution_hosted_zone_id"></a> [cloudfront\_distribution\_hosted\_zone\_id](#output\_cloudfront\_distribution\_hosted\_zone\_id) | The CloudFront Route 53 zone ID that can be used to route an Alias Resource Record Set to. This attribute is simply an alias for the zone ID `Z2FDTNDATAQYW2`. |
| <a name="output_cloudfront_distribution_id"></a> [cloudfront\_distribution\_id](#output\_cloudfront\_distribution\_id) | The identifier for the distribution. For example: `EDFDVBD632BHDS5`. |
| <a name="output_cloudfront_distribution_in_progress_validation_batches"></a> [cloudfront\_distribution\_in\_progress\_validation\_batches](#output\_cloudfront\_distribution\_in\_progress\_validation\_batches) | The number of invalidation batches currently in progress. |
| <a name="output_cloudfront_distribution_last_modified_time"></a> [cloudfront\_distribution\_last\_modified\_time](#output\_cloudfront\_distribution\_last\_modified\_time) | The date and time the distribution was last modified. |
| <a name="output_cloudfront_distribution_status"></a> [cloudfront\_distribution\_status](#output\_cloudfront\_distribution\_status) | The current status of the distribution. Deployed if the distribution's information is fully propagated throughout the Amazon CloudFront system. |
| <a name="output_cloudfront_distribution_tags_all"></a> [cloudfront\_distribution\_tags\_all](#output\_cloudfront\_distribution\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block. |
| <a name="output_cloudfront_distribution_tags_all"></a> [cloudfront\_distribution\_tags\_all](#output\_cloudfront\_distribution\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider `default\_tags` configuration block. |
| <a name="output_cloudfront_distribution_trusted_key_groups"></a> [cloudfront\_distribution\_trusted\_key\_groups](#output\_cloudfront\_distribution\_trusted\_key\_groups) | List of nested attributes for active trusted key groups, if the distribution is set up to serve private content with signed URLs |
| <a name="output_cloudfront_distribution_trusted_signers"></a> [cloudfront\_distribution\_trusted\_signers](#output\_cloudfront\_distribution\_trusted\_signers) | List of nested attributes for active trusted signers, if the distribution is set up to serve private content with signed URLs |
| <a name="output_cloudfront_origin_access_identity_caller_reference"></a> [cloudfront\_origin\_access\_identity\_caller\_reference](#output\_cloudfront\_origin\_access\_identity\_caller\_reference) | Internal value used by CloudFront to allow future updates to the origin access identity. |
| <a name="output_cloudfront_origin_access_identity_cloudfront_access_identity_path"></a> [cloudfront\_origin\_access\_identity\_cloudfront\_access\_identity\_path](#output\_cloudfront\_origin\_access\_identity\_cloudfront\_access\_identity\_path) | A shortcut to the full path for the origin access identity to use in CloudFront, see below. |
| <a name="output_cloudfront_origin_access_identity_etag"></a> [cloudfront\_origin\_access\_identity\_etag](#output\_cloudfront\_origin\_access\_identity\_etag) | The current version of the origin access identity's information. For example: E2QWRUHAPOMQZL. |
| <a name="output_cloudfront_origin_access_identity_etag"></a> [cloudfront\_origin\_access\_identity\_etag](#output\_cloudfront\_origin\_access\_identity\_etag) | The current version of the origin access identity's information. For example: `E2QWRUHAPOMQZL`. |
| <a name="output_cloudfront_origin_access_identity_iam_arn"></a> [cloudfront\_origin\_access\_identity\_iam\_arn](#output\_cloudfront\_origin\_access\_identity\_iam\_arn) | A pre-generated ARN for use in S3 bucket policies (see below). Example: arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E2QWRUHAPOMQZL. |
| <a name="output_cloudfront_origin_access_identity_id"></a> [cloudfront\_origin\_access\_identity\_id](#output\_cloudfront\_origin\_access\_identity\_id) | The identifier for the distribution. For example: EDFDVBD632BHDS5. |
| <a name="output_cloudfront_origin_access_identity_id"></a> [cloudfront\_origin\_access\_identity\_id](#output\_cloudfront\_origin\_access\_identity\_id) | The identifier for the distribution. For example: `EDFDVBD632BHDS5`. |
| <a name="output_cloudfront_origin_access_identity_s3_canonical_user_id"></a> [cloudfront\_origin\_access\_identity\_s3\_canonical\_user\_id](#output\_cloudfront\_origin\_access\_identity\_s3\_canonical\_user\_id) | The Amazon S3 canonical user ID for the origin access identity, which you use when giving the origin access identity read permission to an object in Amazon S3. |
| <a name="output_route53_acm_certificate_validation_records"></a> [route53\_acm\_certificate\_validation\_records](#output\_route53\_acm\_certificate\_validation\_records) | Route 53 validation records for the ACM certificate. |
| <a name="output_route53_root_a_record_name"></a> [route53\_root\_a\_record\_name](#output\_route53\_root\_a\_record\_name) | The name of the root A record. |
| <a name="output_route53_root_www_record_name"></a> [route53\_root\_www\_record\_name](#output\_route53\_root\_www\_record\_name) | The name of the www A record. |
| <a name="output_route53_root_www_record_name"></a> [route53\_root\_www\_record\_name](#output\_route53\_root\_www\_record\_name) | The name of the `www` A record. |
| <a name="output_s3_bucket_access_policy"></a> [s3\_bucket\_access\_policy](#output\_s3\_bucket\_access\_policy) | Bucket policy to allow CloudFront to access the S3 bucket. |
| <a name="output_s3_bucket_access_policy_json"></a> [s3\_bucket\_access\_policy\_json](#output\_s3\_bucket\_access\_policy\_json) | JSON bucket policy to allow CloudFront to access the S3 bucket. |
| <a name="output_s3_bucket_acl"></a> [s3\_bucket\_acl](#output\_s3\_bucket\_acl) | The ACL of the bucket. |
| <a name="output_s3_bucket_arn"></a> [s3\_bucket\_arn](#output\_s3\_bucket\_arn) | The ARN of the bucket. Will be of format arn:aws:s3:::bucketname. |
| <a name="output_s3_bucket_arn"></a> [s3\_bucket\_arn](#output\_s3\_bucket\_arn) | The ARN of the bucket. Will be of format `arn:aws:s3:::bucketname`. |
| <a name="output_s3_bucket_id"></a> [s3\_bucket\_id](#output\_s3\_bucket\_id) | The name of the bucket. |
| <a name="output_s3_bucket_region"></a> [s3\_bucket\_region](#output\_s3\_bucket\_region) | The AWS region this bucket resides in. |
| <a name="output_s3_bucket_versioning"></a> [s3\_bucket\_versioning](#output\_s3\_bucket\_versioning) | The bucket versioning status. |
Expand All @@ -176,14 +175,14 @@ Please use the issue tracker to report any bugs or file feature requests.
Developing
If you are interested in being a contributor and want to get involved in developing this project or help out with our other projects, we would love to hear from you! Shoot us an email.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
In general, PRs are welcome. We follow the typical **"fork-and-pull"** Git workflow.

Fork the repo on GitHub
Clone the project to your own machine
Commit changes to your own branch
Push your work back up to your fork
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 changes from **"upstream"** before making a pull request!

## To Do

Expand All @@ -197,17 +196,17 @@ Please use the [issue tracker](https://github.com/DevOpsNavy/s3-cloudfront-stati

### Developing

If you are interested in being a contributor and want to get involved in developing this project or with our other projects, we would love to hear from you! Shoot us an [email][[email protected]].
If you are interested in being a contributor and want to get involved in developing this project or with our other projects, we would love to hear from you! Shoot us an [email](mailto:[email protected]).

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
In general, PRs are welcome. We follow the typical **"fork-and-pull"** Git workflow.

1. **Fork** the repo on GitHub
1. [**Fork**](https://github.com/InterweaveCloud/terraform-aws-s3-cloudfront-static-website/fork) the repo on GitHub
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

**NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request!
**NOTE:** Be sure to merge the latest changes from **"upstream"** before making a pull request!

## Contributors

Expand Down