Skip to content
v2.274.0

WebSocketApiKeySelectionExpression Class ​

Represents the currently available API Key Selection Expressions.

Example ​

ts
const webSocketApi = new apigwv2.WebSocketApi(this, 'mywsapi',{
  apiKeySelectionExpression: apigwv2.WebSocketApiKeySelectionExpression.HEADER_X_API_KEY,
});
python
web_socket_api = apigwv2.WebSocketApi(self, "mywsapi",
    api_key_selection_expression=apigwv2.WebSocketApiKeySelectionExpression.HEADER_X_API_KEY
)
java
WebSocketApi webSocketApi = WebSocketApi.Builder.create(this, "mywsapi")
        .apiKeySelectionExpression(WebSocketApiKeySelectionExpression.HEADER_X_API_KEY)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var webSocketApi = new WebSocketApi(this, "mywsapi", new WebSocketApiProps {
    ApiKeySelectionExpression = WebSocketApiKeySelectionExpression.HEADER_X_API_KEY
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
webSocketApi := apigwv2.NewWebSocketApi(this, jsii.String("mywsapi"), &WebSocketApiProps{
	ApiKeySelectionExpression: apigwv2.WebSocketApiKeySelectionExpression_HEADER_X_API_KEY(),
})

Initializer ​

ts
new WebSocketApiKeySelectionExpression(customApiKeySelector: string)
python
WebSocketApiKeySelectionExpression(custom_api_key_selector: str)
java
new WebSocketApiKeySelectionExpression(String customApiKeySelector)
csharp
new WebSocketApiKeySelectionExpression(string customApiKeySelector)
go
NewWebSocketApiKeySelectionExpression(CustomApiKeySelector *string)

Properties ​

AUTHORIZER_USAGE_IDENTIFIER_KEYWebSocketApiKeySelectionExpressionauthorizer_usage_identifier_keyWebSocketApiKeySelectionExpressionAUTHORIZER_USAGE_IDENTIFIER_KEYWebSocketApiKeySelectionExpressionAUTHORIZER_USAGE_IDENTIFIER_KEYWebSocketApiKeySelectionExpressionAUTHORIZER_USAGE_IDENTIFIER_KEYWebSocketApiKeySelectionExpressionstatic#
The API will extract the key value from the `usageIdentifierKey` attribute in the `context` map, returned by the Lambda Authorizer.
customApiKeySelectorstringcustom_api_key_selectorstrcustomApiKeySelectorStringCustomApiKeySelectorstringCustomApiKeySelector*string#
The expression used by API Gateway.
The API will extract the key value from the `x-api-key` header in the user request.