All files / src/handler index.ts

100% Statements 28/28
100% Branches 4/4
100% Functions 1/1
100% Lines 28/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 291x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 2x 3x 1x 3x 3x  
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
 
import { CdkCustomResourceEvent, CdkCustomResourceResponse, Context } from "aws-lambda";
import { onCreateUpdate } from "./on-event/on-create-update";
import { onDelete } from "./on-event/on-delete";
import { CustomResourceProperties } from "./types/custom-resource-properties";
 
/**
 * Entry point
 * @param event Input provided to the custom resource
 * @param _context AWS Lambda context
 * @returns CdkCustomResourceResponse
 */
export async function handler(
  event: CdkCustomResourceEvent<CustomResourceProperties>,
  _context: Context,
): Promise<CdkCustomResourceResponse> {
  console.info("CloudFormation event received:", JSON.stringify(event));
 
  switch (event.RequestType) {
    case "Create":
    case "Update":
      return onCreateUpdate(event);
    case "Delete":
      return onDelete(event);
  }
}