Skip to content

Commit 8ddc75f

Browse files
chore: update docs and semantics (#2)
1 parent 3ccf059 commit 8ddc75f

File tree

5 files changed

+102
-14
lines changed

5 files changed

+102
-14
lines changed

.github/workflows/semantic-check.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Semantic Check"
2+
on:
3+
pull_request_target:
4+
types:
5+
- opened
6+
- edited
7+
- synchronize
8+
permissions:
9+
contents: read
10+
pull-requests: read
11+
jobs:
12+
main:
13+
name: Semantic Commit Message Check
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # ratchet:actions/checkout@v4
17+
- uses: amannn/action-semantic-pull-request@cfb60706e18bc85e8aec535e3c577abe8f70378e # ratchet:amannn/action-semantic-pull-request@v5
18+
name: Check PR for Semantic Commit Message
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
with:
22+
requireScope: false
23+
validateSingleCommit: true
24+
ignoreLabels: release merge

README.md

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,89 @@
1-
# AWS Static Website Hosting Project
21

3-
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.
2+
# Terraform AWS Complete Static Site Module
3+
4+
[![Terraform](https://img.shields.io/badge/Terraform-0.12.0-623CE4)](https://www.terraform.io)
5+
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6+
7+
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.
48

59
## Description
610

7-
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.
11+
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.
12+
13+
This module provisions:
14+
15+
- AWS Route53 records
16+
- AWS ACM certificates
17+
- AWS CloudFront distributions
18+
- IAM user
19+
- S3 bucket
20+
21+
![image](assets/diagram.png)
22+
23+
## Usage
24+
25+
### Example with a custom domain (sub domain)
26+
```hcl
27+
module "frontend" {
28+
source = "github.com/iKnowJavaScript/terraform-aws-complete-static-site"
29+
30+
name = "example-website"
31+
environment = "prod"
32+
create_custom_domain = true
33+
hosted_zone_domain = "example.com"
34+
custom_domain_name = "example-website.example.com"
35+
aws_region = "us-east-1"
36+
tags = {}
37+
}
838
9-
## How to Use
39+
provider "aws" {
40+
region = "us-east-1"
41+
}
42+
```
1043

11-
1. **Clone the Repository**: Clone this repository to your local machine.
44+
### Example with default CloudFlare domain
45+
```hcl
46+
module "frontend" {
47+
source = "github.com/iKnowJavaScript/terraform-aws-complete-static-site"
1248
13-
2. **Install Terraform**: If you haven't already, [install Terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli).
49+
name = "example-website"
50+
environment = "prod"
51+
create_custom_domain = false
52+
aws_region = "us-east-1"
53+
tags = {}
54+
}
1455
15-
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.
56+
provider "aws" {
57+
region = "us-east-1"
58+
}
59+
```
1660

17-
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.
61+
## Inputs
1862

19-
5. **Initialize Terraform**: Navigate to the project directory and run `terraform init` to initialize your Terraform workspace.
63+
| Name | Description | Type | Default | Required |
64+
|------|-------------|------|---------|:--------:|
65+
| aws_region | The AWS region to create resources in | `string` | n/a | no |
66+
| hosted_zone_domain | (OPTIONAL) Hosted zone to add doamin and cloufront Cname to | `string` | n/a | no |
67+
| 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 |
68+
| create_custom_domain | Whether to create a custom domain | `bool` | `false` | no |
69+
| name | The project name | `string` | n/a | yes |
70+
| environment | The environment the resources is meant for. | `string` | n/a | yes |
71+
| tags | Resources tags. | `map(string)` | n/a | no |
2072

21-
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.
2273

23-
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.
74+
## Outputs
2475

25-
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.
76+
| Name | Description | Sensitive |
77+
|------|-------------|:---------:|
78+
| cloudflare_domain | Direct cloudflare domain | No |
79+
| custom_domain | Custom domain name | No |
80+
| bucket_name | S3 bucket name | No |
81+
| access_key_id | The access key ID for the S3 user | No |
82+
| secret_access_key | The secret access key for the S3 user | Yes |
83+
| domain_certificate_arn | The ARN of the domain certificate | No |
2684

85+
*To view sensitive secret, try `terraform output secret_access_key`*
2786

2887
## License
2988

30-
This project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.
89+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.

assets/diagram.png

76.3 KB
Loading

output.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@ output "secret_access_key" {
2424
sensitive = true
2525
}
2626

27+
output "domain_certificate_arn" {
28+
value = var.create_custom_domain ? module.dns[0].certificate_arn : null
29+
description = "The ARN of the domain certificate"
30+
}
31+
2732
# to view sensitive secret, try
2833
# terraform output secret_access_key

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ variable "aws_region" {
1818

1919
variable "create_custom_domain" {
2020
type = bool
21-
description = "(OPTIONAL) Whether to use a custom domain or not"
21+
description = "(OPTIONAL) Whether to use a custom domain or not."
2222
default = false
2323
}
2424

0 commit comments

Comments
 (0)