AWS Fundamentals Logo
AWS Fundamentals
L2 Construct

HttpApi

Create a new API Gateway HTTP API endpoint.

Import

import { HttpApi } from 'aws-cdk-lib/aws-apigatewayv2';

Or use the module namespace:

import * as apigatewayv2 from 'aws-cdk-lib/aws-apigatewayv2';
// apigatewayv2.HttpApi

Properties

Configuration passed to the constructor as HttpApiProps.

apiNameOptional
string

Name for the HTTP API resource.

Default: - id of the HttpApi construct.

corsPreflightOptional
CorsPreflightOptions

Specifies a CORS configuration for an API.

Default: - CORS disabled.

createDefaultStageOptional
boolean

Whether a default stage and deployment should be automatically created.

Default: true

defaultAuthorizationScopesOptional
string[]

Default OIDC scopes attached to all routes in the gateway, unless explicitly configured on the route. The scopes are used with a COGNITO_USER_POOLS authorizer to authorize the method invocation.

Default: - no default authorization scopes

defaultAuthorizerOptional
IHttpRouteAuthorizer

Default Authorizer applied to all routes in the gateway.

Default: - no default authorizer

defaultDomainMappingOptional
DomainMappingOptions

Configure a custom domain with the API mapping resource to the HTTP API.

Default: - no default domain mapping configured. meaningless if `createDefaultStage` is `false`.

defaultIntegrationOptional
HttpRouteIntegration

An integration that will be configured on the catch-all route ($default).

Default: - none

descriptionOptional
string

The description of the API.

Default: - none

disableExecuteApiEndpointOptional
boolean

Specifies whether clients can invoke your API using the default endpoint. By default, clients can invoke your API with the default `https://{api_id}.execute-api.{region}.amazonaws.com` endpoint. Set this to true if you would like clients to use your custom domain name.

Default: false execute-api endpoint enabled.

ipAddressTypeOptional
IpAddressType

The IP address types that can invoke the API.

Default: undefined - AWS default is IPV4

routeSelectionExpressionOptional
boolean

Whether to set the default route selection expression for the API. When enabled, "${request.method} ${request.path}" is set as the default route selection expression.

Default: false

Learn AWS the Practical Way

Our bi-weekly newsletter teaches hands-on AWS fundamentals. No certification fluff - just practical knowledge.

Subscribe to Newsletter