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.
Before you begin, make sure you have the following prerequisites:
- Terraform installed on your local machine.
- Cloudflare account with a domain and Cloudflare API token.
- AWS credentials configured with the necessary permissions.
Note: You can't use ".ir" domain name, Amazon ACM doesn't support it.
$ 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
https://github.com/99designs/aws-vault
$ aws-vault add <profile>
You need some permissions for your IAM user that you want to work with that to make your progress.
- Amazon S3
- DynamoDB
- CloudFront
- ACM
- WAF V2
- Your DynamoDB table ARN
- All Resources for other Services
clone the repository:
$ sudo git clone https://github.com/adel-bz/Static-Website-AWS.git
In the second step, You should create a DynamoDB table and S3 bucket. like this link: https://spacelift.io/blog/terraform-s3-backend
Also, go to "backend.tf" file then change the terraform backend block and import your information.
Change Variables in variables.tf
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
Contributions are welcome! Follow these steps to contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature-name
- Make your changes and commit them:
git commit -m 'Add feature'
- Push to the branch:
git push origin feature-name
- Submit a pull request.