UrlShortner using Amazon Web Services, Serverless Application Model. For this service we use CloudFormation to build a stack composed by API Gateway, Lambda and DynamoDB powered by DAX.
For local development, follow the steps below:
- First, we need to setup a local DynamoDB. For this, run the command from the root project. This will run docker with the configurations in the
docker-compose.ymlfiledocker-compose up -d
- Install node dependencies
npm install
- Now, we are ready to go. To run lambda, you just need to run the command provided below and change json payload on
lambda/test.jsfile, which represents the payload lambda will receive from API Gatewaynpm run local
- Make a zip file with necessary folders
zip -qur urlshortner node_modules lambda
- Create a S3 bucket in case you don't have one
aws s3 mb s3://<bucket-name>
- Create an AWS CloudFormation package of the code in that bucket
aws cloudformation package --template-file template.yaml --output-template-file packaged-template.yaml --s3-bucket <bucket-name>
- Finally, deploy the AWS CloudFormation stack which will create all the resources defined in the YAML file
aws cloudformation deploy --template-file packaged-template.yaml --stack-name urlshortner
