Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(apigatewayv2): review readme #27996

Merged
merged 20 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/@aws-cdk/aws-apigatewayv2-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ This module supports features under [API Gateway v2](https://docs.aws.amazon.com
that lets users set up Websocket and HTTP APIs.
REST APIs can be created using the `aws-cdk-lib/aws-apigateway` module.

HTTP and Websocket APIs use the same Cloudformation resources under the hood. However, this module separates them into two separate constructs for a more efficient abstraction since there are a number of Cloudformation properties that specifically apply only to each type of API.
sumupitchayan marked this conversation as resolved.
Show resolved Hide resolved

## HTTP API

HTTP APIs enable creation of RESTful APIs that integrate with AWS Lambda functions, known as Lambda proxy integration,
Expand All @@ -65,16 +67,15 @@ integration, HTTP proxy integration and, AWS service integrations, also known as
[Configuring integrations](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html).

Integrations are available at the `aws-apigatewayv2-integrations` module and more information is available in that module.
As an early example, the following code snippet configures a route `GET /books` with an HTTP proxy integration all
configures all other HTTP method calls to `/books` to a lambda proxy.
As an early example, we have a website for a bookstore where the following code snippet configures a route `GET /books` with an HTTP proxy integration. All other HTTP method calls to `/books` route to a default lambda proxy for the bookstore.

```ts
import { HttpUrlIntegration, HttpLambdaIntegration } from '@aws-cdk/aws-apigatewayv2-integrations-alpha';

const getBooksIntegration = new HttpUrlIntegration('GetBooksIntegration', 'https://get-books-proxy.example.com');

declare const booksDefaultFn: lambda.Function;
const booksDefaultIntegration = new HttpLambdaIntegration('BooksIntegration', booksDefaultFn);
declare const bookStoreDefaultFn: lambda.Function;
const bookStoreDefaultIntegration = new HttpLambdaIntegration('BooksIntegration', bookStoreDefaultFn);

const httpApi = new apigwv2.HttpApi(this, 'HttpApi');

Expand All @@ -86,7 +87,7 @@ httpApi.addRoutes({
httpApi.addRoutes({
path: '/books',
methods: [ apigwv2.HttpMethod.ANY ],
integration: booksDefaultIntegration,
integration: bookStoreDefaultIntegration,
});
```

Expand Down
sumupitchayan marked this conversation as resolved.
Show resolved Hide resolved
sumupitchayan marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete sentence? Access control for Http APIs is managed by restricting which routes can be invoked via.

sumupitchayan marked this conversation as resolved.
Show resolved Hide resolved
sumupitchayan marked this conversation as resolved.
Show resolved Hide resolved
sumupitchayan marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we mean by 'app client'?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can set an authorizer to your WebSocket API's $connect route to control access to your API.

Does this also apply to Lambda Authorizers in WebSocket? Or do we have a property that reflects this?

Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-acces

## HTTP APIs

Access control for Http Apis is managed by restricting which routes can be invoked via.
Access control for Http APIs is managed by restricting which routes can be invoked via.
sumupitchayan marked this conversation as resolved.
Show resolved Hide resolved

Authorizers and scopes can either be applied to the api, or specifically for each route.
Authorizers and scopes can either be applied to the API, or specifically for each route.

### Default Authorization

Expand Down Expand Up @@ -150,7 +150,7 @@ api.addRoutes({

#### User Pool Authorizer

User Pool Authorizer is a type of JWT Authorizer that uses a Cognito user pool and app client to control who can access your Api. After a successful authorization from the app client, the generated access token will be used as the JWT.
User Pool Authorizer is a type of JWT Authorizer that uses a Cognito user pool and app client to control who can access your API. After a successful authorization from the app client, the generated access token will be used as the JWT.

Clients accessing an API that uses a user pool authorizer must first sign in to a user pool and obtain an identity or access token.
They must then use this token in the specified `identitySource` for the API call. More information is available at [using Amazon Cognito user
Expand Down
sumupitchayan marked this conversation as resolved.
Show resolved Hide resolved
sumupitchayan marked this conversation as resolved.
Show resolved Hide resolved
sumupitchayan marked this conversation as resolved.
Show resolved Hide resolved
sumupitchayan marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,4 @@ webSocketApi.addRoute('sendmessage', {
integration: new WebSocketLambdaIntegration('SendMessageIntegration', messageHandler),
});
```
Extra line so this shows up in the files changes for the API Review - delete later
Loading