@ashishpandeyone/cdk-lambda-web-function 0.1.3 → 0.1.4

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 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\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; back if more than 2% of requests get a 5XX.\n deployment: WebFunctionDeployment.canary({ percent: 10, bake: Duration.minutes(10), rollbackOn: { serverErrorRate: 2 } }),\n },\n});\n\n// 25% more every 5 minutes, watching an alarm of your own. Each endpoint has its own deployment.\n// errorRate: any cloudwatch.IAlarm, e.g. on a metric your application publishes.\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\n#### Rollback alarms\n\n`rollbackOn` makes the endpoint create alarms on its own error rates, and the deployment watches them alongside any `alarms` you pass:\n\n| `rollbackOn` | Default | |\n|---|---|---|\n| `serverErrorRate` | none | roll back when more than this % of requests get a 5XX |\n| `clientErrorRate` | none | the same for 4XX (including 429s from `rateLimit` and `maxEnvironments`) |\n| `minimumRequests` | 10 | periods with fewer requests don't count, so one failed request out of two doesn't roll back |\n| `period`, `evaluationPeriods` | 1 minute, 2 | consecutive periods over the threshold before rolling back |\n\n- **One alarm per threshold in every region the endpoint serves from.** Metrics are published in the region that served the request, and an alarm can only watch metrics in its own region. The home region's alarm is a normal CloudFormation alarm; the others are created and deleted with the endpoint by a custom resource, and named `LambdaWeb-<function>-<endpoint>-5xx-rate` (or `-4xx-rate`). `endpoint.rollbackAlarms` lists them all, e.g. to add notifications to the home region's.\n- **The alarms see the whole endpoint.** Lambda Web Function metrics have no revision dimension, so at 10% a new revision's errors are about a tenth of the endpoint's: set the threshold low enough to notice that, or alarm on metrics your application publishes with its version.\n- **5XX includes the platform's 503s** while the endpoint scales up for a sudden burst, not only your application's errors.\n- **A step should outlast the alarm.** CloudWatch needs `period` × `evaluationPeriods`, plus a couple of minutes of delay, to fire; the construct warns when a canary's bake or a linear interval is shorter.\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## Metrics\n\nEndpoints and functions have helpers for their CloudWatch metrics (namespace `AWS/Lambda/Web`), like `lambda.Function`'s:\n\n```ts\nfn.endpoint.metricServerErrorRate().createAlarm(this, 'ErrorRate', { threshold: 1, evaluationPeriods: 3 });\nfn.endpoint.metricRequestThrottles().createAlarm(this, 'Throttled', { threshold: 10, evaluationPeriods: 3 });\nfn.metricConcurrentRequests().createAlarm(this, 'Saturated', { threshold: 60, evaluationPeriods: 3 });\n```\n\n| Endpoint | Metric |\n|---|---|\n| `metricRequests()` | `ExecutedRequests` (there's no separate 2XX count) |\n| `metricClientErrors()`, `metricServerErrors()` | `HTTPResponseStatusClass4XX`, `HTTPResponseStatusClass5XX` |\n| `metricClientErrorRate()`, `metricServerErrorRate()` | 4XX or 5XX as a % of requests (math expression) |\n| `metricActiveEnvironments()` | `EndpointActiveEnvironments`, to compare with `maxEnvironments` |\n| `metricRequestThrottles()`, `metricEnvironmentThrottles()` | 429s from `rateLimit` and from `maxEnvironments` |\n\n| Function | Metric |\n|---|---|\n| `metricConcurrentRequests()` | `EnvironmentConcurrentRequests` (maximum), to compare with `maxConcurrencyPerEnvironment` |\n| `metricMaxMemoryUsage()` | `EnvironmentMaxMemoryUsage` (maximum) |\n| `metricActiveTime()`, `metricCpuTime()`, `metricResponseBytes()` | `EnvironmentActiveTime`, `EnvironmentCPUTime`, `ResponseBytes` |\n\n- **Metrics stay in the region that served the request**; unlike logs, they aren't copied to the home region. Every helper takes `region`. Dashboards can show any region, but an alarm can only use metrics from its own stack's region.\n- 4XX, 5XX and the throttle metrics only exist once they're non-zero: alarm on them with `treatMissingData: NOT_BREACHING`. The rate helpers count missing errors as 0.\n- There's no latency metric. Publish one from your application (e.g. with the CloudWatch embedded metric format).\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"
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### Functions defined elsewhere\n\nImport a Web Function defined in another stack or app to grant access to it, read its metrics, or reference its revisions:\n\n```ts\nconst orders = WebFunction.fromWebFunctionArn(this, 'Orders', 'arn:aws:lambda:us-east-1:111122223333:web-function/orders');\norders.grantInvoke(consumerRole); // every endpoint of the function\n\nconst live = WebFunction.fromWebFunctionAttributes(this, 'Live', {\n webFunctionName: 'orders', // in this stack's account and region\n endpointName: 'live', // grantInvoke allows this endpoint only\n});\nlive.metricConcurrentRequests().createAlarm(this, 'Busy', { threshold: 60, evaluationPeriods: 3 });\n```\n\nAn imported function's metrics default to its own region. Its endpoints, revisions and log groups stay with the stack that defines it.\n\n`grantInvoke` adds to the caller's IAM policy, which is all a caller in the function's account needs. A caller in another account also needs the function's resource policy to allow it, which this library doesn't manage yet.\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. The bucket is emptied and deleted with the stack.\n\nCode copies, log groups in other regions, revision cleanup and the bucket's emptying run in one custom resource Lambda per stack. Its logs go to a log group the stack owns, kept for a month and deleted with the stack.\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\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; back if more than 2% of requests get a 5XX.\n deployment: WebFunctionDeployment.canary({ percent: 10, bake: Duration.minutes(10), rollbackOn: { serverErrorRate: 2 } }),\n },\n});\n\n// 25% more every 5 minutes, watching an alarm of your own. Each endpoint has its own deployment.\n// errorRate: any cloudwatch.IAlarm, e.g. on a metric your application publishes.\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\n#### Rollback alarms\n\n`rollbackOn` makes the endpoint create alarms on its own error rates, and the deployment watches them alongside any `alarms` you pass:\n\n| `rollbackOn` | Default | |\n|---|---|---|\n| `serverErrorRate` | none | roll back when more than this % of requests get a 5XX |\n| `clientErrorRate` | none | the same for 4XX (including 429s from `rateLimit` and `maxEnvironments`) |\n| `minimumRequests` | 10 | periods with fewer requests don't count, so one failed request out of two doesn't roll back |\n| `period`, `evaluationPeriods` | 1 minute, 2 | consecutive periods over the threshold before rolling back |\n\n- **One alarm per threshold in every region the endpoint serves from.** Metrics are published in the region that served the request, and an alarm can only watch metrics in its own region. The home region's alarm is a normal CloudFormation alarm; the others are created and deleted with the endpoint by a custom resource, and named `LambdaWeb-<function>-<endpoint>-5xx-rate` (or `-4xx-rate`). `endpoint.rollbackAlarms` lists them all, e.g. to add notifications to the home region's.\n- **The alarms see the whole endpoint.** Lambda Web Function metrics have no revision dimension, so at 10% a new revision's errors are about a tenth of the endpoint's: set the threshold low enough to notice that, or alarm on metrics your application publishes with its version.\n- **5XX includes the platform's 503s** while the endpoint scales up for a sudden burst, not only your application's errors.\n- **A step should outlast the alarm.** CloudWatch needs `period` × `evaluationPeriods`, plus a couple of minutes of delay, to fire; the construct warns when a canary's bake or a linear interval is shorter.\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## Metrics\n\nEndpoints and functions have helpers for their CloudWatch metrics (namespace `AWS/Lambda/Web`), like `lambda.Function`'s:\n\n```ts\nfn.endpoint.metricServerErrorRate().createAlarm(this, 'ErrorRate', { threshold: 1, evaluationPeriods: 3 });\nfn.endpoint.metricRequestThrottles().createAlarm(this, 'Throttled', { threshold: 10, evaluationPeriods: 3 });\nfn.metricConcurrentRequests().createAlarm(this, 'Saturated', { threshold: 60, evaluationPeriods: 3 });\n```\n\n| Endpoint | Metric |\n|---|---|\n| `metricRequests()` | `ExecutedRequests` (there's no separate 2XX count) |\n| `metricClientErrors()`, `metricServerErrors()` | `HTTPResponseStatusClass4XX`, `HTTPResponseStatusClass5XX` |\n| `metricClientErrorRate()`, `metricServerErrorRate()` | 4XX or 5XX as a % of requests (math expression) |\n| `metricActiveEnvironments()` | `EndpointActiveEnvironments`, to compare with `maxEnvironments` |\n| `metricRequestThrottles()`, `metricEnvironmentThrottles()` | 429s from `rateLimit` and from `maxEnvironments` |\n\n| Function | Metric |\n|---|---|\n| `metricConcurrentRequests()` | `EnvironmentConcurrentRequests` (maximum), to compare with `maxConcurrencyPerEnvironment` |\n| `metricMaxMemoryUsage()` | `EnvironmentMaxMemoryUsage` (maximum) |\n| `metricActiveTime()`, `metricCpuTime()`, `metricResponseBytes()` | `EnvironmentActiveTime`, `EnvironmentCPUTime`, `ResponseBytes` |\n\n- **Metrics stay in the region that served the request**; unlike logs, they aren't copied to the home region. Every helper takes `region`. Dashboards can show any region, but an alarm can only use metrics from its own stack's region.\n- 4XX, 5XX and the throttle metrics only exist once they're non-zero: alarm on them with `treatMissingData: NOT_BREACHING`. The rate helpers count missing errors as 0.\n- There's no latency metric. Publish one from your application (e.g. with the CloudWatch embedded metric format).\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: VPC access (network connectors), resource-policy permissions, KMS encryption, 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\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",
@@ -9841,7 +9841,7 @@
9841
9841
  "assembly": "@ashishpandeyone/cdk-lambda-web-function",
9842
9842
  "docs": {
9843
9843
  "stability": "experimental",
9844
- "summary": "A Lambda Web Function."
9844
+ "summary": "A Lambda Web Function, created in this app (`WebFunction`) or imported (`WebFunction.fromWebFunctionArn`)."
9845
9845
  },
9846
9846
  "fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
9847
9847
  "interfaces": [
@@ -9853,6 +9853,196 @@
9853
9853
  "filename": "src/web-function.ts",
9854
9854
  "line": 155
9855
9855
  },
9856
+ "methods": [
9857
+ {
9858
+ "abstract": true,
9859
+ "docs": {
9860
+ "remarks": "for an imported function, the endpoint named in its attributes, or every endpoint.\n\nThis adds to the grantee's IAM policy. For a function in another account, its resource policy must also allow the grantee.\n[disable-awslint:no-grants]",
9861
+ "stability": "experimental",
9862
+ "summary": "Allows `grantee` to call the function's endpoint (`lambda:InvokeWebFunctionEndpoint`): the default endpoint of a `WebFunction`;"
9863
+ },
9864
+ "locationInModule": {
9865
+ "filename": "src/web-function.ts",
9866
+ "line": 177
9867
+ },
9868
+ "name": "grantInvoke",
9869
+ "parameters": [
9870
+ {
9871
+ "name": "grantee",
9872
+ "type": {
9873
+ "fqn": "aws-cdk-lib.aws_iam.IGrantable"
9874
+ }
9875
+ }
9876
+ ],
9877
+ "returns": {
9878
+ "type": {
9879
+ "fqn": "aws-cdk-lib.aws_iam.Grant"
9880
+ }
9881
+ }
9882
+ },
9883
+ {
9884
+ "abstract": true,
9885
+ "docs": {
9886
+ "stability": "experimental",
9887
+ "summary": "A metric of the function's execution environments in `AWS/Lambda/Web` (dimension `FunctionName`)."
9888
+ },
9889
+ "locationInModule": {
9890
+ "filename": "src/web-function.ts",
9891
+ "line": 182
9892
+ },
9893
+ "name": "metric",
9894
+ "parameters": [
9895
+ {
9896
+ "name": "metricName",
9897
+ "type": {
9898
+ "primitive": "string"
9899
+ }
9900
+ },
9901
+ {
9902
+ "name": "props",
9903
+ "optional": true,
9904
+ "type": {
9905
+ "fqn": "aws-cdk-lib.aws_cloudwatch.MetricOptions"
9906
+ }
9907
+ }
9908
+ ],
9909
+ "returns": {
9910
+ "type": {
9911
+ "fqn": "aws-cdk-lib.aws_cloudwatch.Metric"
9912
+ }
9913
+ }
9914
+ },
9915
+ {
9916
+ "abstract": true,
9917
+ "docs": {
9918
+ "stability": "experimental",
9919
+ "summary": "Time the execution environments were active (`EnvironmentActiveTime`)."
9920
+ },
9921
+ "locationInModule": {
9922
+ "filename": "src/web-function.ts",
9923
+ "line": 185
9924
+ },
9925
+ "name": "metricActiveTime",
9926
+ "parameters": [
9927
+ {
9928
+ "name": "props",
9929
+ "optional": true,
9930
+ "type": {
9931
+ "fqn": "aws-cdk-lib.aws_cloudwatch.MetricOptions"
9932
+ }
9933
+ }
9934
+ ],
9935
+ "returns": {
9936
+ "type": {
9937
+ "fqn": "aws-cdk-lib.aws_cloudwatch.Metric"
9938
+ }
9939
+ }
9940
+ },
9941
+ {
9942
+ "abstract": true,
9943
+ "docs": {
9944
+ "stability": "experimental",
9945
+ "summary": "Requests an execution environment handled at once (`EnvironmentConcurrentRequests`, maximum)."
9946
+ },
9947
+ "locationInModule": {
9948
+ "filename": "src/web-function.ts",
9949
+ "line": 191
9950
+ },
9951
+ "name": "metricConcurrentRequests",
9952
+ "parameters": [
9953
+ {
9954
+ "name": "props",
9955
+ "optional": true,
9956
+ "type": {
9957
+ "fqn": "aws-cdk-lib.aws_cloudwatch.MetricOptions"
9958
+ }
9959
+ }
9960
+ ],
9961
+ "returns": {
9962
+ "type": {
9963
+ "fqn": "aws-cdk-lib.aws_cloudwatch.Metric"
9964
+ }
9965
+ }
9966
+ },
9967
+ {
9968
+ "abstract": true,
9969
+ "docs": {
9970
+ "stability": "experimental",
9971
+ "summary": "CPU time the execution environments used (`EnvironmentCPUTime`)."
9972
+ },
9973
+ "locationInModule": {
9974
+ "filename": "src/web-function.ts",
9975
+ "line": 188
9976
+ },
9977
+ "name": "metricCpuTime",
9978
+ "parameters": [
9979
+ {
9980
+ "name": "props",
9981
+ "optional": true,
9982
+ "type": {
9983
+ "fqn": "aws-cdk-lib.aws_cloudwatch.MetricOptions"
9984
+ }
9985
+ }
9986
+ ],
9987
+ "returns": {
9988
+ "type": {
9989
+ "fqn": "aws-cdk-lib.aws_cloudwatch.Metric"
9990
+ }
9991
+ }
9992
+ },
9993
+ {
9994
+ "abstract": true,
9995
+ "docs": {
9996
+ "stability": "experimental",
9997
+ "summary": "Peak memory an execution environment used (`EnvironmentMaxMemoryUsage`, maximum)."
9998
+ },
9999
+ "locationInModule": {
10000
+ "filename": "src/web-function.ts",
10001
+ "line": 194
10002
+ },
10003
+ "name": "metricMaxMemoryUsage",
10004
+ "parameters": [
10005
+ {
10006
+ "name": "props",
10007
+ "optional": true,
10008
+ "type": {
10009
+ "fqn": "aws-cdk-lib.aws_cloudwatch.MetricOptions"
10010
+ }
10011
+ }
10012
+ ],
10013
+ "returns": {
10014
+ "type": {
10015
+ "fqn": "aws-cdk-lib.aws_cloudwatch.Metric"
10016
+ }
10017
+ }
10018
+ },
10019
+ {
10020
+ "abstract": true,
10021
+ "docs": {
10022
+ "stability": "experimental",
10023
+ "summary": "Bytes sent in responses (`ResponseBytes`)."
10024
+ },
10025
+ "locationInModule": {
10026
+ "filename": "src/web-function.ts",
10027
+ "line": 197
10028
+ },
10029
+ "name": "metricResponseBytes",
10030
+ "parameters": [
10031
+ {
10032
+ "name": "props",
10033
+ "optional": true,
10034
+ "type": {
10035
+ "fqn": "aws-cdk-lib.aws_cloudwatch.MetricOptions"
10036
+ }
10037
+ }
10038
+ ],
10039
+ "returns": {
10040
+ "type": {
10041
+ "fqn": "aws-cdk-lib.aws_cloudwatch.Metric"
10042
+ }
10043
+ }
10044
+ }
10045
+ ],
9856
10046
  "name": "IWebFunction",
9857
10047
  "properties": [
9858
10048
  {
@@ -10436,34 +10626,553 @@
10436
10626
  "filename": "src/nodejs-web-function.ts",
10437
10627
  "line": 135
10438
10628
  },
10439
- "name": "runtime",
10440
- "optional": true,
10441
- "type": {
10442
- "fqn": "aws-cdk-lib.aws_lambda.Runtime"
10443
- }
10629
+ "name": "runtime",
10630
+ "optional": true,
10631
+ "type": {
10632
+ "fqn": "aws-cdk-lib.aws_lambda.Runtime"
10633
+ }
10634
+ }
10635
+ ],
10636
+ "symbolId": "src/nodejs-web-function:NodejsWebFunctionProps"
10637
+ },
10638
+ "@ashishpandeyone/cdk-lambda-web-function.WebFunction": {
10639
+ "assembly": "@ashishpandeyone/cdk-lambda-web-function",
10640
+ "base": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionBase",
10641
+ "docs": {
10642
+ "custom": {
10643
+ "resource": "AWS::Lambda::WebFunction"
10644
+ },
10645
+ "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\nUse `fromWebFunctionArn`, `fromWebFunctionName` or `fromWebFunctionAttributes` for a function defined elsewhere.",
10646
+ "stability": "experimental",
10647
+ "summary": "A Node.js HTTP server running as an AWS Lambda Web Function, served from one or more regions."
10648
+ },
10649
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunction",
10650
+ "initializer": {
10651
+ "docs": {
10652
+ "stability": "experimental"
10653
+ },
10654
+ "locationInModule": {
10655
+ "filename": "src/web-function.ts",
10656
+ "line": 371
10657
+ },
10658
+ "parameters": [
10659
+ {
10660
+ "name": "scope",
10661
+ "type": {
10662
+ "fqn": "constructs.Construct"
10663
+ }
10664
+ },
10665
+ {
10666
+ "name": "id",
10667
+ "type": {
10668
+ "primitive": "string"
10669
+ }
10670
+ },
10671
+ {
10672
+ "name": "props",
10673
+ "type": {
10674
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps"
10675
+ }
10676
+ }
10677
+ ]
10678
+ },
10679
+ "interfaces": [
10680
+ "aws-cdk-lib.aws_iam.IGrantable"
10681
+ ],
10682
+ "kind": "class",
10683
+ "locationInModule": {
10684
+ "filename": "src/web-function.ts",
10685
+ "line": 314
10686
+ },
10687
+ "methods": [
10688
+ {
10689
+ "docs": {
10690
+ "stability": "experimental",
10691
+ "summary": "Imports an existing Web Function by its ARN (in any region or account)."
10692
+ },
10693
+ "locationInModule": {
10694
+ "filename": "src/web-function.ts",
10695
+ "line": 318
10696
+ },
10697
+ "name": "fromWebFunctionArn",
10698
+ "parameters": [
10699
+ {
10700
+ "name": "scope",
10701
+ "type": {
10702
+ "fqn": "constructs.Construct"
10703
+ }
10704
+ },
10705
+ {
10706
+ "name": "id",
10707
+ "type": {
10708
+ "primitive": "string"
10709
+ }
10710
+ },
10711
+ {
10712
+ "name": "webFunctionArn",
10713
+ "type": {
10714
+ "primitive": "string"
10715
+ }
10716
+ }
10717
+ ],
10718
+ "returns": {
10719
+ "type": {
10720
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction"
10721
+ }
10722
+ },
10723
+ "static": true
10724
+ },
10725
+ {
10726
+ "docs": {
10727
+ "stability": "experimental",
10728
+ "summary": "Imports an existing Web Function: give its ARN or its name, and optionally the endpoint `grantInvoke` allows."
10729
+ },
10730
+ "locationInModule": {
10731
+ "filename": "src/web-function.ts",
10732
+ "line": 332
10733
+ },
10734
+ "name": "fromWebFunctionAttributes",
10735
+ "parameters": [
10736
+ {
10737
+ "name": "scope",
10738
+ "type": {
10739
+ "fqn": "constructs.Construct"
10740
+ }
10741
+ },
10742
+ {
10743
+ "name": "id",
10744
+ "type": {
10745
+ "primitive": "string"
10746
+ }
10747
+ },
10748
+ {
10749
+ "name": "attrs",
10750
+ "type": {
10751
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionAttributes"
10752
+ }
10753
+ }
10754
+ ],
10755
+ "returns": {
10756
+ "type": {
10757
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction"
10758
+ }
10759
+ },
10760
+ "static": true
10761
+ },
10762
+ {
10763
+ "docs": {
10764
+ "stability": "experimental",
10765
+ "summary": "Imports an existing Web Function in this stack's account and region by its name."
10766
+ },
10767
+ "locationInModule": {
10768
+ "filename": "src/web-function.ts",
10769
+ "line": 325
10770
+ },
10771
+ "name": "fromWebFunctionName",
10772
+ "parameters": [
10773
+ {
10774
+ "name": "scope",
10775
+ "type": {
10776
+ "fqn": "constructs.Construct"
10777
+ }
10778
+ },
10779
+ {
10780
+ "name": "id",
10781
+ "type": {
10782
+ "primitive": "string"
10783
+ }
10784
+ },
10785
+ {
10786
+ "name": "webFunctionName",
10787
+ "type": {
10788
+ "primitive": "string"
10789
+ }
10790
+ }
10791
+ ],
10792
+ "returns": {
10793
+ "type": {
10794
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction"
10795
+ }
10796
+ },
10797
+ "static": true
10798
+ },
10799
+ {
10800
+ "docs": {
10801
+ "stability": "experimental",
10802
+ "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."
10803
+ },
10804
+ "locationInModule": {
10805
+ "filename": "src/web-function.ts",
10806
+ "line": 473
10807
+ },
10808
+ "name": "addEndpoint",
10809
+ "parameters": [
10810
+ {
10811
+ "docs": {
10812
+ "summary": "the endpoint's construct ID, also used in its generated name (`<id>-<hash>`)."
10813
+ },
10814
+ "name": "id",
10815
+ "type": {
10816
+ "primitive": "string"
10817
+ }
10818
+ },
10819
+ {
10820
+ "name": "options",
10821
+ "type": {
10822
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.AddWebFunctionEndpointOptions"
10823
+ }
10824
+ }
10825
+ ],
10826
+ "returns": {
10827
+ "type": {
10828
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint"
10829
+ }
10830
+ }
10831
+ },
10832
+ {
10833
+ "docs": {
10834
+ "remarks": "Names starting with `AWS_` are reserved.",
10835
+ "stability": "experimental",
10836
+ "summary": "Adds an environment variable."
10837
+ },
10838
+ "locationInModule": {
10839
+ "filename": "src/web-function.ts",
10840
+ "line": 481
10841
+ },
10842
+ "name": "addEnvironment",
10843
+ "parameters": [
10844
+ {
10845
+ "name": "key",
10846
+ "type": {
10847
+ "primitive": "string"
10848
+ }
10849
+ },
10850
+ {
10851
+ "name": "value",
10852
+ "type": {
10853
+ "primitive": "string"
10854
+ }
10855
+ }
10856
+ ],
10857
+ "returns": {
10858
+ "type": {
10859
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunction"
10860
+ }
10861
+ }
10862
+ },
10863
+ {
10864
+ "docs": {
10865
+ "stability": "experimental",
10866
+ "summary": "Adds a statement to the execution role's policy."
10867
+ },
10868
+ "locationInModule": {
10869
+ "filename": "src/web-function.ts",
10870
+ "line": 492
10871
+ },
10872
+ "name": "addToRolePolicy",
10873
+ "parameters": [
10874
+ {
10875
+ "name": "statement",
10876
+ "type": {
10877
+ "fqn": "aws-cdk-lib.aws_iam.PolicyStatement"
10878
+ }
10879
+ }
10880
+ ]
10881
+ },
10882
+ {
10883
+ "docs": {
10884
+ "remarks": "Shortcut for `grants.invoke(grantee)`, as on `lambda.Function`.\n[disable-awslint:no-grants]",
10885
+ "stability": "experimental",
10886
+ "summary": "Allows `grantee` to call the endpoint."
10887
+ },
10888
+ "locationInModule": {
10889
+ "filename": "src/web-function.ts",
10890
+ "line": 500
10891
+ },
10892
+ "name": "grantInvoke",
10893
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionBase",
10894
+ "parameters": [
10895
+ {
10896
+ "name": "grantee",
10897
+ "type": {
10898
+ "fqn": "aws-cdk-lib.aws_iam.IGrantable"
10899
+ }
10900
+ }
10901
+ ],
10902
+ "returns": {
10903
+ "type": {
10904
+ "fqn": "aws-cdk-lib.aws_iam.Grant"
10905
+ }
10906
+ }
10907
+ }
10908
+ ],
10909
+ "name": "WebFunction",
10910
+ "properties": [
10911
+ {
10912
+ "docs": {
10913
+ "stability": "experimental",
10914
+ "summary": "The revision built from the current code and configuration."
10915
+ },
10916
+ "immutable": true,
10917
+ "locationInModule": {
10918
+ "filename": "src/web-function.ts",
10919
+ "line": 343
10920
+ },
10921
+ "name": "currentRevision",
10922
+ "type": {
10923
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision"
10924
+ }
10925
+ },
10926
+ {
10927
+ "docs": {
10928
+ "remarks": "Add more with `addEndpoint`.",
10929
+ "stability": "experimental",
10930
+ "summary": "The default endpoint."
10931
+ },
10932
+ "immutable": true,
10933
+ "locationInModule": {
10934
+ "filename": "src/web-function.ts",
10935
+ "line": 346
10936
+ },
10937
+ "name": "endpoint",
10938
+ "type": {
10939
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint"
10940
+ }
10941
+ },
10942
+ {
10943
+ "docs": {
10944
+ "stability": "experimental",
10945
+ "summary": "The principal to grant permissions to (the execution role)."
10946
+ },
10947
+ "immutable": true,
10948
+ "locationInModule": {
10949
+ "filename": "src/web-function.ts",
10950
+ "line": 355
10951
+ },
10952
+ "name": "grantPrincipal",
10953
+ "overrides": "aws-cdk-lib.aws_iam.IGrantable",
10954
+ "type": {
10955
+ "fqn": "aws-cdk-lib.aws_iam.IPrincipal"
10956
+ }
10957
+ },
10958
+ {
10959
+ "docs": {
10960
+ "stability": "experimental",
10961
+ "summary": "Grants on the default endpoint (e.g. `grants.invoke(principal)`). Other endpoints have their own `grants`."
10962
+ },
10963
+ "immutable": true,
10964
+ "locationInModule": {
10965
+ "filename": "src/web-function.ts",
10966
+ "line": 349
10967
+ },
10968
+ "name": "grants",
10969
+ "type": {
10970
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants"
10971
+ }
10972
+ },
10973
+ {
10974
+ "docs": {
10975
+ "remarks": "Subscribe to this one only: each region's `.local` group holds a copy of the same events.",
10976
+ "stability": "experimental",
10977
+ "summary": "The home-region log group that receives the logs of every region the function serves from."
10978
+ },
10979
+ "immutable": true,
10980
+ "locationInModule": {
10981
+ "filename": "src/web-function.ts",
10982
+ "line": 361
10983
+ },
10984
+ "name": "logGroup",
10985
+ "type": {
10986
+ "fqn": "aws-cdk-lib.aws_logs.ILogGroup"
10987
+ }
10988
+ },
10989
+ {
10990
+ "docs": {
10991
+ "remarks": "Same as `currentRevision.revisionId`.",
10992
+ "stability": "experimental",
10993
+ "summary": "The ID of the current revision."
10994
+ },
10995
+ "immutable": true,
10996
+ "locationInModule": {
10997
+ "filename": "src/web-function.ts",
10998
+ "line": 340
10999
+ },
11000
+ "name": "revisionId",
11001
+ "type": {
11002
+ "primitive": "string"
11003
+ }
11004
+ },
11005
+ {
11006
+ "docs": {
11007
+ "stability": "experimental",
11008
+ "summary": "The execution role."
11009
+ },
11010
+ "immutable": true,
11011
+ "locationInModule": {
11012
+ "filename": "src/web-function.ts",
11013
+ "line": 352
11014
+ },
11015
+ "name": "role",
11016
+ "type": {
11017
+ "fqn": "aws-cdk-lib.aws_iam.IRole"
11018
+ }
11019
+ },
11020
+ {
11021
+ "docs": {
11022
+ "stability": "experimental",
11023
+ "summary": "The function's ARN."
11024
+ },
11025
+ "immutable": true,
11026
+ "locationInModule": {
11027
+ "filename": "src/web-function.ts",
11028
+ "line": 337
11029
+ },
11030
+ "name": "webFunctionArn",
11031
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionBase",
11032
+ "type": {
11033
+ "primitive": "string"
11034
+ }
11035
+ },
11036
+ {
11037
+ "docs": {
11038
+ "stability": "experimental",
11039
+ "summary": "The function's name."
11040
+ },
11041
+ "immutable": true,
11042
+ "locationInModule": {
11043
+ "filename": "src/web-function.ts",
11044
+ "line": 336
11045
+ },
11046
+ "name": "webFunctionName",
11047
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionBase",
11048
+ "type": {
11049
+ "primitive": "string"
11050
+ }
11051
+ }
11052
+ ],
11053
+ "symbolId": "src/web-function:WebFunction"
11054
+ },
11055
+ "@ashishpandeyone/cdk-lambda-web-function.WebFunctionAttributes": {
11056
+ "assembly": "@ashishpandeyone/cdk-lambda-web-function",
11057
+ "datatype": true,
11058
+ "docs": {
11059
+ "remarks": "Give its ARN or its name.",
11060
+ "stability": "experimental",
11061
+ "summary": "Attributes of an existing Web Function."
11062
+ },
11063
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionAttributes",
11064
+ "kind": "interface",
11065
+ "locationInModule": {
11066
+ "filename": "src/web-function.ts",
11067
+ "line": 203
11068
+ },
11069
+ "name": "WebFunctionAttributes",
11070
+ "properties": [
11071
+ {
11072
+ "abstract": true,
11073
+ "docs": {
11074
+ "default": "- every endpoint of the function",
11075
+ "stability": "experimental",
11076
+ "summary": "The endpoint `grantInvoke` allows calling."
11077
+ },
11078
+ "immutable": true,
11079
+ "locationInModule": {
11080
+ "filename": "src/web-function.ts",
11081
+ "line": 224
11082
+ },
11083
+ "name": "endpointName",
11084
+ "optional": true,
11085
+ "type": {
11086
+ "primitive": "string"
11087
+ }
11088
+ },
11089
+ {
11090
+ "abstract": true,
11091
+ "docs": {
11092
+ "default": "- built from `webFunctionName`, in this stack's account and region",
11093
+ "stability": "experimental",
11094
+ "summary": "The function's ARN, e.g. `arn:aws:lambda:us-east-1:111122223333:web-function/orders`. It may be in another region or account; across accounts, `grantInvoke` also needs the function's resource policy to allow the caller."
11095
+ },
11096
+ "immutable": true,
11097
+ "locationInModule": {
11098
+ "filename": "src/web-function.ts",
11099
+ "line": 210
11100
+ },
11101
+ "name": "webFunctionArn",
11102
+ "optional": true,
11103
+ "type": {
11104
+ "primitive": "string"
11105
+ }
11106
+ },
11107
+ {
11108
+ "abstract": true,
11109
+ "docs": {
11110
+ "default": "- taken from `webFunctionArn`",
11111
+ "stability": "experimental",
11112
+ "summary": "The function's name."
11113
+ },
11114
+ "immutable": true,
11115
+ "locationInModule": {
11116
+ "filename": "src/web-function.ts",
11117
+ "line": 217
11118
+ },
11119
+ "name": "webFunctionName",
11120
+ "optional": true,
11121
+ "type": {
11122
+ "primitive": "string"
11123
+ }
11124
+ }
11125
+ ],
11126
+ "symbolId": "src/web-function:WebFunctionAttributes"
11127
+ },
11128
+ "@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType": {
11129
+ "assembly": "@ashishpandeyone/cdk-lambda-web-function",
11130
+ "docs": {
11131
+ "stability": "experimental",
11132
+ "summary": "How callers of a Web Function endpoint are authenticated."
11133
+ },
11134
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType",
11135
+ "kind": "enum",
11136
+ "locationInModule": {
11137
+ "filename": "src/enums.ts",
11138
+ "line": 4
11139
+ },
11140
+ "members": [
11141
+ {
11142
+ "docs": {
11143
+ "stability": "experimental",
11144
+ "summary": "Requests must be signed with SigV4 or SigV4a (signing name `lambda`) by a principal allowed `lambda:InvokeWebFunctionEndpoint` on the endpoint."
11145
+ },
11146
+ "name": "AWS_IAM"
11147
+ },
11148
+ {
11149
+ "docs": {
11150
+ "remarks": "The `Authorization` header reaches your application untouched.",
11151
+ "stability": "experimental",
11152
+ "summary": "No authentication by Lambda: the endpoint is public and your application authenticates requests itself."
11153
+ },
11154
+ "name": "NONE"
10444
11155
  }
10445
11156
  ],
10446
- "symbolId": "src/nodejs-web-function:NodejsWebFunctionProps"
11157
+ "name": "WebFunctionAuthType",
11158
+ "symbolId": "src/enums:WebFunctionAuthType"
10447
11159
  },
10448
- "@ashishpandeyone/cdk-lambda-web-function.WebFunction": {
11160
+ "@ashishpandeyone/cdk-lambda-web-function.WebFunctionBase": {
11161
+ "abstract": true,
10449
11162
  "assembly": "@ashishpandeyone/cdk-lambda-web-function",
10450
11163
  "base": "aws-cdk-lib.Resource",
10451
11164
  "docs": {
10452
- "custom": {
10453
- "resource": "AWS::Lambda::WebFunction"
10454
- },
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.",
10456
11165
  "stability": "experimental",
10457
- "summary": "A Node.js HTTP server running as an AWS Lambda Web Function, served from one or more regions."
11166
+ "summary": "What `WebFunction` and imported functions have in common."
10458
11167
  },
10459
- "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunction",
11168
+ "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionBase",
10460
11169
  "initializer": {
10461
11170
  "docs": {
10462
- "stability": "experimental"
11171
+ "stability": "stable"
10463
11172
  },
10464
11173
  "locationInModule": {
10465
- "filename": "src/web-function.ts",
10466
- "line": 223
11174
+ "filename": "core/lib/resource.ts",
11175
+ "line": 125
10467
11176
  },
10468
11177
  "parameters": [
10469
11178
  {
@@ -10480,116 +11189,35 @@
10480
11189
  },
10481
11190
  {
10482
11191
  "name": "props",
11192
+ "optional": true,
10483
11193
  "type": {
10484
- "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps"
11194
+ "fqn": "aws-cdk-lib.ResourceProps"
10485
11195
  }
10486
11196
  }
10487
11197
  ]
10488
11198
  },
10489
11199
  "interfaces": [
10490
- "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
10491
- "aws-cdk-lib.aws_iam.IGrantable"
11200
+ "@ashishpandeyone/cdk-lambda-web-function.IWebFunction"
10492
11201
  ],
10493
11202
  "kind": "class",
10494
11203
  "locationInModule": {
10495
11204
  "filename": "src/web-function.ts",
10496
- "line": 182
11205
+ "line": 230
10497
11206
  },
10498
11207
  "methods": [
10499
11208
  {
11209
+ "abstract": true,
10500
11210
  "docs": {
11211
+ "remarks": "[disable-awslint:no-grants]",
10501
11212
  "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": 325
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
- },
10532
- {
10533
- "docs": {
10534
- "remarks": "Names starting with `AWS_` are reserved.",
10535
- "stability": "experimental",
10536
- "summary": "Adds an environment variable."
10537
- },
10538
- "locationInModule": {
10539
- "filename": "src/web-function.ts",
10540
- "line": 333
10541
- },
10542
- "name": "addEnvironment",
10543
- "parameters": [
10544
- {
10545
- "name": "key",
10546
- "type": {
10547
- "primitive": "string"
10548
- }
10549
- },
10550
- {
10551
- "name": "value",
10552
- "type": {
10553
- "primitive": "string"
10554
- }
10555
- }
10556
- ],
10557
- "returns": {
10558
- "type": {
10559
- "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunction"
10560
- }
10561
- }
10562
- },
10563
- {
10564
- "docs": {
10565
- "stability": "experimental",
10566
- "summary": "Adds a statement to the execution role's policy."
10567
- },
10568
- "locationInModule": {
10569
- "filename": "src/web-function.ts",
10570
- "line": 344
10571
- },
10572
- "name": "addToRolePolicy",
10573
- "parameters": [
10574
- {
10575
- "name": "statement",
10576
- "type": {
10577
- "fqn": "aws-cdk-lib.aws_iam.PolicyStatement"
10578
- }
10579
- }
10580
- ]
10581
- },
10582
- {
10583
- "docs": {
10584
- "remarks": "Shortcut for `grants.invoke(grantee)`, as on `lambda.Function`.\n[disable-awslint:no-grants]",
10585
- "stability": "experimental",
10586
- "summary": "Allows `grantee` to call the endpoint."
11213
+ "summary": "Allows `grantee` to call the function's endpoint."
10587
11214
  },
10588
11215
  "locationInModule": {
10589
11216
  "filename": "src/web-function.ts",
10590
- "line": 352
11217
+ "line": 243
10591
11218
  },
10592
11219
  "name": "grantInvoke",
11220
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
10593
11221
  "parameters": [
10594
11222
  {
10595
11223
  "name": "grantee",
@@ -10606,16 +11234,17 @@
10606
11234
  },
10607
11235
  {
10608
11236
  "docs": {
10609
- "default": "- sum over 1 minute, in the home region",
11237
+ "default": "- sum over 1 minute, in the function's home region",
10610
11238
  "remarks": "For request and error counts, use the endpoint's metrics (`fn.endpoint.metricRequests()`).\n\nMetrics are published in the region that served the request: pass `region` for another serving region.\nAn alarm can only use metrics from its own stack's region.",
10611
11239
  "stability": "experimental",
10612
11240
  "summary": "A metric of this function's execution environments in `AWS/Lambda/Web` (dimension `FunctionName`), across all endpoints."
10613
11241
  },
10614
11242
  "locationInModule": {
10615
11243
  "filename": "src/web-function.ts",
10616
- "line": 365
11244
+ "line": 254
10617
11245
  },
10618
11246
  "name": "metric",
11247
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
10619
11248
  "parameters": [
10620
11249
  {
10621
11250
  "name": "metricName",
@@ -10644,9 +11273,10 @@
10644
11273
  },
10645
11274
  "locationInModule": {
10646
11275
  "filename": "src/web-function.ts",
10647
- "line": 377
11276
+ "line": 269
10648
11277
  },
10649
11278
  "name": "metricActiveTime",
11279
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
10650
11280
  "parameters": [
10651
11281
  {
10652
11282
  "name": "props",
@@ -10670,9 +11300,10 @@
10670
11300
  },
10671
11301
  "locationInModule": {
10672
11302
  "filename": "src/web-function.ts",
10673
- "line": 392
11303
+ "line": 284
10674
11304
  },
10675
11305
  "name": "metricConcurrentRequests",
11306
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
10676
11307
  "parameters": [
10677
11308
  {
10678
11309
  "name": "props",
@@ -10695,9 +11326,10 @@
10695
11326
  },
10696
11327
  "locationInModule": {
10697
11328
  "filename": "src/web-function.ts",
10698
- "line": 382
11329
+ "line": 274
10699
11330
  },
10700
11331
  "name": "metricCpuTime",
11332
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
10701
11333
  "parameters": [
10702
11334
  {
10703
11335
  "name": "props",
@@ -10722,9 +11354,10 @@
10722
11354
  },
10723
11355
  "locationInModule": {
10724
11356
  "filename": "src/web-function.ts",
10725
- "line": 401
11357
+ "line": 293
10726
11358
  },
10727
11359
  "name": "metricMaxMemoryUsage",
11360
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
10728
11361
  "parameters": [
10729
11362
  {
10730
11363
  "name": "props",
@@ -10747,9 +11380,10 @@
10747
11380
  },
10748
11381
  "locationInModule": {
10749
11382
  "filename": "src/web-function.ts",
10750
- "line": 406
11383
+ "line": 298
10751
11384
  },
10752
11385
  "name": "metricResponseBytes",
11386
+ "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
10753
11387
  "parameters": [
10754
11388
  {
10755
11389
  "name": "props",
@@ -10766,118 +11400,10 @@
10766
11400
  }
10767
11401
  }
10768
11402
  ],
10769
- "name": "WebFunction",
11403
+ "name": "WebFunctionBase",
10770
11404
  "properties": [
10771
11405
  {
10772
- "docs": {
10773
- "stability": "experimental",
10774
- "summary": "The revision built from the current code and configuration."
10775
- },
10776
- "immutable": true,
10777
- "locationInModule": {
10778
- "filename": "src/web-function.ts",
10779
- "line": 190
10780
- },
10781
- "name": "currentRevision",
10782
- "type": {
10783
- "fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunctionRevision"
10784
- }
10785
- },
10786
- {
10787
- "docs": {
10788
- "remarks": "Add more with `addEndpoint`.",
10789
- "stability": "experimental",
10790
- "summary": "The default endpoint."
10791
- },
10792
- "immutable": true,
10793
- "locationInModule": {
10794
- "filename": "src/web-function.ts",
10795
- "line": 193
10796
- },
10797
- "name": "endpoint",
10798
- "type": {
10799
- "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint"
10800
- }
10801
- },
10802
- {
10803
- "docs": {
10804
- "stability": "experimental",
10805
- "summary": "The principal to grant permissions to (the execution role)."
10806
- },
10807
- "immutable": true,
10808
- "locationInModule": {
10809
- "filename": "src/web-function.ts",
10810
- "line": 202
10811
- },
10812
- "name": "grantPrincipal",
10813
- "overrides": "aws-cdk-lib.aws_iam.IGrantable",
10814
- "type": {
10815
- "fqn": "aws-cdk-lib.aws_iam.IPrincipal"
10816
- }
10817
- },
10818
- {
10819
- "docs": {
10820
- "stability": "experimental",
10821
- "summary": "Grants on the default endpoint (e.g. `grants.invoke(principal)`). Other endpoints have their own `grants`."
10822
- },
10823
- "immutable": true,
10824
- "locationInModule": {
10825
- "filename": "src/web-function.ts",
10826
- "line": 196
10827
- },
10828
- "name": "grants",
10829
- "type": {
10830
- "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionGrants"
10831
- }
10832
- },
10833
- {
10834
- "docs": {
10835
- "remarks": "Subscribe to this one only: each region's `.local` group holds a copy of the same events.",
10836
- "stability": "experimental",
10837
- "summary": "The home-region log group that receives the logs of every region the function serves from."
10838
- },
10839
- "immutable": true,
10840
- "locationInModule": {
10841
- "filename": "src/web-function.ts",
10842
- "line": 208
10843
- },
10844
- "name": "logGroup",
10845
- "type": {
10846
- "fqn": "aws-cdk-lib.aws_logs.ILogGroup"
10847
- }
10848
- },
10849
- {
10850
- "docs": {
10851
- "remarks": "Same as `currentRevision.revisionId`.",
10852
- "stability": "experimental",
10853
- "summary": "The ID of the current revision."
10854
- },
10855
- "immutable": true,
10856
- "locationInModule": {
10857
- "filename": "src/web-function.ts",
10858
- "line": 187
10859
- },
10860
- "name": "revisionId",
10861
- "type": {
10862
- "primitive": "string"
10863
- }
10864
- },
10865
- {
10866
- "docs": {
10867
- "stability": "experimental",
10868
- "summary": "The execution role."
10869
- },
10870
- "immutable": true,
10871
- "locationInModule": {
10872
- "filename": "src/web-function.ts",
10873
- "line": 199
10874
- },
10875
- "name": "role",
10876
- "type": {
10877
- "fqn": "aws-cdk-lib.aws_iam.IRole"
10878
- }
10879
- },
10880
- {
11406
+ "abstract": true,
10881
11407
  "docs": {
10882
11408
  "stability": "experimental",
10883
11409
  "summary": "The function's ARN."
@@ -10885,7 +11411,7 @@
10885
11411
  "immutable": true,
10886
11412
  "locationInModule": {
10887
11413
  "filename": "src/web-function.ts",
10888
- "line": 184
11414
+ "line": 232
10889
11415
  },
10890
11416
  "name": "webFunctionArn",
10891
11417
  "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
@@ -10894,6 +11420,7 @@
10894
11420
  }
10895
11421
  },
10896
11422
  {
11423
+ "abstract": true,
10897
11424
  "docs": {
10898
11425
  "stability": "experimental",
10899
11426
  "summary": "The function's name."
@@ -10901,7 +11428,7 @@
10901
11428
  "immutable": true,
10902
11429
  "locationInModule": {
10903
11430
  "filename": "src/web-function.ts",
10904
- "line": 183
11431
+ "line": 231
10905
11432
  },
10906
11433
  "name": "webFunctionName",
10907
11434
  "overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
@@ -10917,7 +11444,7 @@
10917
11444
  "immutable": true,
10918
11445
  "locationInModule": {
10919
11446
  "filename": "src/web-function.ts",
10920
- "line": 219
11447
+ "line": 235
10921
11448
  },
10922
11449
  "name": "webFunctionRef",
10923
11450
  "overrides": "aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef",
@@ -10926,39 +11453,7 @@
10926
11453
  }
10927
11454
  }
10928
11455
  ],
10929
- "symbolId": "src/web-function:WebFunction"
10930
- },
10931
- "@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType": {
10932
- "assembly": "@ashishpandeyone/cdk-lambda-web-function",
10933
- "docs": {
10934
- "stability": "experimental",
10935
- "summary": "How callers of a Web Function endpoint are authenticated."
10936
- },
10937
- "fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionAuthType",
10938
- "kind": "enum",
10939
- "locationInModule": {
10940
- "filename": "src/enums.ts",
10941
- "line": 4
10942
- },
10943
- "members": [
10944
- {
10945
- "docs": {
10946
- "stability": "experimental",
10947
- "summary": "Requests must be signed with SigV4 or SigV4a (signing name `lambda`) by a principal allowed `lambda:InvokeWebFunctionEndpoint` on the endpoint."
10948
- },
10949
- "name": "AWS_IAM"
10950
- },
10951
- {
10952
- "docs": {
10953
- "remarks": "The `Authorization` header reaches your application untouched.",
10954
- "stability": "experimental",
10955
- "summary": "No authentication by Lambda: the endpoint is public and your application authenticates requests itself."
10956
- },
10957
- "name": "NONE"
10958
- }
10959
- ],
10960
- "name": "WebFunctionAuthType",
10961
- "symbolId": "src/enums:WebFunctionAuthType"
11456
+ "symbolId": "src/web-function:WebFunctionBase"
10962
11457
  },
10963
11458
  "@ashishpandeyone/cdk-lambda-web-function.WebFunctionCanaryDeploymentOptions": {
10964
11459
  "assembly": "@ashishpandeyone/cdk-lambda-web-function",
@@ -11843,7 +12338,7 @@
11843
12338
  },
11844
12339
  "locationInModule": {
11845
12340
  "filename": "src/web-function-grants.ts",
11846
- "line": 23
12341
+ "line": 32
11847
12342
  },
11848
12343
  "name": "invoke",
11849
12344
  "parameters": [
@@ -12611,6 +13106,6 @@
12611
13106
  "symbolId": "src/web-function-deployment:WebFunctionRollbackOptions"
12612
13107
  }
12613
13108
  },
12614
- "version": "0.1.3",
12615
- "fingerprint": "F4xpSs8RKEtfPPB2ssJBW33WiisXtZt7E1UR0EZcJQs="
13109
+ "version": "0.1.4",
13110
+ "fingerprint": "jD4b9T+QRqWU7bgpwm773YKwDrQpiy3PKVU2Zby8LP8="
12616
13111
  }