This repository contains everything you need to deploy a sample photo gallery web application, using AWS managed services, including lambda and API-gateway.
The templates assume that you host your domain DNS using AWS route 53. If this is not the case, you can modify the cf-templates/gallery.static.json accordingly. The templates will build an s3 bucket with a name matching the FQDN of the site, eg. gallery.schaus.ca.
You will need to have the aws CLI installed and configured with credentials, as well as nodejs installed.
Follow these steps to deploy this sample application:
-
create a lambda code bucket and update lambda/gallery/package.json with bucket name
aws s3 s3://lambda-code-bucket-name
-
Update lambda/gallery/properties.json, changing the name of the dynamoDB table to match your domain. Build and deploy the lambda function
(cd lambda/gallery; npm install && npm run-script package && npm run-script deploys3)
-
modify default parameters for the cf-templates/gallery-*.json, or note parameters to specify when using cloudformation create-stack commands below
-
Create the static web components
aws cloudformation create-stack --stack-name gallery-1 --template-body file://cf-templates/gallery-static.json --capabilities CAPABILITY_IAM
-
Create the API components
aws cloudformation create-stack --stack-name gallery-api-1 --template-body file://cf-templates/gallery-api.json --capabilities CAPABILITY_IAM
-
Find the API Gateway URL. From the AWS Console, go to API Gateway -> Gallery API -> Stages -> Prod and copy the URL. Edit src/index.html and update the api variable with this value.
-
build and deploy the static web content
npm install -g bower && bower install && npm run-script templates && npm run-script deploy
-
Seed the DynamoDB table
(cd util; npm install && node addGallery.js)