From 8f1de7e126e10496dcc81aa4035b94c4e5839be3 Mon Sep 17 00:00:00 2001
From: bertrand <bpinel@ippon.fr>
Date: Wed, 13 Feb 2019 17:42:13 +0100
Subject: [PATCH] Correct lambda response when receiving a DELETE command

---
 cloud/lambda/lambda-jsonapi.js  |   7 +++----
 cloud/lambda/lambda-jsonapi.zip | Bin 3321 -> 3338 bytes
 cloud/terraform/README.md       |  16 ++++------------
 3 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/cloud/lambda/lambda-jsonapi.js b/cloud/lambda/lambda-jsonapi.js
index bc6ed2b..90bf51a 100644
--- a/cloud/lambda/lambda-jsonapi.js
+++ b/cloud/lambda/lambda-jsonapi.js
@@ -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) => {
               return;
           }
           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));
diff --git a/cloud/lambda/lambda-jsonapi.zip b/cloud/lambda/lambda-jsonapi.zip
index 4c88a99dae208b141ce3294d9ead26ee0d7b52e3..da0dfaa843db5d4a703258544c83ee6185245453 100644
GIT binary patch
delta 3305
zcmV<F3>NeG8HySgP)h>@6aWAK2mqXnO-^+Gh*DAv005ei7af17M`T>6M`T=ecnbgl
z1oZ&`00a~O008Y8Yj@g4_Pc+@gwu^g!7}cN+fx&=OAJow`n5K0wuj{;0u5$jArXxf
z*T?mL-+SjF%?N>Ull``w#3nO$?%ell;$)l>o+fOXI_;fl9PyNN-(QgqN$BT{CDe8N
z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D+8I8FO%d9AO?&K00000vaTWh

diff --git a/cloud/terraform/README.md b/cloud/terraform/README.md
index f965987..518115d 100644
--- a/cloud/terraform/README.md
+++ b/cloud/terraform/README.md
@@ -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.
 
 Installation
 ------------------------------------------------------------------------------
 
-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.zip lambda-jsonapi.js
-aws s3api create-bucket --bucket=lambda-jsonapi-code-bucket --region=us-east-1
-aws s3 cp lambda-jsonapi.zip s3://lambda-jsonapi-code-bucket/v1.0.0/lambda-jsonapi.zip
-```
 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
-- 
GitLab