We will create APIs to integrate with the functions created in the previous step.
/books/order:
get:
responses:
"200":
description: 200 response
headers:
Access-Control-Allow-Origin:
type: string
x-amazon-apigateway-integration:
uri:
Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${OrderManagement.Arn}/invocations"
responses:
default:
statusCode: 200
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
passthroughBehavior: when_no_match
httpMethod: POST #always POST
type: aws_proxy
post:
responses:
"200":
description: 200 response
headers:
Access-Control-Allow-Origin:
type: string
x-amazon-apigateway-integration:
uri:
Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${CheckOutOrder.Arn}/invocations"
responses:
default:
statusCode: 200
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
passthroughBehavior: when_no_match
httpMethod: POST #always POST
type: aws_prox
delete:
responses:
"200":
description: 200 response
headers:
Access-Control-Allow-Origin:
type: string
x-amazon-apigateway-integration:
uri:
Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${DeleteOrder.Arn}/invocations"
responses:
default:
statusCode: 200
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
passthroughBehavior: when_no_match
httpMethod: POST #always POST
type: aws_proxy
/books/order/handle:
post:
responses:
"200":
description: 200 response
headers:
Access-Control-Allow-Origin:
type: string
x-amazon-apigateway-integration:
uri:
Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HandleOrder.Arn}/invocations"
responses:
default:
statusCode: 200
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
passthroughBehavior: when_no_match
httpMethod: POST #always POST
type: aws_proxy
Events:
ConfirmUser:
Type: Api
Properties:
Path: /books/order
Method: post
RestApiId:
Ref: BookApi
Events:
ConfirmUser:
Type: Api
Properties:
Path: /books/order
Method: get
RestApiId:
Ref: BookApi
Events:
ProcessOrder:
Type: Api
Properties:
Path: /books/order/handle
Method: post
RestApiId:
Ref: BookApi
Events:
DeleteOrder:
Type: Api
Properties:
Path: /books/order
Method: delete
RestApiId:
Ref: BookApi
sam build
sam deploy --guided
So we have completed the setup steps. The next part we will check the website operation