Open template.yaml file in fcj-book-shop folder
Add the following script at the end of the file that create the DELETE method
/books/{id}:
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/${BookDelete.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:
DeleteBook:
Type: Api
Properties:
Path: /books/{id}
Method: delete
RestApiId:
Ref: BookApi
Run the following command to deploy SAM
sam build
sam deploy --guided
Enter “y” if asked “BookDelete may not have authorization defined, Is this okay? [y/N]: "
Open book_delete function console
Show API Gateway being interacted with this function
Display the resources and DELETE method
Click Stages on the left menu
Add the following script at the end of the template.yaml file to API can support Binary Media Types files
BinaryMediaTypes:
- multipart~1form-data
Run the following command to deploy SAM
sam build
sam deploy --guided
Back to API console