Commit 8f1de7e1 authored by Bertrand PINEL's avatar Bertrand PINEL
Browse files

Correct lambda response when receiving a DELETE command

parent 0c73bdff
......@@ -271,9 +271,7 @@ const patchMethod = (event, context, callback) => {
'Id': id
'ReturnValues': 'ALL_OLD'
const body=event['body-json'];
let dbDelete = (params) => { return dynamo.delete(params).promise() };
dbDelete(params).then( (data) => {
if (!data.Attributes) {
......@@ -281,7 +279,8 @@ const patchMethod = (event, context, callback) => {
console.log(`DELETED ITEM OF TYPE ${type} SUCCESSFULLY WITH id = ${id}`);
callback(null, body);
const empty = {'data': []};
callback(null, empty);
}).catch( (err) => {
console.log(`DELETE ITEM OF TYPE ${type} FAILED FOR id = ${id}, WITH ERROR: ${err}`);
callback(null, createResponse(500, err));
......@@ -14,23 +14,15 @@ AWS JSON API server relies on 3 main components, plus the needed IAM roles :
- A lambda function in charge of the translation from JSON API format to dynamoDB objects and managing the relationships and the optional parameters provided in the request
- An API Gateway configured to received the REST HTTP requests and proxying the Lambda
It also create three S3 buckets, one for storing the lambda code (nammed lambda-jsonapi-code-bucket) and the two other for receiving the ‘staging’ and ‘production’ version of the application (respectively nammed ember-aws-ehipster-staging and ember-aws-ehipster-production)
Several Terraform files are available, each one creating the needed component and their relationships with each other.
The lambda code needs to be stored in a S3 bucket before running the Terraform scripts.
The script is available in the cloud/lambda directory of this project.
The following operations need to be performed (adapting the region you are using):
cp ../lambda/lambda-jsonapi.js .
zip lambda-jsonapi.js
aws s3api create-bucket --bucket=lambda-jsonapi-code-bucket --region=us-east-1
aws s3 cp s3://lambda-jsonapi-code-bucket/v1.0.0/
One this is done, simply run the terraform script :
terraform init
terraform apply -var bucket_name=<bucket name for static web site>
For a strange reason I don't understand, the first time you run the terraform command, the mapping for the integration response fails. You have to run the command again to have your complete setup.
\ No newline at end of file
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment