Adds typing for CloudWatch Logs events (#21239)

This commit is contained in:
Jamie Starke
2018-01-02 15:47:47 -08:00
committed by Mohamed Hegazy
parent bdde08e944
commit b2517cc5cf
2 changed files with 45 additions and 0 deletions
+14
View File
@@ -65,6 +65,8 @@ var S3CreateEvent: AWSLambda.S3CreateEvent = {
var cognitoUserPoolEvent: AWSLambda.CognitoUserPoolEvent;
var cloudformationCustomResourceEvent: AWSLambda.CloudFormationCustomResourceEvent;
var cloudformationCustomResourceResponse: AWSLambda.CloudFormationCustomResourceResponse;
var cloudwatchLogsEvent: AWSLambda.CloudWatchLogsEvent;
var cloudwatchLogsDecodedData: AWSLambda.CloudWatchLogsDecodedData;
/* API Gateway Event request context */
str = apiGwEvtReqCtx.accountId;
@@ -364,6 +366,18 @@ clientCtx = context.clientContext;
str = identity.cognitoIdentityId;
str = identity.cognitoIdentityPoolId;
/* CloudWatch Logs */
str = cloudwatchLogsEvent.awslogs.data;
str = cloudwatchLogsDecodedData.owner;
str = cloudwatchLogsDecodedData.logGroup;
str = cloudwatchLogsDecodedData.logStream;
str = cloudwatchLogsDecodedData.subscriptionFilters[0];
str = cloudwatchLogsDecodedData.messageType;
str = cloudwatchLogsDecodedData.logEvents[0].id;
num = cloudwatchLogsDecodedData.logEvents[0].timestamp;
str = cloudwatchLogsDecodedData.logEvents[0].message;
/* ClientContext */
clientContextClient = clientCtx.client;
anyObj = clientCtx.Custom;
+31
View File
@@ -294,6 +294,37 @@ type CloudFormationCustomResourceFailedResponse = CloudFormationCustomResourceRe
export type CloudFormationCustomResourceResponse = CloudFormationCustomResourceSuccessResponse | CloudFormationCustomResourceFailedResponse;
/**
* See http://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-cloudwatch-logs
*/
interface CloudWatchLogsEvent {
awslogs: CloudWatchLogsEventData;
}
interface CloudWatchLogsEventData {
data: string;
}
interface CloudWatchLogsDecodedData {
owner: string;
logGroup: string;
logStream: string;
subscriptionFilters: string[];
messageType: string;
logEvents: CloudWatchLogsLogEvent[];
}
/**
* See http://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/SubscriptionFilters.html#LambdaFunctionExample
*/
interface CloudWatchLogsLogEvent {
id: string;
timestamp: number;
message: string;
}
// Context
// http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html
interface Context {