Show / Hide Table of Contents

Class HttpApi

Create a new API Gateway HTTP API endpoint.

Inheritance
object
Resource
HttpApi
Implements
IHttpApi
IApi
IResource
IConstruct
IDependable
IEnvironmentAware
Inherited Members
Resource.IsOwnedResource(IConstruct)
Resource.IsResource(IConstruct)
Resource.ApplyRemovalPolicy(RemovalPolicy)
Resource.GeneratePhysicalName()
Resource.GetResourceArnAttribute(string, IArnComponents)
Resource.GetResourceNameAttribute(string)
Resource.Env
Resource.PhysicalName
Resource.Stack
Namespace: Amazon.CDK.AWS.Apigatewayv2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class HttpApi : Resource, IHttpApi, IApi, IResource, IConstruct, IDependable, IEnvironmentAware
Syntax (vb)
Public Class HttpApi Inherits Resource Implements IHttpApi, IApi, IResource, IConstruct, IDependable, IEnvironmentAware
Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

Examples
using Amazon.CDK.AwsApigatewayv2Integrations;

             Function booksDefaultFn;

             var booksIntegration = new HttpLambdaIntegration("BooksIntegration", booksDefaultFn);

             var httpApi = new HttpApi(this, "HttpApi");

             httpApi.AddRoutes(new AddRoutesOptions {
                 Path = "/books",
                 Methods = new [] { HttpMethod.GET },
                 Integration = booksIntegration
             });

Synopsis

Constructors

HttpApi(Construct, string, IHttpApiProps?)

Create a new API Gateway HTTP API endpoint.

Properties

ApiEndpoint

Get the default endpoint for this API.

ApiId

The identifier of this API Gateway API.

DefaultAuthorizationScopes

Default OIDC scopes attached to all routes in the gateway, unless explicitly configured on the route.

DefaultAuthorizer

Default Authorizer applied to all routes in the gateway.

DefaultStage

The default stage of this API.

DisableExecuteApiEndpoint

Specifies whether clients can invoke this HTTP API by using the default execute-api endpoint.

HttpApiId

The identifier of the HTTP API.

HttpApiName

A human friendly name for this HTTP API.

PROPERTY_INJECTION_ID

Uniquely identifies this class.

Url

Get the URL to the default stage of this API.

Methods

AddRoutes(IAddRoutesOptions)

Add multiple routes that uses the same configuration.

AddStage(string, IHttpStageOptions)

Add a new stage.

AddVpcLink(IVpcLinkProps)

Add a new VpcLink.

ArnForExecuteApi(string?, string?, string?)

Get the "execute-api" ARN.

FromHttpApiAttributes(Construct, string, IHttpApiAttributes)

Import an existing HTTP API into this CDK app.

Metric(string, IMetricOptions?)

Return the given named metric for this Api Gateway.

MetricClientError(IMetricOptions?)

Metric for the number of client-side errors captured in a given period.

MetricCount(IMetricOptions?)

Metric for the total number API requests in a given period.

MetricDataProcessed(IMetricOptions?)

Metric for the amount of data processed in bytes.

MetricIntegrationLatency(IMetricOptions?)

Metric for the time between when API Gateway relays a request to the backend and when it receives a response from the backend.

MetricLatency(IMetricOptions?)

The time between when API Gateway receives a request from a client and when it returns a response to the client.

MetricServerError(IMetricOptions?)

Metric for the number of server-side errors captured in a given period.

Constructors

HttpApi(Construct, string, IHttpApiProps?)

Create a new API Gateway HTTP API endpoint.

public HttpApi(Construct scope, string id, IHttpApiProps? props = null)
Parameters
scope Construct
id string
props IHttpApiProps
Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

Examples
using Amazon.CDK.AwsApigatewayv2Integrations;

             Function booksDefaultFn;

             var booksIntegration = new HttpLambdaIntegration("BooksIntegration", booksDefaultFn);

             var httpApi = new HttpApi(this, "HttpApi");

             httpApi.AddRoutes(new AddRoutesOptions {
                 Path = "/books",
                 Methods = new [] { HttpMethod.GET },
                 Integration = booksIntegration
             });

Properties

ApiEndpoint

Get the default endpoint for this API.

public virtual string ApiEndpoint { get; }
Property Value

string

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

ApiId

The identifier of this API Gateway API.

public virtual string ApiId { get; }
Property Value

string

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

DefaultAuthorizationScopes

Default OIDC scopes attached to all routes in the gateway, unless explicitly configured on the route.

public virtual string[]? DefaultAuthorizationScopes { get; }
Property Value

string[]

Remarks

The scopes are used with a COGNITO_USER_POOLS authorizer to authorize the method invocation.

DefaultAuthorizer

Default Authorizer applied to all routes in the gateway.

public virtual IHttpRouteAuthorizer? DefaultAuthorizer { get; }
Property Value

IHttpRouteAuthorizer

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

DefaultStage

The default stage of this API.

public virtual IHttpStage? DefaultStage { get; }
Property Value

IHttpStage

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

DisableExecuteApiEndpoint

Specifies whether clients can invoke this HTTP API by using the default execute-api endpoint.

public virtual bool? DisableExecuteApiEndpoint { get; }
Property Value

bool?

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

HttpApiId

The identifier of the HTTP API.

public virtual string HttpApiId { get; }
Property Value

string

Remarks

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#aws-resource-apigatewayv2-api-return-values

HttpApiName

A human friendly name for this HTTP API.

public virtual string? HttpApiName { get; }
Property Value

string

Remarks

Note that this is different from httpApiId.

PROPERTY_INJECTION_ID

Uniquely identifies this class.

public static string PROPERTY_INJECTION_ID { get; }
Property Value

string

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

Url

Get the URL to the default stage of this API.

public virtual string? Url { get; }
Property Value

string

Remarks

Returns undefined if createDefaultStage is unset.

Methods

AddRoutes(IAddRoutesOptions)

Add multiple routes that uses the same configuration.

public virtual HttpRoute[] AddRoutes(IAddRoutesOptions options)
Parameters
options IAddRoutesOptions
Returns

HttpRoute[]

Remarks

The routes all go to the same path, but for different methods.

AddStage(string, IHttpStageOptions)

Add a new stage.

public virtual HttpStage AddStage(string id, IHttpStageOptions options)
Parameters
id string
options IHttpStageOptions
Returns

HttpStage

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

AddVpcLink(IVpcLinkProps)

Add a new VpcLink.

public virtual VpcLink AddVpcLink(IVpcLinkProps options)
Parameters
options IVpcLinkProps
Returns

VpcLink

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

ArnForExecuteApi(string?, string?, string?)

Get the "execute-api" ARN.

public virtual string ArnForExecuteApi(string? method = null, string? path = null, string? stage = null)
Parameters
method string
path string
stage string
Returns

string

Remarks

When 'ANY' is passed to the method, an ARN with the method set to '*' is obtained.

FromHttpApiAttributes(Construct, string, IHttpApiAttributes)

Import an existing HTTP API into this CDK app.

public static IHttpApi FromHttpApiAttributes(Construct scope, string id, IHttpApiAttributes attrs)
Parameters
scope Construct
id string
attrs IHttpApiAttributes
Returns

IHttpApi

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

Metric(string, IMetricOptions?)

Return the given named metric for this Api Gateway.

public virtual Metric Metric(string metricName, IMetricOptions? props = null)
Parameters
metricName string
props IMetricOptions
Returns

Metric

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

MetricClientError(IMetricOptions?)

Metric for the number of client-side errors captured in a given period.

public virtual Metric MetricClientError(IMetricOptions? props = null)
Parameters
props IMetricOptions
Returns

Metric

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

MetricCount(IMetricOptions?)

Metric for the total number API requests in a given period.

public virtual Metric MetricCount(IMetricOptions? props = null)
Parameters
props IMetricOptions
Returns

Metric

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

MetricDataProcessed(IMetricOptions?)

Metric for the amount of data processed in bytes.

public virtual Metric MetricDataProcessed(IMetricOptions? props = null)
Parameters
props IMetricOptions
Returns

Metric

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

MetricIntegrationLatency(IMetricOptions?)

Metric for the time between when API Gateway relays a request to the backend and when it receives a response from the backend.

public virtual Metric MetricIntegrationLatency(IMetricOptions? props = null)
Parameters
props IMetricOptions
Returns

Metric

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

MetricLatency(IMetricOptions?)

The time between when API Gateway receives a request from a client and when it returns a response to the client.

public virtual Metric MetricLatency(IMetricOptions? props = null)
Parameters
props IMetricOptions
Returns

Metric

Remarks

The latency includes the integration latency and other API Gateway overhead.

MetricServerError(IMetricOptions?)

Metric for the number of server-side errors captured in a given period.

public virtual Metric MetricServerError(IMetricOptions? props = null)
Parameters
props IMetricOptions
Returns

Metric

Remarks

Resource: AWS::ApiGatewayV2::Api

ExampleMetadata: infused

Implements

IHttpApi
IApi
IResource
Constructs.IConstruct
Constructs.IDependable
IEnvironmentAware
Back to top Generated by DocFX