@aws-cdk_aws-apigatewayv2-authorizers-alpha.WebSocketIamAuthorizer
class WebSocketIamAuthorizer
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Apigatewayv2.Authorizers.Alpha.WebSocketIamAuthorizer |
![]() | github.com/aws/aws-cdk-go/awscdkapigatewayv2authorizersalpha/v2#WebSocketIamAuthorizer |
![]() | software.amazon.awscdk.services.apigatewayv2.authorizers.alpha.WebSocketIamAuthorizer |
![]() | aws_cdk.aws_apigatewayv2_authorizers_alpha.WebSocketIamAuthorizer |
![]() | @aws-cdk/aws-apigatewayv2-authorizers-alpha » WebSocketIamAuthorizer |
Implements
IWeb
Authorize WebSocket API Routes with IAM.
Example
import { WebSocketIamAuthorizer } from '@aws-cdk/aws-apigatewayv2-authorizers-alpha';
import { WebSocketLambdaIntegration } from '@aws-cdk/aws-apigatewayv2-integrations-alpha';
// This function handles your connect route
declare const connectHandler: lambda.Function;
const webSocketApi = new apigwv2.WebSocketApi(this, 'WebSocketApi');
webSocketApi.addRoute('$connect', {
integration: new WebSocketLambdaIntegration('Integration', connectHandler),
authorizer: new WebSocketIamAuthorizer()
});
// Create an IAM user (identity)
const user = new iam.User(this, 'User');
const webSocketArn = Stack.of(this).formatArn({
service: 'execute-api',
resource: webSocketApi.apiId,
});
// Grant access to the IAM user
user.attachInlinePolicy(new iam.Policy(this, 'AllowInvoke', {
statements: [
new iam.PolicyStatement({
actions: ['execute-api:Invoke'],
effect: iam.Effect.ALLOW,
resources: [webSocketArn],
}),
],
}));
Initializer
new WebSocketIamAuthorizer()
Methods
Name | Description |
---|---|
bind(_options) | Bind this authorizer to a specified WebSocket route. |
bind(_options)
public bind(_options: WebSocketRouteAuthorizerBindOptions): WebSocketRouteAuthorizerConfig
Parameters
- _options
Web
Socket Route Authorizer Bind Options
Returns
Bind this authorizer to a specified WebSocket route.