Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dod-iac/terraform-aws-api-gateway-cors-lambda-proxy
A Terraform module to create a Cross-Origin Resource Sharing (CORS) Lambda Proxy
https://github.com/dod-iac/terraform-aws-api-gateway-cors-lambda-proxy
cors lambda proxy terraform terraform-module
Last synced: about 1 month ago
JSON representation
A Terraform module to create a Cross-Origin Resource Sharing (CORS) Lambda Proxy
- Host: GitHub
- URL: https://github.com/dod-iac/terraform-aws-api-gateway-cors-lambda-proxy
- Owner: dod-iac
- License: mit
- Created: 2021-06-11T21:36:57.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-14T21:10:16.000Z (over 3 years ago)
- Last Synced: 2024-11-11T07:31:40.279Z (3 months ago)
- Topics: cors, lambda, proxy, terraform, terraform-module
- Language: HCL
- Homepage: https://registry.terraform.io/modules/dod-iac/api-gateway-cors-lambda-proxy/aws/latest
- Size: 13.7 KB
- Stars: 1
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Authors: AUTHORS.md
Awesome Lists containing this project
README
# Terraform AWS API Gateway CORS Lambda Proxy
## Description
A Terraform module to create a Cross-Origin Resource Sharing (CORS) Lambda Proxy.
Orignal code forked from [squidfunk/terraform-aws-api-gateway-enable-cors](https://github.com/squidfunk/terraform-aws-api-gateway-enable-cors)
## Usage
``` hcl
module "cors_lambda" {
source = "dod-iac/api-gateway-cors-lambda-proxy/aws"
version = "1.0.0"api_id = aws_api_gateway_rest_api.main_api.id
api_resource_id = aws_api_gateway_resource.main_api_streams_resource.id
http_method = "GET"
invoke_arn = aws_lambda_function.stream_lambda.invoke_arn
invoke_policy_arn = aws_iam_role.api_role.arn
allow_methods = [
"OPTIONS",
"GET"
]
allow_headers = [
"Authorization",
"Content-Type",
"X-Amz-Date",
"X-Amz-Security-Token",
"X-Api-Key",
"next-query",
]
}
```By default, this will create a new `MOCK` endpoint on the provided API Gateway
resource allowing CORS preflight requests for **all methods** and
**all origins** by default. Of course this can be customized using variables
as stated in the next section.## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 0.13 |
| [aws](#requirement\_aws) | ~> 3.0 |## Providers
| Name | Version |
|------|---------|
| [aws](#provider\_aws) | ~> 3.0 |## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [aws_api_gateway_integration._](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_integration) | resource |
| [aws_api_gateway_integration_response._](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_integration_response) | resource |
| [aws_api_gateway_method._](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method) | resource |
| [aws_api_gateway_method_response._](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method_response) | resource |## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [allow\_credentials](#input\_allow\_credentials) | Allow credentials (`Access-Control-Allow-Credentials`) | `bool` | `false` | no |
| [allow\_headers](#input\_allow\_headers) | Allow headers (`Access-Control-Allow-Headers`) | `list(string)` |[| no |
"Authorization",
"Content-Type",
"X-Amz-Date",
"X-Amz-Security-Token",
"X-Api-Key"
]
| [allow\_max\_age](#input\_allow\_max\_age) | Allow response caching time (`Access-Control-Allow-Max-Age`) | `string` | `"7200"` | no |
| [allow\_methods](#input\_allow\_methods) | Allow methods (`Access-Control-Allow-Methods`) | `list(string)` |[| no |
"OPTIONS",
"HEAD",
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
]
| [allow\_origin](#input\_allow\_origin) | Allow origin (`Access-Control-Allow-Origin`) | `string` | `"*"` | no |
| [api\_id](#input\_api\_id) | API identifier | `any` | n/a | yes |
| [api\_resource\_id](#input\_api\_resource\_id) | API resource identifier | `any` | n/a | yes |
| [http\_method](#input\_http\_method) | API http method | `any` | n/a | yes |
| [invoke\_arn](#input\_invoke\_arn) | API Lambda Invoke ARN | `any` | n/a | yes |
| [invoke\_policy\_arn](#input\_invoke\_policy\_arn) | IAM Policy to allow Lambda invoke | `any` | n/a | yes |## Outputs
No outputs.