UNPKG

@aws-lambda-powertools/parser

Version:
100 lines (99 loc) 4.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CloudFormationCustomResourceUpdateSchema = exports.CloudFormationCustomResourceDeleteSchema = exports.CloudFormationCustomResourceCreateSchema = void 0; const zod_1 = require("zod"); const CloudFormationCustomResourceBaseSchema = zod_1.z.object({ ServiceToken: zod_1.z.string(), ResponseURL: zod_1.z.url(), StackId: zod_1.z.string(), RequestId: zod_1.z.string(), LogicalResourceId: zod_1.z.string(), ResourceType: zod_1.z.string(), ResourceProperties: zod_1.z.record(zod_1.z.string(), zod_1.z.any()), }); /** * Zod schema for CloudFormation Custom Resource event with RequestType = 'Create' * * @example * ```json * { * "RequestType": "Create", * "ServiceToken": "arn:aws:lambda:us-east-1:xxx:function:xxxx-CrbuiltinfunctionidProvi-2vKAalSppmKe", * "ResponseURL": "https://cloudformation-custom-resource-response-useast1.s3.amazonaws.com/7F%7Cb1f50fdfc25f3b", * "StackId": "arn:aws:cloudformation:us-east-1:xxxx:stack/xxxx/271845b0-f2e8-11ed-90ac-0eeb25b8ae21", * "RequestId": "xxxxx-d2a0-4dfb-ab1f-xxxxxx", * "LogicalResourceId": "xxxxxxxxx", * "ResourceType": "Custom::MyType", * "ResourceProperties": { * "ServiceToken": "arn:aws:lambda:us-east-1:xxxxx:function:xxxxx", * "MyProps": "ss" * } * } * ``` * @see {@link CloudFormationCustomResourceCreateEvent | `CloudFormationCustomResourceCreateEvent`} * @see {@link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requesttypes-create.html} */ const CloudFormationCustomResourceCreateSchema = zod_1.z.object({ ...CloudFormationCustomResourceBaseSchema.shape, RequestType: zod_1.z.literal('Create'), }); exports.CloudFormationCustomResourceCreateSchema = CloudFormationCustomResourceCreateSchema; /** * Zod schema for CloudFormation Custom Resource event with RequestType = 'Delete' * * @example * ```json * { * "RequestType": "Delete", * "ServiceToken": "arn:aws:lambda:us-east-1:xxx:function:xxxx-CrbuiltinfunctionidProvi-2vKAalSppmKe", * "ResponseURL": "https://cloudformation-custom-resource-response-useast1.s3.amazonaws.com/7F%7Cb1f50fdfc25f3b", * "StackId": "arn:aws:cloudformation:us-east-1:xxxx:stack/xxxx/271845b0-f2e8-11ed-90ac-0eeb25b8ae21", * "RequestId": "xxxxx-d2a0-4dfb-ab1f-xxxxxx", * "LogicalResourceId": "xxxxxxxxx", * "ResourceType": "Custom::MyType", * "ResourceProperties": { * "ServiceToken": "arn:aws:lambda:us-east-1:xxxxx:function:xxxxx", * "MyProps": "ss" * } * } * ``` * @see {@link CloudFormationCustomResourceDeleteEvent | `CloudFormationCustomResourceDeleteEvent`} * @see {@link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requesttypes-delete.html} */ const CloudFormationCustomResourceDeleteSchema = zod_1.z.object({ ...CloudFormationCustomResourceBaseSchema.shape, RequestType: zod_1.z.literal('Delete'), }); exports.CloudFormationCustomResourceDeleteSchema = CloudFormationCustomResourceDeleteSchema; /** * Zod schema for CloudFormation Custom Resource event with RequestType = 'Update' * * @example * ```json * { * "RequestType": "Update", * "ServiceToken": "arn:aws:lambda:us-east-1:xxx:function:xxxx-CrbuiltinfunctionidProvi-2vKAalSppmKe", * "ResponseURL": "https://cloudformation-custom-resource-response-useast1.s3.amazonaws.com/7F%7Cb1f50fdfc25f3b", * "StackId": "arn:aws:cloudformation:us-east-1:xxxx:stack/xxxx/271845b0-f2e8-11ed-90ac-0eeb25b8ae21", * "RequestId": "xxxxx-d2a0-4dfb-ab1f-xxxxxx", * "LogicalResourceId": "xxxxxxxxx", * "ResourceType": "Custom::MyType", * "ResourceProperties": { * "ServiceToken": "arn:aws:lambda:us-east-1:xxxxx:function:xxxxx", * "MyProps": "new" * }, * "OldResourceProperties": { * "ServiceToken": "arn:aws:lambda:us-east-1:xxxxx:function:xxxxx-xxxx-xxx", * "MyProps": "old" * } * } * ``` * @see {@link CloudFormationCustomResourceUpdateEvent | `CloudFormationCustomResourceUpdateEvent`} * @see {@link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requesttypes-update.html} */ const CloudFormationCustomResourceUpdateSchema = zod_1.z.object({ ...CloudFormationCustomResourceBaseSchema.shape, RequestType: zod_1.z.literal('Update'), OldResourceProperties: zod_1.z.record(zod_1.z.string(), zod_1.z.any()), }); exports.CloudFormationCustomResourceUpdateSchema = CloudFormationCustomResourceUpdateSchema;