Skip to content

Instantly share code, notes, and snippets.

View secretshardul's full-sized avatar

ss secretshardul

View GitHub Profile
@secretshardul
secretshardul / pathParamXwwForm.vtl
Last active February 3, 2020 09:52
API gateway handles path and query parameters. 'x-www-form-urlencoded' string is passed to Lambda.
{
"my_path_param" : "$input.params('my_path_param')",
"my_query_param" : "$input.params('my_query_param')",
"body": "$input"
}
@secretshardul
secretshardul / lambda_proxy.json
Created February 3, 2020 05:38
Lambda proxy event template. This is an official test event on AWS Lambda console
{
"body": "eyJ0ZXN0IjoiYm9keSJ9",
"resource": "/{proxy+}",
"path": "/path/to/resource",
"httpMethod": "POST",
"isBase64Encoded": true,
"queryStringParameters": {
"foo": "bar"
},
"multiValueQueryStringParameters": {
@secretshardul
secretshardul / lambda_proxy_response
Last active February 3, 2020 07:02
Response template for Lambda Proxy response
{
"isBase64Encoded": true|false,
"statusCode": httpStatusCode,
"headers": { "headerName": "headerValue", ... },
"multiValueHeaders": { "headerName": ["headerValue", "headerValue2", ...], ... },
"body": "..."
}
@secretshardul
secretshardul / index.js
Created February 3, 2020 07:19
Return back binary data with correct headers using Lambda proxy integration
exports.handler = async (event) => {
return {
statusCode: 200,
isBase64Encoded: event["isBase64Encoded"],
headers: {
"Content-Type": event["headers"]["Content-Type"]
},
body: event["body"]
};
};
@secretshardul
secretshardul / template
Created February 3, 2020 12:17
Routes input directly to lambda
{
"params" : "$input"
}
@secretshardul
secretshardul / index.js
Created February 3, 2020 12:29
Demonstration for returning image from Lambda with Lambda integration. The handler simply returns 'params' parameter from the JSON object passed to it by API gateway.
exports.handler = async (event) => {
return event.params;
};
@secretshardul
secretshardul / response header mapping
Created February 4, 2020 11:07
response header mapping
integration.response.header.PARAM_NAME
@secretshardul
secretshardul / index.js
Created February 4, 2020 11:14
Lambda function reads a file from an S3 bucket. It converts it into a base64 encoded string and returns the value. API gateway converts this into binary and adds the appropriate header.
var AWS = require("aws-sdk");
var s3 = new AWS.S3();
exports.handler = (event, context, callback) => {
var params = {Bucket: 'myBucket', Key: 'myImg.png'};
s3.getObject(params, function(err, data) {
if (err) {
console.log(err, err.stack);
}
else{
@secretshardul
secretshardul / README.md
Last active February 7, 2020 13:46
How to send SMS from Textlocal API using Postman and CURL. Here I have used POST method.
  1. HTTP specifications TextLocal API accepts input in application/x-www-form-urlencoded format.
POST /send/ HTTP/1.1
Host: api.textlocal.in
Content-Type: application/x-www-form-urlencoded
Accept: */*

apiKey=<your_API_key>&message=sent+by+me+from+textlocal+API&numbers=<phone_numbers_separated_by_commas>&test=true
@secretshardul
secretshardul / .git-commit-template.txt
Created May 12, 2020 13:52 — forked from adeekshith/.git-commit-template.txt
This commit message template helps you write great commit messages and enforce it across teams.
# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23