The main objective of this module is to leverage the power of AWS services, specifically CloudFront and S3, to host and deliver your static website efficiently and securely. By utilizing Terraform's infrastructure as code capabilities, this project streamlines the deployment process, making it easy for you to set up and manage your AWS static website.
π―οΈ Mandatory
- π³ Docker ( download )
- π€ AWS account + security keys ( instruction )
aws_access_key_id
aws_secret_access_key
ποΈ Optional
- Domain, located in Amazon AWS Route53
βοΈ Zero-config, one-minute setup with a single CLI command
π AWS providers for smooth deployment and certificate generation
β‘ Out-of-the-box support for static website
πͺ Future-proof, robust architecture
π³ Docker commands under the hood
β Full test coverage
π Additional security headers
By using this project, you can save time and effort in setting up your AWS static website. Its comprehensive Terraform code and thoughtful configuration options allow you to create a reliable, scalable, and performant static website on AWS without any problems.
Feel free to explore the project on GitHub. Happy coding!
1st step:
Download two files main.tf
and provider.tf
from one of examples directories.
2nd step:
Run one of the following commands inside directory with those two files.
( it will use docker image with HashiCorp with TerraForm application inside)
If you have used AWS CLI already, you can attach keys by running this command:
docker container run -it --rm -v $PWD:/tf -v ~/.aws:/root/.aws --workdir /tf hashicorp/terraform:latest init
If you haven't used AWS CLI, you can pass those keys directly, by running this command: ( don't forget to replace XXXX with your AWS keys )
docker container run -it --rm -e TF_VAR_aws_access_key_id=XXXXXXXX -e TF_VAR_aws_secret_access_key=XXXXXXX -v $PWD:/tf --workdir /tf hashicorp/terraform:latest init
3rd step:
Run the command, that you used previously, but instead of init
at the end of the command, write apply
It should look like this :
docker container run -it --rm -v $PWD:/tf -v ~/.aws:/root/.aws --workdir /tf hashicorp/terraform:latest apply
4th step:
Run the command, that you used previously, but instead of apply
at the end of the command, write deploy
It should look like this :
docker container run -it --rm -v $PWD:/tf -v ~/.aws:/root/.aws --workdir /tf hashicorp/terraform:latest deploy
5th step:
Profit ! πͺ
Example 1 -> CloudFront + S3
module "website-static-cloudfront-s3" {
source = "nulllogic/website-static-cloudfront-s3/aws"
tags = {
Environment = "dev"
Terraform = "true"
}
}

Example 2 -> CloudFront + S3 + Domain
module "website-static-cloudfront-s3" {
source = "nulllogic/website-static-cloudfront-s3/aws"
route53 = {
domain = "example.com"
}
tags = {
Environment = "dev"
Terraform = "true"
}
}

See Contributing
See Changelog
Licensed under the MIT License