Class WebSocketIamAuthorizer

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.aws_apigatewayv2_authorizers.WebSocketIamAuthorizer
All Implemented Interfaces:
IWebSocketRouteAuthorizer, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-02T15:58:20.902Z") @Stability(Stable) public class WebSocketIamAuthorizer extends software.amazon.jsii.JsiiObject implements IWebSocketRouteAuthorizer
Authorize WebSocket API Routes with IAM.

Example:

 import software.amazon.awscdk.aws_apigatewayv2_authorizers.WebSocketIamAuthorizer;
 import software.amazon.awscdk.aws_apigatewayv2_integrations.WebSocketLambdaIntegration;
 // This function handles your connect route
 Function connectHandler;
 WebSocketApi webSocketApi = new WebSocketApi(this, "WebSocketApi");
 webSocketApi.addRoute("$connect", WebSocketRouteOptions.builder()
         .integration(new WebSocketLambdaIntegration("Integration", connectHandler))
         .authorizer(new WebSocketIamAuthorizer())
         .build());
 // Create an IAM user (identity)
 User user = new User(this, "User");
 String webSocketArn = Stack.of(this).formatArn(ArnComponents.builder()
         .service("execute-api")
         .resource(webSocketApi.getApiId())
         .build());
 // Grant access to the IAM user
 user.attachInlinePolicy(Policy.Builder.create(this, "AllowInvoke")
         .statements(List.of(
             PolicyStatement.Builder.create()
                     .actions(List.of("execute-api:Invoke"))
                     .effect(Effect.ALLOW)
                     .resources(List.of(webSocketArn))
                     .build()))
         .build());
 
  • Constructor Details

    • WebSocketIamAuthorizer

      protected WebSocketIamAuthorizer(software.amazon.jsii.JsiiObjectRef objRef)
    • WebSocketIamAuthorizer

      protected WebSocketIamAuthorizer(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • WebSocketIamAuthorizer

      @Stability(Stable) public WebSocketIamAuthorizer()
  • Method Details