updating custom authorizer event

This commit is contained in:
Daniel Cottone
2017-10-27 14:56:52 -05:00
parent 4982aa7609
commit 5dbba088ed
2 changed files with 67 additions and 52 deletions
+36 -28
View File
@@ -4,6 +4,7 @@ var anyObj: any = { abc: 123 };
var num: number = 5;
var error: Error = new Error();
var b: boolean = true;
var apiGwEvtReqCtx: AWSLambda.APIGatewayEventRequestContext;
var apiGwEvt: AWSLambda.APIGatewayEvent;
var customAuthorizerEvt: AWSLambda.CustomAuthorizerEvent;
var clientCtx: AWSLambda.ClientContext;
@@ -22,33 +23,33 @@ var snsEvtRec: AWSLambda.SNSEventRecord;
var snsMsg: AWSLambda.SNSMessage;
var snsMsgAttr: AWSLambda.SNSMessageAttribute;
var snsMsgAttrs: AWSLambda.SNSMessageAttributes;
var S3EvtRec: AWSLambda.S3EventRecord = {
var S3EvtRec: AWSLambda.S3EventRecord = {
eventVersion: '2.0',
eventSource: 'aws:s3',
awsRegion: 'us-east-1',
eventTime: '1970-01-01T00:00:00.000Z',
eventName: 'ObjectCreated:Put',
userIdentity: {
userIdentity: {
principalId: 'AIDAJDPLRKLG7UEXAMPLE'
},
requestParameters:{
requestParameters:{
sourceIPAddress: '127.0.0.1'
},
responseElements: {
responseElements: {
'x-amz-request-id': 'C3D13FE58DE4C810',
'x-amz-id-2': 'FMyUVURIY8/IgAtTv8xRjskZQpcIZ9KG4V5Wp6S7S/JRWeUWerMUE5JgHvANOjpD'
},
s3: {
s3: {
s3SchemaVersion: '1.0',
configurationId: 'testConfigRule',
bucket: {
bucket: {
name: 'mybucket',
ownerIdentity: {
ownerIdentity: {
principalId: 'A3NL1KOZZKExample'
},
arn: 'arn:aws:s3:::mybucket'
},
object: {
object: {
key: 'HappyFace.jpg',
size: 1024,
eTag: 'd41d8cd98f00b204e9800998ecf8427e',
@@ -65,6 +66,27 @@ var cognitoUserPoolEvent: AWSLambda.CognitoUserPoolEvent;
var cloudformationCustomResourceEvent: AWSLambda.CloudFormationCustomResourceEvent;
var cloudformationCustomResourceResponse: AWSLambda.CloudFormationCustomResourceResponse;
/* API Gateway Event request context */
str = apiGwEvtReqCtx.accountId;
str = apiGwEvtReqCtx.apiId;
str = apiGwEvtReqCtx.httpMethod;
str = apiGwEvtReqCtx.identity.accessKey;
str = apiGwEvtReqCtx.identity.accountId;
str = apiGwEvtReqCtx.identity.apiKey;
str = apiGwEvtReqCtx.identity.caller;
str = apiGwEvtReqCtx.identity.cognitoAuthenticationProvider;
str = apiGwEvtReqCtx.identity.cognitoAuthenticationType;
str = apiGwEvtReqCtx.identity.cognitoIdentityId;
str = apiGwEvtReqCtx.identity.cognitoIdentityPoolId;
str = apiGwEvtReqCtx.identity.sourceIp;
str = apiGwEvtReqCtx.identity.user;
str = apiGwEvtReqCtx.identity.userAgent;
str = apiGwEvtReqCtx.identity.userArn;
str = apiGwEvtReqCtx.stage;
str = apiGwEvtReqCtx.requestId;
str = apiGwEvtReqCtx.resourceId;
str = apiGwEvtReqCtx.resourcePath;
/* API Gateway Event */
str = apiGwEvt.body;
str = apiGwEvt.headers["example"];
@@ -74,31 +96,17 @@ str = apiGwEvt.path;
str = apiGwEvt.pathParameters["example"];
str = apiGwEvt.queryStringParameters["example"];
str = apiGwEvt.stageVariables["example"];
str = apiGwEvt.requestContext.accountId;
str = apiGwEvt.requestContext.apiId;
str = apiGwEvt.requestContext.httpMethod;
str = apiGwEvt.requestContext.identity.accessKey;
str = apiGwEvt.requestContext.identity.accountId;
str = apiGwEvt.requestContext.identity.apiKey;
str = apiGwEvt.requestContext.identity.caller;
str = apiGwEvt.requestContext.identity.cognitoAuthenticationProvider;
str = apiGwEvt.requestContext.identity.cognitoAuthenticationType;
str = apiGwEvt.requestContext.identity.cognitoIdentityId;
str = apiGwEvt.requestContext.identity.cognitoIdentityPoolId;
str = apiGwEvt.requestContext.identity.sourceIp;
str = apiGwEvt.requestContext.identity.user;
str = apiGwEvt.requestContext.identity.userAgent;
str = apiGwEvt.requestContext.identity.userArn;
str = apiGwEvt.requestContext.stage;
str = apiGwEvt.requestContext.requestId;
str = apiGwEvt.requestContext.resourceId;
str = apiGwEvt.requestContext.resourcePath;
apiGwEvtReqCtx = apiGwEvt.requestContext;
str = apiGwEvt.resource;
/* API Gateway CustomAuthorizer Event */
str = customAuthorizerEvt.type;
str = customAuthorizerEvt.authorizationToken;
str = customAuthorizerEvt.methodArn;
str = customAuthorizerEvt.authorizationToken;
str = apiGwEvt.pathParameters["example"];
str = apiGwEvt.queryStringParameters["example"];
str = apiGwEvt.stageVariables["example"];
apiGwEvtReqCtx = apiGwEvt.requestContext;
/* SNS Event */
snsEvtRecs = snsEvt.Records;
+31 -24
View File
@@ -11,6 +11,31 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// API Gateway "event" request context
interface APIGatewayEventRequestContext {
accountId: string;
apiId: string;
httpMethod: string;
identity: {
accessKey: string | null;
accountId: string | null;
apiKey: string | null;
caller: string | null;
cognitoAuthenticationProvider: string | null;
cognitoAuthenticationType: string | null;
cognitoIdentityId: string | null;
cognitoIdentityPoolId: string | null;
sourceIp: string;
user: string | null;
userAgent: string | null;
userArn: string | null;
},
stage: string;
requestId: string;
resourceId: string;
resourcePath: string;
}
// API Gateway "event"
interface APIGatewayEvent {
body: string | null;
@@ -21,37 +46,19 @@ interface APIGatewayEvent {
pathParameters: { [name: string]: string } | null;
queryStringParameters: { [name: string]: string } | null;
stageVariables: { [name: string]: string } | null;
requestContext: {
accountId: string;
apiId: string;
httpMethod: string;
identity: {
accessKey: string | null;
accountId: string | null;
apiKey: string | null;
caller: string | null;
cognitoAuthenticationProvider: string | null;
cognitoAuthenticationType: string | null;
cognitoIdentityId: string | null;
cognitoIdentityPoolId: string | null;
sourceIp: string;
user: string | null;
userAgent: string | null;
userArn: string | null;
},
stage: string;
requestId: string;
resourceId: string;
resourcePath: string;
};
requestContext: APIGatewayEventRequestContext;
resource: string;
}
// API Gateway CustomAuthorizer "event"
interface CustomAuthorizerEvent {
type: string;
authorizationToken: string;
methodArn: string;
authorizationToken?: string;
headers?: { [name: string]: string };
pathParameters?: { [name: string]: string } | null;
queryStringParameters?: { [name: string]: string } | null;
requestContext?: APIGatewayEventRequestContext;
}
// SNS "event"