Adrián Mouly
09/13/2021, 10:44 AMputEvents
. Most of the time works fine, but sometimes when the lambda starts from cold-start I get timeout when calling eventBridge…. it’s like the EventBridge call never ends and this produces a timeout on the lambda/api-gw …. It’s weird because it doesn’t happen all the time.
Checked permissions and those are ok.Ashishkumar Pandey
09/13/2021, 10:50 AMAdrián Mouly
09/13/2021, 5:22 PMAdrián Mouly
09/13/2021, 5:22 PMAdrián Mouly
09/13/2021, 5:22 PMAdrián Mouly
09/13/2021, 5:23 PMAshishkumar Pandey
09/13/2021, 5:31 PMAdrián Mouly
09/13/2021, 5:31 PMAdrián Mouly
09/13/2021, 5:31 PMAdrián Mouly
09/13/2021, 5:33 PMAdrián Mouly
09/13/2021, 5:33 PMFrank
putEvents
call timeout.Adrián Mouly
09/13/2021, 6:12 PMAdrián Mouly
09/13/2021, 6:12 PMFrank
putEvents
call is timing out, you can play around with the aws sdk client’s http timeout and retry.Adrián Mouly
09/13/2021, 6:14 PMFrank
Adrián Mouly
09/13/2021, 6:15 PMAdrián Mouly
09/13/2021, 6:15 PMAdrián Mouly
09/13/2021, 6:15 PMAdrián Mouly
09/13/2021, 6:16 PMconst writeSurveyResponses = new Function(this, 'writeSurveyResponses', {
});
props.tasksEventBus.addRules(this, {
writeSurveyResponsesEventBridgeRule: {
targets: [writeSurveyResponses],
},
});
Frank
Adrián Mouly
09/13/2021, 6:33 PMAdrián Mouly
09/13/2021, 6:33 PMAdrián Mouly
09/13/2021, 6:33 PMAdrián Mouly
09/13/2021, 6:34 PMtargetProps
but it doesn’t accept SST-Queue for deadLetterQueue
.Adrián Mouly
09/13/2021, 6:36 PMTargetBaseProps
from CDK?
It has this definition:
readonly deadLetterQueue?: sqs.IQueue;
Adrián Mouly
09/13/2021, 6:43 PMAdrián Mouly
09/13/2021, 6:43 PMTypeError: construct[methodName] is not a function
at /Users/amouly/Projects/yabble/yabble-serverless/node_modules/@serverless-stack/resources/src/util/permission.ts:205:70
at Array.forEach (<anonymous>)
at Object.attachPermissionsToRole (/Users/amouly/Projects/yabble/yabble-serverless/node_modules/@serverless-stack/resources/src/util/permission.ts:77:15)
at Function.attachPermissions (/Users/amouly/Projects/yabble/yabble-serverless/node_modules/@serverless-stack/resources/src/Function.ts:373:7)
at new Function (/Users/amouly/Projects/yabble/yabble-serverless/node_modules/@serverless-stack/resources/src/Function.ts:357:12)
at Function.fromDefinition (/Users/amouly/Projects/yabble/yabble-serverless/node_modules/@serverless-stack/resources/src/Function.ts:477:14)
at Api.createFunctionIntegration (/Users/amouly/Projects/yabble/yabble-serverless/node_modules/@serverless-stack/resources/src/Api.ts:533:23)
at Api.addRoute (/Users/amouly/Projects/yabble/yabble-serverless/node_modules/@serverless-stack/resources/src/Api.ts:428:26)
at /Users/amouly/Projects/yabble/yabble-serverless/node_modules/@serverless-stack/resources/src/Api.ts:294:12
at Array.forEach (<anonymous>)
Adrián Mouly
09/13/2021, 6:49 PMAdrián Mouly
09/13/2021, 6:49 PMpermissions: [[this.tasksEventBus, 'grantPutEventsTo']],
But it doesn’t compile with SST EB.
But this work with SST EB:
permissions: [this.tasksEventBus],
Frank
this.tasksEventBus
an instance of sst.EventBus
? If it is, events:*
should’ve been granted to the Lambda https://github.com/serverless-stack/serverless-stack/blob/master/packages/resources/src/util/permission.ts#L180-L183Adrián Mouly
09/13/2021, 7:43 PMAdrián Mouly
09/13/2021, 7:43 PM*
.Adrián Mouly
09/13/2021, 7:44 PMputEvents
only.Adrián Mouly
09/13/2021, 7:44 PMAdrián Mouly
09/13/2021, 7:44 PMFrank
permissions: [[this.tasksEventBus, 'grantPutEventsTo']]
only works if this.tasksEventBus
were the CDK EventBridge.Adrián Mouly
09/13/2021, 7:47 PMAdrián Mouly
09/13/2021, 7:47 PMAdrián Mouly
09/13/2021, 7:48 PM*
is not good.Frank
permissions: [sstEventBus]
grants events:* to the specified bus
• permissions: ["events:PutEvents"]
grants the specified permission to all buses
• permissions: [[sstEventBus.eventBridgeEventBus, "grantPutEventsTo"]]
grants the specified permission to the specified bus
• permissions: [new iam.PolicyStatement(...)]
the most precise way to grant permissions, also the most cumbersomeAdrián Mouly
09/13/2021, 8:07 PMAdrián Mouly
09/13/2021, 8:07 PMsstEventBus.eventBridgeEventBus
.Adrián Mouly
09/13/2021, 8:07 PMFrank
sstQueue.sqsQueue
and you can set that as the deadLetterQueue
Adrián Mouly
09/13/2021, 8:17 PMAdrián Mouly
09/13/2021, 8:17 PMAdrián Mouly
09/13/2021, 8:17 PMAdrián Mouly
09/13/2021, 8:18 PMFrank
Adrián Mouly
09/13/2021, 8:19 PMAdrián Mouly
09/13/2021, 9:38 PM