Skip to content

Files

Latest commit

 

History

History

complete

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Complete CloudFront distribution with most of supported features enabled

Configuration in this directory creates CloudFront distribution which demos such capabilities:

  • access logging
  • origins and origin groups
  • caching behaviours
  • Origin Access Identities (with S3 bucket policy)
  • Lambda@Edge
  • ACM certificate
  • Route53 record
  • VPC Origins

Usage

To run this example you need to execute:

$ terraform init
$ terraform plan
$ terraform apply

Note that this example may create resources which cost money. Run terraform destroy when you don't need these resources.

Requirements

Name Version
terraform >= 1.0
aws >= 5.83
null >= 2.0
random >= 2.0

Providers

Name Version
aws >= 5.83
null >= 2.0
random >= 2.0

Modules

Name Source Version
acm terraform-aws-modules/acm/aws ~> 4.0
cloudfront ../../ n/a
ec2 terraform-aws-modules/ec2-instance/aws ~> 5.0
lambda_function terraform-aws-modules/lambda/aws ~> 7.0
log_bucket terraform-aws-modules/s3-bucket/aws ~> 4.0
records terraform-aws-modules/route53/aws//modules/records ~> 2.0
s3_one terraform-aws-modules/s3-bucket/aws ~> 4.0

Resources

Name Type
aws_cloudfront_function.example resource
aws_s3_bucket_policy.bucket_policy resource
null_resource.download_package resource
random_pet.this resource
aws_ami.al2023 data source
aws_canonical_user_id.current data source
aws_cloudfront_log_delivery_canonical_user_id.cloudfront data source
aws_iam_policy_document.s3_policy data source
aws_route53_zone.this data source

Inputs

No inputs.

Outputs

Name Description
cloudfront_distribution_arn The ARN (Amazon Resource Name) for the distribution.
cloudfront_distribution_caller_reference Internal value used by CloudFront to allow future updates to the distribution configuration.
cloudfront_distribution_domain_name The domain name corresponding to the distribution.
cloudfront_distribution_etag The current version of the distribution's information.
cloudfront_distribution_hosted_zone_id The CloudFront Route 53 zone ID that can be used to route an Alias Resource Record Set to.
cloudfront_distribution_id The identifier for the distribution.
cloudfront_distribution_in_progress_validation_batches The number of invalidation batches currently in progress.
cloudfront_distribution_last_modified_time The date and time the distribution was last modified.
cloudfront_distribution_status The current status of the distribution. Deployed if the distribution's information is fully propagated throughout the Amazon CloudFront system.
cloudfront_distribution_trusted_signers List of nested attributes for active trusted signers, if the distribution is set up to serve private content with signed URLs
cloudfront_origin_access_identities The origin access identities created
cloudfront_origin_access_identity_iam_arns The IAM arns of the origin access identities created
cloudfront_origin_access_identity_ids The IDS of the origin access identities created
cloudfront_vpc_origin_ids The IDS of the VPC origin created