I am going to point you to a few resources to help you standup a hello world serverless app using AWS Lambda using AWS Serverless Application Model (SAM).
Serverless is an architecture style, where you leverage a service offering without having to provision or manage underlying infrastructure; and benefit from the service automatically scaling to your needs.
Serverless app platforms (like AWS Lambda or other similar FaaS services) are a particular type of Serverless offering that can take your code, host it in an execution environment and make it available as a (scalable) runtime service to your consumers.
Some Reading & Setup
- More details on Serverless – Read up https://aws.amazon.com/serverless/
- What is SAM?
- The AWS Serverless Application Model (AWS SAM) is an open-source framework that you can use to build serverless applications on AWS. – (from AWS site)
- Read up https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html
- SAM consists of
- AWS SAM Template – specification to define your serverless application
- AWS SAM CLI – command line tool to build serverless applications that are defined by AWS SAM templates
- SAM integrates with the rest of the AWS ecosystem, thus relieving you off other mundane activities.
- Install SAM CLI
- Please have an AWS Account created (with free tier ideally)
- Install Docker so we can run the serverless applications locally (useful during development)
- Refer https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-mac.html
- Setup AWS Credentials – https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-set-up-credentials.html
The Hello World app itself
To get a sample hello world app running follow https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html
- sam init – stands-up a simple hello world app with an AWS SAM template
- sam build – to build the project and generate deployment artifacts
- sam local invoke – to run the code once locally within a docker container
- sam local start-api – brings up your code in a hosted http server
- sam package – uploads deployment artifacts to S3
- sam deploy – deploys the application using Cloudformation changesets
The example application implements a customary hello world application that is a Lambda function and is fronted by an API Gateway.
- sam build (to build the code)
- sam invoke local (to perform one-off invocations)
- sam local start-api (to run a local http server that runs your code)
To run on AWS Cloud
- sam deploy –guided