Skip to content

Instantly share code, notes, and snippets.

@Arunmainthan
Arunmainthan / cloudSettings
Last active January 22, 2021 21:12
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-01-22T18:38:32.761Z","extensionVersion":"v3.4.3"}
@Arunmainthan
Arunmainthan / encodedText.txt
Last active January 7, 2020 16:12
Upload base64 encoded image string to s3
{"e_id":6969,"base64":"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAQDAwMDAgQDAwMEBAQFBgoGBgUFBgwICQcKDgwPDg4MDQ0PERYTDxAVEQ0NExoTFRcYGRkZDxIbHRsYHRYYGRj/2wBDAQQEBAYFBgsGBgsYEA0QGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBj/wAARCAXcB9ADASIAAhEBAxEB/8QAHQAAAQUBAQEBAAAAAAAAAAAAAgABAwQFBgcICf/EAGQQAAEDAwIDBQQGBggBCAUBGQIBAwQABRESIQYTMQciQVFhFDJCcRUjUoGRoQgzYnKxwRYkQ1OCkqLR4RclNGNzssLwRFSDk9LxGCY1RYSU4glVZHSzwzaVo9PyJ2V1xEaGlv/EABwBAAMBAQEBAQEAAAAAAAAAAAABAgMEBQYHCP/EAEURAAICAQMCAwUGBgECBgEBCQABAhEDEiExBEEFE1EUImFxkQYygaGx0RVCUsHh8CMz8RZDU2KSonKCJAc0wuIXg7LS/9oADAMBAAIRAxEAPwD2PFFin0+lEiV9zZ+Zg6fSlp9KPFLFIANPpT4qTFLFA6BxSxRYp9PpSsKAxSxR6fSlp9KLAbFLFPp9KNAoKSsjxSxUihSQKLE4sjxSx3qm0j5UOgaLGosjxSxUmgqWgaLDSyPR86HQVWNHzpYpahuBDilo7tTYpYosNKIML9miQKlxSxTsWhAcsaHR3qm0+lNiptj0kWCpsVNiliqsNJDilipcaqfSPlRYnEhwVLQpVNpGkiUWLT6kWCpaFqSnxS1D0IiVKbFTKlCofZp6glHuRolPgqNA+1RIlJsFFkWCpYKptPpQrnUI0JlONEdKpNCfDQ471OzNqgaVHoKhxSHQ1DR4p6AI6VFp9KWn0pgBimo8UsUxUBSp8UsUCA0+lKipsUANTL1o6EqYAYoV6UdNimAFKjxSxTAjVKHFSL0ocUyHFAU2K
@Arunmainthan
Arunmainthan / template.json
Created January 3, 2020 13:09 — forked from mlabouardy/template.json
EC2 Instance with IAM Role using CloudFormation
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Attach IAM Role to an EC2",
"Parameters" : {
"KeyName" : {
"Description" : "EC2 Instance SSH Key",
"Type" : "AWS::EC2::KeyPair::KeyName"
},
"InstanceType" : {
"Description" : "EC2 instance specs configuration",
@Arunmainthan
Arunmainthan / downloadFile.js
Created December 20, 2019 14:26
Nodejs Express Download file from s3
const express = require('express');
const app = express();
const request = require('request');
app.get('/download-file', function (req, res) {
// sdk way
var s3 = new AWS.S3({});
var options = {
Bucket: 'my-bucket-name',
Key: file,
@Arunmainthan
Arunmainthan / S3Api.sh
Created December 20, 2019 03:58
S3API
aws s3api put-object --bucket first-stack-mys3bucket --key car.jpg --body ~/Downloads/car.jpg --tagging 'clientId=123' --profile test-cfn-user
@Arunmainthan
Arunmainthan / generateAPIGatewaySignatureManually.js
Created December 18, 2019 23:15
Generate AWS signature to call API Gateway end point
var aws4 = require('aws4');
var signature = aws4.sign({
host: '',
method: 'GET',
path: '/development/hello',
headers: {
'x-apigw-api-id': ''
},
region: 'ap-southeast-2',
service: 'execute-api'
@Arunmainthan
Arunmainthan / sendEMail.py
Last active November 20, 2020 09:14
Send Email via SES
from __future__ import print_function
import boto3
import json
import decimal
from datetime import datetime
from boto3.dynamodb.conditions import Key, Attr
from botocore.exceptions import ClientError
ses = boto3.client(
'ses',
@Arunmainthan
Arunmainthan / signature.js
Last active December 16, 2019 21:07
slack signature verification
verifySignature(slackSignature, slackTimestamp, body) {
const slackSigningSecret = process.env.SLACK_SIGNING_SECRET;
console.log('slackTimestamp: ', slackTimestamp);
console.log('slackSignature: ', slackSignature);
const timestamp = slackTimestamp;
const time = Math.floor(new Date().getTime()/1000);
if (Math.abs(time - timestamp) > 300) {
@Arunmainthan
Arunmainthan / handler.py
Last active December 15, 2019 11:05
serverless.yml IAM permissions
import json
import boto3
import json
import boto3
def hello(event, context):
# TODO implement
@Arunmainthan
Arunmainthan / generateS3PresignedURL.ts
Last active December 17, 2019 11:26
Generate S3 Presigned URL
import AWS = require('aws-sdk');
var axios = require('axios');
import { readFileSync } from 'fs'
import * as request from 'request'
import { readFile } from 'fs'
import { promisify } from 'util';
const S3_BUCKET = `your-s3-bucket`;