{"id":26454117,"url":"https://github.com/coolapso/terraform-aws-cloudfront-and-edge","last_synced_at":"2026-05-04T14:42:42.757Z","repository":{"id":223044678,"uuid":"759177174","full_name":"coolapso/terraform-aws-cloudfront-and-edge","owner":"coolapso","description":"Terraform module to serve static website from s3 with cloudfront and lambda@egde function for subdirectories","archived":false,"fork":false,"pushed_at":"2024-07-02T21:28:30.000Z","size":33,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-02T23:10:58.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coolapso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"coolapso","buy_me_a_coffee":"coolapso"}},"created_at":"2024-02-17T21:24:35.000Z","updated_at":"2024-10-30T08:04:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"bc823f56-9c7e-4b8d-b1de-35b2ba8bd118","html_url":"https://github.com/coolapso/terraform-aws-cloudfront-and-edge","commit_stats":null,"previous_names":["4s3ti/terraform-aws-cloudfront-and-edge","coolapso/terraform-aws-cloudfront-and-edge"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/coolapso/terraform-aws-cloudfront-and-edge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolapso%2Fterraform-aws-cloudfront-and-edge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolapso%2Fterraform-aws-cloudfront-and-edge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolapso%2Fterraform-aws-cloudfront-and-edge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolapso%2Fterraform-aws-cloudfront-and-edge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coolapso","download_url":"https://codeload.github.com/coolapso/terraform-aws-cloudfront-and-edge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolapso%2Fterraform-aws-cloudfront-and-edge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32612318,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"ssl_error","status_checked_at":"2026-05-04T10:08:02.005Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-18T19:44:30.164Z","updated_at":"2026-05-04T14:42:42.741Z","avatar_url":"https://github.com/coolapso.png","language":"HCL","funding_links":["https://github.com/sponsors/coolapso","https://buymeacoffee.com/coolapso"],"categories":[],"sub_categories":[],"readme":"# Terraform AWS Cloudfront for s3 \n\nFully written and tested using [OpenTofu](https://github.com/opentofu/opentofu)\n\nSimple AWS Cloudfront to serve static websites from S3.\n\n## Key features\n\n* lambda@edge function if you want to serve content in subfolders without needing to provide the index.html, \nfor example: `https://foo.bar/somepage/`\n* Custom error reponses\n\n\n## TODO:\n\n* Add tests\n\n\u003c!-- BEGIN_TF_DOCS --\u003e\n## Requirements\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"requirement_terraform\"\u003e\u003c/a\u003e [terraform](#requirement\\_terraform) | \u003e= 0.13.0 |\n| \u003ca name=\"requirement_aws\"\u003e\u003c/a\u003e [aws](#requirement\\_aws) | \u003e= 5.0.0 |\n\n## Providers\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"provider_aws\"\u003e\u003c/a\u003e [aws](#provider\\_aws) | \u003e= 5.0.0 |\n\n## Modules\n\nNo modules.\n\n## Resources\n\n| Name | Type |\n|------|------|\n| [aws_cloudfront_cache_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_cache_policy) | resource |\n| [aws_cloudfront_distribution.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution) | resource |\n| [aws_cloudfront_function.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_function) | resource |\n| [aws_cloudfront_origin_access_control.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_origin_access_control) | resource |\n| [aws_s3_bucket_policy.allow_cloudfront](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |\n| [aws_cloudfront_cache_policy.managed](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/cloudfront_cache_policy) | data source |\n| [aws_iam_policy_document.allow_cloudfront](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n\n## Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| \u003ca name=\"input_acm_certificate_arn\"\u003e\u003c/a\u003e [acm\\_certificate\\_arn](#input\\_acm\\_certificate\\_arn) | ACM Certificate ARN, must be us-east-1 | `string` | n/a | yes |\n| \u003ca name=\"input_aliases\"\u003e\u003c/a\u003e [aliases](#input\\_aliases) | Alternate domain names | `list(string)` | `null` | no |\n| \u003ca name=\"input_allowed_methods\"\u003e\u003c/a\u003e [allowed\\_methods](#input\\_allowed\\_methods) | default cache behavior allowed methods | `list(string)` | \u003cpre\u003e[\u003cbr\u003e  \"GET\",\u003cbr\u003e  \"HEAD\"\u003cbr\u003e]\u003c/pre\u003e | no |\n| \u003ca name=\"input_attach_s3_bucket_policy\"\u003e\u003c/a\u003e [attach\\_s3\\_bucket\\_policy](#input\\_attach\\_s3\\_bucket\\_policy) | attach a policy to s3 bucket to allow this distribution | `bool` | `true` | no |\n| \u003ca name=\"input_cache_policy_comment\"\u003e\u003c/a\u003e [cache\\_policy\\_comment](#input\\_cache\\_policy\\_comment) | Cache policy Comment/description | `string` | `null` | no |\n| \u003ca name=\"input_cache_policy_name\"\u003e\u003c/a\u003e [cache\\_policy\\_name](#input\\_cache\\_policy\\_name) | The cache policy name | `string` | `null` | no |\n| \u003ca name=\"input_cached_methods\"\u003e\u003c/a\u003e [cached\\_methods](#input\\_cached\\_methods) | default cache behavior cached methods | `list(string)` | \u003cpre\u003e[\u003cbr\u003e  \"GET\",\u003cbr\u003e  \"HEAD\"\u003cbr\u003e]\u003c/pre\u003e | no |\n| \u003ca name=\"input_cloudfront_origin_description\"\u003e\u003c/a\u003e [cloudfront\\_origin\\_description](#input\\_cloudfront\\_origin\\_description) | Description for the origin | `string` | n/a | yes |\n| \u003ca name=\"input_cloudfront_origin_name\"\u003e\u003c/a\u003e [cloudfront\\_origin\\_name](#input\\_cloudfront\\_origin\\_name) | The name of the cloudfront origin | `string` | n/a | yes |\n| \u003ca name=\"input_cookies_forwarding_behavior\"\u003e\u003c/a\u003e [cookies\\_forwarding\\_behavior](#input\\_cookies\\_forwarding\\_behavior) | Whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. | `string` | `\"none\"` | no |\n| \u003ca name=\"input_custom_cache_policy\"\u003e\u003c/a\u003e [custom\\_cache\\_policy](#input\\_custom\\_cache\\_policy) | If going to create a custom cache policy | `bool` | `false` | no |\n| \u003ca name=\"input_custom_edge_function_associations\"\u003e\u003c/a\u003e [custom\\_edge\\_function\\_associations](#input\\_custom\\_edge\\_function\\_associations) | Edge functions to associate with the distribution | \u003cpre\u003emap(object({\u003cbr\u003e    event_type   = string\u003cbr\u003e    function_arn = string\u003cbr\u003e  }))\u003c/pre\u003e | `{}` | no |\n| \u003ca name=\"input_custom_error_responses\"\u003e\u003c/a\u003e [custom\\_error\\_responses](#input\\_custom\\_error\\_responses) | Custom error response definitions | \u003cpre\u003elist(object({\u003cbr\u003e    error_caching_min_ttl = optional(number)\u003cbr\u003e    error_code            = optional(number)\u003cbr\u003e    response_code         = optional(number)\u003cbr\u003e    response_page_path    = optional(string)\u003cbr\u003e  }))\u003c/pre\u003e | `null` | no |\n| \u003ca name=\"input_default_root_object\"\u003e\u003c/a\u003e [default\\_root\\_object](#input\\_default\\_root\\_object) | The default website root object | `string` | `null` | no |\n| \u003ca name=\"input_default_ttl\"\u003e\u003c/a\u003e [default\\_ttl](#input\\_default\\_ttl) | Default cache ttl | `number` | `1800` | no |\n| \u003ca name=\"input_enable_cloudfront_origin_access_control\"\u003e\u003c/a\u003e [enable\\_cloudfront\\_origin\\_access\\_control](#input\\_enable\\_cloudfront\\_origin\\_access\\_control) | enable/disable cloudfront origin access control | `bool` | `true` | no |\n| \u003ca name=\"input_enable_distribution\"\u003e\u003c/a\u003e [enable\\_distribution](#input\\_enable\\_distribution) | Enables the cf distributuion | `bool` | `true` | no |\n| \u003ca name=\"input_enable_ipv6\"\u003e\u003c/a\u003e [enable\\_ipv6](#input\\_enable\\_ipv6) | Enables ipv6 for the cloudfront distributuion | `bool` | `true` | no |\n| \u003ca name=\"input_enable_noindex_function\"\u003e\u003c/a\u003e [enable\\_noindex\\_function](#input\\_enable\\_noindex\\_function) | Enables lambda@edge function to serve files inside subfolders | `bool` | `true` | no |\n| \u003ca name=\"input_geo_restriction_locations\"\u003e\u003c/a\u003e [geo\\_restriction\\_locations](#input\\_geo\\_restriction\\_locations) | locations to apply restrictions to | `list(string)` | `[]` | no |\n| \u003ca name=\"input_geo_restriction_type\"\u003e\u003c/a\u003e [geo\\_restriction\\_type](#input\\_geo\\_restriction\\_type) | whitelist/blacklist | `string` | `\"none\"` | no |\n| \u003ca name=\"input_headers_forwarding_behavior\"\u003e\u003c/a\u003e [headers\\_forwarding\\_behavior](#input\\_headers\\_forwarding\\_behavior) | Whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin | `string` | `\"none\"` | no |\n| \u003ca name=\"input_managed_cache_policy_name\"\u003e\u003c/a\u003e [managed\\_cache\\_policy\\_name](#input\\_managed\\_cache\\_policy\\_name) | The default cache policy name | `string` | `null` | no |\n| \u003ca name=\"input_max_ttl\"\u003e\u003c/a\u003e [max\\_ttl](#input\\_max\\_ttl) | Max cache ttl | `number` | `3600` | no |\n| \u003ca name=\"input_min_ttl\"\u003e\u003c/a\u003e [min\\_ttl](#input\\_min\\_ttl) | Min cache ttl | `number` | `0` | no |\n| \u003ca name=\"input_origin_access_identity\"\u003e\u003c/a\u003e [origin\\_access\\_identity](#input\\_origin\\_access\\_identity) | CloudFront S3 origin configuration information | `string` | `null` | no |\n| \u003ca name=\"input_price_class\"\u003e\u003c/a\u003e [price\\_class](#input\\_price\\_class) | Price class for this distribution | `string` | `\"PriceClass_All\"` | no |\n| \u003ca name=\"input_query_string_forwarding_behavior\"\u003e\u003c/a\u003e [query\\_string\\_forwarding\\_behavior](#input\\_query\\_string\\_forwarding\\_behavior) | Whether URL query strings in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin | `string` | `\"none\"` | no |\n| \u003ca name=\"input_s3_bucket_id\"\u003e\u003c/a\u003e [s3\\_bucket\\_id](#input\\_s3\\_bucket\\_id) | Name of s3 bucket | `string` | n/a | yes |\n| \u003ca name=\"input_s3_objects\"\u003e\u003c/a\u003e [s3\\_objects](#input\\_s3\\_objects) | The s3 onjects to allow access to ARN/objects | `list(any)` | n/a | yes |\n| \u003ca name=\"input_s3_origin_id\"\u003e\u003c/a\u003e [s3\\_origin\\_id](#input\\_s3\\_origin\\_id) | unique origin id | `string` | `\"s3Website\"` | no |\n| \u003ca name=\"input_s3_origin_path\"\u003e\u003c/a\u003e [s3\\_origin\\_path](#input\\_s3\\_origin\\_path) | objects origin path if using subfolders | `string` | `null` | no |\n| \u003ca name=\"input_s3_regional_domain_name\"\u003e\u003c/a\u003e [s3\\_regional\\_domain\\_name](#input\\_s3\\_regional\\_domain\\_name) | The regional domain name of the bucket | `string` | n/a | yes |\n| \u003ca name=\"input_ssl_support_method\"\u003e\u003c/a\u003e [ssl\\_support\\_method](#input\\_ssl\\_support\\_method) | SSL support method to be used | `string` | `\"sni-only\"` | no |\n| \u003ca name=\"input_tls_minimum_protocol_version\"\u003e\u003c/a\u003e [tls\\_minimum\\_protocol\\_version](#input\\_tls\\_minimum\\_protocol\\_version) | Minimum TLS version | `string` | `\"TLSv1.2_2021\"` | no |\n| \u003ca name=\"input_viewer_protocol_policy\"\u003e\u003c/a\u003e [viewer\\_protocol\\_policy](#input\\_viewer\\_protocol\\_policy) | specify the protocol that users can use to access the files in the origin | `string` | `\"redirect-to-https\"` | no |\n\n## Outputs\n\nNo outputs.\n\u003c!-- END_TF_DOCS --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoolapso%2Fterraform-aws-cloudfront-and-edge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoolapso%2Fterraform-aws-cloudfront-and-edge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoolapso%2Fterraform-aws-cloudfront-and-edge/lists"}