CloudWiki
Resource
Detect, troubleshoot & optimize AWS environments in real-time ->

Amazon Web Service (AWS)

API Gateway

Network
Amazon API Gateway is a fully managed service that enables developers to create, publish, maintain, monitor, and secure APIs at any scale. It basically connects non-AWS applications to AWS back-end resources, such as servers and code. The API gateway accepts and processes concurrent API calls, which happens when APIs submit requests to a server. It manages traffic, authorizes end users and monitors performance.
Costs
API Gateway charges for the number of API calls received and the amount of data transferred out, with varying prices based on the geographical region in which the service is used. You are also charged for the amount of storage used by your APIs and the amount of data transferred in. The cost of using API Gateway can vary based on the number of API calls made, the size of data transferred, and the amount of storage used.
Direct Cost

<Region>-DataTransfer-Out-Bytes

<Region>-ApiGatewayRequest

Indirect Cost
No items found.
Terraform Name
aws_api_gateway_resource
API Gateway
attributes:
  • rest_api_id - (Required) ID of the associated REST API
  • parent_id - (Required) ID of the parent API resource
  • path_part - (Required) Last path segment of this API resource.

Associating resources with a
API Gateway
Resources do not "belong" to a
API Gateway
Rather, one or more Security Groups are associated to a resource.
Create
API Gateway
via Terraform:
The following HCL creates an API Gateway resource
Syntax:

resource "aws_api_gateway_rest_api" "MyDemoAPI" {
 name        = "MyDemoAPI"
 description = "This is my API for demonstration purposes"
}

resource "aws_api_gateway_resource" "MyDemoResource" {
 rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id
 parent_id   = aws_api_gateway_rest_api.MyDemoAPI.root_resource_id
 path_part   = "mydemoresource"
}

Create
API Gateway
via CLI:
Parametres:

create-resource
--rest-api-id <value>
--parent-id <value>
--path-part <value>
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]

Example:

aws apigateway create-resource --rest-api-id 1234123412 --parent-id a1b2c3 --path-part 'new-resource'

Best Practices for
API Gateway

Categorized by Availability, Security & Compliance and Cost

Explore all the rules our platform covers
Related blog posts
All Resources