Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

chore: update docs and setup for next release #4

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

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions 8 README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -18,14 +19,15 @@ This module provisions:
- IAM user
- S3 bucket

### Architecture Diagram
![image](assets/diagram.png)

## Usage

### 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"
Expand All @@ -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"
Expand Down
66 changes: 66 additions & 0 deletions 66 examples/with-custom-subdomain/README.md
Original file line number Diff line number Diff line change
@@ -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.
55 changes: 55 additions & 0 deletions 55 examples/without-custom-domain/README.md
Original file line number Diff line number Diff line change
@@ -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.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.