The release of AWS Lambda and AWS API Gateway have made serverless microservice architecture a viable option for building cost-effective web apps. Considering the price (1 million AWS Lambda executions is only $0.20), a small web app can run nearly free in the cloud. There is only one problem: AWS has not included AWS API Gateway in CloudFormation, which makes continuous integration and deployment of API Gateway a difficult — if not impossible — task.
AWS has released a Java library (a CLI tool to import the gateway, which is basically a shell script wrapped around a JAR) and officially endorsed Swagger API for API Gateway’s acceptable (JSON) format. But here at RBN, we don’t just stop when AWS stops, so we took the cloud provider’s Java library and imported it into our Java Lambda function. Then we called the function with CloudFormation Custom Resource and deployed the Gateway. See how we did it on our GitHub Repo.