terraform-aws-cloudfront

Terraform Module that implements a CloudFront Distribution (CDN) for a custom origin (e.g. website or video streaming)

linter release.draft

Maintenance GitHub forks

Documentation

Terraform resources

Usage example

IMPORTANT: The master branch is used in source just as an example. In your code, do not pin to master because there may be breaking changes between releases. Instead pin to the release tag (e.g. ?ref=tags/x.y.z) of one of our latest releases.

See examples directory for working examples to reference:

module cloudfront {
  source  = "terraform-module/cloudfront/aws"
  version = "~> 1"

  tags = { Environment = "dev" }
  comment = "dev"
  dynamic_s3_origin_config = [{
    domain_name = "media-assets.s3.us-west-2.amazonaws.com"
  }]
}

Assumptions

Available features

Module Variables

Requirements

Name Version
terraform >= 1

Providers

Name Version
aws n/a

Modules

No modules.

Resources

Name Type
aws_cloudfront_distribution.this resource
aws_cloudfront_origin_access_identity.this resource
aws_cloudfront_response_headers_policy.this data source

Inputs

Name Description Type Default Required
aliases Extra CNAMEs (alternate domain names), if any, for this distribution. list(string) null no
comment Any comments you want to include about the distribution. string "Managed by Terraform" no
default_cache_behavior Default Cache Behviors to be used in dynamic block. any
{
"allowed_methods": [
"GET",
"HEAD",
"OPTIONS"
],
"default_ttl": 3600,
"max_ttl": 86400,
"min_ttl": 0
}
no
default_root_object The object that you want CloudFront to return (for example, index.html) when an end user requests the root URL. string null no
enabled Set to false to prevent the module from creating any resources. bool "true" no
geo_restrictions The method that you want to use to restrict distribution of your content by country.
list(object({
locations = list(string)
restriction_type = string
}))
[
{
"locations": [],
"restriction_type": "none"
}
]
no
is_ipv6_enabled State of CloudFront IPv6 bool "false" no
price_class The price class for this distribution. Values: PriceClass_All, PriceClass_200, PriceClass_100. string "PriceClass_100" no
s3_origin_config Configuration for the s3 origin config to be used in dynamic block. list(map(string)) [] no
tags A mapping of tags to assign to the object. map(any) {} no
viewer_certificate The SSL configuration for this distribution any
{
"cloudfront_default_certificate": true,
"minimum_protocol_version": "TLSv1"
}
no

Outputs

Name Description
ai_iam_arn Access identity pre-generated ARN for use in S3 bucket policies
ai_id Access identity identifier for the distribution. For example: EDFDVBD632BHDS5
ai_path Access identity shortcut to the full path for the origin access identity to use in CloudFron
cf_arn ARN of AWS CloudFront distribution
cf_domain_name Domain name corresponding to the distribution
cf_etag Current version of the distribution's information
cf_hosted_zone_id CloudFront Route 53 zone ID
cf_id ID of AWS CloudFront distribution
cf_status Current status of the distribution

Commands

$ make help
hooks                          Commit hooks setup
validate                       Validate with pre-commit hooks
changelog                      Update changelog

📝 Guidelines

  • 📝 Use a succinct title and description.
  • 🐛 Bugs & feature requests can be be opened
  • 📶 Support questions are better asked on Stack Overflow
  • 😊 Be nice, civil and polite (as always).

License

Copyright 2019 Ivan Katliarhcuk

MIT Licensed. See LICENSE for full details.

How to Contribute

Submit a pull request

Authors

Currently maintained by Ivan Katliarchuk and these awesome contributors.

ForTheBadge uses-git

Terraform Registry

Resources