Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Open `cdk/bin/websockets-blog.ts` and adjust the Regions to deploy the applicati

```
// List of Region codes to deploy the application to
const regionsToDeploy = ['us-west-1', 'eu-west-1', 'ap-northeast-1'];
const regionsToDeploy = ['us-east-1', 'eu-west-1', 'ap-northeast-1'];
```

#### 5. Deploy your application
Expand Down
3 changes: 2 additions & 1 deletion cdk/bin/websockets-blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import { WebsocketsBlogStack } from '../lib/websockets-blog-stack';

const app = new cdk.App();

const regionsToDeploy = ['us-west-1', 'eu-west-1', 'ap-northeast-1'];
const regionsToDeploy = ['us-east-1', 'eu-west-1', 'ap-northeast-1'];

// Regional stacks
regionsToDeploy.forEach((regionCode) => {
const stack = new WebsocketsBlogStack(app, `WebsocketsBlogStack-${regionCode}`, {
env: { region: regionCode },
regionCodesToReplicate: regionsToDeploy.filter((replicationRegion) => replicationRegion !== regionCode),
description: 'Deploys the regional Stack for multi-region Websocket API demo (uksb-1tupboc29)',
});
Tags.of(stack).add('project', 'aws-blogpost');
Tags.of(stack).add('topic', 'multi-region-websocket-api');
Expand Down
12 changes: 6 additions & 6 deletions cdk/lib/websockets-blog-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
import { Construct } from 'constructs';

import { AttributeType, BillingMode, Table } from 'aws-cdk-lib/aws-dynamodb';
import { WebSocketLambdaIntegration } from '@aws-cdk/aws-apigatewayv2-integrations-alpha';
import * as apigwv2 from '@aws-cdk/aws-apigatewayv2-alpha';
import { WebSocketLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
import { WebSocketApi, WebSocketStage } from 'aws-cdk-lib/aws-apigatewayv2';
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
import * as events from 'aws-cdk-lib/aws-events';
import { Runtime, Tracing } from 'aws-cdk-lib/aws-lambda';
Expand Down Expand Up @@ -36,7 +36,7 @@ export class SimpleLambda extends Construct {
this.fn = new NodejsFunction(this, id, {
entry: `../src/lambda/${props.entryFilename}`,
handler: props.handler ?? 'handler',
runtime: props.runtime ?? Runtime.NODEJS_16_X,
runtime: props.runtime ?? Runtime.NODEJS_20_X,
timeout: props.timeout ?? Duration.seconds(5),
memorySize: props.memorySize ?? 1024,
tracing: Tracing.ACTIVE,
Expand Down Expand Up @@ -99,7 +99,7 @@ export class WebsocketsBlogStack extends Stack {

eventBus.grantPutEventsTo(requestHandlerLambda.fn);

const webSocketApi = new apigwv2.WebSocketApi(this, 'WebsocketApi', {
const webSocketApi = new WebSocketApi(this, 'WebsocketApi', {
apiName: 'WebSocketApi',
description: 'A regional Websocket API for the multi-region chat application.',
connectRouteOptions: {
Expand All @@ -113,7 +113,7 @@ export class WebsocketsBlogStack extends Stack {
},
});

const websocketStage = new apigwv2.WebSocketStage(this, 'WebsocketStage', {
const websocketStage = new WebSocketStage(this, 'WebsocketStage', {
webSocketApi,
stageName: 'chat',
autoDeploy: true,
Expand Down Expand Up @@ -178,7 +178,7 @@ export class WebsocketsBlogStack extends Stack {
eventBus.grantPutEventsTo(processLambda.fn);
table.grantReadData(processLambda.fn);

new CfnOutput(this, 'bucketName', {
new CfnOutput(this, 'WebSocket API URL', {
value: websocketStage.url,
description: 'WebSocket API URL',
exportName: `websocketAPIUrl-${this.region}`,
Expand Down
Loading