AddRoutesOptions

class aws_cdk.aws_apigatewayv2.AddRoutesOptions(*, integration, path, authorization_scopes=None, authorizer=None, methods=None)

Bases: BatchHttpRouteOptions

Options for the Route with Integration resource.

Parameters:
  • integration (HttpRouteIntegration) – The integration to be configured on this route.

  • path (str) – The path at which all of these routes are configured.

  • authorization_scopes (Optional[Sequence[str]]) – The list of OIDC scopes to include in the authorization. These scopes will override the default authorization scopes on the gateway. Set to [] to remove default scopes Default: - uses defaultAuthorizationScopes if configured on the API, otherwise none.

  • authorizer (Optional[IHttpRouteAuthorizer]) – Authorizer to be associated to these routes. Use NoneAuthorizer to remove the default authorizer for the api Default: - uses the default authorizer if one is specified on the HttpApi

  • methods (Optional[Sequence[HttpMethod]]) – The HTTP methods to be configured. Default: HttpMethod.ANY

ExampleMetadata:

infused

Example:

from aws_cdk.aws_apigatewayv2_integrations import HttpUrlIntegration, HttpLambdaIntegration

# book_store_default_fn: lambda.Function


get_books_integration = HttpUrlIntegration("GetBooksIntegration", "https://get-books-proxy.example.com")
book_store_default_integration = HttpLambdaIntegration("BooksIntegration", book_store_default_fn)

http_api = apigwv2.HttpApi(self, "HttpApi")

http_api.add_routes(
    path="/books",
    methods=[apigwv2.HttpMethod.GET],
    integration=get_books_integration
)
http_api.add_routes(
    path="/books",
    methods=[apigwv2.HttpMethod.ANY],
    integration=book_store_default_integration
)

Attributes

authorization_scopes

The list of OIDC scopes to include in the authorization.

These scopes will override the default authorization scopes on the gateway. Set to [] to remove default scopes

Default:
  • uses defaultAuthorizationScopes if configured on the API, otherwise none.

authorizer

Authorizer to be associated to these routes.

Use NoneAuthorizer to remove the default authorizer for the api

Default:
  • uses the default authorizer if one is specified on the HttpApi

integration

The integration to be configured on this route.

methods

The HTTP methods to be configured.

Default:

HttpMethod.ANY

path

The path at which all of these routes are configured.