Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mewa/terraform-aws-apigateway-cors
Terraform module that sets up CORS
https://github.com/mewa/terraform-aws-apigateway-cors
apigateway cors terraform terraform-modules
Last synced: about 1 month ago
JSON representation
Terraform module that sets up CORS
- Host: GitHub
- URL: https://github.com/mewa/terraform-aws-apigateway-cors
- Owner: mewa
- License: mit
- Created: 2018-03-25T12:57:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-07T12:52:35.000Z (over 3 years ago)
- Last Synced: 2024-04-14T07:54:03.264Z (8 months ago)
- Topics: apigateway, cors, terraform, terraform-modules
- Language: HCL
- Homepage: https://registry.terraform.io/modules/mewa/apigateway-cors/aws
- Size: 6.84 KB
- Stars: 7
- Watchers: 2
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Terraform API Gateway CORS module
This module intends to reduce boilerplate required when setting up CORS for API Gateway resources.
# Examples
An example module usage, which allows `GET` and `POST` methods from any origin (`*`), accepting default headers (Content-Type, X-Amz-Date, Authorization, X-Api-Key, X-Amz-Security-Token):
```
module "example_cors" {
source = "mewa/apigateway-cors/aws"
version = "2.0.1"api = aws_api_gateway_rest_api.example.id
resource = aws_api_gateway_resource.example.idmethods = ["GET", "POST"]
}
```### Restrict origin
If you want to customize the allowed origin simply set the `origin` variable to your desired value:
```
module "confirm_cors" {
source = "mewa/apigateway-cors/aws"
version = "2.0.1"api = aws_api_gateway_rest_api.example.id
resource = aws_api_gateway_resource.example.idmethods = [aws_api_gateway_method.method01.http_method, aws_api_gateway_method.method02.http_method]
origin = "https://example.com"
}
```### Custom headers
You can also add other permitted headers, which will be appended to the default headers:```
module "confirm_cors" {
source = "mewa/apigateway-cors/aws"
version = "2.0.1"api = aws_api_gateway_rest_api.example.id
resource = aws_api_gateway_resource.example.idmethods = ["GET"]
origin = "https://example.com"
headers = "X-Custom-Header"
}
```Setting `discard_default_headers` variable to true will result in including only the headers defined in `headers` variable.