Reputation: 7988
I've successfully deployed my lambda function (in Nodejs runtime) using the serverless framework
The thing is that serverless deploy
also creates a bunch of AWS services which I do not want such as:
Q: Is there anyway to tell serverless to deploy just the lambda function? (Or at least avoid the API gateway)
Upvotes: 1
Views: 906
Reputation: 1540
The Serverless Framework creates an S3 bucket as a way to get your service into AWS. Instead of trying to push directly at the Lambda service, it packages it in a zip, uploads to S3 and then points at that S3 bucket for the deployment process to know where to find stuff. You can specify your own S3 bucket which should be used to store all the deployment artifacts. The deploymentBucket config which is nested under provider lets you e.g. set the name or the serverSideEncryption method for this bucket. If you don't provide your own bucket, Serverless will create a bucket which uses default AES256 encryption.
As for the API Gateway, if you want to use an existing API Gateway resource (no real need to though as they cost nothing unless there is traffic going through them), you can share the same API Gateway between multiple projects by referencing its REST API ID and Root Resource ID in serverless.yml as follows:
service: service-name
provider:
name: aws
apiGateway:
restApiId: xxxxxxxxxx # REST API resource ID. Default is generated by the framework
restApiRootResourceId: xxxxxxxxxx # Root resource, represent as / path
websocketApiId: xxxxxxxxxx # Websocket API resource ID. Default is generated by the framework
description: Some Description # optional - description of deployment history
functions: ...
You should reconsider using CloudWatch at least at a basic level. It is the only way you can get output from your functions unless you tie in a service that makes API requests which can add latency to your service. CloudWatch doesn't add latency (or at least so small as to be insignificant). However, if you really must turn CloudWatch off, you can't stop it creating the log group in ClouWatch but you can restrict the time for logs to live to 0 or a small number of days:
provider:
logRetentionInDays: 0
Upvotes: 1