Skip to content

Commit

Permalink
Merge pull request #5 from Flaconi/plt-797
Browse files Browse the repository at this point in the history
PLT-797 - Add support for custom gateway responses
  • Loading branch information
Engerim authored Jan 23, 2024
2 parents ad99c1b + f26abb1 commit dd25851
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ Type: `list(string)`

Default: `[]`

### <a name="input_gateway_response"></a> [gateway\_response](#input\_gateway\_response)

Description: n/a

Type:

```hcl
map(object({
status_code = number
#https://docs.aws.amazon.com/apigateway/latest/developerguide/supported-gateway-response-types.html
response_templates = object({
json = string
})
}))
```

Default: `{}`

<!-- TFDOCS_INPUTS_END -->

<!-- TFDOCS_OUTPUTS_START -->
Expand Down
12 changes: 12 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ resource "aws_api_gateway_integration_response" "default_integration_response" {
}
}

# gateway response

resource "aws_api_gateway_gateway_response" "gateway_response" {
for_each = var.gateway_response
rest_api_id = aws_api_gateway_rest_api.this[0].id
response_type = each.key
status_code = each.value.status_code
response_templates = {
"application/json" = each.value.response_templates.json
}
}

# authorizer

resource "aws_api_gateway_authorizer" "cognito" {
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,15 @@ variable "resource_paths" {
default = []
description = "a list of root resource paths to be used in sharded environment"
}

variable "gateway_response" {
#response_type => {response_templates}
type = map(object({
status_code = number
#https://docs.aws.amazon.com/apigateway/latest/developerguide/supported-gateway-response-types.html
response_templates = object({
json = string
})
}))
default = {}
}

0 comments on commit dd25851

Please sign in to comment.