amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

function hotswap for development

Open lambdasawa opened this issue 4 years ago • 4 comments

Is this feature request related to a new or existing Amplify category?

function

Is this related to another service?

function

Describe the feature you'd like to request

When I execute amplify push, amplify-cli calls the CloudFormation API to update the Lambda Function. Updating Lambda using CloudFormation is slow compared to updating using the aws lambda update-function-code command.

I want to send the code to Lambda faster during development and debugging.

Describe the solution you'd like

I want the amplify function watch command.

When this command is executed, the files under amplify/backend/function/*/src are watched, and when a file change is detected, lambda:UpdateFunctionCode, lambda:PublishLayerVersion, lambda:UpdateFunctionConfiguration are executed.

Describe alternatives you've considered

AWS CDK takes this approach. (see https://github.com/aws/aws-cdk/pull/15748)

Serverless Stack takes a different approach. (see: https://docs.serverless-stack.com/live-lambda-development) Serverless Stack provides an intermediate server and connects the local environment and Lambda with WebSocket.

I like the AWS CDK approach because it's simple.

Additional context

I implemented this feature as a plugin. (currently Node.js only) Recently, colleagues and I have started using this plugin at work. For now, this plugin is working fine, so I think this approach will work.

Is this something that you'd be interested in working on?

  • [X] 👋 I may be able to implement this feature request
  • [ ] ⚠️ This feature might incur a breaking change

lambdasawa avatar Nov 03 '21 03:11 lambdasawa

Hey @lambdasawa, this is a great idea we could directly update the code without a push for hotswap. I will bring it up to my team.

ammarkarachi avatar Nov 03 '21 20:11 ammarkarachi

I'm currently implementing this. I think I can probably send a pull request tomorrow.

https://github.com/lambdasawa/amplify-cli/tree/function-hotswap

lambdasawa avatar Nov 05 '21 00:11 lambdasawa

Can wait to see this make it into Amplify! Great idea and work!

houmark avatar Nov 25 '21 03:11 houmark

This would be great, looks like the plugin listed above has now been archived

jlsorak avatar Apr 27 '24 10:04 jlsorak