In this step, we do some preparations steps to create REST APIs later.
Open template.yaml in fcj-book-shop folder.
Add the following script at the end of the file.
Firstly, we will create apiType, binaryMediaType and getOrPostPathPart parameters.
apiType:
  Type: String
  Default: REGIONAL
binaryMediaType:
  Type: String
  Default: multipart/form-data
getOrPostPathPart:
  Type: String
  Default: books
deletePathPart:
  Type: String
  Default: "{id}"

Next, we will create BookApi RestApi and BookApiResource Resource.
BookApi:
  Type: AWS::ApiGateway::RestApi
  Properties:
    Name: fcj-serverless-api
    EndpointConfiguration:
      Types:
        - !Ref apiType
    BinaryMediaTypes:
      - !Ref binaryMediaType
BookApiResource:
  Type: AWS::ApiGateway::Resource
  Properties:
    RestApiId: !Ref BookApi
    ParentId: !GetAtt BookApi.RootResourceId
    PathPart: !Ref getOrPostPathPart
BookDeleteApiResource:
  Type: AWS::ApiGateway::Resource
  Properties:
    RestApiId: !Ref BookApi
    ParentId: !Ref BookApiResource
    PathPart: !Ref deletePathPart

Run the following command to deploy SAM.
sam build
sam validate
sam deploy

Open AWS API Gateway console.




So we finish some preparation steps. Next, we will create GET, POST and DELETE api.