Skip to content

s4nt14go/helloSam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Serverless Application Model app 👋

Version License: ISC

Description

Deploy an endpoint which will tell you what time is in the timezone you code in index.js file. You will be able to navigate to the url endpoint and you will get the time.

Requirements:

Instructions:

  1. Clone this repo and cd into it
    git clone https://github.com/s4nt14go/helloSam.git
  2. Check your are using your AWS credentials and the region you want
    aws configure list
  3. Create a bucket filling with a random suffix (because the name has to be unique), for example if we want to deploy in region us-east-2 Ohio:
    aws s3 mb s3://lambda-deployment-artifacts-<yourRandomSuffix> --region us-east-2
  4. We will first build the project locally and then deploy it, so cd into the repo. As the runtime specified in template.yml is node v12 we have to use the same version locally, so make sure you are using node v12 running node -v. If you aren't using v12 you can use nvm to install and set node v12 as the current node version.
  5. Build the project locally
    sam build
  6. Check it works locally
    sam local invoke TimeFunction
  7. Deploy it!
    sam deploy --stack-name myStack --s3-bucket lambda-deployment-artifacts-<yourRandomSuffix> --capabilities CAPABILITY_IAM --region us-east-2

The last comand will output an url similar to
https://<randomChars>.execute-api.us-east-2.amazonaws.com/prod/TimeResource
visit it with your browser and you will get the time from the timezone set in index.js.

You can try changing tz value in index.js for the timezone of your choice according to moment-timezone and repeat steps 5, 6 and 7.

As a demo you can browse to the endpoint this repo deploys:
https://hmddi9jmv3.execute-api.us-east-1.amazonaws.com/prod/TimeResource