Merge pull request #31311 from dalen/lambda-codepipeline-events

aws-lambda: Add CloudWatch events for CodePipeline
This commit is contained in:
Nathan Shively-Sanders 2018-12-18 16:30:17 -08:00 committed by GitHub
commit 316ea9e823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 130 additions and 0 deletions

View File

@ -599,6 +599,27 @@ const CodePipelineEvent: AWSLambda.CodePipelineEvent = {
CodePipelineEvent["CodePipeline.job"].data.encryptionKey = { type: 'KMS', id: 'key' };
/* CodePipeline CloudWatch Events
* see https://docs.aws.amazon.com/codepipeline/latest/userguide/detect-state-changes-cloudwatch-events.html
* Their documentation says that detail.version is a string, but it is actually an integer
*/
const CodePipelineCloudWatchEvent: AWSLambda.CodePipelineCloudWatchEvent = {
version: '0',
id: 'event_Id',
'detail-type': 'CodePipeline Pipeline Execution State Change',
source: 'aws.codepipeline',
account: 'Pipeline_Account',
time: 'TimeStamp',
region: 'us-east-1',
resources: ['arn:aws:codepipeline:us-east-1:account_ID:myPipeline'],
detail: {
pipeline: 'myPipeline',
version: 1,
state: 'STARTED',
'execution-id': 'execution_Id',
},
};
/* CloudFront events, see http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html */
const CloudFrontRequestWithCustomOriginEvent: AWSLambda.CloudFrontRequestEvent = {
Records: [

View File

@ -24,6 +24,7 @@
// Oliver Hookins <https://github.com/ohookins>
// Trevor Leach <https://github.com/trevor-leach>
// James Gregory <https://github.com/jagregory>
// Erik Dalén <https://github.com/dalen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@ -576,6 +577,109 @@ export interface CodePipelineEvent {
};
}
/**
* CodePipeline CloudWatch Events
* https://docs.aws.amazon.com/codepipeline/latest/userguide/detect-state-changes-cloudwatch-events.html
*
* The above CodePipelineEvent is when a lambda is invoked by a CodePipeline.
* These events are when you subsribe to CodePipeline events in CloudWatch.
*
* Their documentation says that detail.version is a string, but it is actually an integer
*/
export type CodePipelineState =
| 'STARTED'
| 'SUCCEEDED'
| 'RESUMED'
| 'FAILED'
| 'CANCELED'
| 'SUPERSEDED';
export type CodePipelineStageState =
| 'STARTED'
| 'SUCCEEDED'
| 'RESUMED'
| 'FAILED'
| 'CANCELED';
export type CodePipelineActionState =
| 'STARTED'
| 'SUCCEEDED'
| 'FAILED'
| 'CANCELED';
export interface CodePipelineCloudWatchPipelineEvent {
version: string;
id: string;
'detail-type': 'CodePipeline Pipeline Execution State Change';
source: 'aws.codepipeline';
account: string;
time: string;
region: string;
resources: string[];
detail: {
pipeline: string;
version: number;
state: CodePipelineState;
'execution-id': string;
};
}
export interface CodePipelineCloudWatchStageEvent {
version: string;
id: string;
'detail-type': 'CodePipeline Stage Execution State Change';
source: 'aws.codepipeline';
account: string;
time: string;
region: string;
resources: string[];
detail: {
pipeline: string;
version: number;
'execution-id': string;
stage: string;
state: CodePipelineStageState;
};
}
export type CodePipelineActionCategory =
| 'Approval'
| 'Build'
| 'Deploy'
| 'Invoke'
| 'Source'
| 'Test';
export interface CodePipelineCloudWatchActionEvent {
version: string;
id: string;
'detail-type': 'CodePipeline Action Execution State Change';
source: 'aws.codepipeline';
account: string;
time: string;
region: string;
resources: string[];
detail: {
pipeline: string;
version: number;
'execution-id': string;
stage: string;
action: string;
state: CodePipelineActionState;
type: {
owner: 'AWS' | 'Custom' | 'ThirdParty';
category: CodePipelineActionCategory;
provider: string;
version: number;
};
};
}
export type CodePipelineCloudWatchEvent =
| CodePipelineCloudWatchPipelineEvent
| CodePipelineCloudWatchStageEvent
| CodePipelineCloudWatchActionEvent;
/**
* CloudFront events
* http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html
@ -837,6 +941,11 @@ export type ProxyCallback = APIGatewayProxyCallback; // Old name
export type CodePipelineHandler = Handler<CodePipelineEvent, void>;
export type CodePipelineCloudWatchHandler = Handler<CodePipelineCloudWatchEvent, void>;
export type CodePipelineCloudWatchPipelineHandler = Handler<CodePipelineCloudWatchPipelineEvent, void>;
export type CodePipelineCloudWatchStageHandler = Handler<CodePipelineCloudWatchStageEvent, void>;
export type CodePipelineCloudWatchActionHandler = Handler<CodePipelineCloudWatchActionEvent, void>;
export type CloudFrontRequestHandler = Handler<CloudFrontRequestEvent, CloudFrontRequestResult>;
export type CloudFrontRequestCallback = Callback<CloudFrontRequestResult>;