1 réponse
- Le plus récent
- Le plus de votes
- La plupart des commentaires
0
if you are not already using latest CDK version, try to update it and see if it helps. I tried to replicate your issue, but I could not. Here's the code
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
// import * as sqs from 'aws-cdk-lib/aws-sqs';
export class WebsocketApiGwStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
//Node.js lambda function that prints hello. take code from JS file
const hello = new cdk.aws_lambda.Function(this, 'hello', {
runtime: cdk.aws_lambda.Runtime.NODEJS_LATEST,
code: cdk.aws_lambda.Code.fromAsset('lambda/hello'),
handler: 'hello.handler',
});
//API Gateway websocket API
const api = new cdk.aws_apigatewayv2.WebSocketApi(this, 'api', {
connectRouteOptions: { integration: new cdk.aws_apigatewayv2_integrations.WebSocketLambdaIntegration('connect', hello) },
disconnectRouteOptions: { integration: new cdk.aws_apigatewayv2_integrations.WebSocketLambdaIntegration('disconnect', hello) },
});
//add a new stage to api
const stage = new cdk.aws_apigatewayv2.WebSocketStage(this, 'stage', {
webSocketApi: api,
stageName: 'dev',
});
//format arn
const arn = cdk.Stack.of(this).formatArn({
service: 'execute-api',
resource: `${stage.stageName}/POST/*`,
resourceName: api.apiId
});
//add to lambda role policy
hello.addToRolePolicy(new cdk.aws_iam.PolicyStatement({
actions: ['execute-api:ManageConnections'],
resources: [arn]
}));
api.grantManageConnections(hello)
}
}
répondu il y a un mois
Contenus pertinents
- Réponse acceptéedemandé il y a 2 ans
- demandé il y a 3 mois
- demandé il y a un an
- demandé il y a un an
- AWS OFFICIELA mis à jour il y a un an
- AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a 2 ans