aws-apigateway-dynamodb - AWS Solutions Constructs

aws-apigateway-dynamodb

All classes are under active development and subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.

Language Package
Python
aws_solutions_constructs.aws_apigateway_dynamodb
Typescript
@aws-solutions-constructs/aws-apigateway-dynamodb
Java
software.amazon.awsconstructs.services.apigatewaydynamodb

Overview

This AWS Solutions Constructs pattern implements an Amazon API Gateway REST API connected to Amazon DynamoDB table.

Here is a minimal deployable pattern definition:

import { ApiGatewayToDynamoDBProps, ApiGatewayToDynamoDB } from "@aws-solutions-constructs/aws-apigateway-dynamodb"; const props: ApiGatewayToDynamoDBProps = {}; new ApiGatewayToDynamoDB(stack, 'test-api-gateway-dynamodb-default', props);

Initializer

new ApiGatewayToDynamoDB(scope: Construct, id: string, props: ApiGatewayToDynamoDBProps);

Parameters

Pattern Construct Props

Name Type Description
dynamoTableProps dynamodb.TableProps Optional user provided props to override the default props for DynamoDB Table
apiGatewayProps? api.RestApiProps Optional user-provided props to override the default props for the API Gateway.
allowCreateOperation boolean Whether to deploy API Gateway Method for Create operation on DynamoDB table.
createRequestTemplate string API Gateway Request template for Create method, required if allowCreateOperation set to true
allowReadOperation boolean Whether to deploy API Gateway Method for Read operation on DynamoDB table.
allowUpdateOperation boolean Whether to deploy API Gateway Method for Update operation on DynamoDB table.
updateRequestTemplate string API Gateway Request template for Update method, required if allowUpdateOperation set to true
allowDeleteOperation boolean Whether to deploy API Gateway Method for Delete operation on DynamoDB table.

Pattern Properties

Name Type Description
apiGateway api.RestApi Returns an instance of the API Gateway REST API created by the pattern.
apiGatewayCloudWatchRole iam.Role Returns an instance of the IAM role created by the pattern that enables access logging from the API Gateway REST API to CloudWatch.
apiGatewayLogGroup logs.LogGroup Returns an instance of the log group created by the pattern that API Gateway REST API access logs are sent to.
apiGatewayRole iam.Role Returns an instance of the IAM role created by the pattern for the API Gateway REST API.
dynamoTable dynamodb.Table Returns an instance of the DynamoDB table created by the pattern.

Default settings

Out-of-the-box implementation of this pattern without any overrides will set the following defaults:

Amazon API Gateway

  • Deploy an edge-optimized API endpoint

  • Enable CloudWatch logging for API Gateway

  • Configure least privilege access IAM role for API Gateway

  • Set the default authorizationType for all API methods to IAM

Amazon DynamoDB Table

  • Set the billing mode for DynamoDB Table to On-Demand (Pay per request)

  • Enable server-side encryption for DynamoDB Table using AWS managed KMS Key

  • Creates a partition key called 'id' for DynamoDB Table

  • Retain the Table when deleting the CloudFormation stack

Architecture