UNPKG

@aws-lambda-powertools/parser

Version:
75 lines (74 loc) 2.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VpcLatticeV2Schema = void 0; const zod_1 = require("zod"); const VpcLatticeV2RequestContextIdentity = zod_1.z.object({ sourceVpcArn: zod_1.z.string().optional(), type: zod_1.z.string().optional(), principal: zod_1.z.string().optional(), principalOrgId: zod_1.z.string().optional(), sessionName: zod_1.z.string().optional(), X509SubjectCn: zod_1.z.string().optional(), X509IssuerOu: zod_1.z.string().optional(), x509SanDns: zod_1.z.string().optional(), x509SanUri: zod_1.z.string().optional(), X509SanNameCn: zod_1.z.string().optional(), }); const VpcLatticeV2RequestContext = zod_1.z.object({ serviceNetworkArn: zod_1.z.string(), serviceArn: zod_1.z.string(), targetGroupArn: zod_1.z.string(), region: zod_1.z.string(), timeEpoch: zod_1.z.string(), identity: VpcLatticeV2RequestContextIdentity, }); /** * Zod schema for VpcLatticeV2 event * * @example * ```json * { * "version": "2.0", * "path": "/newpath", * "method": "GET", * "headers": { * "user_agent": "curl/7.64.1", * "x-forwarded-for": "10.213.229.10", * "host": "test-lambda-service-3908sdf9u3u.dkfjd93.vpc-lattice-svcs.us-east-2.on.aws", * "accept": "*]/*" * }, * "queryStringParameters": { * "order-id": "1" * }, * "body": "{\"message\": \"Hello from Lambda!\"}", * "isBase64Encoded": false, * "requestContext": { * "serviceNetworkArn": "arn:aws:vpc-lattice:us-east-2:123456789012:servicenetwork/sn-0bf3f2882e9cc805a", * "serviceArn": "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0a40eebed65f8d69c", * "targetGroupArn": "arn:aws:vpc-lattice:us-east-2:123456789012:targetgroup/tg-6d0ecf831eec9f09", * "identity": { * "sourceVpcArn": "arn:aws:ec2:region:123456789012:vpc/vpc-0b8276c84697e7339", * "type": "AWS_IAM", * "principal": "arn:aws:sts::123456789012:assumed-role/example-role/057d00f8b51257ba3c853a0f248943cf", * "sessionName": "057d00f8b51257ba3c853a0f248943cf", * "x509SanDns": "example.com" * }, * "region": "us-east-2", * "timeEpoch": "1696331543569073" * } * } * ``` * @see {@link VpcLatticeEventV2 | `VpcLatticeEventV2`} * @see {@link https://docs.aws.amazon.com/vpc-lattice/latest/ug/lambda-functions.html#receive-event-from-service} */ const VpcLatticeV2Schema = zod_1.z.object({ version: zod_1.z.string(), path: zod_1.z.string(), method: zod_1.z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS']), headers: zod_1.z.record(zod_1.z.string(), zod_1.z.string()), queryStringParameters: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(), body: zod_1.z.string().optional(), isBase64Encoded: zod_1.z.boolean().optional(), requestContext: VpcLatticeV2RequestContext, }); exports.VpcLatticeV2Schema = VpcLatticeV2Schema;