@ashishpandeyone/cdk-lambda-web-function 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.jsii CHANGED
@@ -9745,7 +9745,7 @@
9745
9745
  },
9746
9746
  "name": "@ashishpandeyone/cdk-lambda-web-function",
9747
9747
  "readme": {
9748
- "markdown": "# CDK constructs for AWS Lambda Web Functions\n\n<!--BEGIN STABILITY BANNER-->\n\n---\n\n![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)\n\n> The APIs of higher level constructs in this module are experimental and under active development.\n> They are subject to non-backward compatible changes or removal in any future version. These are\n> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be\n> announced in the release notes. This means that while you may use them, you may need to update\n> your source code when upgrading to a newer version of this package.\n\n---\n\n<!--END STABILITY BANNER-->\n\n[AWS Lambda Web Functions](https://aws.amazon.com/lambda/) run an ordinary Node.js HTTP server (Express, Fastify, Hono, `node:http`) on Lambda and give it an HTTPS endpoint, optionally served from several regions. `WebFunction` deploys one, following the conventions of `aws-cdk-lib/aws-lambda` where the two services overlap.\n\n```ts fixture=bare\nimport * as lambda from 'aws-cdk-lib/aws-lambda';\nimport { WebFunction, WebFunctionAuthType, WebFunctionEndpointType } from '@ashishpandeyone/cdk-lambda-web-function';\n\nconst fn = new WebFunction(this, 'Api', {\n runtime: lambda.Runtime.NODEJS_24_X,\n code: lambda.Code.fromAsset('dist'),\n authType: WebFunctionAuthType.AWS_IAM,\n endpoint: {\n endpointType: WebFunctionEndpointType.MULTI_REGION,\n regions: ['us-east-1', 'eu-west-1'],\n },\n});\n\nnew CfnOutput(this, 'Url', { value: fn.endpoint.url }); // https://<id>.lambda-web.global.on.aws\n```\n\nThe stack's region is the function's **home region**. Multi-region endpoints need a stack with an explicit `env.region`.\n\n## Writing the server\n\n1. Listen on the host and port in **`AWS_LAMBDA_HTTP_ENDPOINT`** (`0.0.0.0:3000` today). `PORT` is not set.\n2. Start listening within **about 9 seconds**, or initialisation fails with `Application.TimeoutListenError`.\n3. Put the entry file at the root of your bundle as **`index.js`**, or set `entrypoint`.\n4. The runtime has **no AWS SDK**: bundle the clients you import.\n5. Code runs on **arm64**.\n\n```js\nconst express = require('express');\n\nconst app = express();\napp.get('/', (req, res) => res.json({ hello: 'world', region: process.env.AWS_REGION }));\n\nconst [host, port] = process.env.AWS_LAMBDA_HTTP_ENDPOINT.split(':');\napp.listen(Number(port), host);\n```\n\nRequests carry `lambda-web-request-id` and `lambda-web-endpoint-name` headers.\n\n## Regions and endpoints\n\nEach `WebFunction` has one endpoint, `fn.endpoint`:\n\n| `endpointType` | URL | Routing |\n|---|---|---|\n| `HOME_REGION` (default) | `https://<id>.<cell>.lambda-web.<home>.on.aws` | home region only |\n| `MULTI_REGION` | one global `https://<id>.lambda-web.global.on.aws` | nearest region |\n| `PER_REGION` | one URL per region, from `fn.endpoint.regionalUrl(region)` | the region in the hostname |\n\n```ts\nconst perRegion = new WebFunction(this, 'Api', {\n runtime: lambda.Runtime.NODEJS_24_X,\n code: lambda.Code.fromAsset('dist'),\n authType: WebFunctionAuthType.AWS_IAM,\n endpoint: {\n endpointType: WebFunctionEndpointType.PER_REGION,\n regions: ['us-east-1', 'eu-west-1'],\n },\n});\n\nnew CfnOutput(this, 'UsEast1Url', { value: perRegion.endpoint.regionalUrl('us-east-1') });\n// perRegion.endpoint.regions is ['<home region>', 'eu-west-1', 'us-east-1']\n```\n\n- `MULTI_REGION` and `PER_REGION` need at least one region besides the home region; `HOME_REGION` takes none.\n- A MultiRegion endpoint takes about a minute to create.\n\n### Changing regions or the endpoint type\n\nAn endpoint's type and regions can't change in place: a change creates a **new endpoint with a new URL**, and the old one is deleted once the new one is live. Two endpoints of one function can't share a name, so:\n\n| `endpointName` | Physical name | Changing `regions` or `endpointType` |\n|---|---|---|\n| omitted (recommended) | `default-<hash of type and regions>` | works: new endpoint, new URL |\n| set, e.g. `'live'` | `live` | also change the name in the same deployment, or it fails with *The endpoint live already exists* (the stack rolls back and the old endpoint keeps serving) |\n\nThe construct warns at synth time when `endpointName` is set.\n\n## Authentication and invoking\n\n| `authType` | Meaning |\n|---|---|\n| `AWS_IAM` | Callers sign requests (SigV4 or SigV4a, signing name `lambda`) and need `lambda:InvokeWebFunctionEndpoint` |\n| `NONE` | **Public**: Lambda does no authentication; your application does (JWT, sessions). The `Authorization` header reaches your application untouched. The construct warns at synth time |\n\n```ts\nfn.grants.invoke(consumerRole); // or fn.grantInvoke(consumerRole), as on lambda.Function\n```\n\nThe grant is on the endpoint's home-region ARN, which IAM evaluates in every region the endpoint serves from, including the global URL.\n\n| Endpoint | How to sign |\n|---|---|\n| `HOME_REGION` | SigV4 for the home region |\n| `PER_REGION` | SigV4 for the hostname's region, or SigV4a |\n| `MULTI_REGION` | **SigV4a with region set `*`**: you can't know which region will serve the request |\n\n```js\nimport { SignatureV4a } from '@smithy/signature-v4a';\nimport { Sha256 } from '@aws-crypto/sha256-js';\nimport { fromNodeProviderChain } from '@aws-sdk/credential-providers';\n\nconst signer = new SignatureV4a({ service: 'lambda', region: '*', sha256: Sha256, credentials: fromNodeProviderChain() });\nconst signed = await signer.sign(\n { method: 'GET', protocol: 'https:', hostname: host, path: '/', headers: { host } },\n { signingRegion: '*' },\n);\nconst response = await fetch(`https://${host}/`, { headers: signed.headers });\n```\n\n## Configuration\n\n```ts\nconst api = new WebFunction(this, 'Api', {\n runtime: lambda.Runtime.NODEJS_24_X,\n code: lambda.Code.fromAsset('build'),\n authType: WebFunctionAuthType.AWS_IAM,\n entrypoint: 'server.js', // default index.js\n webFunctionName: 'orders-api', // default: generated from the construct path\n description: 'Orders HTTP API',\n environment: { TABLE_NAME: table.tableName },\n timeout: Duration.seconds(60), // per request: 3 seconds to 15 minutes, default 30 seconds\n maxConcurrencyPerEnvironment: 32, // requests per environment at once: 1-128, default 64\n});\n\napi.addEnvironment('FEATURE_FLAG', 'on');\ntable.grantReadWriteData(api); // the default role trusts lambda.amazonaws.com\n```\n\n- Requests handled by one environment share module-level state, so keep handlers concurrency-safe.\n- Environment variable names starting with `AWS_` are reserved.\n- **Renaming the function replaces it and changes its URL.** A generated name depends on the construct path, so moving the construct renames it too.\n\n### Bundling TypeScript with `NodejsWebFunction`\n\n`NodejsWebFunction` is a `WebFunction` that bundles your server from a TypeScript or JavaScript entry file with esbuild, like `NodejsFunction` does for Lambda functions:\n\n```ts\nnew NodejsWebFunction(this, 'Api', {\n entry: 'src/server.ts',\n authType: WebFunctionAuthType.AWS_IAM,\n bundling: {\n minify: true, // default true\n sourceMap: true, // default true\n format: lambdaNodejs.OutputFormat.ESM, // default ESM (index.mjs); CJS gives index.js\n externalModules: [], // default: bundle everything you import\n },\n});\n```\n\n- **Defaults:** `runtime` is `NODEJS_24_X`, and the esbuild target follows the runtime (`node24`). The project root is the directory of the nearest lock file above `entry` (override it with `depsLockFilePath` or `projectRoot`).\n- **It also sets what a `lambda.Code` can't:** the entry point that matches the bundle, and `NODE_OPTIONS=--enable-source-maps` when source maps are on, appended to any `NODE_OPTIONS` you set, so stack traces point at your `.ts` files (e.g. `/var/task/src/server.ts:22:12`). Source map paths are relative to the project root, so no build-machine paths are deployed.\n- **ESM bundles include a `require` shim**, so CommonJS dependencies that load Node.js built-ins (Express, for example) work.\n- **The AWS SDK is bundled like any other dependency**, since the runtime has none. Only the clients you import are included.\n- **Bundling runs locally** when esbuild is installed in your project, and otherwise in Docker (an arm64 AWS SAM build image; set `forceDockerBundling` to always use Docker).\n- **Not yet supported:** installing native modules next to the bundle (`nodeModules`) and command hooks. For native dependencies, use `WebFunction` with `Code.fromAsset(..., { bundling: { image, command } })`.\n\n### Code\n\n`code` takes any `lambda.Code` that produces a zip in S3: `fromAsset`, `fromBucket`/`fromBucketV2`, `fromCustomCommand`, `fromDockerBuild`. Inline code and container images fail at synth time.\n\nLambda Web Functions download code as the `lambda.amazonaws.com` service principal, from a **versioned** bucket, and the CDK bootstrap bucket allows neither. So each stack gets a small code bucket, and the code is copied into it on deploy.\n\n### Updates\n\nAny change to code or configuration creates a new **revision**. The endpoint switches to it once it's ready, and the old revision is deleted after the deployment succeeds; a failed deployment rolls back to it. If nothing changed, nothing is deployed.\n\n## Logs in every region\n\nWeb Functions log in two tiers:\n\n```text\n every serving region home region\n ┌──────────────────┐ ┌──────────────────────────────────────────┐\n │ <group>.local │── copied ───►│ <group> every region's logs │\n │ (that region's │ (seconds) │ streams …[rev]<instance>-<acct>-<region> │\n │ environments) │ │ <group>.local (home-region traffic) │\n └──────────────────┘ └──────────────────────────────────────────┘\n```\n\n**Query `fn.logGroup`**, the home-region group that receives every region's logs. The service would create missing groups without retention and never delete them, so the construct creates and owns all of them: both home-region groups, and `<group>.local` in every other region of the endpoint.\n\n```ts\nnew WebFunction(this, 'Api', {\n runtime: lambda.Runtime.NODEJS_24_X,\n code: lambda.Code.fromAsset('dist'),\n authType: WebFunctionAuthType.AWS_IAM,\n logRetention: logs.RetentionDays.THREE_MONTHS, // default ONE_MONTH, every group in every region\n logRemovalPolicy: RemovalPolicy.DESTROY, // default RETAIN\n applicationLogLevelV2: lambda.ApplicationLogLevel.WARN,\n systemLogLevelV2: lambda.SystemLogLevel.INFO, // DEBUG, INFO or WARN\n});\n```\n\n- The default group is `/aws/lambda/web/<function name>`. Log lines are JSON; application lines carry `requestId`, `endpointName` and `region`.\n- Every event is stored twice (`.local` plus the home-region copy), so expect about double log ingestion, plus cross-region transfer.\n- With `DESTROY`, deletion waits about a minute after the function is gone, because environments flush their last lines late.\n- Subscribe only to `fn.logGroup`: subscribing to the `.local` groups as well delivers every event twice.\n\n## Limitations\n\n- One endpoint per function; no traffic splitting between revisions.\n- Not yet supported: importing existing functions, VPC access (network connectors), resource-policy permissions, KMS encryption, metrics helpers, tracing, and a CloudFront origin.\n- `cdk deploy --hotswap` and `cdk watch` don't support Web Functions.\n- Quotas per account and region: 50 revisions and 10 endpoints per function, 200 Arm vCPUs, 10,000 requests per second.\n- The stack's custom resource provider Lambda keeps its own log group after the stack is deleted, as with other CDK custom resources.\n\n## Development\n\nTooling is pinned in `mise.toml` (Node 24, AWS CDK CLI). Personal settings, such as the AWS profile for the live end-to-end tests, go in a git-ignored `mise.local.toml`.\n\n```bash\nmise install\nnpx projen build # compile, unit tests, lint, API docs\nnpx projen e2e # deploy, verify and destroy real stacks in three regions (needs AWS credentials)\n```\n"
9748
+ "markdown": "# CDK constructs for AWS Lambda Web Functions\n\n<!--BEGIN STABILITY BANNER-->\n\n---\n\n![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)\n\n> The APIs of higher level constructs in this module are experimental and under active development.\n> They are subject to non-backward compatible changes or removal in any future version. These are\n> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be\n> announced in the release notes. This means that while you may use them, you may need to update\n> your source code when upgrading to a newer version of this package.\n\n---\n\n<!--END STABILITY BANNER-->\n\n[AWS Lambda Web Functions](https://aws.amazon.com/lambda/) run an ordinary Node.js HTTP server (Express, Fastify, Hono, `node:http`) on Lambda and give it an HTTPS endpoint, optionally served from several regions. `WebFunction` deploys one, following the conventions of `aws-cdk-lib/aws-lambda` where the two services overlap.\n\n```ts fixture=bare\nimport * as lambda from 'aws-cdk-lib/aws-lambda';\nimport { WebFunction, WebFunctionAuthType, WebFunctionEndpointType } from '@ashishpandeyone/cdk-lambda-web-function';\n\nconst fn = new WebFunction(this, 'Api', {\n runtime: lambda.Runtime.NODEJS_24_X,\n code: lambda.Code.fromAsset('dist'),\n authType: WebFunctionAuthType.AWS_IAM,\n endpoint: {\n endpointType: WebFunctionEndpointType.MULTI_REGION,\n regions: ['us-east-1', 'eu-west-1'],\n },\n});\n\nnew CfnOutput(this, 'Url', { value: fn.endpoint.url }); // https://<id>.lambda-web.global.on.aws\n```\n\nThe stack's region is the function's **home region**. Multi-region endpoints need a stack with an explicit `env.region`.\n\n## Writing the server\n\n1. Listen on the host and port in **`AWS_LAMBDA_HTTP_ENDPOINT`** (`0.0.0.0:3000` today). `PORT` is not set.\n2. Start listening within **about 9 seconds**, or initialisation fails with `Application.TimeoutListenError`.\n3. Put the entry file at the root of your bundle as **`index.js`**, or set `entrypoint`.\n4. The runtime has **no AWS SDK**: bundle the clients you import.\n5. Code runs on **arm64**.\n\n```js\nconst express = require('express');\n\nconst app = express();\napp.get('/', (req, res) => res.json({ hello: 'world', region: process.env.AWS_REGION }));\n\nconst [host, port] = process.env.AWS_LAMBDA_HTTP_ENDPOINT.split(':');\napp.listen(Number(port), host);\n```\n\nRequests carry `lambda-web-request-id` and `lambda-web-endpoint-name` headers.\n\n## Regions and endpoints\n\nEach `WebFunction` has a default endpoint, `fn.endpoint`, configured with the `endpoint` property. [Add more](#more-endpoints) with `fn.addEndpoint()`.\n\n| `endpointType` | URL | Routing |\n|---|---|---|\n| `HOME_REGION` (default) | `https://<id>.<cell>.lambda-web.<home>.on.aws` | home region only |\n| `MULTI_REGION` | one global `https://<id>.lambda-web.global.on.aws` | nearest region |\n| `PER_REGION` | one URL per region, from `fn.endpoint.regionalUrl(region)` | the region in the hostname |\n\n```ts\nconst perRegion = new WebFunction(this, 'Api', {\n runtime: lambda.Runtime.NODEJS_24_X,\n code: lambda.Code.fromAsset('dist'),\n authType: WebFunctionAuthType.AWS_IAM,\n endpoint: {\n endpointType: WebFunctionEndpointType.PER_REGION,\n regions: ['us-east-1', 'eu-west-1'],\n },\n});\n\nnew CfnOutput(this, 'UsEast1Url', { value: perRegion.endpoint.regionalUrl('us-east-1') });\n// perRegion.endpoint.regions is ['<home region>', 'eu-west-1', 'us-east-1']\n```\n\n- `MULTI_REGION` and `PER_REGION` need at least one region besides the home region; `HOME_REGION` takes none.\n- A MultiRegion endpoint takes about a minute to create.\n- Lambda routes a `MULTI_REGION` endpoint by latency, not by health: it doesn't fail over when a region has problems.\n\n### More endpoints\n\nA function can have up to 10 endpoints, each with its own URL, authentication, regions and limits. For example, a public endpoint next to an IAM-only global one:\n\n```ts\nconst api = new WebFunction(this, 'Api', {\n runtime: lambda.Runtime.NODEJS_24_X,\n code: lambda.Code.fromAsset('dist'),\n authType: WebFunctionAuthType.NONE, // the default endpoint is public\n endpoint: { rateLimit: 1000 }, // requests per second\n});\n\nconst internal = api.addEndpoint('Internal', {\n authType: WebFunctionAuthType.AWS_IAM,\n endpointType: WebFunctionEndpointType.MULTI_REGION,\n regions: ['us-east-1', 'eu-west-1'],\n description: 'Service-to-service traffic',\n maxEnvironments: 50,\n});\ninternal.grantInvoke(consumerRole);\nnew CfnOutput(this, 'InternalUrl', { value: internal.url });\n```\n\n- `rateLimit` takes 0 (blocks all traffic), 100–1,000 in steps of 100, or 2,000–10,000 in steps of 1,000; excess requests get HTTP 429. `maxEnvironments` takes 2–10,000.\n- **Both limits apply separately in each region** an endpoint serves from: a 3-region endpoint with `rateLimit: 1000` accepts up to 1,000 requests per second in each region.\n- Endpoints can serve the same regions. The construct owns one `.local` log group per region, whichever endpoints serve it.\n\n### Changing regions or the endpoint type\n\nAn endpoint's type and regions can't change in place: a change creates a **new endpoint with a new URL**, and the old one is deleted once the new one is live. Two endpoints of one function can't share a name, so:\n\n| `endpointName` | Physical name | Changing `regions` or `endpointType` |\n|---|---|---|\n| omitted (recommended) | `default-<hash>` for `fn.endpoint`, `<id>-<hash>` for added endpoints; the hash covers the type and regions | works: new endpoint, new URL |\n| set, e.g. `'live'` | `live` | also change the name in the same deployment, or it fails with *The endpoint live already exists* (the stack rolls back and the old endpoint keeps serving) |\n\nThe construct warns at synth time when `endpointName` is set.\n\n## Authentication and invoking\n\n| `authType` | Meaning |\n|---|---|\n| `AWS_IAM` | Callers sign requests (SigV4 or SigV4a, signing name `lambda`) and need `lambda:InvokeWebFunctionEndpoint` |\n| `NONE` | **Public**: Lambda does no authentication; your application does (JWT, sessions). The `Authorization` header reaches your application untouched. The construct warns at synth time |\n\n```ts\nfn.grants.invoke(consumerRole); // or fn.grantInvoke(consumerRole), as on lambda.Function\n```\n\nThe grant is on the endpoint's home-region ARN, which IAM evaluates in every region the endpoint serves from, including the global URL. `fn.grants` covers the default endpoint only; grant other endpoints with their own `grantInvoke()` or `grants.invoke()`.\n\n| Endpoint | How to sign |\n|---|---|\n| `HOME_REGION` | SigV4 for the home region |\n| `PER_REGION` | SigV4 for the hostname's region, or SigV4a |\n| `MULTI_REGION` | **SigV4a with region set `*`**: you can't know which region will serve the request |\n\n```js\nimport { SignatureV4a } from '@smithy/signature-v4a';\nimport { Sha256 } from '@aws-crypto/sha256-js';\nimport { fromNodeProviderChain } from '@aws-sdk/credential-providers';\n\nconst signer = new SignatureV4a({ service: 'lambda', region: '*', sha256: Sha256, credentials: fromNodeProviderChain() });\nconst signed = await signer.sign(\n { method: 'GET', protocol: 'https:', hostname: host, path: '/', headers: { host } },\n { signingRegion: '*' },\n);\nconst response = await fetch(`https://${host}/`, { headers: signed.headers });\n```\n\n## Configuration\n\n```ts\nconst api = new WebFunction(this, 'Api', {\n runtime: lambda.Runtime.NODEJS_24_X,\n code: lambda.Code.fromAsset('build'),\n authType: WebFunctionAuthType.AWS_IAM,\n entrypoint: 'server.js', // default index.js\n webFunctionName: 'orders-api', // default: generated from the construct path\n description: 'Orders HTTP API',\n environment: { TABLE_NAME: table.tableName },\n timeout: Duration.seconds(60), // per request: 3 seconds to 15 minutes, default 30 seconds\n maxConcurrencyPerEnvironment: 32, // requests per environment at once: 1-128, default 64\n});\n\napi.addEnvironment('FEATURE_FLAG', 'on');\ntable.grantReadWriteData(api); // the default role trusts lambda.amazonaws.com\n```\n\n- Requests handled by one environment share module-level state, so keep handlers concurrency-safe.\n- Environment variable names starting with `AWS_` are reserved.\n- **Renaming the function replaces it and changes its URL.** A generated name depends on the construct path, so moving the construct renames it too.\n\n### Bundling TypeScript with `NodejsWebFunction`\n\n`NodejsWebFunction` is a `WebFunction` that bundles your server from a TypeScript or JavaScript entry file with esbuild, like `NodejsFunction` does for Lambda functions:\n\n```ts\nnew NodejsWebFunction(this, 'Api', {\n entry: 'src/server.ts',\n authType: WebFunctionAuthType.AWS_IAM,\n bundling: {\n minify: true, // default true\n sourceMap: true, // default true\n format: lambdaNodejs.OutputFormat.ESM, // default ESM (index.mjs); CJS gives index.js\n externalModules: [], // default: bundle everything you import\n },\n});\n```\n\n- **Defaults:** `runtime` is `NODEJS_24_X`, and the esbuild target follows the runtime (`node24`). The project root is the directory of the nearest lock file above `entry` (override it with `depsLockFilePath` or `projectRoot`).\n- **It also sets what a `lambda.Code` can't:** the entry point that matches the bundle, and `NODE_OPTIONS=--enable-source-maps` when source maps are on, appended to any `NODE_OPTIONS` you set, so stack traces point at your `.ts` files (e.g. `/var/task/src/server.ts:22:12`). Source map paths are relative to the project root, so no build-machine paths are deployed.\n- **ESM bundles include a `require` shim**, so CommonJS dependencies that load Node.js built-ins (Express, for example) work.\n- **The AWS SDK is bundled like any other dependency**, since the runtime has none. Only the clients you import are included.\n- **Bundling runs locally** when esbuild is installed in your project, and otherwise in Docker (an arm64 AWS SAM build image; set `forceDockerBundling` to always use Docker).\n- **Not yet supported:** installing native modules next to the bundle (`nodeModules`) and command hooks. For native dependencies, use `WebFunction` with `Code.fromAsset(..., { bundling: { image, command } })`.\n\n### Code\n\n`code` takes any `lambda.Code` that produces a zip in S3: `fromAsset`, `fromBucket`/`fromBucketV2`, `fromCustomCommand`, `fromDockerBuild`. Inline code and container images fail at synth time.\n\nLambda Web Functions download code as the `lambda.amazonaws.com` service principal, from a **versioned** bucket, and the CDK bootstrap bucket allows neither. So each stack gets a small code bucket, and the code is copied into it on deploy.\n\n## Revisions\n\nAny change to code or configuration creates a new **revision** (`fn.currentRevision`), and endpoints switch to it once it's ready. A failed deployment rolls back to the previous revision. If nothing changed, nothing is deployed.\n\nEarlier revisions are kept, so you can roll back or route traffic to them. After each deployment, the construct deletes the oldest beyond `revisionRetention` (default 20, up to 50). It never deletes a revision an endpoint routes to, or one the previous deployment used, which a rollback returns to.\n\n```ts\nnew WebFunction(this, 'Api', {\n runtime: lambda.Runtime.NODEJS_24_X,\n code: lambda.Code.fromAsset('dist'),\n authType: WebFunctionAuthType.AWS_IAM,\n revisionRetention: 5,\n});\n```\n\n### Routing to earlier revisions\n\nReference an earlier revision by its ID (for example from a `CfnOutput` of `fn.currentRevision.revisionId`, or `aws lambda-web list-web-function-revisions`). Then pin an endpoint to it, or split traffic between two revisions:\n\n```ts\nconst previous = WebFunctionRevision.fromRevisionAttributes(this, 'Previous', {\n webFunction: fn,\n revisionId: 'rev-a1b2c',\n});\n\n// Keep the default endpoint on the previous revision, and send 10% to the new one:\nfn.endpoint.routeTraffic(previous, [{ revision: fn.currentRevision, weight: 0.1 }]);\n\n// Or a second endpoint that stays on the previous revision while fn.endpoint moves on:\nfn.addEndpoint('Stable', { authType: WebFunctionAuthType.AWS_IAM, revision: previous });\n```\n\n- An endpoint routes to at most two revisions. The additional revision's `weight` is a whole percentage, from 0.01 to 0.99.\n- To promote, remove `routeTraffic` (or `revision`) and deploy: the endpoint serves the current revision again.\n- Lambda Web Function metrics have no revision dimension. To compare a split's revisions, log a version you control (for example an environment variable) from your application.\n\n### Canary and linear deployments\n\nBy default an endpoint moves all its traffic to a new revision at once. With `deployment`, it moves in steps instead, watching CloudWatch alarms: if one goes into ALARM, the endpoint goes back to the revision it served before and the deployment fails, so CloudFormation rolls the stack back.\n\n```ts\n// errorRate: a cloudwatch.IAlarm, for example on the share of 5xx responses\nconst api = new WebFunction(this, 'Api', {\n runtime: lambda.Runtime.NODEJS_24_X,\n code: lambda.Code.fromAsset('dist'),\n authType: WebFunctionAuthType.AWS_IAM,\n endpoint: {\n // 10% of the traffic for 10 minutes, then all of it.\n deployment: WebFunctionDeployment.canary({ percent: 10, bake: Duration.minutes(10), alarms: [errorRate] }),\n },\n});\n\n// 25% more every 5 minutes. Each endpoint has its own deployment.\napi.addEndpoint('Public', {\n authType: WebFunctionAuthType.NONE,\n deployment: WebFunctionDeployment.linear({ percent: 25, interval: Duration.minutes(5), alarms: [errorRate] }),\n});\n```\n\n| | Steps | Limits |\n|---|---|---|\n| `allAtOnce()` (default) | 100% | |\n| `canary({ percent, bake })` | `percent`, then 100% after `bake` | `percent` 1–99, `bake` 1–45 minutes |\n| `linear({ percent, interval })` | `percent` more every `interval` | `percent` 5–50, `interval` from 1 minute, at most 45 minutes in all |\n\nHow it works:\n\n- Each deployment that creates a revision (code or configuration) moves the traffic from the revision the endpoint serves at that moment, which is also what it goes back to. If someone switched the endpoint outside CloudFormation, the deployment starts from there.\n- Each step waits until every region of a `MULTI_REGION` or `PER_REGION` endpoint has applied it (usually about 15 seconds), and if a region fails to update, the endpoint goes back as for an alarm. The bake or interval counts from the start of the step.\n- Alarms are checked before the first step (an alarm already in ALARM stops the deployment before any traffic moves), throughout every step, and once the new revision has all the traffic. They can be in any region, and composite alarms work. `INSUFFICIENT_DATA` doesn't stop a deployment.\n- A rollback of the stack, for any reason, moves the traffic back at once, without waiting or checking alarms.\n- A stack's first deployment, and a new endpoint (including one renamed by a region change), serve the revision at once: there's nothing to move from.\n- A deployment can take up to an hour: CloudFormation waits for it before it updates the endpoint. Deployments of different endpoints run in parallel.\n- A canary or linear endpoint always moves to the current revision, so it can't also use `revision`, `additionalRevisions` or `routeTraffic()`. Use `allAtOnce()` to deploy a fix immediately, for example while an alarm is in ALARM.\n\nLambda Web Function metrics have no revision dimension, so an alarm sees the whole endpoint: at 10%, a new revision's errors are a tenth of the endpoint's. Alarm on a rate, with a threshold low enough to notice that, or publish metrics from your application that carry its version. A bake should be longer than an alarm needs to fire (its period times its evaluation periods).\n\nThe deployment runs in a few resources per stack, created on first use: two Lambda functions, a Step Functions state machine that calls them every 15 seconds, and a log group.\n\n## Logs in every region\n\nWeb Functions log in two tiers:\n\n```text\n every serving region home region\n ┌──────────────────┐ ┌──────────────────────────────────────────┐\n │ <group>.local │── copied ───►│ <group> every region's logs │\n │ (that region's │ (seconds) │ streams …[rev]<instance>-<acct>-<region> │\n │ environments) │ │ <group>.local (home-region traffic) │\n └──────────────────┘ └──────────────────────────────────────────┘\n```\n\n**Query `fn.logGroup`**, the home-region group that receives every region's logs. The service would create missing groups without retention and never delete them, so the construct creates and owns all of them: both home-region groups, and `<group>.local` in every other region of the endpoint.\n\n```ts\nnew WebFunction(this, 'Api', {\n runtime: lambda.Runtime.NODEJS_24_X,\n code: lambda.Code.fromAsset('dist'),\n authType: WebFunctionAuthType.AWS_IAM,\n logRetention: logs.RetentionDays.THREE_MONTHS, // default ONE_MONTH, every group in every region\n logRemovalPolicy: RemovalPolicy.DESTROY, // default RETAIN\n applicationLogLevelV2: lambda.ApplicationLogLevel.WARN,\n systemLogLevelV2: lambda.SystemLogLevel.INFO, // DEBUG, INFO or WARN\n});\n```\n\n- The default group is `/aws/lambda/web/<function name>`. Log lines are JSON; application lines carry `requestId`, `endpointName` and `region`.\n- Every event is stored twice (`.local` plus the home-region copy), so expect about double log ingestion, plus cross-region transfer.\n- With `DESTROY`, deletion waits about a minute after the function is gone, because environments flush their last lines late.\n- Subscribe only to `fn.logGroup`: subscribing to the `.local` groups as well delivers every event twice.\n\n## Limitations\n\n- Not yet supported: importing existing functions, VPC access (network connectors), resource-policy permissions, KMS encryption, metrics helpers, tracing, and a CloudFront origin.\n- `cdk deploy --hotswap` and `cdk watch` don't support Web Functions.\n- Quotas: 10 endpoints and about 50 revisions per function (Lambda cleans up older revisions automatically), and 10,000 requests per second per endpoint. Per account and region: 100,000 requests per second and 2,000 Arm64 vCPUs (each execution environment uses 2). The account quotas are adjustable, and new accounts start lower. See [Lambda quotas](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html).\n- The stack's custom resource provider Lambda keeps its own log group after the stack is deleted, as with other CDK custom resources.\n\n## Development\n\nTooling is pinned in `mise.toml` (Node 24, AWS CDK CLI). Personal settings, such as the AWS profile for the live end-to-end tests, go in a git-ignored `mise.local.toml`.\n\n```bash\nmise install\nnpx projen build # compile, unit tests, lint, API docs\nnpx projen e2e # deploy, verify and destroy real stacks in three regions (needs AWS credentials)\n```\n"
9749
9749
  },
9750
9750
  "repository": {
9751
9751
  "type": "git",
@@ -9758,6 +9758,85 @@
9758
9758
  }
9759
9759
  },
9760
9760
  "types": {
9761
+ "@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions": {
9762
+ "assembly": "@ashishpandeyone/cdk-lambda-web-function",
9763
+ "datatype": true,
9764
+ "docs": {
9765
+ "stability": "experimental",
9766
+ "summary": "Options for `WebFunction.addEndpoint`."
9767
+ },
9768
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions",
9769
+ "interfaces": [
9770
+ "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointOptions"
9771
+ ],
9772
+ "kind": "interface",
9773
+ "locationInModule": {
9774
+ "filename": "src/web-function-endpoint.ts",
9775
+ "line": 105
9776
+ },
9777
+ "name": "AddWebFunctionEndpointOptions",
9778
+ "properties": [
9779
+ {
9780
+ "abstract": true,
9781
+ "docs": {
9782
+ "stability": "experimental",
9783
+ "summary": "How callers of this endpoint are authenticated."
9784
+ },
9785
+ "immutable": true,
9786
+ "locationInModule": {
9787
+ "filename": "src/web-function-endpoint.ts",
9788
+ "line": 109
9789
+ },
9790
+ "name": "authType",
9791
+ "type": {
9792
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType"
9793
+ }
9794
+ },
9795
+ {
9796
+ "abstract": true,
9797
+ "docs": {
9798
+ "default": "- all traffic goes to `revision`",
9799
+ "remarks": "`revision` gets the rest.\nAn endpoint routes to at most two revisions.",
9800
+ "stability": "experimental",
9801
+ "summary": "A second revision and its share of the endpoint's traffic;"
9802
+ },
9803
+ "immutable": true,
9804
+ "locationInModule": {
9805
+ "filename": "src/web-function-endpoint.ts",
9806
+ "line": 125
9807
+ },
9808
+ "name": "additionalRevisions",
9809
+ "optional": true,
9810
+ "type": {
9811
+ "collection": {
9812
+ "elementtype": {
9813
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight"
9814
+ },
9815
+ "kind": "array"
9816
+ }
9817
+ }
9818
+ },
9819
+ {
9820
+ "abstract": true,
9821
+ "docs": {
9822
+ "default": "- the function's current revision (`currentRevision`)",
9823
+ "stability": "experimental",
9824
+ "summary": "The revision the endpoint serves, e.g. an earlier one from `WebFunctionRevision.fromRevisionAttributes` to keep this endpoint on it while others move on. Same as calling `routeTraffic`."
9825
+ },
9826
+ "immutable": true,
9827
+ "locationInModule": {
9828
+ "filename": "src/web-function-endpoint.ts",
9829
+ "line": 117
9830
+ },
9831
+ "name": "revision",
9832
+ "optional": true,
9833
+ "type": {
9834
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision"
9835
+ }
9836
+ }
9837
+ ],
9838
+ "symbolId": "src/web-function-endpoint:AddWebFunctionEndpointOptions"
9839
+ },
9761
9840
  "@ashishpandeyone/cdk-lambda-web-function.IWebFunction": {
9762
9841
  "assembly": "@ashishpandeyone/cdk-lambda-web-function",
9763
9842
  "docs": {
@@ -9772,7 +9851,7 @@
9772
9851
  "kind": "interface",
9773
9852
  "locationInModule": {
9774
9853
  "filename": "src/web-function.ts",
9775
- "line": 134
9854
+ "line": 153
9776
9855
  },
9777
9856
  "name": "IWebFunction",
9778
9857
  "properties": [
@@ -9788,7 +9867,7 @@
9788
9867
  "immutable": true,
9789
9868
  "locationInModule": {
9790
9869
  "filename": "src/web-function.ts",
9791
- "line": 147
9870
+ "line": 166
9792
9871
  },
9793
9872
  "name": "webFunctionArn",
9794
9873
  "type": {
@@ -9807,7 +9886,7 @@
9807
9886
  "immutable": true,
9808
9887
  "locationInModule": {
9809
9888
  "filename": "src/web-function.ts",
9810
- "line": 140
9889
+ "line": 159
9811
9890
  },
9812
9891
  "name": "webFunctionName",
9813
9892
  "type": {
@@ -9817,6 +9896,74 @@
9817
9896
  ],
9818
9897
  "symbolId": "src/web-function:IWebFunction"
9819
9898
  },
9899
+ "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision": {
9900
+ "assembly": "@ashishpandeyone/cdk-lambda-web-function",
9901
+ "docs": {
9902
+ "stability": "experimental",
9903
+ "summary": "A revision of a Web Function: an immutable snapshot of its code and configuration."
9904
+ },
9905
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision",
9906
+ "interfaces": [
9907
+ "constructs.IConstruct"
9908
+ ],
9909
+ "kind": "interface",
9910
+ "locationInModule": {
9911
+ "filename": "src/web-function-revision.ts",
9912
+ "line": 7
9913
+ },
9914
+ "name": "IWebFunctionRevision",
9915
+ "properties": [
9916
+ {
9917
+ "abstract": true,
9918
+ "docs": {
9919
+ "stability": "experimental",
9920
+ "summary": "The revision's ARN."
9921
+ },
9922
+ "immutable": true,
9923
+ "locationInModule": {
9924
+ "filename": "src/web-function-revision.ts",
9925
+ "line": 12
9926
+ },
9927
+ "name": "revisionArn",
9928
+ "type": {
9929
+ "primitive": "string"
9930
+ }
9931
+ },
9932
+ {
9933
+ "abstract": true,
9934
+ "docs": {
9935
+ "stability": "experimental",
9936
+ "summary": "The revision's ID, e.g. `rev-a1b2c`."
9937
+ },
9938
+ "immutable": true,
9939
+ "locationInModule": {
9940
+ "filename": "src/web-function-revision.ts",
9941
+ "line": 9
9942
+ },
9943
+ "name": "revisionId",
9944
+ "type": {
9945
+ "primitive": "string"
9946
+ }
9947
+ },
9948
+ {
9949
+ "abstract": true,
9950
+ "docs": {
9951
+ "stability": "experimental",
9952
+ "summary": "The function the revision belongs to."
9953
+ },
9954
+ "immutable": true,
9955
+ "locationInModule": {
9956
+ "filename": "src/web-function-revision.ts",
9957
+ "line": 15
9958
+ },
9959
+ "name": "webFunction",
9960
+ "type": {
9961
+ "fqn": "aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef"
9962
+ }
9963
+ }
9964
+ ],
9965
+ "symbolId": "src/web-function-revision:IWebFunctionRevision"
9966
+ },
9820
9967
  "@ashishpandeyone/cdk-lambda-web-function.NodejsWebFunction": {
9821
9968
  "assembly": "@ashishpandeyone/cdk-lambda-web-function",
9822
9969
  "base": "@ashishpandeyone/cdk-lambda-web-function.WebFunction",
@@ -10305,7 +10452,7 @@
10305
10452
  "custom": {
10306
10453
  "resource": "AWS::Lambda::WebFunction"
10307
10454
  },
10308
- "remarks": "Creates the function, its current revision (code and configuration; any change replaces it),\nan HTTPS endpoint, an execution role, and owns the function's log groups in every region.\n\nImporting existing functions (`fromXxx` methods) is planned after 0.1.",
10455
+ "remarks": "Creates the function, its current revision (code and configuration; any change creates a new one,\nand the newest `revisionRetention` are kept), a default HTTPS endpoint, an execution role, and owns\nthe function's log groups in every region its endpoints serve from.\n\nImporting existing functions (`fromXxx` methods) is planned after 0.1.",
10309
10456
  "stability": "experimental",
10310
10457
  "summary": "A Node.js HTTP server running as an AWS Lambda Web Function, served from one or more regions."
10311
10458
  },
@@ -10316,7 +10463,7 @@
10316
10463
  },
10317
10464
  "locationInModule": {
10318
10465
  "filename": "src/web-function.ts",
10319
- "line": 192
10466
+ "line": 221
10320
10467
  },
10321
10468
  "parameters": [
10322
10469
  {
@@ -10346,9 +10493,42 @@
10346
10493
  "kind": "class",
10347
10494
  "locationInModule": {
10348
10495
  "filename": "src/web-function.ts",
10349
- "line": 160
10496
+ "line": 180
10350
10497
  },
10351
10498
  "methods": [
10499
+ {
10500
+ "docs": {
10501
+ "stability": "experimental",
10502
+ "summary": "Adds an endpoint (up to 10 per function), e.g. a public one next to an IAM-only one, or one pinned to an earlier revision. Each endpoint has its own URL, authentication, regions and limits."
10503
+ },
10504
+ "locationInModule": {
10505
+ "filename": "src/web-function.ts",
10506
+ "line": 323
10507
+ },
10508
+ "name": "addEndpoint",
10509
+ "parameters": [
10510
+ {
10511
+ "docs": {
10512
+ "summary": "the endpoint's construct ID, also used in its generated name (`<id>-<hash>`)."
10513
+ },
10514
+ "name": "id",
10515
+ "type": {
10516
+ "primitive": "string"
10517
+ }
10518
+ },
10519
+ {
10520
+ "name": "options",
10521
+ "type": {
10522
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions"
10523
+ }
10524
+ }
10525
+ ],
10526
+ "returns": {
10527
+ "type": {
10528
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint"
10529
+ }
10530
+ }
10531
+ },
10352
10532
  {
10353
10533
  "docs": {
10354
10534
  "remarks": "Names starting with `AWS_` are reserved.",
@@ -10357,7 +10537,7 @@
10357
10537
  },
10358
10538
  "locationInModule": {
10359
10539
  "filename": "src/web-function.ts",
10360
- "line": 284
10540
+ "line": 331
10361
10541
  },
10362
10542
  "name": "addEnvironment",
10363
10543
  "parameters": [
@@ -10387,7 +10567,7 @@
10387
10567
  },
10388
10568
  "locationInModule": {
10389
10569
  "filename": "src/web-function.ts",
10390
- "line": 295
10570
+ "line": 342
10391
10571
  },
10392
10572
  "name": "addToRolePolicy",
10393
10573
  "parameters": [
@@ -10407,7 +10587,7 @@
10407
10587
  },
10408
10588
  "locationInModule": {
10409
10589
  "filename": "src/web-function.ts",
10410
- "line": 303
10590
+ "line": 350
10411
10591
  },
10412
10592
  "name": "grantInvoke",
10413
10593
  "parameters": [
@@ -10430,12 +10610,28 @@
10430
10610
  {
10431
10611
  "docs": {
10432
10612
  "stability": "experimental",
10433
- "summary": "The function's endpoint."
10613
+ "summary": "The revision built from the current code and configuration."
10614
+ },
10615
+ "immutable": true,
10616
+ "locationInModule": {
10617
+ "filename": "src/web-function.ts",
10618
+ "line": 188
10619
+ },
10620
+ "name": "currentRevision",
10621
+ "type": {
10622
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision"
10623
+ }
10624
+ },
10625
+ {
10626
+ "docs": {
10627
+ "remarks": "Add more with `addEndpoint`.",
10628
+ "stability": "experimental",
10629
+ "summary": "The default endpoint."
10434
10630
  },
10435
10631
  "immutable": true,
10436
10632
  "locationInModule": {
10437
10633
  "filename": "src/web-function.ts",
10438
- "line": 168
10634
+ "line": 191
10439
10635
  },
10440
10636
  "name": "endpoint",
10441
10637
  "type": {
@@ -10450,7 +10646,7 @@
10450
10646
  "immutable": true,
10451
10647
  "locationInModule": {
10452
10648
  "filename": "src/web-function.ts",
10453
- "line": 177
10649
+ "line": 200
10454
10650
  },
10455
10651
  "name": "grantPrincipal",
10456
10652
  "overrides": "aws-cdk-lib.aws_iam.IGrantable",
@@ -10461,12 +10657,12 @@
10461
10657
  {
10462
10658
  "docs": {
10463
10659
  "stability": "experimental",
10464
- "summary": "Grants on the function (e.g. `grants.invoke(principal)`)."
10660
+ "summary": "Grants on the default endpoint (e.g. `grants.invoke(principal)`). Other endpoints have their own `grants`."
10465
10661
  },
10466
10662
  "immutable": true,
10467
10663
  "locationInModule": {
10468
10664
  "filename": "src/web-function.ts",
10469
- "line": 171
10665
+ "line": 194
10470
10666
  },
10471
10667
  "name": "grants",
10472
10668
  "type": {
@@ -10482,7 +10678,7 @@
10482
10678
  "immutable": true,
10483
10679
  "locationInModule": {
10484
10680
  "filename": "src/web-function.ts",
10485
- "line": 183
10681
+ "line": 206
10486
10682
  },
10487
10683
  "name": "logGroup",
10488
10684
  "type": {
@@ -10491,13 +10687,14 @@
10491
10687
  },
10492
10688
  {
10493
10689
  "docs": {
10690
+ "remarks": "Same as `currentRevision.revisionId`.",
10494
10691
  "stability": "experimental",
10495
10692
  "summary": "The ID of the current revision."
10496
10693
  },
10497
10694
  "immutable": true,
10498
10695
  "locationInModule": {
10499
10696
  "filename": "src/web-function.ts",
10500
- "line": 165
10697
+ "line": 185
10501
10698
  },
10502
10699
  "name": "revisionId",
10503
10700
  "type": {
@@ -10512,7 +10709,7 @@
10512
10709
  "immutable": true,
10513
10710
  "locationInModule": {
10514
10711
  "filename": "src/web-function.ts",
10515
- "line": 174
10712
+ "line": 197
10516
10713
  },
10517
10714
  "name": "role",
10518
10715
  "type": {
@@ -10527,7 +10724,7 @@
10527
10724
  "immutable": true,
10528
10725
  "locationInModule": {
10529
10726
  "filename": "src/web-function.ts",
10530
- "line": 162
10727
+ "line": 182
10531
10728
  },
10532
10729
  "name": "webFunctionArn",
10533
10730
  "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
@@ -10543,7 +10740,7 @@
10543
10740
  "immutable": true,
10544
10741
  "locationInModule": {
10545
10742
  "filename": "src/web-function.ts",
10546
- "line": 161
10743
+ "line": 181
10547
10744
  },
10548
10745
  "name": "webFunctionName",
10549
10746
  "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
@@ -10559,7 +10756,7 @@
10559
10756
  "immutable": true,
10560
10757
  "locationInModule": {
10561
10758
  "filename": "src/web-function.ts",
10562
- "line": 188
10759
+ "line": 217
10563
10760
  },
10564
10761
  "name": "webFunctionRef",
10565
10762
  "overrides": "aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef",
@@ -10602,122 +10799,368 @@
10602
10799
  "name": "WebFunctionAuthType",
10603
10800
  "symbolId": "src/enums:WebFunctionAuthType"
10604
10801
  },
10605
- "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint": {
10802
+ "@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions": {
10606
10803
  "assembly": "@ashishpandeyone/cdk-lambda-web-function",
10607
- "base": "constructs.Construct",
10804
+ "datatype": true,
10608
10805
  "docs": {
10609
- "remarks": "Only `WebFunction` creates endpoints in this version (one per function), so the constructor is private.",
10610
10806
  "stability": "experimental",
10611
- "summary": "The HTTPS endpoint of a Web Function. Created by `WebFunction`; access it as `fn.endpoint`."
10807
+ "summary": "Options for a canary deployment."
10612
10808
  },
10613
- "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint",
10614
- "kind": "class",
10809
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions",
10810
+ "kind": "interface",
10615
10811
  "locationInModule": {
10616
- "filename": "src/web-function-endpoint.ts",
10617
- "line": 65
10812
+ "filename": "src/web-function-deployment.ts",
10813
+ "line": 12
10618
10814
  },
10619
- "methods": [
10815
+ "name": "WebFunctionCanaryDeploymentOptions",
10816
+ "properties": [
10620
10817
  {
10818
+ "abstract": true,
10621
10819
  "docs": {
10622
- "remarks": "Only for `PER_REGION` endpoints.",
10820
+ "remarks": "Make it longer than the time your alarms need to fire (period × evaluation periods).",
10623
10821
  "stability": "experimental",
10624
- "summary": "The URL of this endpoint in one region."
10822
+ "summary": "How long the new revision serves `percent` before it gets all traffic (1-45 minutes)."
10625
10823
  },
10824
+ "immutable": true,
10626
10825
  "locationInModule": {
10627
- "filename": "src/web-function-endpoint.ts",
10628
- "line": 146
10826
+ "filename": "src/web-function-deployment.ts",
10827
+ "line": 22
10629
10828
  },
10630
- "name": "regionalUrl",
10631
- "parameters": [
10632
- {
10633
- "docs": {
10634
- "summary": "one of `regions`."
10635
- },
10636
- "name": "region",
10637
- "type": {
10638
- "primitive": "string"
10639
- }
10640
- }
10641
- ],
10642
- "returns": {
10643
- "type": {
10644
- "primitive": "string"
10645
- }
10829
+ "name": "bake",
10830
+ "type": {
10831
+ "fqn": "aws-cdk-lib.Duration"
10646
10832
  }
10647
- }
10648
- ],
10649
- "name": "WebFunctionEndpoint",
10650
- "properties": [
10833
+ },
10651
10834
  {
10835
+ "abstract": true,
10652
10836
  "docs": {
10653
10837
  "stability": "experimental",
10654
- "summary": "The endpoint's domain name: the global domain for `MULTI_REGION`, otherwise the home region's."
10838
+ "summary": "The share of traffic, in whole percent (1-99), that the new revision gets first."
10655
10839
  },
10656
10840
  "immutable": true,
10657
10841
  "locationInModule": {
10658
- "filename": "src/web-function-endpoint.ts",
10659
- "line": 90
10842
+ "filename": "src/web-function-deployment.ts",
10843
+ "line": 16
10660
10844
  },
10661
- "name": "domainName",
10845
+ "name": "percent",
10662
10846
  "type": {
10663
- "primitive": "string"
10847
+ "primitive": "number"
10664
10848
  }
10665
10849
  },
10666
10850
  {
10851
+ "abstract": true,
10667
10852
  "docs": {
10853
+ "default": "- no alarms: traffic moves on a timer",
10854
+ "remarks": "They're checked before traffic moves, during the bake, and once the new revision has all traffic.\nUse alarms in any region (by ARN), including composite alarms.",
10668
10855
  "stability": "experimental",
10669
- "summary": "The endpoint's ARN."
10856
+ "summary": "Alarms that stop the deployment: if one is in ALARM, the endpoint goes back to the previous revision and the deployment fails, so CloudFormation rolls the stack back."
10670
10857
  },
10671
10858
  "immutable": true,
10672
10859
  "locationInModule": {
10673
- "filename": "src/web-function-endpoint.ts",
10674
- "line": 79
10860
+ "filename": "src/web-function-deployment.ts",
10861
+ "line": 33
10675
10862
  },
10676
- "name": "endpointArn",
10863
+ "name": "alarms",
10864
+ "optional": true,
10677
10865
  "type": {
10678
- "primitive": "string"
10866
+ "collection": {
10867
+ "elementtype": {
10868
+ "fqn": "aws-cdk-lib.aws_cloudwatch.IAlarm"
10869
+ },
10870
+ "kind": "array"
10871
+ }
10679
10872
  }
10680
- },
10873
+ }
10874
+ ],
10875
+ "symbolId": "src/web-function-deployment:WebFunctionCanaryDeploymentOptions"
10876
+ },
10877
+ "@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment": {
10878
+ "assembly": "@ashishpandeyone/cdk-lambda-web-function",
10879
+ "docs": {
10880
+ "stability": "experimental",
10881
+ "summary": "How an endpoint moves its traffic to a new revision."
10882
+ },
10883
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment",
10884
+ "kind": "class",
10885
+ "locationInModule": {
10886
+ "filename": "src/web-function-deployment.ts",
10887
+ "line": 65
10888
+ },
10889
+ "methods": [
10681
10890
  {
10682
10891
  "docs": {
10683
10892
  "stability": "experimental",
10684
- "summary": "The endpoint's name."
10893
+ "summary": "All traffic moves to the new revision at once, as soon as it's ready (the default)."
10685
10894
  },
10686
- "immutable": true,
10687
10895
  "locationInModule": {
10688
- "filename": "src/web-function-endpoint.ts",
10689
- "line": 76
10896
+ "filename": "src/web-function-deployment.ts",
10897
+ "line": 69
10690
10898
  },
10691
- "name": "endpointName",
10692
- "type": {
10693
- "primitive": "string"
10694
- }
10899
+ "name": "allAtOnce",
10900
+ "returns": {
10901
+ "type": {
10902
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment"
10903
+ }
10904
+ },
10905
+ "static": true
10695
10906
  },
10696
10907
  {
10697
10908
  "docs": {
10698
10909
  "stability": "experimental",
10699
- "summary": "Where the endpoint serves traffic from."
10910
+ "summary": "The new revision first gets `percent` of the traffic for `bake`, then all of it."
10700
10911
  },
10701
- "immutable": true,
10702
10912
  "locationInModule": {
10703
- "filename": "src/web-function-endpoint.ts",
10704
- "line": 82
10913
+ "filename": "src/web-function-deployment.ts",
10914
+ "line": 76
10705
10915
  },
10706
- "name": "endpointType",
10707
- "type": {
10708
- "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointType"
10709
- }
10916
+ "name": "canary",
10917
+ "parameters": [
10918
+ {
10919
+ "name": "options",
10920
+ "type": {
10921
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions"
10922
+ }
10923
+ }
10924
+ ],
10925
+ "returns": {
10926
+ "type": {
10927
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment"
10928
+ }
10929
+ },
10930
+ "static": true
10710
10931
  },
10711
10932
  {
10712
10933
  "docs": {
10713
10934
  "stability": "experimental",
10714
- "summary": "Every region the endpoint serves from: the home region first, then the others in alphabetical order."
10935
+ "summary": "The new revision gets `percent` more of the traffic every `interval` until it has all of it."
10715
10936
  },
10716
- "immutable": true,
10717
10937
  "locationInModule": {
10718
- "filename": "src/web-function-endpoint.ts",
10938
+ "filename": "src/web-function-deployment.ts",
10719
10939
  "line": 85
10720
10940
  },
10941
+ "name": "linear",
10942
+ "parameters": [
10943
+ {
10944
+ "name": "options",
10945
+ "type": {
10946
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions"
10947
+ }
10948
+ }
10949
+ ],
10950
+ "returns": {
10951
+ "type": {
10952
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment"
10953
+ }
10954
+ },
10955
+ "static": true
10956
+ }
10957
+ ],
10958
+ "name": "WebFunctionDeployment",
10959
+ "symbolId": "src/web-function-deployment:WebFunctionDeployment"
10960
+ },
10961
+ "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint": {
10962
+ "assembly": "@ashishpandeyone/cdk-lambda-web-function",
10963
+ "base": "constructs.Construct",
10964
+ "docs": {
10965
+ "remarks": "Endpoints are created only through `WebFunction`, which owns their log groups in every region, so the constructor is private.",
10966
+ "stability": "experimental",
10967
+ "summary": "An HTTPS endpoint of a Web Function: `fn.endpoint` (the default one) or the result of `fn.addEndpoint()`."
10968
+ },
10969
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint",
10970
+ "kind": "class",
10971
+ "locationInModule": {
10972
+ "filename": "src/web-function-endpoint.ts",
10973
+ "line": 150
10974
+ },
10975
+ "methods": [
10976
+ {
10977
+ "docs": {
10978
+ "remarks": "Shortcut for `grants.invoke(grantee)`.\n[disable-awslint:no-grants]",
10979
+ "stability": "experimental",
10980
+ "summary": "Allows `grantee` to call this endpoint."
10981
+ },
10982
+ "locationInModule": {
10983
+ "filename": "src/web-function-endpoint.ts",
10984
+ "line": 328
10985
+ },
10986
+ "name": "grantInvoke",
10987
+ "parameters": [
10988
+ {
10989
+ "name": "grantee",
10990
+ "type": {
10991
+ "fqn": "aws-cdk-lib.aws_iam.IGrantable"
10992
+ }
10993
+ }
10994
+ ],
10995
+ "returns": {
10996
+ "type": {
10997
+ "fqn": "aws-cdk-lib.aws_iam.Grant"
10998
+ }
10999
+ }
11000
+ },
11001
+ {
11002
+ "docs": {
11003
+ "remarks": "Only for `PER_REGION` endpoints.",
11004
+ "stability": "experimental",
11005
+ "summary": "The URL of this endpoint in one region."
11006
+ },
11007
+ "locationInModule": {
11008
+ "filename": "src/web-function-endpoint.ts",
11009
+ "line": 275
11010
+ },
11011
+ "name": "regionalUrl",
11012
+ "parameters": [
11013
+ {
11014
+ "docs": {
11015
+ "summary": "one of `regions`."
11016
+ },
11017
+ "name": "region",
11018
+ "type": {
11019
+ "primitive": "string"
11020
+ }
11021
+ }
11022
+ ],
11023
+ "returns": {
11024
+ "type": {
11025
+ "primitive": "string"
11026
+ }
11027
+ }
11028
+ },
11029
+ {
11030
+ "docs": {
11031
+ "remarks": "`revision` gets the rest).\n\nUse it to keep an endpoint on an earlier revision (`WebFunctionRevision.fromRevisionAttributes`),\nor to send part of the traffic to the current revision:\n`fn.endpoint.routeTraffic(previous, [{ revision: fn.currentRevision, weight: 0.1 }])`.\nCan be called once per endpoint, and not on one created with `revision` or `additionalRevisions`.",
11032
+ "stability": "experimental",
11033
+ "summary": "Routes the endpoint to `revision` instead of the function's current revision, optionally sharing traffic with one more revision (`additionalRevisions`, which gets its weight;"
11034
+ },
11035
+ "locationInModule": {
11036
+ "filename": "src/web-function-endpoint.ts",
11037
+ "line": 303
11038
+ },
11039
+ "name": "routeTraffic",
11040
+ "parameters": [
11041
+ {
11042
+ "name": "revision",
11043
+ "type": {
11044
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision"
11045
+ }
11046
+ },
11047
+ {
11048
+ "name": "additionalRevisions",
11049
+ "optional": true,
11050
+ "type": {
11051
+ "collection": {
11052
+ "elementtype": {
11053
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight"
11054
+ },
11055
+ "kind": "array"
11056
+ }
11057
+ }
11058
+ }
11059
+ ]
11060
+ }
11061
+ ],
11062
+ "name": "WebFunctionEndpoint",
11063
+ "properties": [
11064
+ {
11065
+ "docs": {
11066
+ "stability": "experimental",
11067
+ "summary": "How callers of the endpoint are authenticated."
11068
+ },
11069
+ "immutable": true,
11070
+ "locationInModule": {
11071
+ "filename": "src/web-function-endpoint.ts",
11072
+ "line": 170
11073
+ },
11074
+ "name": "authType",
11075
+ "type": {
11076
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType"
11077
+ }
11078
+ },
11079
+ {
11080
+ "docs": {
11081
+ "stability": "experimental",
11082
+ "summary": "The endpoint's domain name: the global domain for `MULTI_REGION`, otherwise the home region's."
11083
+ },
11084
+ "immutable": true,
11085
+ "locationInModule": {
11086
+ "filename": "src/web-function-endpoint.ts",
11087
+ "line": 178
11088
+ },
11089
+ "name": "domainName",
11090
+ "type": {
11091
+ "primitive": "string"
11092
+ }
11093
+ },
11094
+ {
11095
+ "docs": {
11096
+ "stability": "experimental",
11097
+ "summary": "The endpoint's ARN."
11098
+ },
11099
+ "immutable": true,
11100
+ "locationInModule": {
11101
+ "filename": "src/web-function-endpoint.ts",
11102
+ "line": 164
11103
+ },
11104
+ "name": "endpointArn",
11105
+ "type": {
11106
+ "primitive": "string"
11107
+ }
11108
+ },
11109
+ {
11110
+ "docs": {
11111
+ "stability": "experimental",
11112
+ "summary": "The endpoint's name."
11113
+ },
11114
+ "immutable": true,
11115
+ "locationInModule": {
11116
+ "filename": "src/web-function-endpoint.ts",
11117
+ "line": 161
11118
+ },
11119
+ "name": "endpointName",
11120
+ "type": {
11121
+ "primitive": "string"
11122
+ }
11123
+ },
11124
+ {
11125
+ "docs": {
11126
+ "stability": "experimental",
11127
+ "summary": "Where the endpoint serves traffic from."
11128
+ },
11129
+ "immutable": true,
11130
+ "locationInModule": {
11131
+ "filename": "src/web-function-endpoint.ts",
11132
+ "line": 167
11133
+ },
11134
+ "name": "endpointType",
11135
+ "type": {
11136
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointType"
11137
+ }
11138
+ },
11139
+ {
11140
+ "docs": {
11141
+ "stability": "experimental",
11142
+ "summary": "Grants on this endpoint (e.g. `grants.invoke(principal)`)."
11143
+ },
11144
+ "immutable": true,
11145
+ "locationInModule": {
11146
+ "filename": "src/web-function-endpoint.ts",
11147
+ "line": 186
11148
+ },
11149
+ "name": "grants",
11150
+ "type": {
11151
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants"
11152
+ }
11153
+ },
11154
+ {
11155
+ "docs": {
11156
+ "stability": "experimental",
11157
+ "summary": "Every region the endpoint serves from: the home region first, then the others in alphabetical order."
11158
+ },
11159
+ "immutable": true,
11160
+ "locationInModule": {
11161
+ "filename": "src/web-function-endpoint.ts",
11162
+ "line": 173
11163
+ },
10721
11164
  "name": "regions",
10722
11165
  "type": {
10723
11166
  "collection": {
@@ -10736,7 +11179,7 @@
10736
11179
  "immutable": true,
10737
11180
  "locationInModule": {
10738
11181
  "filename": "src/web-function-endpoint.ts",
10739
- "line": 95
11182
+ "line": 183
10740
11183
  },
10741
11184
  "name": "url",
10742
11185
  "type": {
@@ -10757,22 +11200,59 @@
10757
11200
  "kind": "interface",
10758
11201
  "locationInModule": {
10759
11202
  "filename": "src/web-function-endpoint.ts",
10760
- "line": 12
11203
+ "line": 32
10761
11204
  },
10762
11205
  "name": "WebFunctionEndpointOptions",
10763
11206
  "properties": [
10764
11207
  {
10765
11208
  "abstract": true,
10766
11209
  "docs": {
10767
- "default": "- `default-<hash of type and regions>`",
10768
- "remarks": "When omitted, the name is `default-<hash>`, with the hash covering the endpoint type and regions,\nso changing either deploys a new endpoint cleanly. When set, changing the endpoint type or\nregions also requires a new name: two endpoints of one function can't share a name, and\nCloudFormation creates the replacement before deleting the old one.",
11210
+ "default": "WebFunctionDeployment.allAtOnce()",
11211
+ "remarks": "A deployment in steps can't be combined with `revision`, `additionalRevisions` or `routeTraffic()`.",
10769
11212
  "stability": "experimental",
10770
- "summary": "The endpoint's name, shown in logs (`endpointName`) and in the `lambda-web-endpoint-name` header."
11213
+ "summary": "How the endpoint moves its traffic to a new revision: all at once, or in steps (`WebFunctionDeployment.canary()` or `linear()`) that watch CloudWatch alarms and move the traffic back when one goes into ALARM."
10771
11214
  },
10772
11215
  "immutable": true,
10773
11216
  "locationInModule": {
10774
11217
  "filename": "src/web-function-endpoint.ts",
10775
- "line": 40
11218
+ "line": 99
11219
+ },
11220
+ "name": "deployment",
11221
+ "optional": true,
11222
+ "type": {
11223
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionDeployment"
11224
+ }
11225
+ },
11226
+ {
11227
+ "abstract": true,
11228
+ "docs": {
11229
+ "default": "- no description",
11230
+ "stability": "experimental",
11231
+ "summary": "A description of the endpoint."
11232
+ },
11233
+ "immutable": true,
11234
+ "locationInModule": {
11235
+ "filename": "src/web-function-endpoint.ts",
11236
+ "line": 68
11237
+ },
11238
+ "name": "description",
11239
+ "optional": true,
11240
+ "type": {
11241
+ "primitive": "string"
11242
+ }
11243
+ },
11244
+ {
11245
+ "abstract": true,
11246
+ "docs": {
11247
+ "default": "- `default-<hash>` for the function's default endpoint, `<id>-<hash>` for endpoints added with `addEndpoint`",
11248
+ "remarks": "When omitted, the name ends in a hash of the endpoint type and regions, so changing either deploys\na new endpoint cleanly. When set, changing the endpoint type or regions also requires a new name:\ntwo endpoints of one function can't share a name, and CloudFormation creates the replacement\nbefore deleting the old one.",
11249
+ "stability": "experimental",
11250
+ "summary": "The endpoint's name, shown in logs (`endpointName`) and in the `lambda-web-endpoint-name` header. Names are unique per function."
11251
+ },
11252
+ "immutable": true,
11253
+ "locationInModule": {
11254
+ "filename": "src/web-function-endpoint.ts",
11255
+ "line": 61
10776
11256
  },
10777
11257
  "name": "endpointName",
10778
11258
  "optional": true,
@@ -10790,7 +11270,7 @@
10790
11270
  "immutable": true,
10791
11271
  "locationInModule": {
10792
11272
  "filename": "src/web-function-endpoint.ts",
10793
- "line": 18
11273
+ "line": 38
10794
11274
  },
10795
11275
  "name": "endpointType",
10796
11276
  "optional": true,
@@ -10798,6 +11278,44 @@
10798
11278
  "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpointType"
10799
11279
  }
10800
11280
  },
11281
+ {
11282
+ "abstract": true,
11283
+ "docs": {
11284
+ "default": "- scales within the account's vCPU quota",
11285
+ "remarks": "Enforced separately in each region the endpoint serves from.",
11286
+ "stability": "experimental",
11287
+ "summary": "The most execution environments the endpoint may use (2–10,000). Each one uses 2 vCPUs of the account's quota."
11288
+ },
11289
+ "immutable": true,
11290
+ "locationInModule": {
11291
+ "filename": "src/web-function-endpoint.ts",
11292
+ "line": 88
11293
+ },
11294
+ "name": "maxEnvironments",
11295
+ "optional": true,
11296
+ "type": {
11297
+ "primitive": "number"
11298
+ }
11299
+ },
11300
+ {
11301
+ "abstract": true,
11302
+ "docs": {
11303
+ "default": "- no limit beyond the service quota of 10,000 requests per second per endpoint (per region)",
11304
+ "remarks": "excess requests get HTTP 429.\nAllowed: 0 (blocks all traffic), 100–1,000 in steps of 100, or 2,000–10,000 in steps of 1,000.\n\nEnforced separately in each region the endpoint serves from, so a multi-region endpoint\ncan accept this many requests per second in every region.",
11305
+ "stability": "experimental",
11306
+ "summary": "The most requests per second the endpoint accepts;"
11307
+ },
11308
+ "immutable": true,
11309
+ "locationInModule": {
11310
+ "filename": "src/web-function-endpoint.ts",
11311
+ "line": 79
11312
+ },
11313
+ "name": "rateLimit",
11314
+ "optional": true,
11315
+ "type": {
11316
+ "primitive": "number"
11317
+ }
11318
+ },
10801
11319
  {
10802
11320
  "abstract": true,
10803
11321
  "docs": {
@@ -10809,7 +11327,7 @@
10809
11327
  "immutable": true,
10810
11328
  "locationInModule": {
10811
11329
  "filename": "src/web-function-endpoint.ts",
10812
- "line": 28
11330
+ "line": 48
10813
11331
  },
10814
11332
  "name": "regions",
10815
11333
  "optional": true,
@@ -10866,9 +11384,9 @@
10866
11384
  "@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants": {
10867
11385
  "assembly": "@ashishpandeyone/cdk-lambda-web-function",
10868
11386
  "docs": {
10869
- "remarks": "Access it as `fn.grants`.",
11387
+ "remarks": "Access them as `fn.grants` (the default endpoint) or `endpoint.grants`.",
10870
11388
  "stability": "experimental",
10871
- "summary": "Grants on a Web Function."
11389
+ "summary": "Grants on a Web Function endpoint."
10872
11390
  },
10873
11391
  "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants",
10874
11392
  "kind": "class",
@@ -10881,7 +11399,7 @@
10881
11399
  "docs": {
10882
11400
  "remarks": "The grant is on the endpoint's home-region ARN, which IAM evaluates for every region the\nendpoint serves from, including a MULTI_REGION global URL.",
10883
11401
  "stability": "experimental",
10884
- "summary": "Allows `grantee` to call the function's endpoint (`lambda:InvokeWebFunctionEndpoint`)."
11402
+ "summary": "Allows `grantee` to call the endpoint (`lambda:InvokeWebFunctionEndpoint`)."
10885
11403
  },
10886
11404
  "locationInModule": {
10887
11405
  "filename": "src/web-function-grants.ts",
@@ -10906,6 +11424,80 @@
10906
11424
  "name": "WebFunctionGrants",
10907
11425
  "symbolId": "src/web-function-grants:WebFunctionGrants"
10908
11426
  },
11427
+ "@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions": {
11428
+ "assembly": "@ashishpandeyone/cdk-lambda-web-function",
11429
+ "datatype": true,
11430
+ "docs": {
11431
+ "stability": "experimental",
11432
+ "summary": "Options for a linear deployment."
11433
+ },
11434
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionLinearDeploymentOptions",
11435
+ "kind": "interface",
11436
+ "locationInModule": {
11437
+ "filename": "src/web-function-deployment.ts",
11438
+ "line": 39
11439
+ },
11440
+ "name": "WebFunctionLinearDeploymentOptions",
11441
+ "properties": [
11442
+ {
11443
+ "abstract": true,
11444
+ "docs": {
11445
+ "stability": "experimental",
11446
+ "summary": "How long each step serves before the next one (at least 1 minute, and at most 45 minutes in total)."
11447
+ },
11448
+ "immutable": true,
11449
+ "locationInModule": {
11450
+ "filename": "src/web-function-deployment.ts",
11451
+ "line": 48
11452
+ },
11453
+ "name": "interval",
11454
+ "type": {
11455
+ "fqn": "aws-cdk-lib.Duration"
11456
+ }
11457
+ },
11458
+ {
11459
+ "abstract": true,
11460
+ "docs": {
11461
+ "stability": "experimental",
11462
+ "summary": "The share of traffic, in whole percent (5-50), that moves to the new revision at each step."
11463
+ },
11464
+ "immutable": true,
11465
+ "locationInModule": {
11466
+ "filename": "src/web-function-deployment.ts",
11467
+ "line": 43
11468
+ },
11469
+ "name": "percent",
11470
+ "type": {
11471
+ "primitive": "number"
11472
+ }
11473
+ },
11474
+ {
11475
+ "abstract": true,
11476
+ "docs": {
11477
+ "default": "- no alarms: traffic moves on a timer",
11478
+ "remarks": "They're checked before traffic moves, during every step, and once the new revision has all traffic.\nUse alarms in any region (by ARN), including composite alarms.",
11479
+ "stability": "experimental",
11480
+ "summary": "Alarms that stop the deployment: if one is in ALARM, the endpoint goes back to the previous revision and the deployment fails, so CloudFormation rolls the stack back."
11481
+ },
11482
+ "immutable": true,
11483
+ "locationInModule": {
11484
+ "filename": "src/web-function-deployment.ts",
11485
+ "line": 59
11486
+ },
11487
+ "name": "alarms",
11488
+ "optional": true,
11489
+ "type": {
11490
+ "collection": {
11491
+ "elementtype": {
11492
+ "fqn": "aws-cdk-lib.aws_cloudwatch.IAlarm"
11493
+ },
11494
+ "kind": "array"
11495
+ }
11496
+ }
11497
+ }
11498
+ ],
11499
+ "symbolId": "src/web-function-deployment:WebFunctionLinearDeploymentOptions"
11500
+ },
10909
11501
  "@ashishpandeyone/cdk-lambda-web-function.WebFunctionOptions": {
10910
11502
  "assembly": "@ashishpandeyone/cdk-lambda-web-function",
10911
11503
  "datatype": true,
@@ -10917,7 +11509,7 @@
10917
11509
  "kind": "interface",
10918
11510
  "locationInModule": {
10919
11511
  "filename": "src/web-function.ts",
10920
- "line": 16
11512
+ "line": 21
10921
11513
  },
10922
11514
  "name": "WebFunctionOptions",
10923
11515
  "properties": [
@@ -10930,7 +11522,7 @@
10930
11522
  "immutable": true,
10931
11523
  "locationInModule": {
10932
11524
  "filename": "src/web-function.ts",
10933
- "line": 20
11525
+ "line": 25
10934
11526
  },
10935
11527
  "name": "authType",
10936
11528
  "type": {
@@ -10947,7 +11539,7 @@
10947
11539
  "immutable": true,
10948
11540
  "locationInModule": {
10949
11541
  "filename": "src/web-function.ts",
10950
- "line": 95
11542
+ "line": 114
10951
11543
  },
10952
11544
  "name": "applicationLogLevelV2",
10953
11545
  "optional": true,
@@ -10965,7 +11557,7 @@
10965
11557
  "immutable": true,
10966
11558
  "locationInModule": {
10967
11559
  "filename": "src/web-function.ts",
10968
- "line": 41
11560
+ "line": 60
10969
11561
  },
10970
11562
  "name": "description",
10971
11563
  "optional": true,
@@ -10976,14 +11568,14 @@
10976
11568
  {
10977
11569
  "abstract": true,
10978
11570
  "docs": {
10979
- "default": "- a HOME_REGION endpoint",
11571
+ "default": "- a HOME_REGION endpoint serving the current revision",
10980
11572
  "stability": "experimental",
10981
- "summary": "The endpoint: where it serves from, and its name."
11573
+ "summary": "The default endpoint (`fn.endpoint`): where it serves from, its name and limits. It serves the current revision; route it elsewhere with `fn.endpoint.routeTraffic()`. Add more endpoints with `addEndpoint`."
10982
11574
  },
10983
11575
  "immutable": true,
10984
11576
  "locationInModule": {
10985
11577
  "filename": "src/web-function.ts",
10986
- "line": 27
11578
+ "line": 34
10987
11579
  },
10988
11580
  "name": "endpoint",
10989
11581
  "optional": true,
@@ -11002,7 +11594,7 @@
11002
11594
  "immutable": true,
11003
11595
  "locationInModule": {
11004
11596
  "filename": "src/web-function.ts",
11005
- "line": 58
11597
+ "line": 77
11006
11598
  },
11007
11599
  "name": "environment",
11008
11600
  "optional": true,
@@ -11026,7 +11618,7 @@
11026
11618
  "immutable": true,
11027
11619
  "locationInModule": {
11028
11620
  "filename": "src/web-function.ts",
11029
- "line": 88
11621
+ "line": 107
11030
11622
  },
11031
11623
  "name": "logRemovalPolicy",
11032
11624
  "optional": true,
@@ -11044,7 +11636,7 @@
11044
11636
  "immutable": true,
11045
11637
  "locationInModule": {
11046
11638
  "filename": "src/web-function.ts",
11047
- "line": 80
11639
+ "line": 99
11048
11640
  },
11049
11641
  "name": "logRetention",
11050
11642
  "optional": true,
@@ -11063,7 +11655,7 @@
11063
11655
  "immutable": true,
11064
11656
  "locationInModule": {
11065
11657
  "filename": "src/web-function.ts",
11066
- "line": 73
11658
+ "line": 92
11067
11659
  },
11068
11660
  "name": "maxConcurrencyPerEnvironment",
11069
11661
  "optional": true,
@@ -11071,6 +11663,25 @@
11071
11663
  "primitive": "number"
11072
11664
  }
11073
11665
  },
11666
+ {
11667
+ "abstract": true,
11668
+ "docs": {
11669
+ "default": "20",
11670
+ "remarks": "Each deployment that changes the code or\nconfiguration creates a revision; older ones stay available to roll back to or route traffic to,\nand the oldest beyond this count are deleted after each deployment.\n\nRevisions that an endpoint routes to are never deleted, and neither are those the previous\ndeployment used (a rollback returns to them).",
11671
+ "stability": "experimental",
11672
+ "summary": "How many of the newest revisions to keep (1-50)."
11673
+ },
11674
+ "immutable": true,
11675
+ "locationInModule": {
11676
+ "filename": "src/web-function.ts",
11677
+ "line": 46
11678
+ },
11679
+ "name": "revisionRetention",
11680
+ "optional": true,
11681
+ "type": {
11682
+ "primitive": "number"
11683
+ }
11684
+ },
11074
11685
  {
11075
11686
  "abstract": true,
11076
11687
  "docs": {
@@ -11082,7 +11693,7 @@
11082
11693
  "immutable": true,
11083
11694
  "locationInModule": {
11084
11695
  "filename": "src/web-function.ts",
11085
- "line": 51
11696
+ "line": 70
11086
11697
  },
11087
11698
  "name": "role",
11088
11699
  "optional": true,
@@ -11100,7 +11711,7 @@
11100
11711
  "immutable": true,
11101
11712
  "locationInModule": {
11102
11713
  "filename": "src/web-function.ts",
11103
- "line": 102
11714
+ "line": 121
11104
11715
  },
11105
11716
  "name": "systemLogLevelV2",
11106
11717
  "optional": true,
@@ -11118,7 +11729,7 @@
11118
11729
  "immutable": true,
11119
11730
  "locationInModule": {
11120
11731
  "filename": "src/web-function.ts",
11121
- "line": 65
11732
+ "line": 84
11122
11733
  },
11123
11734
  "name": "timeout",
11124
11735
  "optional": true,
@@ -11137,7 +11748,7 @@
11137
11748
  "immutable": true,
11138
11749
  "locationInModule": {
11139
11750
  "filename": "src/web-function.ts",
11140
- "line": 34
11751
+ "line": 53
11141
11752
  },
11142
11753
  "name": "webFunctionName",
11143
11754
  "optional": true,
@@ -11162,7 +11773,7 @@
11162
11773
  "kind": "interface",
11163
11774
  "locationInModule": {
11164
11775
  "filename": "src/web-function.ts",
11165
- "line": 108
11776
+ "line": 127
11166
11777
  },
11167
11778
  "name": "WebFunctionProps",
11168
11779
  "properties": [
@@ -11176,7 +11787,7 @@
11176
11787
  "immutable": true,
11177
11788
  "locationInModule": {
11178
11789
  "filename": "src/web-function.ts",
11179
- "line": 120
11790
+ "line": 139
11180
11791
  },
11181
11792
  "name": "code",
11182
11793
  "type": {
@@ -11192,7 +11803,7 @@
11192
11803
  "immutable": true,
11193
11804
  "locationInModule": {
11194
11805
  "filename": "src/web-function.ts",
11195
- "line": 112
11806
+ "line": 131
11196
11807
  },
11197
11808
  "name": "runtime",
11198
11809
  "type": {
@@ -11209,7 +11820,7 @@
11209
11820
  "immutable": true,
11210
11821
  "locationInModule": {
11211
11822
  "filename": "src/web-function.ts",
11212
- "line": 127
11823
+ "line": 146
11213
11824
  },
11214
11825
  "name": "entrypoint",
11215
11826
  "optional": true,
@@ -11219,8 +11830,217 @@
11219
11830
  }
11220
11831
  ],
11221
11832
  "symbolId": "src/web-function:WebFunctionProps"
11833
+ },
11834
+ "@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision": {
11835
+ "assembly": "@ashishpandeyone/cdk-lambda-web-function",
11836
+ "base": "constructs.Construct",
11837
+ "docs": {
11838
+ "remarks": "`WebFunction` creates its current revision (`fn.currentRevision`) from its code and configuration.\nUse `fromRevisionAttributes` to route an endpoint to an earlier one, which must still exist:\nonly revisions within `revisionRetention`, or that an endpoint routes to, are kept.",
11839
+ "stability": "experimental",
11840
+ "summary": "A revision of a Web Function."
11841
+ },
11842
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevision",
11843
+ "interfaces": [
11844
+ "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision"
11845
+ ],
11846
+ "kind": "class",
11847
+ "locationInModule": {
11848
+ "filename": "src/web-function-revision.ts",
11849
+ "line": 36
11850
+ },
11851
+ "methods": [
11852
+ {
11853
+ "docs": {
11854
+ "stability": "experimental",
11855
+ "summary": "References an existing revision of `webFunction`, e.g. to pin an endpoint to it or split traffic with it."
11856
+ },
11857
+ "locationInModule": {
11858
+ "filename": "src/web-function-revision.ts",
11859
+ "line": 40
11860
+ },
11861
+ "name": "fromRevisionAttributes",
11862
+ "parameters": [
11863
+ {
11864
+ "name": "scope",
11865
+ "type": {
11866
+ "fqn": "constructs.Construct"
11867
+ }
11868
+ },
11869
+ {
11870
+ "name": "id",
11871
+ "type": {
11872
+ "primitive": "string"
11873
+ }
11874
+ },
11875
+ {
11876
+ "name": "attrs",
11877
+ "type": {
11878
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionAttributes"
11879
+ }
11880
+ }
11881
+ ],
11882
+ "returns": {
11883
+ "type": {
11884
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision"
11885
+ }
11886
+ },
11887
+ "static": true
11888
+ }
11889
+ ],
11890
+ "name": "WebFunctionRevision",
11891
+ "properties": [
11892
+ {
11893
+ "docs": {
11894
+ "stability": "experimental",
11895
+ "summary": "The revision's ARN."
11896
+ },
11897
+ "immutable": true,
11898
+ "locationInModule": {
11899
+ "filename": "src/web-function-revision.ts",
11900
+ "line": 57
11901
+ },
11902
+ "name": "revisionArn",
11903
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision",
11904
+ "type": {
11905
+ "primitive": "string"
11906
+ }
11907
+ },
11908
+ {
11909
+ "docs": {
11910
+ "stability": "experimental",
11911
+ "summary": "The revision's ID, e.g. `rev-a1b2c`."
11912
+ },
11913
+ "immutable": true,
11914
+ "locationInModule": {
11915
+ "filename": "src/web-function-revision.ts",
11916
+ "line": 56
11917
+ },
11918
+ "name": "revisionId",
11919
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision",
11920
+ "type": {
11921
+ "primitive": "string"
11922
+ }
11923
+ },
11924
+ {
11925
+ "docs": {
11926
+ "stability": "experimental",
11927
+ "summary": "The function the revision belongs to."
11928
+ },
11929
+ "immutable": true,
11930
+ "locationInModule": {
11931
+ "filename": "src/web-function-revision.ts",
11932
+ "line": 55
11933
+ },
11934
+ "name": "webFunction",
11935
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision",
11936
+ "type": {
11937
+ "fqn": "aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef"
11938
+ }
11939
+ }
11940
+ ],
11941
+ "symbolId": "src/web-function-revision:WebFunctionRevision"
11942
+ },
11943
+ "@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionAttributes": {
11944
+ "assembly": "@ashishpandeyone/cdk-lambda-web-function",
11945
+ "datatype": true,
11946
+ "docs": {
11947
+ "stability": "experimental",
11948
+ "summary": "Attributes of an existing revision."
11949
+ },
11950
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionAttributes",
11951
+ "kind": "interface",
11952
+ "locationInModule": {
11953
+ "filename": "src/web-function-revision.ts",
11954
+ "line": 21
11955
+ },
11956
+ "name": "WebFunctionRevisionAttributes",
11957
+ "properties": [
11958
+ {
11959
+ "abstract": true,
11960
+ "docs": {
11961
+ "stability": "experimental",
11962
+ "summary": "The revision's ID, e.g. `rev-a1b2c` (the `revisionId` of an earlier deployment)."
11963
+ },
11964
+ "immutable": true,
11965
+ "locationInModule": {
11966
+ "filename": "src/web-function-revision.ts",
11967
+ "line": 26
11968
+ },
11969
+ "name": "revisionId",
11970
+ "type": {
11971
+ "primitive": "string"
11972
+ }
11973
+ },
11974
+ {
11975
+ "abstract": true,
11976
+ "docs": {
11977
+ "stability": "experimental",
11978
+ "summary": "The function the revision belongs to."
11979
+ },
11980
+ "immutable": true,
11981
+ "locationInModule": {
11982
+ "filename": "src/web-function-revision.ts",
11983
+ "line": 23
11984
+ },
11985
+ "name": "webFunction",
11986
+ "type": {
11987
+ "fqn": "aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef"
11988
+ }
11989
+ }
11990
+ ],
11991
+ "symbolId": "src/web-function-revision:WebFunctionRevisionAttributes"
11992
+ },
11993
+ "@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight": {
11994
+ "assembly": "@ashishpandeyone/cdk-lambda-web-function",
11995
+ "datatype": true,
11996
+ "docs": {
11997
+ "stability": "experimental",
11998
+ "summary": "A revision and the share of an endpoint's traffic it receives."
11999
+ },
12000
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionRevisionWeight",
12001
+ "kind": "interface",
12002
+ "locationInModule": {
12003
+ "filename": "src/web-function-endpoint.ts",
12004
+ "line": 18
12005
+ },
12006
+ "name": "WebFunctionRevisionWeight",
12007
+ "properties": [
12008
+ {
12009
+ "abstract": true,
12010
+ "docs": {
12011
+ "stability": "experimental",
12012
+ "summary": "The revision."
12013
+ },
12014
+ "immutable": true,
12015
+ "locationInModule": {
12016
+ "filename": "src/web-function-endpoint.ts",
12017
+ "line": 20
12018
+ },
12019
+ "name": "revision",
12020
+ "type": {
12021
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision"
12022
+ }
12023
+ },
12024
+ {
12025
+ "abstract": true,
12026
+ "docs": {
12027
+ "stability": "experimental",
12028
+ "summary": "The revision's share of the endpoint's traffic, as a fraction (like `lambda.Alias` `additionalVersions`). Must be a whole percentage from 0.01 to 0.99."
12029
+ },
12030
+ "immutable": true,
12031
+ "locationInModule": {
12032
+ "filename": "src/web-function-endpoint.ts",
12033
+ "line": 26
12034
+ },
12035
+ "name": "weight",
12036
+ "type": {
12037
+ "primitive": "number"
12038
+ }
12039
+ }
12040
+ ],
12041
+ "symbolId": "src/web-function-endpoint:WebFunctionRevisionWeight"
11222
12042
  }
11223
12043
  },
11224
- "version": "0.1.1",
11225
- "fingerprint": "ft/zQrWlxxNtDAXuxZWYBBawuxOtM3nKh3Fy62u1HaY="
12044
+ "version": "0.1.2",
12045
+ "fingerprint": "klXX+MmGau/7IlYuQHB50VIISLQsvsWWTDfCXLEc9FQ="
11226
12046
  }