Skip to content

Instantly share code, notes, and snippets.

View gpmilliken's full-sized avatar

George P. Milliken gpmilliken

View GitHub Profile
@gpmilliken
gpmilliken / get-lambda-event-source.js
Created January 20, 2025 16:15 — forked from jeshan/get-lambda-event-source.js
AWS Lambda: Determine Event Source from event object. Note that this is an approximation as anybody can send a payload that resembles the real thing.
function getLambdaEventSource(event) {
if (event.Records && event.Records[0].cf) return 'isCloudfront';
if (event.configRuleId && event.configRuleName && event.configRuleArn) return 'isAwsConfig';
if (event.Records && (event.Records[0].eventSource === 'aws:codecommit')) return 'isCodeCommit';
if (event.authorizationToken === "incoming-client-token") return 'isApiGatewayAuthorizer';
if (event.StackId && event.RequestType && event.ResourceType) return 'isCloudFormation';