@ashishpandeyone/cdk-lambda-web-function 0.1.4 → 0.1.6
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 +527 -82
- package/.jsii.tabl.json +1 -1
- package/API.md +785 -2
- package/README.md +83 -7
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/nodejs-web-function.js +1 -1
- package/lib/private/resource-policy.d.ts +15 -0
- package/lib/private/resource-policy.js +48 -0
- package/lib/web-function-deployment.js +1 -1
- package/lib/web-function-endpoint.d.ts +8 -1
- package/lib/web-function-endpoint.js +16 -7
- package/lib/web-function-grants.d.ts +6 -1
- package/lib/web-function-grants.js +14 -10
- package/lib/web-function-origin.d.ts +66 -0
- package/lib/web-function-origin.js +201 -0
- package/lib/web-function-revision.js +1 -1
- package/lib/web-function.d.ts +62 -2
- package/lib/web-function.js +73 -3
- package/package.json +1 -1
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\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"
|
|
9748
|
+
"markdown": "# CDK constructs for AWS Lambda Web Functions\n\n<!--BEGIN STABILITY BANNER-->\n\n---\n\n\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://docs.aws.amazon.com/lambda/latest/dg/web-functions.html) 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## Installation\n\n```bash\nnpm install @ashishpandeyone/cdk-lambda-web-function\n```\n\nIt needs `aws-cdk-lib` 2.273.0 or later and `constructs` 10.5.1 or later (peer dependencies), and Node.js 22 or later. The package is published for TypeScript and JavaScript only.\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 **10 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 host = new URL(url).hostname; // url: the endpoint's URL\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### Other accounts and AWS services\n\nA caller in another account needs permission twice: in its own IAM policy, and in the function's **resource policy**. `grantInvoke` handles the function's side: a role in the function's account only gets an IAM policy statement, while a principal in another account or an AWS service also gets a statement in the resource policy.\n\n```ts\nfn.grantInvoke(iam.Role.fromRoleArn(this, 'Partner', 'arn:aws:iam::444455556666:role/caller'));\n```\n\nFor principals you can't grant to (a whole account, an organization, an AWS service with conditions), use `addPermission`. The `id` becomes the statement's `Sid`:\n\n```ts\nfn.addPermission('PartnerAccount', { principal: new iam.AccountPrincipal('444455556666') });\nfn.addPermission('MyOrg', { principal: new iam.OrganizationPrincipal('o-a1b2c3d4e5'), endpoint: fn.endpoint });\nfn.addPermission('Cdn', {\n principal: new iam.ServicePrincipal('cloudfront.amazonaws.com'),\n sourceArn: `arn:aws:cloudfront::${this.account}:distribution/EDFDVBD6EXAMPLE`,\n});\n```\n\n`addPermission` allows calling every endpoint unless you pass `endpoint`. For other actions, such as letting another account create revisions, use `fn.addToResourcePolicy(statement)`. Statements use the endpoint ARN for invoking and the function ARN for actions on the function.\n\n- **One resource policy per function, written by the function's stack.** The construct creates it (`AWS::Lambda::ResourcePolicy`) with the first statement. CloudFormation can't attach a second one: another stack, or a `CfnResourcePolicy` of your own on the function, fails at change-set validation with \"already exists\". If you attached one yourself, move its statements into `addPermission` or `addToResourcePolicy`. Each update of the policy replaces any statements added outside CloudFormation.\n- **Public policies are rejected.** Lambda refuses a policy that lets anyone call the function, and the construct fails synthesis first. A `*` principal is only accepted with a condition that pins the caller, such as `aws:PrincipalOrgID` (`iam.OrganizationPrincipal`) or `aws:SourceAccount`. For a public endpoint, use `authType: NONE`.\n- **Scope AWS services to your resource.** Lambda accepts a service principal with no condition, which would let that service call the endpoint on behalf of any account. The construct warns unless you give `sourceArn` or `sourceAccount` (or an `aws:SourceArn`, `aws:SourceAccount`, `aws:SourceOrgID` or `aws:SourceOrgPaths` condition).\n- Lambda copies the policy to every region the function's endpoints serve from. The copy is eventually consistent, and in tests changes applied in every region within seconds.\n\n### CloudFront\n\nPut a CloudFront distribution (`aws-cdk-lib/aws-cloudfront`) in front of an `AWS_IAM` endpoint to serve the public with a custom domain, caching and AWS WAF. Viewers don't sign anything, and only your distribution may call the endpoint:\n\n```ts\nnew cloudfront.Distribution(this, 'Cdn', {\n defaultBehavior: {\n origin: WebFunctionOrigin.withOriginAccessControl(fn.endpoint),\n viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,\n allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,\n cachePolicy: cloudfront.CachePolicy.CACHING_DISABLED,\n originRequestPolicy: cloudfront.OriginRequestPolicy.ALL_VIEWER_EXCEPT_HOST_HEADER,\n },\n});\n```\n\n`withOriginAccessControl` adds:\n- an origin access control (origin type `lambda`, signing behavior `always-amz-auth`, the only one CloudFront accepts for Web Function origins), one per stack and signing protocol: SigV4 for a regional domain, SigV4a for a `MULTI_REGION` endpoint's global domain;\n- a statement in the function's resource policy that allows `cloudfront.amazonaws.com` to call this endpoint on behalf of this distribution only (`aws:SourceArn`).\n\nSome things to know:\n- **Forward everything except `Host`.** The endpoint answers 404 when `Host` is the distribution's domain, so use `ALL_VIEWER_EXCEPT_HOST_HEADER` (not `ALL_VIEWER`), or a policy of your own without `Host`.\n- **Your application can still authenticate viewers.** CloudFront signs in its own headers and passes the viewer's `Authorization` header (a JWT, for example) through unchanged, but only when `Authorization` is in the cache policy. CloudFront drops it from `GET` and `HEAD` requests otherwise:\n\n ```ts\n const forwardAuthorization = new cloudfront.CachePolicy(this, 'ForwardAuthorization', {\n headerBehavior: cloudfront.CacheHeaderBehavior.allowList('Authorization'),\n minTtl: Duration.seconds(0),\n defaultTtl: Duration.seconds(0),\n maxTtl: Duration.seconds(1), // a cache key with headers needs caching enabled; 0/0/1 keeps it off in practice\n });\n ```\n- Request bodies work without clients sending `x-amz-content-sha256`: CloudFront signs `POST`, `PUT` and `PATCH` requests with an unsigned payload.\n- A `PER_REGION` endpoint's origin calls one region: the home region, or the one you pass as `region`. Use one origin per region, for example in an origin group.\n- A `MULTI_REGION` endpoint can't include opt-in regions (such as `me-central-1`), because CloudFront can't sign for them. The construct fails synthesis.\n- The distribution must be in the function's stack. Lambda@Edge origin-request and origin-response triggers aren't supported on behaviors with this origin.\n- The endpoint stays reachable at its own domain for signed requests your policies allow. Until a new distribution finishes deploying, requests through it can get a transient 403.\n- `new WebFunctionOrigin(endpoint)` is for a public (`NONE`) endpoint, for example behind AWS WAF. Lambda doesn't authenticate those requests, so the endpoint's own domain stays public too.\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\nAn imported function's `grantInvoke` adds to the caller's IAM policy only, 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 only the function's own stack can change: `addToResourcePolicy` on an imported function adds nothing and warns.\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- **Each execution environment has 2 vCPUs and 2 GB of memory.** There's no memory setting as on Lambda functions; scale with `maxConcurrencyPerEnvironment` and more environments instead.\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\nCopying code, managing the function's log groups in every region, looking up regional URLs, cleaning up old revisions, creating rollback alarms in other regions and emptying the code bucket all 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 any of its endpoints serves from.\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), KMS encryption, and tracing.\n- **Hotswap skips Web Functions without a warning.** `cdk deploy --hotswap` and `cdk watch`, which hotswaps by default, report `(no changes)` for a code or configuration change and the endpoint keeps serving the old revision. Use `cdk watch --hotswap-fallback` (or `cdk deploy --hotswap-fallback`): it deploys Web Function changes through CloudFormation, in about 40 seconds for a home-region endpoint.\n- Fixed limits: 512 MB of code (unzipped) and 32 KB of environment variables per revision, 512 MB of `/tmp` per execution environment, and 128 KiB of headers per request.\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",
|
|
@@ -9840,30 +9840,32 @@
|
|
|
9840
9840
|
"@ashishpandeyone/cdk-lambda-web-function.IWebFunction": {
|
|
9841
9841
|
"assembly": "@ashishpandeyone/cdk-lambda-web-function",
|
|
9842
9842
|
"docs": {
|
|
9843
|
+
"remarks": "`addToResourcePolicy` adds to the function's resource policy (who else may call or manage it). A `WebFunction` has\none, created by its stack on the first statement. An imported function's policy belongs to the stack that created\nit, so the statement isn't added (`statementAdded: false`).",
|
|
9843
9844
|
"stability": "experimental",
|
|
9844
9845
|
"summary": "A Lambda Web Function, created in this app (`WebFunction`) or imported (`WebFunction.fromWebFunctionArn`)."
|
|
9845
9846
|
},
|
|
9846
9847
|
"fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
|
|
9847
9848
|
"interfaces": [
|
|
9848
9849
|
"aws-cdk-lib.IResource",
|
|
9849
|
-
"aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef"
|
|
9850
|
+
"aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef",
|
|
9851
|
+
"aws-cdk-lib.aws_iam.IResourceWithPolicy"
|
|
9850
9852
|
],
|
|
9851
9853
|
"kind": "interface",
|
|
9852
9854
|
"locationInModule": {
|
|
9853
9855
|
"filename": "src/web-function.ts",
|
|
9854
|
-
"line":
|
|
9856
|
+
"line": 160
|
|
9855
9857
|
},
|
|
9856
9858
|
"methods": [
|
|
9857
9859
|
{
|
|
9858
9860
|
"abstract": true,
|
|
9859
9861
|
"docs": {
|
|
9860
|
-
"remarks": "for an imported function, the endpoint named in its attributes, or every endpoint.\n\
|
|
9862
|
+
"remarks": "for an imported function, the endpoint named in its attributes, or every endpoint.\n\nFor a `WebFunction`, a grantee in this account gets an IAM policy statement; another account or an AWS service\nalso gets a statement in the function's resource policy. For an imported function, only the grantee's IAM policy\nchanges: across accounts, the function's own resource policy must also allow the grantee.\n[disable-awslint:no-grants]",
|
|
9861
9863
|
"stability": "experimental",
|
|
9862
9864
|
"summary": "Allows `grantee` to call the function's endpoint (`lambda:InvokeWebFunctionEndpoint`): the default endpoint of a `WebFunction`;"
|
|
9863
9865
|
},
|
|
9864
9866
|
"locationInModule": {
|
|
9865
9867
|
"filename": "src/web-function.ts",
|
|
9866
|
-
"line":
|
|
9868
|
+
"line": 184
|
|
9867
9869
|
},
|
|
9868
9870
|
"name": "grantInvoke",
|
|
9869
9871
|
"parameters": [
|
|
@@ -9888,7 +9890,7 @@
|
|
|
9888
9890
|
},
|
|
9889
9891
|
"locationInModule": {
|
|
9890
9892
|
"filename": "src/web-function.ts",
|
|
9891
|
-
"line":
|
|
9893
|
+
"line": 189
|
|
9892
9894
|
},
|
|
9893
9895
|
"name": "metric",
|
|
9894
9896
|
"parameters": [
|
|
@@ -9920,7 +9922,7 @@
|
|
|
9920
9922
|
},
|
|
9921
9923
|
"locationInModule": {
|
|
9922
9924
|
"filename": "src/web-function.ts",
|
|
9923
|
-
"line":
|
|
9925
|
+
"line": 192
|
|
9924
9926
|
},
|
|
9925
9927
|
"name": "metricActiveTime",
|
|
9926
9928
|
"parameters": [
|
|
@@ -9946,7 +9948,7 @@
|
|
|
9946
9948
|
},
|
|
9947
9949
|
"locationInModule": {
|
|
9948
9950
|
"filename": "src/web-function.ts",
|
|
9949
|
-
"line":
|
|
9951
|
+
"line": 198
|
|
9950
9952
|
},
|
|
9951
9953
|
"name": "metricConcurrentRequests",
|
|
9952
9954
|
"parameters": [
|
|
@@ -9972,7 +9974,7 @@
|
|
|
9972
9974
|
},
|
|
9973
9975
|
"locationInModule": {
|
|
9974
9976
|
"filename": "src/web-function.ts",
|
|
9975
|
-
"line":
|
|
9977
|
+
"line": 195
|
|
9976
9978
|
},
|
|
9977
9979
|
"name": "metricCpuTime",
|
|
9978
9980
|
"parameters": [
|
|
@@ -9998,7 +10000,7 @@
|
|
|
9998
10000
|
},
|
|
9999
10001
|
"locationInModule": {
|
|
10000
10002
|
"filename": "src/web-function.ts",
|
|
10001
|
-
"line":
|
|
10003
|
+
"line": 201
|
|
10002
10004
|
},
|
|
10003
10005
|
"name": "metricMaxMemoryUsage",
|
|
10004
10006
|
"parameters": [
|
|
@@ -10024,7 +10026,7 @@
|
|
|
10024
10026
|
},
|
|
10025
10027
|
"locationInModule": {
|
|
10026
10028
|
"filename": "src/web-function.ts",
|
|
10027
|
-
"line":
|
|
10029
|
+
"line": 204
|
|
10028
10030
|
},
|
|
10029
10031
|
"name": "metricResponseBytes",
|
|
10030
10032
|
"parameters": [
|
|
@@ -10057,7 +10059,7 @@
|
|
|
10057
10059
|
"immutable": true,
|
|
10058
10060
|
"locationInModule": {
|
|
10059
10061
|
"filename": "src/web-function.ts",
|
|
10060
|
-
"line":
|
|
10062
|
+
"line": 173
|
|
10061
10063
|
},
|
|
10062
10064
|
"name": "webFunctionArn",
|
|
10063
10065
|
"type": {
|
|
@@ -10076,7 +10078,7 @@
|
|
|
10076
10078
|
"immutable": true,
|
|
10077
10079
|
"locationInModule": {
|
|
10078
10080
|
"filename": "src/web-function.ts",
|
|
10079
|
-
"line":
|
|
10081
|
+
"line": 166
|
|
10080
10082
|
},
|
|
10081
10083
|
"name": "webFunctionName",
|
|
10082
10084
|
"type": {
|
|
@@ -10653,7 +10655,7 @@
|
|
|
10653
10655
|
},
|
|
10654
10656
|
"locationInModule": {
|
|
10655
10657
|
"filename": "src/web-function.ts",
|
|
10656
|
-
"line":
|
|
10658
|
+
"line": 420
|
|
10657
10659
|
},
|
|
10658
10660
|
"parameters": [
|
|
10659
10661
|
{
|
|
@@ -10682,7 +10684,7 @@
|
|
|
10682
10684
|
"kind": "class",
|
|
10683
10685
|
"locationInModule": {
|
|
10684
10686
|
"filename": "src/web-function.ts",
|
|
10685
|
-
"line":
|
|
10687
|
+
"line": 361
|
|
10686
10688
|
},
|
|
10687
10689
|
"methods": [
|
|
10688
10690
|
{
|
|
@@ -10692,7 +10694,7 @@
|
|
|
10692
10694
|
},
|
|
10693
10695
|
"locationInModule": {
|
|
10694
10696
|
"filename": "src/web-function.ts",
|
|
10695
|
-
"line":
|
|
10697
|
+
"line": 365
|
|
10696
10698
|
},
|
|
10697
10699
|
"name": "fromWebFunctionArn",
|
|
10698
10700
|
"parameters": [
|
|
@@ -10729,7 +10731,7 @@
|
|
|
10729
10731
|
},
|
|
10730
10732
|
"locationInModule": {
|
|
10731
10733
|
"filename": "src/web-function.ts",
|
|
10732
|
-
"line":
|
|
10734
|
+
"line": 379
|
|
10733
10735
|
},
|
|
10734
10736
|
"name": "fromWebFunctionAttributes",
|
|
10735
10737
|
"parameters": [
|
|
@@ -10766,7 +10768,7 @@
|
|
|
10766
10768
|
},
|
|
10767
10769
|
"locationInModule": {
|
|
10768
10770
|
"filename": "src/web-function.ts",
|
|
10769
|
-
"line":
|
|
10771
|
+
"line": 372
|
|
10770
10772
|
},
|
|
10771
10773
|
"name": "fromWebFunctionName",
|
|
10772
10774
|
"parameters": [
|
|
@@ -10803,7 +10805,7 @@
|
|
|
10803
10805
|
},
|
|
10804
10806
|
"locationInModule": {
|
|
10805
10807
|
"filename": "src/web-function.ts",
|
|
10806
|
-
"line":
|
|
10808
|
+
"line": 522
|
|
10807
10809
|
},
|
|
10808
10810
|
"name": "addEndpoint",
|
|
10809
10811
|
"parameters": [
|
|
@@ -10837,7 +10839,7 @@
|
|
|
10837
10839
|
},
|
|
10838
10840
|
"locationInModule": {
|
|
10839
10841
|
"filename": "src/web-function.ts",
|
|
10840
|
-
"line":
|
|
10842
|
+
"line": 530
|
|
10841
10843
|
},
|
|
10842
10844
|
"name": "addEnvironment",
|
|
10843
10845
|
"parameters": [
|
|
@@ -10860,6 +10862,61 @@
|
|
|
10860
10862
|
}
|
|
10861
10863
|
}
|
|
10862
10864
|
},
|
|
10865
|
+
{
|
|
10866
|
+
"docs": {
|
|
10867
|
+
"remarks": "For a role in this account, use `grantInvoke`.",
|
|
10868
|
+
"stability": "experimental",
|
|
10869
|
+
"summary": "Allows a principal in another account, an AWS service or an organization to call the function's endpoints, through the function's resource policy."
|
|
10870
|
+
},
|
|
10871
|
+
"locationInModule": {
|
|
10872
|
+
"filename": "src/web-function.ts",
|
|
10873
|
+
"line": 559
|
|
10874
|
+
},
|
|
10875
|
+
"name": "addPermission",
|
|
10876
|
+
"parameters": [
|
|
10877
|
+
{
|
|
10878
|
+
"docs": {
|
|
10879
|
+
"summary": "the statement ID (`Sid`): letters and digits, unique within the function."
|
|
10880
|
+
},
|
|
10881
|
+
"name": "id",
|
|
10882
|
+
"type": {
|
|
10883
|
+
"primitive": "string"
|
|
10884
|
+
}
|
|
10885
|
+
},
|
|
10886
|
+
{
|
|
10887
|
+
"name": "permission",
|
|
10888
|
+
"type": {
|
|
10889
|
+
"fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionPermission"
|
|
10890
|
+
}
|
|
10891
|
+
}
|
|
10892
|
+
]
|
|
10893
|
+
},
|
|
10894
|
+
{
|
|
10895
|
+
"docs": {
|
|
10896
|
+
"remarks": "The function has one resource policy (`AWS::Lambda::ResourcePolicy`), created on the first statement. This stack\nis its only writer: another stack or template can't also attach one, and changes made outside CloudFormation\nare overwritten by the next update of the policy.",
|
|
10897
|
+
"stability": "experimental",
|
|
10898
|
+
"summary": "Adds a statement to the function's resource policy, e.g. to let another account manage the function. For invoking, prefer `addPermission` or `grantInvoke`."
|
|
10899
|
+
},
|
|
10900
|
+
"locationInModule": {
|
|
10901
|
+
"filename": "src/web-function.ts",
|
|
10902
|
+
"line": 590
|
|
10903
|
+
},
|
|
10904
|
+
"name": "addToResourcePolicy",
|
|
10905
|
+
"overrides": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionBase",
|
|
10906
|
+
"parameters": [
|
|
10907
|
+
{
|
|
10908
|
+
"name": "statement",
|
|
10909
|
+
"type": {
|
|
10910
|
+
"fqn": "aws-cdk-lib.aws_iam.PolicyStatement"
|
|
10911
|
+
}
|
|
10912
|
+
}
|
|
10913
|
+
],
|
|
10914
|
+
"returns": {
|
|
10915
|
+
"type": {
|
|
10916
|
+
"fqn": "aws-cdk-lib.aws_iam.AddToResourcePolicyResult"
|
|
10917
|
+
}
|
|
10918
|
+
}
|
|
10919
|
+
},
|
|
10863
10920
|
{
|
|
10864
10921
|
"docs": {
|
|
10865
10922
|
"stability": "experimental",
|
|
@@ -10867,7 +10924,7 @@
|
|
|
10867
10924
|
},
|
|
10868
10925
|
"locationInModule": {
|
|
10869
10926
|
"filename": "src/web-function.ts",
|
|
10870
|
-
"line":
|
|
10927
|
+
"line": 541
|
|
10871
10928
|
},
|
|
10872
10929
|
"name": "addToRolePolicy",
|
|
10873
10930
|
"parameters": [
|
|
@@ -10887,7 +10944,7 @@
|
|
|
10887
10944
|
},
|
|
10888
10945
|
"locationInModule": {
|
|
10889
10946
|
"filename": "src/web-function.ts",
|
|
10890
|
-
"line":
|
|
10947
|
+
"line": 549
|
|
10891
10948
|
},
|
|
10892
10949
|
"name": "grantInvoke",
|
|
10893
10950
|
"overrides": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionBase",
|
|
@@ -10916,7 +10973,7 @@
|
|
|
10916
10973
|
"immutable": true,
|
|
10917
10974
|
"locationInModule": {
|
|
10918
10975
|
"filename": "src/web-function.ts",
|
|
10919
|
-
"line":
|
|
10976
|
+
"line": 390
|
|
10920
10977
|
},
|
|
10921
10978
|
"name": "currentRevision",
|
|
10922
10979
|
"type": {
|
|
@@ -10932,7 +10989,7 @@
|
|
|
10932
10989
|
"immutable": true,
|
|
10933
10990
|
"locationInModule": {
|
|
10934
10991
|
"filename": "src/web-function.ts",
|
|
10935
|
-
"line":
|
|
10992
|
+
"line": 393
|
|
10936
10993
|
},
|
|
10937
10994
|
"name": "endpoint",
|
|
10938
10995
|
"type": {
|
|
@@ -10947,7 +11004,7 @@
|
|
|
10947
11004
|
"immutable": true,
|
|
10948
11005
|
"locationInModule": {
|
|
10949
11006
|
"filename": "src/web-function.ts",
|
|
10950
|
-
"line":
|
|
11007
|
+
"line": 402
|
|
10951
11008
|
},
|
|
10952
11009
|
"name": "grantPrincipal",
|
|
10953
11010
|
"overrides": "aws-cdk-lib.aws_iam.IGrantable",
|
|
@@ -10963,7 +11020,7 @@
|
|
|
10963
11020
|
"immutable": true,
|
|
10964
11021
|
"locationInModule": {
|
|
10965
11022
|
"filename": "src/web-function.ts",
|
|
10966
|
-
"line":
|
|
11023
|
+
"line": 396
|
|
10967
11024
|
},
|
|
10968
11025
|
"name": "grants",
|
|
10969
11026
|
"type": {
|
|
@@ -10979,7 +11036,7 @@
|
|
|
10979
11036
|
"immutable": true,
|
|
10980
11037
|
"locationInModule": {
|
|
10981
11038
|
"filename": "src/web-function.ts",
|
|
10982
|
-
"line":
|
|
11039
|
+
"line": 408
|
|
10983
11040
|
},
|
|
10984
11041
|
"name": "logGroup",
|
|
10985
11042
|
"type": {
|
|
@@ -10995,7 +11052,7 @@
|
|
|
10995
11052
|
"immutable": true,
|
|
10996
11053
|
"locationInModule": {
|
|
10997
11054
|
"filename": "src/web-function.ts",
|
|
10998
|
-
"line":
|
|
11055
|
+
"line": 387
|
|
10999
11056
|
},
|
|
11000
11057
|
"name": "revisionId",
|
|
11001
11058
|
"type": {
|
|
@@ -11010,7 +11067,7 @@
|
|
|
11010
11067
|
"immutable": true,
|
|
11011
11068
|
"locationInModule": {
|
|
11012
11069
|
"filename": "src/web-function.ts",
|
|
11013
|
-
"line":
|
|
11070
|
+
"line": 399
|
|
11014
11071
|
},
|
|
11015
11072
|
"name": "role",
|
|
11016
11073
|
"type": {
|
|
@@ -11025,7 +11082,7 @@
|
|
|
11025
11082
|
"immutable": true,
|
|
11026
11083
|
"locationInModule": {
|
|
11027
11084
|
"filename": "src/web-function.ts",
|
|
11028
|
-
"line":
|
|
11085
|
+
"line": 384
|
|
11029
11086
|
},
|
|
11030
11087
|
"name": "webFunctionArn",
|
|
11031
11088
|
"overrides": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionBase",
|
|
@@ -11041,7 +11098,7 @@
|
|
|
11041
11098
|
"immutable": true,
|
|
11042
11099
|
"locationInModule": {
|
|
11043
11100
|
"filename": "src/web-function.ts",
|
|
11044
|
-
"line":
|
|
11101
|
+
"line": 383
|
|
11045
11102
|
},
|
|
11046
11103
|
"name": "webFunctionName",
|
|
11047
11104
|
"overrides": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionBase",
|
|
@@ -11064,7 +11121,7 @@
|
|
|
11064
11121
|
"kind": "interface",
|
|
11065
11122
|
"locationInModule": {
|
|
11066
11123
|
"filename": "src/web-function.ts",
|
|
11067
|
-
"line":
|
|
11124
|
+
"line": 210
|
|
11068
11125
|
},
|
|
11069
11126
|
"name": "WebFunctionAttributes",
|
|
11070
11127
|
"properties": [
|
|
@@ -11078,7 +11135,7 @@
|
|
|
11078
11135
|
"immutable": true,
|
|
11079
11136
|
"locationInModule": {
|
|
11080
11137
|
"filename": "src/web-function.ts",
|
|
11081
|
-
"line":
|
|
11138
|
+
"line": 231
|
|
11082
11139
|
},
|
|
11083
11140
|
"name": "endpointName",
|
|
11084
11141
|
"optional": true,
|
|
@@ -11096,7 +11153,7 @@
|
|
|
11096
11153
|
"immutable": true,
|
|
11097
11154
|
"locationInModule": {
|
|
11098
11155
|
"filename": "src/web-function.ts",
|
|
11099
|
-
"line":
|
|
11156
|
+
"line": 217
|
|
11100
11157
|
},
|
|
11101
11158
|
"name": "webFunctionArn",
|
|
11102
11159
|
"optional": true,
|
|
@@ -11114,7 +11171,7 @@
|
|
|
11114
11171
|
"immutable": true,
|
|
11115
11172
|
"locationInModule": {
|
|
11116
11173
|
"filename": "src/web-function.ts",
|
|
11117
|
-
"line":
|
|
11174
|
+
"line": 224
|
|
11118
11175
|
},
|
|
11119
11176
|
"name": "webFunctionName",
|
|
11120
11177
|
"optional": true,
|
|
@@ -11202,9 +11259,35 @@
|
|
|
11202
11259
|
"kind": "class",
|
|
11203
11260
|
"locationInModule": {
|
|
11204
11261
|
"filename": "src/web-function.ts",
|
|
11205
|
-
"line":
|
|
11262
|
+
"line": 272
|
|
11206
11263
|
},
|
|
11207
11264
|
"methods": [
|
|
11265
|
+
{
|
|
11266
|
+
"abstract": true,
|
|
11267
|
+
"docs": {
|
|
11268
|
+
"stability": "experimental",
|
|
11269
|
+
"summary": "Adds a statement to the function's resource policy (not added for an imported function)."
|
|
11270
|
+
},
|
|
11271
|
+
"locationInModule": {
|
|
11272
|
+
"filename": "src/web-function.ts",
|
|
11273
|
+
"line": 290
|
|
11274
|
+
},
|
|
11275
|
+
"name": "addToResourcePolicy",
|
|
11276
|
+
"overrides": "aws-cdk-lib.aws_iam.IResourceWithPolicyV2",
|
|
11277
|
+
"parameters": [
|
|
11278
|
+
{
|
|
11279
|
+
"name": "statement",
|
|
11280
|
+
"type": {
|
|
11281
|
+
"fqn": "aws-cdk-lib.aws_iam.PolicyStatement"
|
|
11282
|
+
}
|
|
11283
|
+
}
|
|
11284
|
+
],
|
|
11285
|
+
"returns": {
|
|
11286
|
+
"type": {
|
|
11287
|
+
"fqn": "aws-cdk-lib.aws_iam.AddToResourcePolicyResult"
|
|
11288
|
+
}
|
|
11289
|
+
}
|
|
11290
|
+
},
|
|
11208
11291
|
{
|
|
11209
11292
|
"abstract": true,
|
|
11210
11293
|
"docs": {
|
|
@@ -11214,7 +11297,7 @@
|
|
|
11214
11297
|
},
|
|
11215
11298
|
"locationInModule": {
|
|
11216
11299
|
"filename": "src/web-function.ts",
|
|
11217
|
-
"line":
|
|
11300
|
+
"line": 285
|
|
11218
11301
|
},
|
|
11219
11302
|
"name": "grantInvoke",
|
|
11220
11303
|
"overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
|
|
@@ -11241,7 +11324,7 @@
|
|
|
11241
11324
|
},
|
|
11242
11325
|
"locationInModule": {
|
|
11243
11326
|
"filename": "src/web-function.ts",
|
|
11244
|
-
"line":
|
|
11327
|
+
"line": 301
|
|
11245
11328
|
},
|
|
11246
11329
|
"name": "metric",
|
|
11247
11330
|
"overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
|
|
@@ -11273,7 +11356,7 @@
|
|
|
11273
11356
|
},
|
|
11274
11357
|
"locationInModule": {
|
|
11275
11358
|
"filename": "src/web-function.ts",
|
|
11276
|
-
"line":
|
|
11359
|
+
"line": 316
|
|
11277
11360
|
},
|
|
11278
11361
|
"name": "metricActiveTime",
|
|
11279
11362
|
"overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
|
|
@@ -11300,7 +11383,7 @@
|
|
|
11300
11383
|
},
|
|
11301
11384
|
"locationInModule": {
|
|
11302
11385
|
"filename": "src/web-function.ts",
|
|
11303
|
-
"line":
|
|
11386
|
+
"line": 331
|
|
11304
11387
|
},
|
|
11305
11388
|
"name": "metricConcurrentRequests",
|
|
11306
11389
|
"overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
|
|
@@ -11326,7 +11409,7 @@
|
|
|
11326
11409
|
},
|
|
11327
11410
|
"locationInModule": {
|
|
11328
11411
|
"filename": "src/web-function.ts",
|
|
11329
|
-
"line":
|
|
11412
|
+
"line": 321
|
|
11330
11413
|
},
|
|
11331
11414
|
"name": "metricCpuTime",
|
|
11332
11415
|
"overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
|
|
@@ -11354,7 +11437,7 @@
|
|
|
11354
11437
|
},
|
|
11355
11438
|
"locationInModule": {
|
|
11356
11439
|
"filename": "src/web-function.ts",
|
|
11357
|
-
"line":
|
|
11440
|
+
"line": 340
|
|
11358
11441
|
},
|
|
11359
11442
|
"name": "metricMaxMemoryUsage",
|
|
11360
11443
|
"overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
|
|
@@ -11380,7 +11463,7 @@
|
|
|
11380
11463
|
},
|
|
11381
11464
|
"locationInModule": {
|
|
11382
11465
|
"filename": "src/web-function.ts",
|
|
11383
|
-
"line":
|
|
11466
|
+
"line": 345
|
|
11384
11467
|
},
|
|
11385
11468
|
"name": "metricResponseBytes",
|
|
11386
11469
|
"overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
|
|
@@ -11411,7 +11494,7 @@
|
|
|
11411
11494
|
"immutable": true,
|
|
11412
11495
|
"locationInModule": {
|
|
11413
11496
|
"filename": "src/web-function.ts",
|
|
11414
|
-
"line":
|
|
11497
|
+
"line": 274
|
|
11415
11498
|
},
|
|
11416
11499
|
"name": "webFunctionArn",
|
|
11417
11500
|
"overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
|
|
@@ -11428,7 +11511,7 @@
|
|
|
11428
11511
|
"immutable": true,
|
|
11429
11512
|
"locationInModule": {
|
|
11430
11513
|
"filename": "src/web-function.ts",
|
|
11431
|
-
"line":
|
|
11514
|
+
"line": 273
|
|
11432
11515
|
},
|
|
11433
11516
|
"name": "webFunctionName",
|
|
11434
11517
|
"overrides": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction",
|
|
@@ -11444,7 +11527,7 @@
|
|
|
11444
11527
|
"immutable": true,
|
|
11445
11528
|
"locationInModule": {
|
|
11446
11529
|
"filename": "src/web-function.ts",
|
|
11447
|
-
"line":
|
|
11530
|
+
"line": 277
|
|
11448
11531
|
},
|
|
11449
11532
|
"name": "webFunctionRef",
|
|
11450
11533
|
"overrides": "aws-cdk-lib.interfaces.aws_lambda.IWebFunctionRef",
|
|
@@ -11656,7 +11739,7 @@
|
|
|
11656
11739
|
},
|
|
11657
11740
|
"locationInModule": {
|
|
11658
11741
|
"filename": "src/web-function-endpoint.ts",
|
|
11659
|
-
"line":
|
|
11742
|
+
"line": 431
|
|
11660
11743
|
},
|
|
11661
11744
|
"name": "grantInvoke",
|
|
11662
11745
|
"parameters": [
|
|
@@ -11682,7 +11765,7 @@
|
|
|
11682
11765
|
},
|
|
11683
11766
|
"locationInModule": {
|
|
11684
11767
|
"filename": "src/web-function-endpoint.ts",
|
|
11685
|
-
"line":
|
|
11768
|
+
"line": 366
|
|
11686
11769
|
},
|
|
11687
11770
|
"name": "metric",
|
|
11688
11771
|
"parameters": [
|
|
@@ -11714,7 +11797,7 @@
|
|
|
11714
11797
|
},
|
|
11715
11798
|
"locationInModule": {
|
|
11716
11799
|
"filename": "src/web-function-endpoint.ts",
|
|
11717
|
-
"line":
|
|
11800
|
+
"line": 413
|
|
11718
11801
|
},
|
|
11719
11802
|
"name": "metricActiveEnvironments",
|
|
11720
11803
|
"parameters": [
|
|
@@ -11740,7 +11823,7 @@
|
|
|
11740
11823
|
},
|
|
11741
11824
|
"locationInModule": {
|
|
11742
11825
|
"filename": "src/web-function-endpoint.ts",
|
|
11743
|
-
"line":
|
|
11826
|
+
"line": 399
|
|
11744
11827
|
},
|
|
11745
11828
|
"name": "metricClientErrorRate",
|
|
11746
11829
|
"parameters": [
|
|
@@ -11766,7 +11849,7 @@
|
|
|
11766
11849
|
},
|
|
11767
11850
|
"locationInModule": {
|
|
11768
11851
|
"filename": "src/web-function-endpoint.ts",
|
|
11769
|
-
"line":
|
|
11852
|
+
"line": 386
|
|
11770
11853
|
},
|
|
11771
11854
|
"name": "metricClientErrors",
|
|
11772
11855
|
"parameters": [
|
|
@@ -11791,7 +11874,7 @@
|
|
|
11791
11874
|
},
|
|
11792
11875
|
"locationInModule": {
|
|
11793
11876
|
"filename": "src/web-function-endpoint.ts",
|
|
11794
|
-
"line":
|
|
11877
|
+
"line": 423
|
|
11795
11878
|
},
|
|
11796
11879
|
"name": "metricEnvironmentThrottles",
|
|
11797
11880
|
"parameters": [
|
|
@@ -11817,7 +11900,7 @@
|
|
|
11817
11900
|
},
|
|
11818
11901
|
"locationInModule": {
|
|
11819
11902
|
"filename": "src/web-function-endpoint.ts",
|
|
11820
|
-
"line":
|
|
11903
|
+
"line": 378
|
|
11821
11904
|
},
|
|
11822
11905
|
"name": "metricRequests",
|
|
11823
11906
|
"parameters": [
|
|
@@ -11842,7 +11925,7 @@
|
|
|
11842
11925
|
},
|
|
11843
11926
|
"locationInModule": {
|
|
11844
11927
|
"filename": "src/web-function-endpoint.ts",
|
|
11845
|
-
"line":
|
|
11928
|
+
"line": 418
|
|
11846
11929
|
},
|
|
11847
11930
|
"name": "metricRequestThrottles",
|
|
11848
11931
|
"parameters": [
|
|
@@ -11868,7 +11951,7 @@
|
|
|
11868
11951
|
},
|
|
11869
11952
|
"locationInModule": {
|
|
11870
11953
|
"filename": "src/web-function-endpoint.ts",
|
|
11871
|
-
"line":
|
|
11954
|
+
"line": 404
|
|
11872
11955
|
},
|
|
11873
11956
|
"name": "metricServerErrorRate",
|
|
11874
11957
|
"parameters": [
|
|
@@ -11894,7 +11977,7 @@
|
|
|
11894
11977
|
},
|
|
11895
11978
|
"locationInModule": {
|
|
11896
11979
|
"filename": "src/web-function-endpoint.ts",
|
|
11897
|
-
"line":
|
|
11980
|
+
"line": 394
|
|
11898
11981
|
},
|
|
11899
11982
|
"name": "metricServerErrors",
|
|
11900
11983
|
"parameters": [
|
|
@@ -11912,6 +11995,34 @@
|
|
|
11912
11995
|
}
|
|
11913
11996
|
}
|
|
11914
11997
|
},
|
|
11998
|
+
{
|
|
11999
|
+
"docs": {
|
|
12000
|
+
"remarks": "Only for `PER_REGION` endpoints.",
|
|
12001
|
+
"stability": "experimental",
|
|
12002
|
+
"summary": "The domain name of this endpoint in one region."
|
|
12003
|
+
},
|
|
12004
|
+
"locationInModule": {
|
|
12005
|
+
"filename": "src/web-function-endpoint.ts",
|
|
12006
|
+
"line": 309
|
|
12007
|
+
},
|
|
12008
|
+
"name": "regionalDomainName",
|
|
12009
|
+
"parameters": [
|
|
12010
|
+
{
|
|
12011
|
+
"docs": {
|
|
12012
|
+
"summary": "one of `regions`."
|
|
12013
|
+
},
|
|
12014
|
+
"name": "region",
|
|
12015
|
+
"type": {
|
|
12016
|
+
"primitive": "string"
|
|
12017
|
+
}
|
|
12018
|
+
}
|
|
12019
|
+
],
|
|
12020
|
+
"returns": {
|
|
12021
|
+
"type": {
|
|
12022
|
+
"primitive": "string"
|
|
12023
|
+
}
|
|
12024
|
+
}
|
|
12025
|
+
},
|
|
11915
12026
|
{
|
|
11916
12027
|
"docs": {
|
|
11917
12028
|
"remarks": "Only for `PER_REGION` endpoints.",
|
|
@@ -11920,7 +12031,7 @@
|
|
|
11920
12031
|
},
|
|
11921
12032
|
"locationInModule": {
|
|
11922
12033
|
"filename": "src/web-function-endpoint.ts",
|
|
11923
|
-
"line":
|
|
12034
|
+
"line": 300
|
|
11924
12035
|
},
|
|
11925
12036
|
"name": "regionalUrl",
|
|
11926
12037
|
"parameters": [
|
|
@@ -11948,7 +12059,7 @@
|
|
|
11948
12059
|
},
|
|
11949
12060
|
"locationInModule": {
|
|
11950
12061
|
"filename": "src/web-function-endpoint.ts",
|
|
11951
|
-
"line":
|
|
12062
|
+
"line": 337
|
|
11952
12063
|
},
|
|
11953
12064
|
"name": "routeTraffic",
|
|
11954
12065
|
"parameters": [
|
|
@@ -12094,7 +12205,7 @@
|
|
|
12094
12205
|
"immutable": true,
|
|
12095
12206
|
"locationInModule": {
|
|
12096
12207
|
"filename": "src/web-function-endpoint.ts",
|
|
12097
|
-
"line":
|
|
12208
|
+
"line": 202
|
|
12098
12209
|
},
|
|
12099
12210
|
"name": "rollbackAlarms",
|
|
12100
12211
|
"type": {
|
|
@@ -12120,6 +12231,21 @@
|
|
|
12120
12231
|
"type": {
|
|
12121
12232
|
"primitive": "string"
|
|
12122
12233
|
}
|
|
12234
|
+
},
|
|
12235
|
+
{
|
|
12236
|
+
"docs": {
|
|
12237
|
+
"stability": "experimental",
|
|
12238
|
+
"summary": "The function this endpoint belongs to."
|
|
12239
|
+
},
|
|
12240
|
+
"immutable": true,
|
|
12241
|
+
"locationInModule": {
|
|
12242
|
+
"filename": "src/web-function-endpoint.ts",
|
|
12243
|
+
"line": 196
|
|
12244
|
+
},
|
|
12245
|
+
"name": "webFunction",
|
|
12246
|
+
"type": {
|
|
12247
|
+
"fqn": "@ashishpandeyone/cdk-lambda-web-function.IWebFunction"
|
|
12248
|
+
}
|
|
12123
12249
|
}
|
|
12124
12250
|
],
|
|
12125
12251
|
"symbolId": "src/web-function-endpoint:WebFunctionEndpoint"
|
|
@@ -12327,18 +12453,18 @@
|
|
|
12327
12453
|
"kind": "class",
|
|
12328
12454
|
"locationInModule": {
|
|
12329
12455
|
"filename": "src/web-function-grants.ts",
|
|
12330
|
-
"line":
|
|
12456
|
+
"line": 8
|
|
12331
12457
|
},
|
|
12332
12458
|
"methods": [
|
|
12333
12459
|
{
|
|
12334
12460
|
"docs": {
|
|
12335
|
-
"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.",
|
|
12461
|
+
"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.\n\nA grantee in the function's account gets an IAM policy statement. Another account or an AWS service also gets\na statement in the function's resource policy (not for an imported function's endpoints).",
|
|
12336
12462
|
"stability": "experimental",
|
|
12337
12463
|
"summary": "Allows `grantee` to call the endpoint (`lambda:InvokeWebFunctionEndpoint`)."
|
|
12338
12464
|
},
|
|
12339
12465
|
"locationInModule": {
|
|
12340
12466
|
"filename": "src/web-function-grants.ts",
|
|
12341
|
-
"line":
|
|
12467
|
+
"line": 36
|
|
12342
12468
|
},
|
|
12343
12469
|
"name": "invoke",
|
|
12344
12470
|
"parameters": [
|
|
@@ -12463,7 +12589,7 @@
|
|
|
12463
12589
|
"kind": "interface",
|
|
12464
12590
|
"locationInModule": {
|
|
12465
12591
|
"filename": "src/web-function.ts",
|
|
12466
|
-
"line":
|
|
12592
|
+
"line": 24
|
|
12467
12593
|
},
|
|
12468
12594
|
"name": "WebFunctionOptions",
|
|
12469
12595
|
"properties": [
|
|
@@ -12476,7 +12602,7 @@
|
|
|
12476
12602
|
"immutable": true,
|
|
12477
12603
|
"locationInModule": {
|
|
12478
12604
|
"filename": "src/web-function.ts",
|
|
12479
|
-
"line":
|
|
12605
|
+
"line": 28
|
|
12480
12606
|
},
|
|
12481
12607
|
"name": "authType",
|
|
12482
12608
|
"type": {
|
|
@@ -12493,7 +12619,7 @@
|
|
|
12493
12619
|
"immutable": true,
|
|
12494
12620
|
"locationInModule": {
|
|
12495
12621
|
"filename": "src/web-function.ts",
|
|
12496
|
-
"line":
|
|
12622
|
+
"line": 117
|
|
12497
12623
|
},
|
|
12498
12624
|
"name": "applicationLogLevelV2",
|
|
12499
12625
|
"optional": true,
|
|
@@ -12511,7 +12637,7 @@
|
|
|
12511
12637
|
"immutable": true,
|
|
12512
12638
|
"locationInModule": {
|
|
12513
12639
|
"filename": "src/web-function.ts",
|
|
12514
|
-
"line":
|
|
12640
|
+
"line": 63
|
|
12515
12641
|
},
|
|
12516
12642
|
"name": "description",
|
|
12517
12643
|
"optional": true,
|
|
@@ -12529,7 +12655,7 @@
|
|
|
12529
12655
|
"immutable": true,
|
|
12530
12656
|
"locationInModule": {
|
|
12531
12657
|
"filename": "src/web-function.ts",
|
|
12532
|
-
"line":
|
|
12658
|
+
"line": 37
|
|
12533
12659
|
},
|
|
12534
12660
|
"name": "endpoint",
|
|
12535
12661
|
"optional": true,
|
|
@@ -12548,7 +12674,7 @@
|
|
|
12548
12674
|
"immutable": true,
|
|
12549
12675
|
"locationInModule": {
|
|
12550
12676
|
"filename": "src/web-function.ts",
|
|
12551
|
-
"line":
|
|
12677
|
+
"line": 80
|
|
12552
12678
|
},
|
|
12553
12679
|
"name": "environment",
|
|
12554
12680
|
"optional": true,
|
|
@@ -12572,7 +12698,7 @@
|
|
|
12572
12698
|
"immutable": true,
|
|
12573
12699
|
"locationInModule": {
|
|
12574
12700
|
"filename": "src/web-function.ts",
|
|
12575
|
-
"line":
|
|
12701
|
+
"line": 110
|
|
12576
12702
|
},
|
|
12577
12703
|
"name": "logRemovalPolicy",
|
|
12578
12704
|
"optional": true,
|
|
@@ -12590,7 +12716,7 @@
|
|
|
12590
12716
|
"immutable": true,
|
|
12591
12717
|
"locationInModule": {
|
|
12592
12718
|
"filename": "src/web-function.ts",
|
|
12593
|
-
"line":
|
|
12719
|
+
"line": 102
|
|
12594
12720
|
},
|
|
12595
12721
|
"name": "logRetention",
|
|
12596
12722
|
"optional": true,
|
|
@@ -12609,7 +12735,7 @@
|
|
|
12609
12735
|
"immutable": true,
|
|
12610
12736
|
"locationInModule": {
|
|
12611
12737
|
"filename": "src/web-function.ts",
|
|
12612
|
-
"line":
|
|
12738
|
+
"line": 95
|
|
12613
12739
|
},
|
|
12614
12740
|
"name": "maxConcurrencyPerEnvironment",
|
|
12615
12741
|
"optional": true,
|
|
@@ -12628,7 +12754,7 @@
|
|
|
12628
12754
|
"immutable": true,
|
|
12629
12755
|
"locationInModule": {
|
|
12630
12756
|
"filename": "src/web-function.ts",
|
|
12631
|
-
"line":
|
|
12757
|
+
"line": 49
|
|
12632
12758
|
},
|
|
12633
12759
|
"name": "revisionRetention",
|
|
12634
12760
|
"optional": true,
|
|
@@ -12647,7 +12773,7 @@
|
|
|
12647
12773
|
"immutable": true,
|
|
12648
12774
|
"locationInModule": {
|
|
12649
12775
|
"filename": "src/web-function.ts",
|
|
12650
|
-
"line":
|
|
12776
|
+
"line": 73
|
|
12651
12777
|
},
|
|
12652
12778
|
"name": "role",
|
|
12653
12779
|
"optional": true,
|
|
@@ -12665,7 +12791,7 @@
|
|
|
12665
12791
|
"immutable": true,
|
|
12666
12792
|
"locationInModule": {
|
|
12667
12793
|
"filename": "src/web-function.ts",
|
|
12668
|
-
"line":
|
|
12794
|
+
"line": 124
|
|
12669
12795
|
},
|
|
12670
12796
|
"name": "systemLogLevelV2",
|
|
12671
12797
|
"optional": true,
|
|
@@ -12683,7 +12809,7 @@
|
|
|
12683
12809
|
"immutable": true,
|
|
12684
12810
|
"locationInModule": {
|
|
12685
12811
|
"filename": "src/web-function.ts",
|
|
12686
|
-
"line":
|
|
12812
|
+
"line": 87
|
|
12687
12813
|
},
|
|
12688
12814
|
"name": "timeout",
|
|
12689
12815
|
"optional": true,
|
|
@@ -12702,7 +12828,7 @@
|
|
|
12702
12828
|
"immutable": true,
|
|
12703
12829
|
"locationInModule": {
|
|
12704
12830
|
"filename": "src/web-function.ts",
|
|
12705
|
-
"line":
|
|
12831
|
+
"line": 56
|
|
12706
12832
|
},
|
|
12707
12833
|
"name": "webFunctionName",
|
|
12708
12834
|
"optional": true,
|
|
@@ -12713,6 +12839,325 @@
|
|
|
12713
12839
|
],
|
|
12714
12840
|
"symbolId": "src/web-function:WebFunctionOptions"
|
|
12715
12841
|
},
|
|
12842
|
+
"@ashishpandeyone/cdk-lambda-web-function.WebFunctionOrigin": {
|
|
12843
|
+
"assembly": "@ashishpandeyone/cdk-lambda-web-function",
|
|
12844
|
+
"base": "aws-cdk-lib.aws_cloudfront.OriginBase",
|
|
12845
|
+
"docs": {
|
|
12846
|
+
"remarks": "Use `WebFunctionOrigin.withOriginAccessControl(endpoint)` for an `AWS_IAM` endpoint: CloudFront signs every request,\nand only your distribution may call the endpoint. `new WebFunctionOrigin(endpoint)` is for a public (`NONE`) endpoint.",
|
|
12847
|
+
"stability": "experimental",
|
|
12848
|
+
"summary": "A CloudFront origin for a Web Function endpoint."
|
|
12849
|
+
},
|
|
12850
|
+
"fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionOrigin",
|
|
12851
|
+
"initializer": {
|
|
12852
|
+
"docs": {
|
|
12853
|
+
"stability": "experimental"
|
|
12854
|
+
},
|
|
12855
|
+
"locationInModule": {
|
|
12856
|
+
"filename": "src/web-function-origin.ts",
|
|
12857
|
+
"line": 95
|
|
12858
|
+
},
|
|
12859
|
+
"parameters": [
|
|
12860
|
+
{
|
|
12861
|
+
"name": "endpoint",
|
|
12862
|
+
"type": {
|
|
12863
|
+
"fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint"
|
|
12864
|
+
}
|
|
12865
|
+
},
|
|
12866
|
+
{
|
|
12867
|
+
"name": "props",
|
|
12868
|
+
"optional": true,
|
|
12869
|
+
"type": {
|
|
12870
|
+
"fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionOriginProps"
|
|
12871
|
+
}
|
|
12872
|
+
}
|
|
12873
|
+
]
|
|
12874
|
+
},
|
|
12875
|
+
"kind": "class",
|
|
12876
|
+
"locationInModule": {
|
|
12877
|
+
"filename": "src/web-function-origin.ts",
|
|
12878
|
+
"line": 72
|
|
12879
|
+
},
|
|
12880
|
+
"methods": [
|
|
12881
|
+
{
|
|
12882
|
+
"docs": {
|
|
12883
|
+
"remarks": "The distribution must be in the function's stack.",
|
|
12884
|
+
"stability": "experimental",
|
|
12885
|
+
"summary": "An origin for an `AWS_IAM` endpoint, with origin access control: CloudFront signs every request to the endpoint (`always-amz-auth`, which keeps the viewer's `Authorization` header for your application), and the function's resource policy allows `cloudfront.amazonaws.com` to call this endpoint on behalf of this distribution only."
|
|
12886
|
+
},
|
|
12887
|
+
"locationInModule": {
|
|
12888
|
+
"filename": "src/web-function-origin.ts",
|
|
12889
|
+
"line": 80
|
|
12890
|
+
},
|
|
12891
|
+
"name": "withOriginAccessControl",
|
|
12892
|
+
"parameters": [
|
|
12893
|
+
{
|
|
12894
|
+
"name": "endpoint",
|
|
12895
|
+
"type": {
|
|
12896
|
+
"fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint"
|
|
12897
|
+
}
|
|
12898
|
+
},
|
|
12899
|
+
{
|
|
12900
|
+
"name": "props",
|
|
12901
|
+
"optional": true,
|
|
12902
|
+
"type": {
|
|
12903
|
+
"fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionOriginWithOacProps"
|
|
12904
|
+
}
|
|
12905
|
+
}
|
|
12906
|
+
],
|
|
12907
|
+
"returns": {
|
|
12908
|
+
"type": {
|
|
12909
|
+
"fqn": "aws-cdk-lib.aws_cloudfront.IOrigin"
|
|
12910
|
+
}
|
|
12911
|
+
},
|
|
12912
|
+
"static": true
|
|
12913
|
+
},
|
|
12914
|
+
{
|
|
12915
|
+
"docs": {
|
|
12916
|
+
"stability": "experimental"
|
|
12917
|
+
},
|
|
12918
|
+
"locationInModule": {
|
|
12919
|
+
"filename": "src/web-function-origin.ts",
|
|
12920
|
+
"line": 105
|
|
12921
|
+
},
|
|
12922
|
+
"name": "renderCustomOriginConfig",
|
|
12923
|
+
"overrides": "aws-cdk-lib.aws_cloudfront.OriginBase",
|
|
12924
|
+
"protected": true,
|
|
12925
|
+
"returns": {
|
|
12926
|
+
"optional": true,
|
|
12927
|
+
"type": {
|
|
12928
|
+
"fqn": "aws-cdk-lib.aws_cloudfront.CfnDistribution.CustomOriginConfigProperty"
|
|
12929
|
+
}
|
|
12930
|
+
}
|
|
12931
|
+
}
|
|
12932
|
+
],
|
|
12933
|
+
"name": "WebFunctionOrigin",
|
|
12934
|
+
"symbolId": "src/web-function-origin:WebFunctionOrigin"
|
|
12935
|
+
},
|
|
12936
|
+
"@ashishpandeyone/cdk-lambda-web-function.WebFunctionOriginProps": {
|
|
12937
|
+
"assembly": "@ashishpandeyone/cdk-lambda-web-function",
|
|
12938
|
+
"datatype": true,
|
|
12939
|
+
"docs": {
|
|
12940
|
+
"stability": "experimental",
|
|
12941
|
+
"summary": "Properties for a Web Function endpoint origin."
|
|
12942
|
+
},
|
|
12943
|
+
"fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionOriginProps",
|
|
12944
|
+
"interfaces": [
|
|
12945
|
+
"aws-cdk-lib.aws_cloudfront.OriginProps"
|
|
12946
|
+
],
|
|
12947
|
+
"kind": "interface",
|
|
12948
|
+
"locationInModule": {
|
|
12949
|
+
"filename": "src/web-function-origin.ts",
|
|
12950
|
+
"line": 20
|
|
12951
|
+
},
|
|
12952
|
+
"name": "WebFunctionOriginProps",
|
|
12953
|
+
"properties": [
|
|
12954
|
+
{
|
|
12955
|
+
"abstract": true,
|
|
12956
|
+
"docs": {
|
|
12957
|
+
"default": "OriginIpAddressType.IPV4",
|
|
12958
|
+
"stability": "experimental",
|
|
12959
|
+
"summary": "Which IP protocol CloudFront uses to connect to the origin."
|
|
12960
|
+
},
|
|
12961
|
+
"immutable": true,
|
|
12962
|
+
"locationInModule": {
|
|
12963
|
+
"filename": "src/web-function-origin.ts",
|
|
12964
|
+
"line": 48
|
|
12965
|
+
},
|
|
12966
|
+
"name": "ipAddressType",
|
|
12967
|
+
"optional": true,
|
|
12968
|
+
"type": {
|
|
12969
|
+
"fqn": "aws-cdk-lib.aws_cloudfront.OriginIpAddressType"
|
|
12970
|
+
}
|
|
12971
|
+
},
|
|
12972
|
+
{
|
|
12973
|
+
"abstract": true,
|
|
12974
|
+
"docs": {
|
|
12975
|
+
"default": "Duration.seconds(5)",
|
|
12976
|
+
"stability": "experimental",
|
|
12977
|
+
"summary": "How long CloudFront keeps its connection to the origin open."
|
|
12978
|
+
},
|
|
12979
|
+
"immutable": true,
|
|
12980
|
+
"locationInModule": {
|
|
12981
|
+
"filename": "src/web-function-origin.ts",
|
|
12982
|
+
"line": 41
|
|
12983
|
+
},
|
|
12984
|
+
"name": "keepaliveTimeout",
|
|
12985
|
+
"optional": true,
|
|
12986
|
+
"type": {
|
|
12987
|
+
"fqn": "aws-cdk-lib.Duration"
|
|
12988
|
+
}
|
|
12989
|
+
},
|
|
12990
|
+
{
|
|
12991
|
+
"abstract": true,
|
|
12992
|
+
"docs": {
|
|
12993
|
+
"default": "Duration.seconds(30)",
|
|
12994
|
+
"remarks": "Above 120 seconds needs a CloudFront quota increase.",
|
|
12995
|
+
"stability": "experimental",
|
|
12996
|
+
"summary": "How long CloudFront waits for a response from the origin."
|
|
12997
|
+
},
|
|
12998
|
+
"immutable": true,
|
|
12999
|
+
"locationInModule": {
|
|
13000
|
+
"filename": "src/web-function-origin.ts",
|
|
13001
|
+
"line": 34
|
|
13002
|
+
},
|
|
13003
|
+
"name": "readTimeout",
|
|
13004
|
+
"optional": true,
|
|
13005
|
+
"type": {
|
|
13006
|
+
"fqn": "aws-cdk-lib.Duration"
|
|
13007
|
+
}
|
|
13008
|
+
},
|
|
13009
|
+
{
|
|
13010
|
+
"abstract": true,
|
|
13011
|
+
"docs": {
|
|
13012
|
+
"default": "- the endpoint's home region",
|
|
13013
|
+
"remarks": "Only one region per origin; use an origin\ngroup or one origin per behavior for more.",
|
|
13014
|
+
"stability": "experimental",
|
|
13015
|
+
"summary": "For a `PER_REGION` endpoint: the region whose URL CloudFront calls."
|
|
13016
|
+
},
|
|
13017
|
+
"immutable": true,
|
|
13018
|
+
"locationInModule": {
|
|
13019
|
+
"filename": "src/web-function-origin.ts",
|
|
13020
|
+
"line": 27
|
|
13021
|
+
},
|
|
13022
|
+
"name": "region",
|
|
13023
|
+
"optional": true,
|
|
13024
|
+
"type": {
|
|
13025
|
+
"primitive": "string"
|
|
13026
|
+
}
|
|
13027
|
+
}
|
|
13028
|
+
],
|
|
13029
|
+
"symbolId": "src/web-function-origin:WebFunctionOriginProps"
|
|
13030
|
+
},
|
|
13031
|
+
"@ashishpandeyone/cdk-lambda-web-function.WebFunctionOriginWithOacProps": {
|
|
13032
|
+
"assembly": "@ashishpandeyone/cdk-lambda-web-function",
|
|
13033
|
+
"datatype": true,
|
|
13034
|
+
"docs": {
|
|
13035
|
+
"stability": "experimental",
|
|
13036
|
+
"summary": "Properties for a Web Function endpoint origin with origin access control."
|
|
13037
|
+
},
|
|
13038
|
+
"fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionOriginWithOacProps",
|
|
13039
|
+
"interfaces": [
|
|
13040
|
+
"@ashishpandeyone/cdk-lambda-web-function.WebFunctionOriginProps"
|
|
13041
|
+
],
|
|
13042
|
+
"kind": "interface",
|
|
13043
|
+
"locationInModule": {
|
|
13044
|
+
"filename": "src/web-function-origin.ts",
|
|
13045
|
+
"line": 54
|
|
13046
|
+
},
|
|
13047
|
+
"name": "WebFunctionOriginWithOacProps",
|
|
13048
|
+
"properties": [
|
|
13049
|
+
{
|
|
13050
|
+
"abstract": true,
|
|
13051
|
+
"docs": {
|
|
13052
|
+
"default": "- one is created per stack and signing protocol",
|
|
13053
|
+
"remarks": "It must have origin type `lambda`, signing behavior `always-amz-auth`, and signing\nprotocol `sigv4` (a regional endpoint) or `sigv4a` (a `MULTI_REGION` endpoint's global domain). Checked at\nsynthesis when it's defined in this app (CDK's `FunctionUrlOriginAccessControl` signs with `always`, which\nCloudFront rejects for Web Function origins).",
|
|
13054
|
+
"stability": "experimental",
|
|
13055
|
+
"summary": "The origin access control."
|
|
13056
|
+
},
|
|
13057
|
+
"immutable": true,
|
|
13058
|
+
"locationInModule": {
|
|
13059
|
+
"filename": "src/web-function-origin.ts",
|
|
13060
|
+
"line": 63
|
|
13061
|
+
},
|
|
13062
|
+
"name": "originAccessControl",
|
|
13063
|
+
"optional": true,
|
|
13064
|
+
"type": {
|
|
13065
|
+
"fqn": "aws-cdk-lib.interfaces.aws_cloudfront.IOriginAccessControlRef"
|
|
13066
|
+
}
|
|
13067
|
+
}
|
|
13068
|
+
],
|
|
13069
|
+
"symbolId": "src/web-function-origin:WebFunctionOriginWithOacProps"
|
|
13070
|
+
},
|
|
13071
|
+
"@ashishpandeyone/cdk-lambda-web-function.WebFunctionPermission": {
|
|
13072
|
+
"assembly": "@ashishpandeyone/cdk-lambda-web-function",
|
|
13073
|
+
"datatype": true,
|
|
13074
|
+
"docs": {
|
|
13075
|
+
"stability": "experimental",
|
|
13076
|
+
"summary": "Permission for a principal outside this account, an AWS service or an organization to call a function's endpoints."
|
|
13077
|
+
},
|
|
13078
|
+
"fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionPermission",
|
|
13079
|
+
"kind": "interface",
|
|
13080
|
+
"locationInModule": {
|
|
13081
|
+
"filename": "src/web-function.ts",
|
|
13082
|
+
"line": 237
|
|
13083
|
+
},
|
|
13084
|
+
"name": "WebFunctionPermission",
|
|
13085
|
+
"properties": [
|
|
13086
|
+
{
|
|
13087
|
+
"abstract": true,
|
|
13088
|
+
"docs": {
|
|
13089
|
+
"remarks": "A principal in another account also needs `lambda:InvokeWebFunctionEndpoint` in its own IAM policy.",
|
|
13090
|
+
"stability": "experimental",
|
|
13091
|
+
"summary": "Who may call: an account (`iam.AccountPrincipal`), a role or user (`iam.ArnPrincipal`), an AWS service (`iam.ServicePrincipal`, with `sourceArn` or `sourceAccount`) or an organization (`iam.OrganizationPrincipal`)."
|
|
13092
|
+
},
|
|
13093
|
+
"immutable": true,
|
|
13094
|
+
"locationInModule": {
|
|
13095
|
+
"filename": "src/web-function.ts",
|
|
13096
|
+
"line": 244
|
|
13097
|
+
},
|
|
13098
|
+
"name": "principal",
|
|
13099
|
+
"type": {
|
|
13100
|
+
"fqn": "aws-cdk-lib.aws_iam.IPrincipal"
|
|
13101
|
+
}
|
|
13102
|
+
},
|
|
13103
|
+
{
|
|
13104
|
+
"abstract": true,
|
|
13105
|
+
"docs": {
|
|
13106
|
+
"default": "- every endpoint of the function, including ones added later",
|
|
13107
|
+
"remarks": "It must belong to this function.",
|
|
13108
|
+
"stability": "experimental",
|
|
13109
|
+
"summary": "The endpoint the principal may call."
|
|
13110
|
+
},
|
|
13111
|
+
"immutable": true,
|
|
13112
|
+
"locationInModule": {
|
|
13113
|
+
"filename": "src/web-function.ts",
|
|
13114
|
+
"line": 251
|
|
13115
|
+
},
|
|
13116
|
+
"name": "endpoint",
|
|
13117
|
+
"optional": true,
|
|
13118
|
+
"type": {
|
|
13119
|
+
"fqn": "@ashishpandeyone/cdk-lambda-web-function.WebFunctionEndpoint"
|
|
13120
|
+
}
|
|
13121
|
+
},
|
|
13122
|
+
{
|
|
13123
|
+
"abstract": true,
|
|
13124
|
+
"docs": {
|
|
13125
|
+
"default": "- no condition",
|
|
13126
|
+
"stability": "experimental",
|
|
13127
|
+
"summary": "For an AWS service: the account that owns the resource calling on its behalf (condition `aws:SourceAccount`)."
|
|
13128
|
+
},
|
|
13129
|
+
"immutable": true,
|
|
13130
|
+
"locationInModule": {
|
|
13131
|
+
"filename": "src/web-function.ts",
|
|
13132
|
+
"line": 266
|
|
13133
|
+
},
|
|
13134
|
+
"name": "sourceAccount",
|
|
13135
|
+
"optional": true,
|
|
13136
|
+
"type": {
|
|
13137
|
+
"primitive": "string"
|
|
13138
|
+
}
|
|
13139
|
+
},
|
|
13140
|
+
{
|
|
13141
|
+
"abstract": true,
|
|
13142
|
+
"docs": {
|
|
13143
|
+
"default": "- no condition",
|
|
13144
|
+
"stability": "experimental",
|
|
13145
|
+
"summary": "For an AWS service: the ARN of the resource calling on its behalf (condition `aws:SourceArn`, `ArnLike`), e.g. a CloudFront distribution. Without it or `sourceAccount`, any account's use of the service could call the endpoint."
|
|
13146
|
+
},
|
|
13147
|
+
"immutable": true,
|
|
13148
|
+
"locationInModule": {
|
|
13149
|
+
"filename": "src/web-function.ts",
|
|
13150
|
+
"line": 259
|
|
13151
|
+
},
|
|
13152
|
+
"name": "sourceArn",
|
|
13153
|
+
"optional": true,
|
|
13154
|
+
"type": {
|
|
13155
|
+
"primitive": "string"
|
|
13156
|
+
}
|
|
13157
|
+
}
|
|
13158
|
+
],
|
|
13159
|
+
"symbolId": "src/web-function:WebFunctionPermission"
|
|
13160
|
+
},
|
|
12716
13161
|
"@ashishpandeyone/cdk-lambda-web-function.WebFunctionProps": {
|
|
12717
13162
|
"assembly": "@ashishpandeyone/cdk-lambda-web-function",
|
|
12718
13163
|
"datatype": true,
|
|
@@ -12727,7 +13172,7 @@
|
|
|
12727
13172
|
"kind": "interface",
|
|
12728
13173
|
"locationInModule": {
|
|
12729
13174
|
"filename": "src/web-function.ts",
|
|
12730
|
-
"line":
|
|
13175
|
+
"line": 130
|
|
12731
13176
|
},
|
|
12732
13177
|
"name": "WebFunctionProps",
|
|
12733
13178
|
"properties": [
|
|
@@ -12741,7 +13186,7 @@
|
|
|
12741
13186
|
"immutable": true,
|
|
12742
13187
|
"locationInModule": {
|
|
12743
13188
|
"filename": "src/web-function.ts",
|
|
12744
|
-
"line":
|
|
13189
|
+
"line": 142
|
|
12745
13190
|
},
|
|
12746
13191
|
"name": "code",
|
|
12747
13192
|
"type": {
|
|
@@ -12757,7 +13202,7 @@
|
|
|
12757
13202
|
"immutable": true,
|
|
12758
13203
|
"locationInModule": {
|
|
12759
13204
|
"filename": "src/web-function.ts",
|
|
12760
|
-
"line":
|
|
13205
|
+
"line": 134
|
|
12761
13206
|
},
|
|
12762
13207
|
"name": "runtime",
|
|
12763
13208
|
"type": {
|
|
@@ -12774,7 +13219,7 @@
|
|
|
12774
13219
|
"immutable": true,
|
|
12775
13220
|
"locationInModule": {
|
|
12776
13221
|
"filename": "src/web-function.ts",
|
|
12777
|
-
"line":
|
|
13222
|
+
"line": 149
|
|
12778
13223
|
},
|
|
12779
13224
|
"name": "entrypoint",
|
|
12780
13225
|
"optional": true,
|
|
@@ -13106,6 +13551,6 @@
|
|
|
13106
13551
|
"symbolId": "src/web-function-deployment:WebFunctionRollbackOptions"
|
|
13107
13552
|
}
|
|
13108
13553
|
},
|
|
13109
|
-
"version": "0.1.
|
|
13110
|
-
"fingerprint": "
|
|
13554
|
+
"version": "0.1.6",
|
|
13555
|
+
"fingerprint": "eGWPF/6zI40HXyruY2PzoVPkeVUOe5zzMjEJ5vx0MkE="
|
|
13111
13556
|
}
|