Add CloudWatch events for CodePipeline

Add AWS lambda event type definitions for https://docs.aws.amazon.com/codepipeline/latest/userguide/detect-state-changes-cloudwatch-events.html
This commit is contained in:
Erik Dalén 2018-12-12 16:14:18 +01:00
parent cca60bd544
commit a056705264
2 changed files with 125 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 CodePipelinePiplelineEvent {
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 CodePipelineStageEvent {
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 CodePipelineActionEvent {
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: 'CodeDeploy';
version: number;
};
};
}
export type CodePipelineCloudWatchEvent =
| CodePipelinePiplelineEvent
| CodePipelineStageEvent
| CodePipelineActionEvent;
/**
* CloudFront events
* http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html