Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: added examples for awscc_apigateway_gateway_response #1801

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion docs/resources/apigateway_gateway_response.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "awscc_apigateway_gateway_response Resource - terraform-provider-awscc"
subcategory: ""
description: |-
Expand All @@ -10,7 +9,41 @@ description: |-

The ``AWS::ApiGateway::GatewayResponse`` resource creates a gateway response for your API. For more information, see [API Gateway Responses](https://docs.aws.amazon.com/apigateway/latest/developerguide/customize-gateway-responses.html#api-gateway-gatewayResponse-definition) in the *API Gateway Developer Guide*.

## Example Usage

### 404 Response
The following example returns a 404 status code for resource not found instead of missing authentication token for a CORS request (applicable to unsecured/unrestricted APIs).

```terraform
resource "awscc_apigateway_gateway_response" "example" {
rest_api_id = awscc_apigateway_rest_api.example.id
status_code = "404"
response_type = "MISSING_AUTHENTICATION_TOKEN"

response_parameters = {
"gatewayresponse.header.Access-Control-Allow-Origin" = "'*'"
"gatewayresponse.header.Access-Control-Allow-Headers" = "'*'"
}
}
```

### 401 Response

```terraform
resource "awscc_apigateway_gateway_response" "example" {
rest_api_id = awscc_apigateway_rest_api.example.id
status_code = "401"
response_type = "UNAUTHORIZED"

response_templates = {
"application/json" = "{\"message\":$context.error.messageString}"
}

response_parameters = {
"gatewayresponse.header.Authorization" = "'Basic'"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "awscc_apigateway_gateway_response" "example" {
rest_api_id = awscc_apigateway_rest_api.example.id
status_code = "401"
response_type = "UNAUTHORIZED"

response_templates = {
"application/json" = "{\"message\":$context.error.messageString}"
}

response_parameters = {
"gatewayresponse.header.Authorization" = "'Basic'"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "awscc_apigateway_gateway_response" "example" {
rest_api_id = awscc_apigateway_rest_api.example.id
status_code = "404"
response_type = "MISSING_AUTHENTICATION_TOKEN"

response_parameters = {
"gatewayresponse.header.Access-Control-Allow-Origin" = "'*'"
"gatewayresponse.header.Access-Control-Allow-Headers" = "'*'"
}
}
32 changes: 32 additions & 0 deletions templates/resources/apigateway_gateway_response.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}"
subcategory: ""
description: |-
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
---

# {{.Name}} ({{.Type}})

{{ .Description | trimspace }}

## Example Usage

### 404 Response
The following example returns a 404 status code for resource not found instead of missing authentication token for a CORS request (applicable to unsecured/unrestricted APIs).

{{ tffile (printf "examples/resources/%s/apigateway_gateway_response_404.tf" .Name)}}

### 401 Response

{{ tffile (printf "examples/resources/%s/apigateway_gateway_response_401.tf" .Name)}}

{{ .SchemaMarkdown | trimspace }}
{{- if .HasImport }}

## Import

Import is supported using the following syntax:

{{ codefile "shell" .ImportFile }}

{{- end }}
Loading