Closed calebebrim closed 1 year ago
~What is - msk
? Shouldn't it be - kafka
?~
NVM, I see now. I think the problem is with the iterator
and template
indentation. It should be
events:
- $forEach:
iterator: ...
template: ...
I'm trying this:
msk_event:
handler: src/handler.msk_event_handler
environment: ${file(envs/env.${sls:stage}.yml)}
timeout: 29
layers:
- { Ref: PythonRequirementsLambdaLayer }
package:
patterns:
- "!./**"
- "src/**/*.py"
events:
- $forEach:
iterator: $split(${file(./envs/env.${sls:stage, 'dev'}.yml):topicsNames}, ',')}
template:
- msk:
arn: "${file(envs/env.${opt:stage, 'dev'}.yml):KAFKA_CLUSTER_ARN}"
topic: $forEach.value
batchSize: 10
maximumBatchingWindow: 10
startingPosition: LATEST
Still failing:
Now template indentation seems not correct
msk_event:
handler: src/handler.msk_event_handler
environment: ${file(envs/env.${sls:stage}.yml)}
timeout: 29
layers:
- { Ref: PythonRequirementsLambdaLayer }
package:
patterns:
- "!./**"
- "src/**/*.py"
events:
- $forEach:
iterator: $split(${file(./envs/env.${sls:stage, 'dev'}.yml):topicsNames}, ',')}
template:
- msk:
arn: "${file(envs/env.${opt:stage, 'dev'}.yml):KAFKA_CLUSTER_ARN}"
topic: $forEach.value
batchSize: 10
maximumBatchingWindow: 10
startingPosition: LATEST
msk_event:
handler: src/handler.msk_event_handler
environment: ${file(envs/env.${sls:stage}.yml)}
timeout: 29
layers:
- { Ref: PythonRequirementsLambdaLayer }
package:
patterns:
- "!./**"
- "src/**/*.py"
events:
- $forEach:
iterator: $split(${file(./envs/env.${sls:stage, 'dev'}.yml):topicNames}, ',')}
template:
- msk:
arn: "${file(envs/env.${opt:stage, 'dev'}.yml):KAFKA_CLUSTER_ARN}"
topic: $forEach.value
batchSize: 10
maximumBatchingWindow: 10
startingPosition: LATEST
Still:
Make sure iterator
is an array. I do not know what the $split
is but it's likely that it's doing its thing after serverless-plugin-for-each
, so it's not an array from the plugin perspective.
Same thing mate!
The $split comes from: https://www.npmjs.com/package/serverless-plugin-utils
Did you add the plugin to the list in serverless.yml
? Does your console output has Found and replaced XXX $forEach matches
?
Hum... That is it... I'm new to serverless so I thought it isn't necessary.
- serverless-plugin-for-each
I shoud put like this right?
Yes, just add it to the list of plugins
I've tryed also with the commented line and it does not work.
frameworkVersion: '3'