Skip to content

chore: update docs and semantics #3

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
24 changes: 24 additions & 0 deletions .github/workflows/semantic-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Semantic Check"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
permissions:
contents: read
pull-requests: read
jobs:
main:
name: Semantic Commit Message Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # ratchet:actions/checkout@v4
- uses: amannn/action-semantic-pull-request@cfb60706e18bc85e8aec535e3c577abe8f70378e # ratchet:amannn/action-semantic-pull-request@v5
name: Check PR for Semantic Commit Message
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
requireScope: false
validateSingleCommit: true
ignoreLabels: release merge
85 changes: 72 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,89 @@
# AWS Static Website Hosting Project

This project provides a Terraform 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.
# Terraform AWS Complete Static Site Module

[![Terraform](https://img.shields.io/badge/Terraform-0.12.0-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.

## Description

This project sets up an S3 bucket for storing your static website content, a CloudFront distribution for content delivery, a WAF WebACL for protecting your site, and a Route 53 record for DNS. It also creates an IAM user for managing continuous deployment to the s3 bucket.
This Terraform module sets up an S3 bucket for storing your static website content, a CloudFront distribution for content delivery, OAI for access the bucket through CloudFront(Secure access), a WAF WebACL for protecting your site, and a Route 53 record for DNS. It also creates an IAM user for managing continuous deployment to the s3 bucket.

This module provisions:

- AWS Route53 records
- AWS ACM certificates
- AWS CloudFront distributions
- IAM user
- S3 bucket

![image](assets/diagram.png)

## Usage

### Example with a custom domain (sub domain)
```hcl
module "frontend" {
source = "github.com/iKnowJavaScript/terraform-aws-complete-static-site"

name = "example-website"
environment = "prod"
create_custom_domain = true
hosted_zone_domain = "example.com"
custom_domain_name = "example-website.example.com"
aws_region = "us-east-1"
tags = {}
}

## How to Use
provider "aws" {
region = "us-east-1"
}
```

1. **Clone the Repository**: Clone this repository to your local machine.
### Example with default CloudFlare domain
```hcl
module "frontend" {
source = "github.com/iKnowJavaScript/terraform-aws-complete-static-site"

2. **Install Terraform**: If you haven't already, [install Terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli).
name = "example-website"
environment = "prod"
create_custom_domain = false
aws_region = "us-east-1"
tags = {}
}

3. **Configure AWS Credentials**: Ensure your AWS credentials are correctly configured. You can set them in your environment variables or in your AWS credentials file.
provider "aws" {
region = "us-east-1"
}
```

4. **Update Credential**: Navigate to the project directory, update the `input.auto.tfvars` file to suite your project need and update `terraform.tf` backend object as deem fit or remove if you don't intent to save your states remotely.
## Inputs

5. **Initialize Terraform**: Navigate to the project directory and run `terraform init` to initialize your Terraform workspace.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| aws_region | The AWS region to create resources in | `string` | n/a | no |
| hosted_zone_domain | (OPTIONAL) Hosted zone to add doamin and cloufront Cname to | `string` | n/a | no |
| custom_domain_name | (OPTIONAL) Custom domain name. should be a sub.domain to the main domain available on the hosted zone or ''(empty string) to use the domain on hosted zone. | `string` | n/a | no |
| create_custom_domain | Whether to create a custom domain | `bool` | `false` | no |
| name | The project name | `string` | n/a | yes |
| environment | The environment the resources is meant for. | `string` | n/a | yes |
| tags | Resources tags. | `map(string)` | n/a | no |

6. **Apply the Configuration**: Run `terraform apply` to create the AWS resources. You'll be prompted to confirm that you want to create the resources.

7. **Upload Your Website**: Once the resources are created, you can upload your static website content to the S3 bucket. The bucket name will be output by the `terraform apply` command.
## Outputs

8. **Access Your Website**: After your content is uploaded, you can access your website via the CloudFront distribution URL, which will also be output by the `terraform apply` command.
| Name | Description | Sensitive |
|------|-------------|:---------:|
| cloudflare_domain | Direct cloudflare domain | No |
| custom_domain | Custom domain name | No |
| bucket_name | S3 bucket name | No |
| access_key_id | The access key ID for the S3 user | No |
| secret_access_key | The secret access key for the S3 user | Yes |
| domain_certificate_arn | The ARN of the domain certificate | No |

*To view sensitive secret, try `terraform output secret_access_key`*

## License

This project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
Binary file added assets/diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@ output "secret_access_key" {
sensitive = true
}

output "domain_certificate_arn" {
value = var.create_custom_domain ? module.dns[0].certificate_arn : null
description = "The ARN of the domain certificate"
}

# to view sensitive secret, try
# terraform output secret_access_key
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ variable "aws_region" {

variable "create_custom_domain" {
type = bool
description = "(OPTIONAL) Whether to use a custom domain or not"
description = "(OPTIONAL) Whether to use a custom domain or not."
default = false
}

Expand Down
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