aws-delivlib
Version:
A fabulous library for defining continuous pipelines for building, testing and releasing code libraries.
77 lines (76 loc) • 2.8 kB
TypeScript
import * as lambda from './_lambda';
export type LambdaHandler = (event: Event, context: lambda.Context) => Promise<void>;
export type ResourceHandler = (event: Event, context: lambda.Context) => Promise<ResourceAttributes>;
/**
* Implements a Lambda CloudFormation custom resource handler.
*
* @param handleEvent the handler function that creates, updates and deletes the resource.
* @param refAttribute the name of the attribute holindg the Physical ID of the resource.
* @returns a handler function.
*/
export declare function customResourceHandler(handleEvent: ResourceHandler): LambdaHandler;
/**
* General shape of custom resource attributes.
*/
export interface ResourceAttributes {
/** The physical reference to this resource instance. */
Ref: string;
/** Other attributes of the resource. */
[key: string]: string | undefined;
}
/**
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-responses.html
*/
export declare function sendResponse(event: Event, status: Status, physicalResourceId: string | undefined, data: {
[name: string]: string | undefined;
}, reason?: string): Promise<void>;
export declare enum Status {
SUCCESS = "SUCCESS",
FAILED = "FAILED"
}
export declare enum RequestType {
CREATE = "Create",
UPDATE = "Update",
DELETE = "Delete"
}
/** @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requests.html */
export type Event = CreateEvent | UpdateEvent | DeleteEvent;
export interface CloudFormationEventBase {
readonly RequestType: RequestType;
readonly ResponseURL: string;
readonly StackId: string;
readonly RequestId: string;
readonly ResourceType: string;
readonly LogicalResourceId: string;
readonly ResourceProperties: {
[name: string]: any;
};
}
export interface CreateEvent extends CloudFormationEventBase {
readonly RequestType: RequestType.CREATE;
readonly PhysicalResourceId: undefined;
}
export interface UpdateEvent extends CloudFormationEventBase {
readonly RequestType: RequestType.UPDATE;
readonly PhysicalResourceId: string;
readonly OldResourceProperties: {
[name: string]: any;
};
}
export interface DeleteEvent extends CloudFormationEventBase {
readonly RequestType: RequestType.DELETE;
readonly PhysicalResourceId: string;
}
/**
* Validates that all required properties are present, and that no extraneous properties are provided.
*
* @param props the properties to be validated.
* @param validProps a mapping of valid property names to a boolean instructing whether the property is required or not.
*/
export declare function validateProperties(props: {
[name: string]: any;
}, validProps: {
[name: string]: boolean;
}): {
[name: string]: any;
};