Config a function in serverless.yml that it should only be invoked locally

I some functions that I only invoke locally. They are used to setting up initial the s3 content, so i need them to be able to access the serverless.yml properties. However, I i don’t need them to be installed to aws lambda. Is there a way l to allow a function to be invoked locally but prevent it from be installed as a lambda?

I don’t completely understand your question, but my question is if you only need to invoke a function locally, why even include it in your serverless.yml file? Any functions in the serverless.yml file will be deployed to the ‘provider’.

Can you describe your use case so I can better help you?

Rupak Ganguly

I do the similar thing, differences are, I need initialise dynamodb tables.

I split the tasks seperately, and managed with npm scripts.

sls deploy
npm run db-init

I want to to have access to properties stated in the serverlesss.yml.
e.g: “stage”, “environment variables” etc’…

You have access to the variables using the framework’s variable system, or if you need access to those to modify the life-cycle events of the framework itself, you can write a plugin. The plugin system has access to lot more things.

Let me know if that answers your question.

To the best of my knowledge, the variable system works only under “sls invoke” or “sls invoke local”. So if i want a local function to access the variable system i need to “invoke” it.

@amitm02 Not really sure what you want to do, TBH. If you can describe your use case a little better, I can be of better help. Where is your function in relation to the serverless service? What are you trying to do? etc.

I have a use case that is similar to this. I have a daily batch processing lambda function whose input data finally grew enough that it exceeds the current memory limit of AWS Lambda functions. I would like to configure a larger memory limit for local invocation instead of rewriting the process to live outside of the serverless framework if possible.

I’m looking for ideas on how I could achieve that (increased memory/timeout) when invoked locally.