This project uses Terraform to set up and manage AWS CloudFront distributions for a static website, checkout process, and other custom distributions on Amazon S3.
main.tf
: Main Terraform configuration filevariables.tf
: Input variables for the Terraform configurationoutputs.tf
: Output values from the Terraform configurationproviders.tf
: Provider configuration for AWSmodules/
: Custom Terraform modulescloudfront_distribution/
: Standard CloudFront distribution modulecustom_cloudfront_distribution/
: Customizable CloudFront distribution module
- Terraform v0.12+
- AWS CLI configured with appropriate credentials
- An Amazon S3 bucket to host your static website content
- Clone this repository
- Update the
variables.tf
file with your desired values - Run
terraform init
to initialize the Terraform working directory - Run
terraform plan
to see the execution plan - Run
terraform apply
to create the resources - After the resources are created, upload your static website content to the S3 bucket
Key variables include:
static_site_bucket_name
: Name of the S3 bucket for the static siteenvironment
: Environment name (e.g., prod, dev, staging)cloudfront_price_class
: CloudFront distribution price classcloudfront_allowed_methods
: HTTP methods that CloudFront processes and forwardscloudfront_cached_methods
: HTTP methods for which CloudFront caches responsescloudfront_min_ttl
: Minimum time for objects to stay in CloudFront cachescloudfront_default_ttl
: Default time for objects in CloudFront cachecloudfront_max_ttl
: Maximum time for objects in CloudFront cache
For a complete list of variables and their descriptions, please refer to the variables.tf
file.
This module creates a customizable CloudFront distribution. It allows you to specify:
- Origin domain name
- Allowed HTTP methods
- Cached HTTP methods
- Price class
- TTL settings (minimum, default, maximum)
- And more
cdn_distribution_domain
: The domain name of the CDN CloudFront distributioncheckout_distribution_domain
: The domain name of the checkout CloudFront distribution
Use these domain names to access your CloudFront-distributed content.
This project uses AWS CloudFront Origin Access Identity (OAI) to secure access to the S3 bucket. Only CloudFront can access the S3 bucket directly.
You can customize the CloudFront distributions by modifying the custom_cloudfront_distribution
module calls in main.tf
. Adjust the input variables to change behaviors such as allowed methods, TTL settings, and more.
[Specify your license here]
[Add contributing guidelines if applicable]
For support, please open an issue in the GitHub repository or contact [your contact information].
This project is provided as-is, without any guarantees or warranty. Users are responsible for ensuring that their use of this code complies with all applicable laws and regulations.