How to do it...

Let's create the same API that we created in the previous recipe, but do it by using a CloudFormation template, and then deploy it using the AWS CLI. Finally, we will invoke the API from a browser. The CLI commands corresponding to the CloudFormation template components were already discussed in the previous recipe:

  1. Start by defining the template with AWSTemplateFormatVersion and a description, as follows:
---AWSTemplateFormatVersion: '2010-09-09'Description: Building API with AWS CloudFormation
  1. Define our REST API with the resource type AWS::ApiGateway::RestApi, as follows:
Resources: MyFirstRestAPI: Type: AWS::ApiGateway::RestApi Properties: Name: Greeting API      Description: API for greeting an user      FailOnWarnings: true ...

Get Serverless Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.