diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts index 00b71132e9..566e01c592 100644 --- a/types/aws-lambda/aws-lambda-tests.ts +++ b/types/aws-lambda/aws-lambda-tests.ts @@ -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: [ diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index d9d22f8c65..799f9062fd 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -24,6 +24,7 @@ // Oliver Hookins // Trevor Leach // James Gregory +// Erik Dalén // 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; +export type CodePipelineCloudWatchHandler = Handler; +export type CodePipelineCloudWatchPipelineHandler = Handler; +export type CodePipelineCloudWatchStageHandler = Handler; +export type CodePipelineCloudWatchActionHandler = Handler; + export type CloudFrontRequestHandler = Handler; export type CloudFrontRequestCallback = Callback;