mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-21 05:20:24 +08:00
[aws-lambda] add CloudFront request and response events
See http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html
This commit is contained in:
@@ -315,6 +315,131 @@ function customAuthorizerCallback(cb: AWSLambda.CustomAuthorizerCallback) {
|
||||
cb(null, authResponse);
|
||||
}
|
||||
|
||||
/* CloudFront events, see http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html */
|
||||
var CloudFrontRequestEvent: AWSLambda.CloudFrontRequestEvent = {
|
||||
"Records": [
|
||||
{
|
||||
"cf": {
|
||||
"config": {
|
||||
"distributionId": "EDFDVBD6EXAMPLE",
|
||||
"requestId": "MRVMF7KydIvxMWfJIglgwHQwZsbG2IhRJ07sn9AkKUFSHS9EXAMPLE=="
|
||||
},
|
||||
"request": {
|
||||
"clientIp": "2001:0db8:85a3:0:0:8a2e:0370:7334",
|
||||
"method": "GET",
|
||||
"uri": "/picture.jpg",
|
||||
"querystring": "size=large",
|
||||
"headers": {
|
||||
"host": [
|
||||
{
|
||||
"key": "Host",
|
||||
"value": "d111111abcdef8.cloudfront.net"
|
||||
}
|
||||
],
|
||||
"user-agent": [
|
||||
{
|
||||
"key": "User-Agent",
|
||||
"value": "curl/7.51.0"
|
||||
}
|
||||
]
|
||||
},
|
||||
"origin": {
|
||||
"custom": {
|
||||
"customHeaders": {
|
||||
"my-origin-custom-header": [
|
||||
{
|
||||
"key": "My-Origin-Custom-Header",
|
||||
"value": "Test"
|
||||
}
|
||||
]
|
||||
},
|
||||
"domainName": "example.com",
|
||||
"keepaliveTimeout": 5,
|
||||
"path": "/custom_path",
|
||||
"port": 443,
|
||||
"protocol": "https",
|
||||
"readTimeout": 5,
|
||||
"sslProtocols": [
|
||||
"TLSv1",
|
||||
"TLSv1.1"
|
||||
]
|
||||
},
|
||||
"s3": {
|
||||
"authMethod": "origin-access-identity",
|
||||
"customHeaders": {
|
||||
"my-origin-custom-header": [
|
||||
{
|
||||
"key": "My-Origin-Custom-Header",
|
||||
"value": "Test"
|
||||
}
|
||||
]
|
||||
},
|
||||
"domainName": "my-bucket.s3.amazonaws.com",
|
||||
"path": "/s3_path",
|
||||
"region": "us-east-1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var CloudFrontResponseEvent: AWSLambda.CloudFrontResponseEvent = {
|
||||
"Records": [
|
||||
{
|
||||
"cf": {
|
||||
"config": {
|
||||
"distributionId": "EDFDVBD6EXAMPLE",
|
||||
"requestId": "xGN7KWpVEmB9Dp7ctcVFQC4E-nrcOcEKS3QyAez--06dV7TEXAMPLE=="
|
||||
},
|
||||
"request": {
|
||||
"clientIp": "2001:0db8:85a3:0:0:8a2e:0370:7334",
|
||||
"method": "GET",
|
||||
"uri": "/picture.jpg",
|
||||
"querystring": "size=large",
|
||||
"headers": {
|
||||
"host": [
|
||||
{
|
||||
"key": "Host",
|
||||
"value": "d111111abcdef8.cloudfront.net"
|
||||
}
|
||||
],
|
||||
"user-agent": [
|
||||
{
|
||||
"key": "User-Agent",
|
||||
"value": "curl/7.18.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": "200",
|
||||
"statusDescription": "OK",
|
||||
"headers": {
|
||||
"server": [
|
||||
{
|
||||
"key": "Server",
|
||||
"value": "MyCustomOrigin"
|
||||
}
|
||||
],
|
||||
"set-cookie": [
|
||||
{
|
||||
"key": "Set-Cookie",
|
||||
"value": "theme=light"
|
||||
},
|
||||
{
|
||||
"key": "Set-Cookie",
|
||||
"value": "sessionToken=abc123; Expires=Wed, 09 Jun 2021 10:18:14 GMT"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/* Compatibility functions */
|
||||
context.done();
|
||||
context.done(error);
|
||||
|
||||
50
types/aws-lambda/index.d.ts
vendored
50
types/aws-lambda/index.d.ts
vendored
@@ -10,6 +10,7 @@
|
||||
// Ishaan Malhi <https://github.com/OrthoDex>
|
||||
// Daniel Cottone <https://github.com/daniel-cottone>
|
||||
// Kostya Misura <https://github.com/kostya-misura>
|
||||
// Markus Tacker <https://github.com/coderbyheart>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@@ -346,6 +347,55 @@ interface AuthResponseContext {
|
||||
[name: string]: string | number | boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* CloudFront events
|
||||
* http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html
|
||||
*/
|
||||
type CloudFrontHeaders = {
|
||||
[name: string]: {
|
||||
key: string;
|
||||
value: string;
|
||||
}[]
|
||||
};
|
||||
|
||||
type CloudFrontResponse = {
|
||||
status: string;
|
||||
statusDescription: string;
|
||||
headers: CloudFrontHeaders;
|
||||
};
|
||||
|
||||
type CloudFrontRequest = {
|
||||
clientIp: string;
|
||||
method: string;
|
||||
uri: string;
|
||||
querystring: string;
|
||||
headers: CloudFrontHeaders;
|
||||
};
|
||||
|
||||
type CloudFrontEvent = {
|
||||
config: {
|
||||
distributionId: string;
|
||||
requestId: string;
|
||||
}
|
||||
}
|
||||
|
||||
export type CloudFrontResponseEvent = {
|
||||
Records: {
|
||||
cf: CloudFrontEvent & {
|
||||
request: CloudFrontRequest;
|
||||
response: CloudFrontResponse;
|
||||
}
|
||||
}[]
|
||||
};
|
||||
|
||||
export type CloudFrontRequestEvent = {
|
||||
Records: {
|
||||
cf: CloudFrontEvent & {
|
||||
request: CloudFrontRequest;
|
||||
}
|
||||
}[]
|
||||
};
|
||||
|
||||
/**
|
||||
* AWS Lambda handler function.
|
||||
* http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
|
||||
|
||||
Reference in New Issue
Block a user