WebSocketStageAttributes Struct
The attributes used to import existing WebSocketStage.
| Source | aws-apigatewayv2/lib/websocket/stage.ts |
|---|---|
| Type last changed |
Example
ts
declare const webSocketApi: apigwv2.IWebSocketApi;
const importedStage = apigwv2.WebSocketStage.fromWebSocketStageAttributes(this, 'imported-stage', {
stageName: 'myStage',
api: webSocketApi,
});
const apiKey = new apigwv2.ApiKey(this, 'MyApiKey');
const usagePlan = new apigwv2.UsagePlan(this, 'MyUsagePlan', {
apiStages: [{ api: webSocketApi, stage: importedStage }],
});
usagePlan.addApiKey(apiKey);
python
# web_socket_api: apigwv2.IWebSocketApi
imported_stage = apigwv2.WebSocketStage.from_web_socket_stage_attributes(self, "imported-stage",
stage_name="myStage",
api=web_socket_api
)
api_key = apigwv2.ApiKey(self, "MyApiKey")
usage_plan = apigwv2.UsagePlan(self, "MyUsagePlan",
api_stages=[apigwv2.UsagePlanPerApiStage(api=web_socket_api, stage=imported_stage)]
)
usage_plan.add_api_key(api_key)
java
IWebSocketApi webSocketApi;
IWebSocketStage importedStage = WebSocketStage.fromWebSocketStageAttributes(this, "imported-stage", WebSocketStageAttributes.builder()
.stageName("myStage")
.api(webSocketApi)
.build());
ApiKey apiKey = new ApiKey(this, "MyApiKey");
UsagePlan usagePlan = UsagePlan.Builder.create(this, "MyUsagePlan")
.apiStages(List.of(UsagePlanPerApiStage.builder().api(webSocketApi).stage(importedStage).build()))
.build();
usagePlan.addApiKey(apiKey);
csharp
// Install: dotnet add package Amazon.CDK.Lib
IWebSocketApi webSocketApi;
var importedStage = WebSocketStage.FromWebSocketStageAttributes(this, "imported-stage", new WebSocketStageAttributes {
StageName = "myStage",
Api = webSocketApi
});
var apiKey = new ApiKey(this, "MyApiKey");
var usagePlan = new UsagePlan(this, "MyUsagePlan", new UsagePlanProps {
ApiStages = new [] { new UsagePlanPerApiStage { Api = webSocketApi, Stage = importedStage } }
});
usagePlan.AddApiKey(apiKey);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var webSocketApi IWebSocketApi
importedStage := apigwv2.WebSocketStage_FromWebSocketStageAttributes(this, jsii.String("imported-stage"), &WebSocketStageAttributes{
StageName: jsii.String("myStage"),
Api: webSocketApi,
})
apiKey := apigwv2.NewApiKey(this, jsii.String("MyApiKey"))
usagePlan := apigwv2.NewUsagePlan(this, jsii.String("MyUsagePlan"), &UsagePlanProps{
ApiStages: []UsagePlanPerApiStage{
&UsagePlanPerApiStage{
Api: webSocketApi,
Stage: importedStage,
},
},
})
usagePlan.addApiKey(apiKey)
Properties
The API to which this stage is associated.
The name of the stage.