From a3f993d6dbd1a1feb08ca805d98080f1a3899e94 Mon Sep 17 00:00:00 2001 From: Victor Omolayo Date: Mon, 20 May 2024 20:20:45 +0100 Subject: [PATCH 1/2] chore: update docs and setup for next release (#4) --- README.md | 8 +-- examples/with-custom-subdomain/README.md | 66 ++++++++++++++++++++++++ examples/without-custom-domain/README.md | 55 ++++++++++++++++++++ 3 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 examples/with-custom-subdomain/README.md create mode 100644 examples/without-custom-domain/README.md diff --git a/README.md b/README.md index e3dde5c..5d650ce 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Terraform AWS Complete Static Site Module -[![Terraform](https://img.shields.io/badge/Terraform-0.12.0-623CE4)](https://www.terraform.io) +[![Terraform registry](https://img.shields.io/badge/Terraform_Registry-0.0.2-blue)](https://registry.terraform.io/modules/iKnowJavaScript/complete-static-site/aws/latest) +[![Terraform](https://img.shields.io/badge/Terraform-0.0.2-623CE4)](https://www.terraform.io) [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) This Terraform module consist the configuration for hosting a static website on AWS. It creates and configures the necessary AWS resources including S3, Route 53 (DNS), IAM, CloudFront, and WAF. @@ -18,6 +19,7 @@ This module provisions: - IAM user - S3 bucket +### Architecture Diagram ![image](assets/diagram.png) ## Usage @@ -25,7 +27,7 @@ This module provisions: ### Example with a custom domain (sub domain) ```hcl module "frontend" { - source = "github.com/iKnowJavaScript/terraform-aws-complete-static-site" + source = "iKnowJavaScript/complete-static-site/aws" name = "example-website" environment = "prod" @@ -44,7 +46,7 @@ provider "aws" { ### Example with default CloudFlare domain ```hcl module "frontend" { - source = "github.com/iKnowJavaScript/terraform-aws-complete-static-site" + source = "iKnowJavaScript/complete-static-site/aws" name = "example-website" environment = "prod" diff --git a/examples/with-custom-subdomain/README.md b/examples/with-custom-subdomain/README.md new file mode 100644 index 0000000..f635653 --- /dev/null +++ b/examples/with-custom-subdomain/README.md @@ -0,0 +1,66 @@ +# Example Website Terraform Module with Custom Sub domain + +This Terraform module is utilized for deploying a static website on AWS with a custom subdomain, leveraging resources such as S3, CloudFront, Route 53, WAF, and IAM. + +## Overview + +Using this module, users can easily create a production-ready static website hosted on AWS infrastructure. With features like a secure S3 bucket for website content, CloudFront for optimized delivery, WAF WebACL for site protection, and a custom domain setup through Route 53, the module simplifies the way static websites are deployed and managed. + +The configuration also includes an IAM user for facilitating continuous deployment processes directly to the S3 bucket. + +### Architecture Diagram + +![](../../assets/diagram.png) + +## How to Use This Module + +Below is an example of how you can use this module in your Terraform configuration to set up a static website with a custom subdomain. + +```hcl +module "website" { + source = "../../" + + name = "example-website" + environment = "prod" + hosted_zone_domain = "example.com" + custom_domain_name = "example-website.example.com" + create_custom_domain = true + aws_region = "us-east-2" +} +``` + +Make sure to include the `aws` provider block in your configuration: + +```hcl +provider "aws" { + region = "us-east-2" +} +``` + +### Inputs for Custom Domain Setup + +| Name | Description | Type | Default | Required | +|---------------------|---------------------------------------------------------------------|------------|---------|:--------:| +| `name` | The project/site name | `string` | n/a | yes | +| `environment` | The environment (e.g., staging, prod) | `string` | n/a | yes | +| `hosted_zone_domain`| Your hosted zone domain in Route 53 | `string` | n/a | yes | +| `custom_domain_name`| The full custom subdomain to set up | `string` | n/a | yes | +| `create_custom_domain` | A flag indicating whether to create a custom domain | `bool` | `true` | no | +| `aws_region` | AWS region where resources will be created | `string` | n/a | yes | + +### Outputs + +| Name | Description | Sensitive | +|---------------------------|---------------------------------------------|:---------:| +| `cloudflare_domain` | The direct CloudFront domain | No | +| `custom_domain` | The custom domain name | No | +| `bucket_name` | The name of the S3 bucket | No | +| `access_key_id` | Access key ID for the S3 user | No | +| `secret_access_key` | Secret access key for the S3 user | Yes | +| `domain_certificate_arn` | The ARN of the domain certificate | No | + +Sensitive information like the `secret_access_key` can be accessed using the Terraform CLI command `terraform output secret_access_key`. + +## License + +This code is provided under the MIT License. See the included [LICENSE.md](LICENSE.md) file for more information. \ No newline at end of file diff --git a/examples/without-custom-domain/README.md b/examples/without-custom-domain/README.md new file mode 100644 index 0000000..69909fd --- /dev/null +++ b/examples/without-custom-domain/README.md @@ -0,0 +1,55 @@ +# Example Website Terraform Module without Custom Domain + +Deploy your static website on AWS without the need for a custom domain using this Terraform module. It provisions essential resources such as an S3 bucket, CloudFront distribution, and IAM user for secure and efficient hosting. + +## Overview + +This module sets up a static website hosting environment optimized for production use. By creating a secure S3 bucket to host your content, setting up a CloudFront distribution for fast global access, and establishing IAM security for continuous deployment processes, the module offers a straightforward approach to deploying static websites on AWS. + +### Architecture Diagram + +![](../../assets/diagram.png) + +## How to Use This Module + +To deploy your static website without a custom domain, you can use the module in your Terraform configuration like so: + +```hcl +module "website" { + source = "../../" + + name = "example-website" + environment = "prod" + create_custom_domain = false + aws_region = "us-east-2" +} + +provider "aws" { + region = "us-east-2" +} +``` + +### Inputs for Default Domain Setup + +| Name | Description | Type | Default | Required | +|-------------------------|--------------------------------------------------------|----------|---------|:--------:| +| `name` | The project/site name | `string` | n/a | yes | +| `environment` | The environment (e.g., staging, prod) | `string` | n/a | yes | +| `create_custom_domain` | A flag indicating whether to create a custom domain | `bool` | `false` | no | +| `aws_region` | AWS region where resources will be created | `string` | n/a | yes | + +### Outputs + +| Name | Description | Sensitive | +|---------------------------|------------------------------------------|:---------:| +| `cloudflare_domain` | The direct CloudFront domain | No | +| `bucket_name` | The name of the S3 bucket | No | +| `access_key_id` | Access key ID for the S3 user | No | +| `secret_access_key` | Secret access key for the S3 user | Yes | +| `domain_certificate_arn` | The ARN of the default domain certificate| No | + +To retrieve sensitive outputs like the `secret_access_key`, use the `terraform output` command with caution, for example: `terraform output secret_access_key`. + +## License + +This code is provided under the MIT License. Full licensing details are available in the included [LICENSE.md](LICENSE.md) file. \ No newline at end of file From d09465709c0ffa7dab311824dee1253e2cc20895 Mon Sep 17 00:00:00 2001 From: Victor Omolayo Date: Tue, 21 May 2024 23:22:56 +0100 Subject: [PATCH 2/2] chore: add cost estmate to documentation (#5) --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 5d650ce..be66db7 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,39 @@ provider "aws" { *To view sensitive secret, try `terraform output secret_access_key`* +## Cost Estimate + +This cost estimate is based on **on-demand** pricing. AWS offers free tiers for some of these resources, which may reduce or eliminate costs for small-scale or new users. + +Assuming 1,000 unique IPs traffic daily with the assumption of 1MB as page size, we'll have 30,000 Requests monthly and 30GB data transfer. Here's how the estimated breakdown will look like: + +### S3 +- **Storage**: $0.023/GB (Standard Storage) (Assuming our app is 100MB) = $0.0023 (Pretty low) +- **Request**: GET $0.0004 per 1,000 requests. 30,000 will be $0.012 +- **Data Transfer**: Too low - CloudFront caching + +### CloudFront +- **Data Transfer**: $0.085 per GB for the first 10TB = $0.085 * 30 = $2.55 +- **Request**: $0.0075 per 10,000 HTTP/HTTPS requests. 30,000 will be $0.0225 + +### WAF +- **WebACL**: $5 per WebACL +- **Rule**: $1 per rule per WebACL. Assuming 10 rules, the cost will be $10 +- **Requests**: $0.60 per 1 million requests. 30,000 requests will be $0.018 + +The total cost will be approximately **$2.586** for S3 and CloudFront, and $15.018 for WAF, making the grand total approximately $17.604. + +Please note that these are just estimates. The actual cost may vary depending on the usage, data transfer, and number of requests. Also, this doesn't include potential costs for Route53, ACM, and other AWS services that might be used. + +This changes drastically for 100M visits daily or weekly but latency will still be guaranteed. + +This estimation serves as a rough guide. Actual costs may vary based on several factors, including the geographic distribution of requests, the size of the objects being requested, caching efficiency, and any applicable discounts or reserved pricing. + +It’s important to employ strategies to minimize costs, such as optimizing content delivery, using budget alarms, employing efficient caching, and regularly reviewing usage patterns. + +AWS offers a [pricing calculator](https://calculator.aws/#/) to provide more precise and tailored cost estimations, considering specific details and configurations of your static site deployment. + + ## License This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy