- Create node js project with the following code in index.js
- 
```
//---------------------------------------
// Code for the aws lambda function sfpe
// Mohan Chinnappan (mar-12-2020)
//---------------------------------------
const fetch = require('node-fetch');
exports.handler = async (event) => {
await sendPOST();
return { statusCode: 200, body: "Ok"};
};
async function sendGET() {
const url = "https://mohansun-fsc-21.my.salesforce.com/services/data";
const params = {
method: "GET",
mode: "cors",
headers: {"Content-Type":"application/json" },
};
await fetch(url, params);
}
async function sendPOST() {
const sobj = 'LCTest__e';
const url = `https://mohansun-fsc-21.my.salesforce.com/services/data/v46.0/sobjects/${sobj}`;
// access token can be passed from outside (via event...)
const at = `00D3h000000DC8N!ARcAQAEoNV.jGPdWoODD.GeAp.tzVqKQt_Cci1lrl91CL__WosVlAfOLCKx9tjIuI.I7JWablqx9pu8q209Y2434234234`;
const postbody = { "msg__c": "Lead Conversion via AWS Lambda completed", "fname__c": "Johnny", "lname__c": "Sailer", "cname__c": "Jonny Sailer Sons" } ;
const params = {
method: "POST",
mode: "cors",
headers: {"Content-Type":"application/json", "Authorization": `Bearer ${at}` },
body: JSON.stringify(postbody)
};
await fetch(url, params);
}
```
- Node Project Folder
```
$ tree
.
├── index.js
├── l_app.js
├── node_modules
│ └── node-fetch
│ ├── CHANGELOG.md
│ ├── LICENSE.md
│ ├── README.md
│ ├── browser.js
│ ├── lib
│ │ ├── index.es.js
│ │ ├── index.js
│ │ └── index.mjs
│ └── package.json
├── package-lock.json
├── package.json
└── sf-pe.zip
```
- package.json
```
$ cat package.json
{
"name": "aws-lambda-sf",
"version": "0.0.1",
"description": "aws lambda and salesforce",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"aws",
"lambda",
"salesforce"
],
"author": "mohan chinnappan",
"license": "MIT",
"dependencies": {
"node-fetch": "^2.6.0"
}
}
```
- Lambda function Permission

- Event to trigger the Lambda function
