{"id":19084415,"url":"https://github.com/cloudandthings/terraform-aws-cors","last_synced_at":"2026-05-17T00:04:00.863Z","repository":{"id":214968090,"uuid":"736232551","full_name":"cloudandthings/terraform-aws-cors","owner":"cloudandthings","description":"One module to manage REST and HTTP API Gateway CORS config.","archived":false,"fork":false,"pushed_at":"2024-01-01T13:47:41.000Z","size":27,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-22T06:41:24.763Z","etag":null,"topics":["api-gateway","aws","cors","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudandthings.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/contributing.md","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}},"created_at":"2023-12-27T10:42:58.000Z","updated_at":"2024-01-04T08:18:03.000Z","dependencies_parsed_at":"2024-01-01T15:41:10.034Z","dependency_job_id":"d0948a64-31a2-453a-9fd8-dc4cec2092c7","html_url":"https://github.com/cloudandthings/terraform-aws-cors","commit_stats":null,"previous_names":["cloudandthings/terraform-aws-cors"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/cloudandthings/terraform-aws-cors","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudandthings%2Fterraform-aws-cors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudandthings%2Fterraform-aws-cors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudandthings%2Fterraform-aws-cors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudandthings%2Fterraform-aws-cors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudandthings","download_url":"https://codeload.github.com/cloudandthings/terraform-aws-cors/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudandthings%2Fterraform-aws-cors/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262490410,"owners_count":23319286,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["api-gateway","aws","cors","terraform"],"created_at":"2024-11-09T02:51:16.115Z","updated_at":"2025-10-25T15:03:51.428Z","avatar_url":"https://github.com/cloudandthings.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform AWS CORS\nA single module to setup CORS for both REST and HTTP APIs.\n\n## Headers\nThe following commonly used headers are set by default: `Content-Type`, `X-Amz-Date`, `Authorization`, `X-Api-Key`, `X-Amz-Security-Token`. These can be disbaled using the `disable_default_headers` variable.\n\nAdditional headers can be set using the `allowed_headers` variable.\n\n## Usage with REST API (v1)\n### Basic usage\n`REST` APIs only support a single origin, if more than one is supplied the module will throw a validation error.\n\n```hcl\nmodule \"basic_cors_rest\" {\n  source  = \"cloudandthings/cors/aws\"\n  version = \"1.0.0\"\n\n  api_gateway_type = 'REST'\n  api              = aws_api_gateway_rest_api.your_api.id\n\n  resources = [\n    aws_api_gateway_resource.a.id,\n    aws_api_gateway_resource.b.id\n  ]\n\n  methods = [\n    \"GET\",\n    \"POST\"\n  ]\n\n  allowed_origins = ['*']\n}\n```\n\n### All features\n```hcl\nmodule \"basic_cors_rest\" {\n  source  = \"cloudandthings/cors/aws\"\n  version = \"1.0.0\"\n\n  api_gateway_type = \"REST\"\n  api              = aws_api_gateway_rest_api.your_api.id\n\n  resources = [\n    aws_api_gateway_resource.a.id,\n    aws_api_gateway_resource.b.id\n  ]\n\n  methods = [\n    \"GET\",\n    \"POST\",\n    \"PUT\",\n    \"DELETE\",\n    \"HEAD\",\n    \"PATCH\",\n    \"OPTIONS\"\n  ]\n\n  allowed_origins = [\"http://your_domain\"]\n\n  disable_default_headers = true\n\n  allowed_headers = [\n    \"Authentication\"\n  ]\n}\n```\n\n## Usage with HTTP API (v2)\n\n\n## Caveats\n- **PROXY_INTEGRATION** does not allow you to modify the response. This means you need to set the CORS headers in your code (see examples folder).\n- The module will create an `OPTIONS` method on every provided API resource. The browser will not always send a preflight request, this can be forced by adding some custom header (\"X-PING: pong\").\n\n\u003c!-- BEGIN_TF_DOCS --\u003e\n## Terraform Documentation\n### Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| \u003ca name=\"input_allowed_headers\"\u003e\u003c/a\u003e [allowed\\_headers](#input\\_allowed\\_headers) | A list of additionally allowed headers. If you are using Access-Control-Allow-Headers as a wildcard, you must specify ['*'] explicitly. | `list(string)` | `[]` | no |\n| \u003ca name=\"input_allowed_origins\"\u003e\u003c/a\u003e [allowed\\_origins](#input\\_allowed\\_origins) | A list of allowed origins. REST API only support a single origin. | `list(string)` | n/a | yes |\n| \u003ca name=\"input_api\"\u003e\u003c/a\u003e [api](#input\\_api) | ID of the API Gateway. | `string` | n/a | yes |\n| \u003ca name=\"input_api_gateway_type\"\u003e\u003c/a\u003e [api\\_gateway\\_type](#input\\_api\\_gateway\\_type) | The type of the API Gateway to create. Valid values are REST (v1) or HTTP (v2). Defaults to REST. | `string` | n/a | yes |\n| \u003ca name=\"input_disable_default_headers\"\u003e\u003c/a\u003e [disable\\_default\\_headers](#input\\_disable\\_default\\_headers) | Whether to disable the default headers. Defaults to false. | `bool` | `false` | no |\n| \u003ca name=\"input_methods\"\u003e\u003c/a\u003e [methods](#input\\_methods) | List of permitted HTTP methods. OPTIONS is added by default. | `list(string)` | n/a | yes |\n| \u003ca name=\"input_rest_resources\"\u003e\u003c/a\u003e [rest\\_resources](#input\\_rest\\_resources) | List of the IDs of an aws\\_api\\_gateway\\_resource resource. This must be set if api\\_gateway\\_type is REST. | `list(string)` | `[]` | no |\n\n----\n### Modules\n\n| Name | Source | Version |\n|------|--------|---------|\n| \u003ca name=\"module_http\"\u003e\u003c/a\u003e [http](#module\\_http) | ./local-modules/HTTP | n/a |\n| \u003ca name=\"module_rest\"\u003e\u003c/a\u003e [rest](#module\\_rest) | ./local-modules/REST | n/a |\n\n----\n### Outputs\n\n| Name | Description |\n|------|-------------|\n| \u003ca name=\"output_headers\"\u003e\u003c/a\u003e [headers](#output\\_headers) | A list of headers that are allowed in a preflight request. |\n| \u003ca name=\"output_methods\"\u003e\u003c/a\u003e [methods](#output\\_methods) | A list of methods that are allowed in a preflight request. |\n| \u003ca name=\"output_origins\"\u003e\u003c/a\u003e [origins](#output\\_origins) | A list of origins that are allowed in a preflight request. |\n\n----\n### Providers\n\nNo providers.\n\n----\n### Requirements\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"requirement_terraform\"\u003e\u003c/a\u003e [terraform](#requirement\\_terraform) | \u003e= 0.15.0 |\n| \u003ca name=\"requirement_aws\"\u003e\u003c/a\u003e [aws](#requirement\\_aws) | \u003e= 4.9 |\n| \u003ca name=\"requirement_null\"\u003e\u003c/a\u003e [null](#requirement\\_null) | \u003e= 3.1 |\n\n----\n### Resources\n\nNo resources.\n\n----\n\u003c!-- END_TF_DOCS --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudandthings%2Fterraform-aws-cors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudandthings%2Fterraform-aws-cors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudandthings%2Fterraform-aws-cors/lists"}