I’m trying to figure out how to use LocalStack with serverless. I am figuring out most of it but I am currently having an issue referencing an existing MSK cluster that is not created in the serverless file.
My configuration is basically a lambda, S3 Bucket, and MSK. I am working on a new configuration, but it is based on an existing working project using lambda and MSK. The Serverless file provides the MSK ARN to the Lambda configuration via a CloudFormation parameter ‘cf’. However, when I run serverless with LocalStack I get an error saying the cf isn’t available. Currently I am starting MSK manually in LocalStack , then running Serverless with LocalStack configurations in the serverless file.
Does LocalStack work with serverless and CloudFormation? In particular, using the cf variable? If so, what would I need to do to get it to work, or is there any documentation on how to do this? If not, is there any other way to get a reference to existing services.
Error Message:
mydir $ serverless deploy --stage local
Running “serverless” from node_modules
Environment: linux, node 20.9.0, framework 3.37.0 (local) 3.37.0v (global), plugin 7.2.0, SDK 4.5.1
Credentials: xxx
Error:
Cannot resolve serverless.yml: Variables resolution errored with:
- Cannot resolve variable at “functions.MyLambda.events.0.msk.arn”: Value not found at “cf” source
Serverless Config snippet:
functions:
MyLambda:
events:
-msk:
arn: ${cf:my–msk-cluster.MSKClusterArn}
topic: my-topic-name
enabled: true
handler: my-lambda-handler
name: my-lambda-name