Skip to content

Instantly share code, notes, and snippets.

{
"Effect":"Allow",
"Principal":{
"AWS":"<SUBSCRIBER_ACCOUNT_ID>"
},
"Action":"sns:Subscribe",
"Resource":"arn:aws:sns:<REGION>:<PUBLISHER_ACCOUNT_ID>:<TOPIC_NAME>"
}
Pre-Reqs
---
1) CDK
2) NPM
3) A Github repository
1. Run this command
export CDK_NEW_BOOTSTRAP=1
npx cdk bootstrap aws://<YOUR_ACCONT_ID>/<YOUR_REGION> --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess aws://<YOUR_ACCONT_ID>/<YOUR_REGION>
# aws s3api get-object --bucket arn:aws:s3-object-lambda:us-east-1:xxxxx:accesspoint/just-purchases --key orders.json transformed_data.json
import boto3
import urllib3
import json
http = urllib3.PoolManager()
def lambda_handler(event, context):
print(event)
lambda function
----
exports.handler = async (event) => {
console.log(event)
const customerId = event.pathParameters.customerId;
const customer = {'customerId': customerId, 'customerName': "Customer " + customerId };
const response = {
statusCode: 200,
// Uncomment below to enable CORS requests
headers: {
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "*"
},
{
Connect & Disconnect
---
import json
def lambda_handler(event, context):
print(event)
print("****")
print(context)
import json
import boto3
firehose_client = boto3.client('firehose')
def lambda_handler(event, context):
resultString = ""
for record in event['Records']:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"cloudformation:DescribeStacks",
"cloudformation:CreateChangeSet",
"cloudformation:DescribeChangeSet",
CODE
---
import json
import uuid
GET_RAW_PATH = "/getPerson"
CREATE_RAW_PATH = "/createPerson"
def lambda_handler(event, context):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],