Skip to content

Instantly share code, notes, and snippets.

View alexkates's full-sized avatar
👋

alexkates alexkates

👋
View GitHub Profile
// Import aws-cdk packages
import * as cdk from '@aws-cdk/core';
import * as s3 from '@aws-cdk/aws-s3';
import * as lambda from '@aws-cdk/aws-lambda';
import * as lambdaEventSources from '@aws-cdk/aws-lambda-event-sources';
export class HowToTriggerLambdaFromS3Stack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
aws dynamodb put-item \
--table-name Table \
--item '{
"id": {"S": "test123"}
}'
// Import aws-cdk packages
import * as cdk from '@aws-cdk/core';
import * as dynamodb from '@aws-cdk/aws-dynamodb';
import * as lambda from '@aws-cdk/aws-lambda';
import { DynamoEventSource } from '@aws-cdk/aws-lambda-event-sources';
export class HowToTriggerLambdaFromDdbStreamStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
aws sqs get-queue-url --queue-name OurSQSQueue
@alexkates
alexkates / index.js
Last active July 4, 2021 11:23
Log all event records passed into Lambda
/**
* Loop over each event record and log to the console.
* Since this is a Lambda Function, the log statements will
* also be logged to CloudWatch.
*/
exports.handler = async (event) => {
event.Records.forEach((record) => {
console.log('Record: %j', record);
});
@alexkates
alexkates / how-to-trigger-lambda-from-sqs-stack.ts
Last active April 19, 2024 20:00
How to Trigger an AWS Lambda from SQS using the AWS CDK
// Import aws-cdk packages
import * as cdk from '@aws-cdk/core';
import * as sqs from '@aws-cdk/aws-sqs';
import * as lambda from '@aws-cdk/aws-lambda';
import * as lambdaEventSources from '@aws-cdk/aws-lambda-event-sources';
export class HowToTriggerLambdaFromSqsStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);