AWS API Gateway Documentation Part
This page shows how to write Terraform and CloudFormation for API Gateway Documentation Part and write them securely.
aws_api_gateway_documentation_part (Terraform)
The Documentation Part in API Gateway can be configured in Terraform with the resource name aws_api_gateway_documentation_part
. The following sections describe 3 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_api_gateway_documentation_part" "this" {
properties = var.properties
rest_api_id = var.rest_api_id
dynamic "location" {
for_each = var.location
resource "aws_api_gateway_documentation_part" "api_gateway_documentation_part" {
count = var.enable_api_gateway_documentation_part ? 1 : 0
rest_api_id = var.api_gateway_documentation_part_rest_api_id != "" && !var.enable_api_gateway_rest_api ? var.api_gateway_documentation_part_rest_api_id : element(concat(aws_api_gateway_rest_api.api_gateway_rest_api.*.id, [""]), 0)
properties = var.api_gateway_documentation_part_properties
resource "aws_api_gateway_documentation_part" "api_gateway_documentation_part" {
count = var.enable_api_gateway_documentation_part ? 1 : 0
rest_api_id = var.api_gateway_documentation_part_rest_api_id != "" && !var.enable_api_gateway_rest_api ? var.api_gateway_documentation_part_rest_api_id : element(concat(aws_api_gateway_rest_api.api_gateway_rest_api.*.id, [""]), 0)
properties = var.api_gateway_documentation_part_properties
Parameters
-
id
optional computed - string -
properties
required - string -
rest_api_id
required - string -
location
list block-
method
optional - string -
name
optional - string -
path
optional - string -
status_code
optional - string -
type
required - string
-
Explanation in Terraform Registry
Provides a settings of an API Gateway Documentation Part.
Tips: Best Practices for The Other AWS API Gateway Resources
In addition to the aws_api_gateway_method_settings, AWS API Gateway has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
aws_api_gateway_method_settings
Ensure that API Gateway stage-level cache is encrypted
It is better to enable the stage-level cache encryption which reduces the risk of data leakage.
aws_api_gateway_domain_name
Ensure to use modern TLS protocols
It is better to adopt TLS v1.2+.
aws_api_gateway_stage
Ensure to enable access logging of your API Gateway stage (v1)
It is better to enable the access logging of your API Gateway stage (v1).
aws_api_gateway_method
Ensure that your API Gateway method blocks unwanted access
It is better that the API Gateway method does not allow public access.
AWS::ApiGateway::DocumentationPart (CloudFormation)
The DocumentationPart in ApiGateway can be configured in CloudFormation with the resource name AWS::ApiGateway::DocumentationPart
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
-
Location
required - Location -
Properties
required - String -
RestApiId
required - String
Explanation in CloudFormation Registry
The
AWS::ApiGateway::DocumentationPart
resource creates a documentation part for an API. For more information, see Representation of API Documentation in API Gateway in the API Gateway Developer Guide.
Frequently asked questions
What is AWS API Gateway Documentation Part?
AWS API Gateway Documentation Part is a resource for API Gateway of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS API Gateway Documentation Part?
For Terraform, the niveklabs/aws, asrkata/SebastianUA-terraform and SebastianUA/terraform source code examples are useful. See the Terraform Example section for further details.