Serverless Framework dry run or test without deploying - yaml

There's any way to test Serverless Framework code without deploying it? Similar to Terraform's dry run.
I've tried using the --noDeploy flag, but it doesn't seem to work. I'm trying to create a CI pipeline for it, but can't find any solution.

the closest we have in Serverless Framework is the serverless package command, it will build and save all of the deployment artifacts in the .serverless directory:
https://www.serverless.com/framework/docs/providers/aws/guide/packaging/
you can inspect the CloudFormation and anything else (e.g. code transpilation, plugins etc) generated by Serverless Framework in that folder

Related

Running/Testing an AWS Serverless API written in Terraform

No clear path to do development in a serverless environment.
I have an API Gateway backed by some Lambda functions declared in Terraform. I deploy to the cloud and everything is fine, but how do I go about setting a proper workflow for development? It seems like a struggle to push every small code change to the cloud while developing in order to run your code. Terraform has started getting some support by the SAM framework to run your Lambda functions locally (https://aws.amazon.com/blogs/compute/better-together-aws-sam-cli-and-hashicorp-terraform/), but still no way to simulate a local server and test out your endpoints in Postman for example.
First of all I use serverless plugin instead of terraform, my answer is based on what you provided and what I found around.
From what I understood so far with priovided documentation you are able to run sam CLI with terraform (cf: Chapter Local testing)
You might follow this documentation to invoke local functions.
I recommend to use JSON files to create use cases instead of stdin injection.
First step is to create your payload in json file and to invoke your lambda with the json payload like
sam local invoke "YOUR_LAMBDA_NAME" -e ./path/to/yourjsonfile.json

How to deploy ziped lambda code from s3 using code deploy service alone?

I'm trying to deploy the zipped lambda functions to lambda application using codedeploy but unable to deploy. But i'm able to switch traffic from alreday existing lambda current version to newer versions..using appspec file declaration. Not sure if codedeploy support deployment of lambdas. Can someone help me with this.
CodeDeploy supports deployment to Lambda natively.
https://docs.aws.amazon.com/codedeploy/latest/userguide/applications-create-lambda.html
https://docs.aws.amazon.com/codedeploy/latest/userguide/tutorial-lambda-sam.html

How to do not deploy lambda if no changes on code

AWS Lambda are deployed even if there is no change on code and serverless configuration. I would like to do not deploy it...
My code is redeployed even after 2 consecutive serverless deploy
I tried to launch, on the same code base, serverless package twice and the only the difference is on the S3Key and artifactDirectoryName.
The resulting serverless-states.json files contain the following S3Key:
serverless/[...]/1560423171166-2019-06-13T10:52:51.166Z
serverless/[...]/1560423200593-2019-06-13T10:53:20.593Z
So I'd like to understand if this can cause deployment ?
Or is this a bad behavior of serverless ?
serverless --version
1.45.1
Actually, I'm expecting to do not deploy my lambdas

What’s the best way to deploy multiple lambda functions from a single github repo onto AWS?

I have a single repository that hosts my lambda functions on github. I would like to be able to deploy the new versions whenever new logic is pushed to master.
I did a lot of reasearch and found a few different approaches, but nothing really clear. Would like to know what others feel would be the best way to go about this, and maybe some detail (if possible) into how that pipeline is setup.
Thanks
Welcome to StackOverflow. You can improve your question by reading this page.
You can setup a CI/CD pipeline using CircleCI with its GitHub integration (which is an online Service, so you don't need to maintain anything, like a Jenkins server, for example)
Upon every commit to your repository, a CircleCI build will be triggered. Once the build process is over, you can declare sls deploy, sam deploy, use Terraform or even create a script to upload the .zip file from your GitHub repo to an S3 Bucket and then, within your script, invoke the create-function command. There's an example how to deploy Serverless applications using CircleCI along with the Serverless Framework here
Other options include TravisCI, AWS Code Deploy or even maintain your own CI/CD Server. The same logic applies to all of these tools though: commit -> build -> deploy (using one of the tools you've chosen).
EDIT: After #Matt's answer, it clicked that the OP never mentioned the Serverless Framework (I, somehow, thought he was already using it, so I pointed the OP to tutorials using the Serverless Framework already). I then decided to update my answer with a few other options for serverless deployment
I know that this isn't exactly what you asked for but I use Serverless Framework (https://serverless.com) for deployment and I love it. I don't do my deployments when I push to my repo. Instead I push to my repo after I've deployed. I like this flow because a deployment can fail due to so many things and pushing to GitHub is much less likely to fail. I this way, I prevent pushing code that failed to deploy to my master branch.
I don't know if you're familiar with the framework but it is super simple. The website describes the simple steps to creating and deploy a function like this.
1 # Step 1. Install serverless globally
2 $ npm install serverless -g
3
4 # Step 2. Create a serverless function
5 $ serverless create --template hello-world
6
7 # Step 3. deploy to cloud provider
8 $ serverless deploy
9
10 # Your function is deployed!
11 $ http://xyz.amazonaws.com/hello-world
There are also a number of plugins you can use to integrate easily with custom domains on APIGateway, prune older versions of lambda functions that might be filling up your limits, etc...
Overall, I've found it to be the easiest way to manage and deploy my lambdas. Hope it helps!
Given that you're using AWS Lambda, you may want to consider CodePipeline to automate your release process. [SAM(https://docs.aws.amazon.com/lambda/latest/dg/serverless_app.html) may also be interesting.
I too had the same problem. I wanted to manage 12 lambdas with 1 git repository. I solved it by introducing travis-ci. travis-ci saved the time and really useful in many ways. We can check the logs whenever we want and you can share the logs to anyone by sharing the URL. The sample documentation of all steps can be found here. You can go through it. 👍

Building JAR files in a Heroku app

I have a web app running on Heroku from which I need to build and make available a JAR file when a user of the app requests it. I also need to run ProGuard on the generated JAR file. Is it possible to do this on Heroku?
We're working on exposing Heroku build infrastructure as services and what you describe is a use case that we want to support. You might be able to get something working by using or reverse-engineering heroku-push: https://github.com/ddollar/heroku-push
Here's the server-side bit that actually builds code: https://github.com/ddollar/anvil
Ryan Brainard has built a Java wrapper for Anvil: https://github.com/ryanbrainard/janvil

Resources