https://github.com/adel-bz/static-website-aws
Static Website on AWS with Terraform
https://github.com/adel-bz/static-website-aws
aws aws-acm aws-cloudfront aws-s3 cloudflare terraform wafv2
Last synced: 8 months ago
JSON representation
Static Website on AWS with Terraform
- Host: GitHub
- URL: https://github.com/adel-bz/static-website-aws
- Owner: adel-bz
- Created: 2024-01-22T05:48:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-03T08:22:31.000Z (over 1 year ago)
- Last Synced: 2025-01-01T04:35:05.659Z (9 months ago)
- Topics: aws, aws-acm, aws-cloudfront, aws-s3, cloudflare, terraform, wafv2
- Language: HCL
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Static Website on AWS with Terraform
# Introduction
This repository contains Terraform scripts to set up a static website on AWS using Amazon S3 and Amazon CloudFront.
Also, It has used Cloudflare and Amazon ACM to manage Domain and SSL Certification.
# Prerequisites
Before you begin, make sure you have the following prerequisites:
- [Terraform](https://www.terraform.io/) installed on your local machine.
- Cloudflare account with a domain and Cloudflare API [token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/).
- AWS credentials configured with the necessary [permissions](https://github.com/adel-bz/Static-Website-AWS#permissions).
> **Note:**
> You can't use ".ir" domain name, Amazon ACM doesn't support it.#### Install aws-vault on Ubuntu:
```
$ sudo curl -L -o /usr/local/bin/aws-vault https://github.com/99designs/aws-vault/releases/latest/download/aws-vault-linux-amd64
$ sudo chmod 755 /usr/local/bin/aws-vault
```
#### Install aws-vault on other OS:
https://github.com/99designs/aws-vault#### To store AWS credentials for use, enter:
```
$ aws-vault add
```# Permissions
You need some permissions for your IAM user that you want to work with that to make your progress.
#### Services
- Amazon S3
- DynamoDB
- CloudFront
- ACM
- WAF V2#### Resources
- Your DynamoDB table ARN
- All Resources for other Services
# Usage
### Step 1:
clone the repository:
```
$ sudo git clone https://github.com/adel-bz/Static-Website-AWS.git
```
### Step 2:
In the second step, You should create a DynamoDB table and S3 bucket. like this link: https://spacelift.io/blog/terraform-s3-backendAlso, go to "backend.tf" file then change the terraform backend block and import your information.
### Step 3:
Change Variables in variables.tf### Step 4:
Run these commands step by step:
```
$ terraform init
$ terraform workspace new production # To create the production environment, you can change it to dev, stage, or any environment you want.
$ terraform fmt
$ terraform validate
$ terraform plan
$ terraform apply## If you want to destroy your infrastructure, use:
$ terraform destroy
```

# ContributingContributions are welcome! Follow these steps to contribute:
1. Fork the repository.
2. Create a new branch: ```git checkout -b feature-name```
3. Make your changes and commit them: ```git commit -m 'Add feature'```
4. Push to the branch: ```git push origin feature-name```
5. Submit a pull request.