diff --git a/.projen/deps.json b/.projen/deps.json index ff76964..dd0a0e6 100644 --- a/.projen/deps.json +++ b/.projen/deps.json @@ -150,10 +150,6 @@ "name": "@types/aws-lambda", "type": "runtime" }, - { - "name": "axios", - "type": "runtime" - }, { "name": "constructs", "type": "runtime" diff --git a/.projen/tasks.json b/.projen/tasks.json index 2eac037..9c6bd6e 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -254,13 +254,13 @@ }, "steps": [ { - "exec": "npx npm-check-updates@20 --upgrade --target=minor --peer --no-deprecated --dep=dev,peer,prod,optional --filter=@aws-sdk/client-cognito-identity-provider,@aws-sdk/client-dynamodb,@aws-sdk/client-s3,@aws-sdk/lib-dynamodb,@hapi/boom,@types/jest,@types/js-yaml,@types/jsonwebtoken,@types/jwk-to-pem,@types/lambda-log,@types/node,eslint-import-resolver-typescript,eslint-plugin-import,jest,projen,ts-jest,ts-node,typedoc,typescript,openapi-typescript,@types/aws-lambda,axios,constructs,date-fns,js-yaml,jsonwebtoken,jwk-to-pem,lambda-log" + "exec": "npx npm-check-updates@20 --upgrade --target=minor --peer --no-deprecated --dep=dev,peer,prod,optional --filter=@aws-sdk/client-cognito-identity-provider,@aws-sdk/client-dynamodb,@aws-sdk/client-s3,@aws-sdk/lib-dynamodb,@hapi/boom,@types/jest,@types/js-yaml,@types/jsonwebtoken,@types/jwk-to-pem,@types/lambda-log,@types/node,eslint-import-resolver-typescript,eslint-plugin-import,jest,projen,ts-jest,ts-node,typedoc,typescript,openapi-typescript,@types/aws-lambda,constructs,date-fns,js-yaml,jsonwebtoken,jwk-to-pem,lambda-log" }, { "exec": "npm install" }, { - "exec": "npm update @aws-sdk/client-cognito-identity-provider @aws-sdk/client-dynamodb @aws-sdk/client-s3 @aws-sdk/lib-dynamodb @hapi/boom @stylistic/eslint-plugin @types/jest @types/js-yaml @types/jsonwebtoken @types/jwk-to-pem @types/lambda-log @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser commit-and-tag-version constructs eslint-import-resolver-typescript eslint-plugin-import eslint jest jest-junit projen ts-jest ts-node typedoc typescript aws-cdk-lib dynamodb-onetable openapi-typescript @types/aws-lambda axios date-fns js-yaml jsonwebtoken jwk-to-pem lambda-log" + "exec": "npm update @aws-sdk/client-cognito-identity-provider @aws-sdk/client-dynamodb @aws-sdk/client-s3 @aws-sdk/lib-dynamodb @hapi/boom @stylistic/eslint-plugin @types/jest @types/js-yaml @types/jsonwebtoken @types/jwk-to-pem @types/lambda-log @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser commit-and-tag-version constructs eslint-import-resolver-typescript eslint-plugin-import eslint jest jest-junit projen ts-jest ts-node typedoc typescript aws-cdk-lib dynamodb-onetable openapi-typescript @types/aws-lambda date-fns js-yaml jsonwebtoken jwk-to-pem lambda-log" }, { "exec": "npx projen" diff --git a/.projenrc.ts b/.projenrc.ts index b37c8c9..5c29d09 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -17,7 +17,6 @@ const project = new typescript.TypeScriptProject({ 'js-yaml', 'jsonwebtoken', 'jwk-to-pem', - 'axios', 'lambda-log', 'constructs', ], diff --git a/README.md b/README.md index 69fbeda..f2aeef2 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,70 @@ await test.cleanupItems(); await test.removeUser('test@example.com'); ``` +## Breaking Change: `axios` Removed + +CDK Serverless no longer depends on `axios`. The library now uses the +platform-native `fetch` API (stable in Node.js 18+; the Lambda functions +created by this library use `Runtime.NODEJS_LATEST`, currently Node 22). + +This removes one third-party runtime dependency from every Lambda bundle that +imports from `cdk-serverless/lambda` and from every test workspace that +imports from `cdk-serverless/tests`. It was motivated by repeated axios +security advisories — landing this as a deliberate breaking change so the +fix is permanent rather than chasing CVE upgrades. + +### Impact on Lambda handlers (`cdk-serverless/lambda`) + +None. The internal JWKS / well-known-issuer fetches in the JWT authorizers +were the only axios call sites in the Lambda runtime code, and their public +behavior is unchanged. Errors now surface as `Error` (or a `TimeoutError` +from `AbortSignal.timeout`) instead of `AxiosError`; if you catch errors +inside the authorizer, the message text is similar but the type guard is +different. + +### Impact on `IntegTestUtil` (`cdk-serverless/tests`) + +`IntegTestUtil.getClient()` and `IntegTestUtil.getAuthenticatedClient()` +previously returned an `Axios` instance. They now return a small +`HttpClient` exported from `cdk-serverless/tests`. The migration is +mechanical: + +```typescript +// Before +const client = await test.getAuthenticatedClient('test@example.com'); +const response = await client.get('/items'); +// response.data is the parsed JSON, response.status is the HTTP status code +const items = response.data.items; + +// After +const client = await test.getAuthenticatedClient('test@example.com'); +const response = await client.get('/items'); +// response.body is the raw string, response.json() parses it, response.ok +// reports 2xx, response.status is the HTTP status code +const items = response.json<{ items: Item[] }>().items; +``` + +The `HttpClient` exposes the methods that integration tests in this +ecosystem actually use: + +- `get(path, options?)` +- `post(path, body?, options?)` — `body` may be a string or any JSON-serializable + value; objects are stringified and `Content-Type: application/json` is added + automatically if the caller did not set it. +- `put(path, body?, options?)`, `patch(path, body?, options?)`, `delete(path, options?)` + +Configuration accepted by `HttpClient` and by `getClient(config)`: + +- `baseURL` — prepended to relative paths. +- `headers` — default headers applied to every request; per-request `headers` + override these on collision. + +If you relied on axios-specific features (interceptors, `defaults`, +`transformRequest` / `transformResponse`, automatic `data` parsing), implement +the equivalent in your test code or wrap `HttpClient`. If your use case +needs richer client features and we should expose them, please open an +issue. + ## Contribute ### How to contribute to CDK Serverless diff --git a/docs/constructs/assets/highlight.css b/docs/constructs/assets/highlight.css index 0022ac6..72a5329 100644 --- a/docs/constructs/assets/highlight.css +++ b/docs/constructs/assets/highlight.css @@ -15,10 +15,10 @@ --dark-hl-6: #6A9955; --light-hl-7: #0070C1; --dark-hl-7: #4FC1FF; - --light-hl-8: #098658; - --dark-hl-8: #B5CEA8; - --light-hl-9: #267F99; - --dark-hl-9: #4EC9B0; + --light-hl-8: #267F99; + --dark-hl-8: #4EC9B0; + --light-hl-9: #098658; + --dark-hl-9: #B5CEA8; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } diff --git a/docs/constructs/classes/LambdaFunction.html b/docs/constructs/classes/LambdaFunction.html index 8068e89..af3b3a4 100644 --- a/docs/constructs/classes/LambdaFunction.html +++ b/docs/constructs/classes/LambdaFunction.html @@ -2,7 +2,7 @@ This construct facilitates setting up a Lambda function with various custom options, environment variables, and permissions required to interact with AWS services such as DynamoDB, Cognito, and S3. It supports setting up Lambda functions with pre-defined bundles, custom handlers, and integrations with AWS services. The construct also provides methods to dynamically update the configuration and permissions of the Lambda function after it has been created.
-
Example
Example
Hierarchy
Index
Constructors
Returns Stack
Methods
add Alias
Defines an alias for this function.
The alias will automatically be updated to point to the latest version of the function as it is being updated during a deployment.
-Parameters
The name of the alias
@@ -282,27 +282,27 @@Parameters
Returns boolean
StaticisCheck whether the given construct is a Resource
Parameters
Returns construct is Resource
StaticmetricReturn the given named metric for this Lambda
Parameters
Optionalprops: MetricOptionsReturns Metric
StaticmetricMetric for the number of concurrent executions across all Lambdas
-Parameters
Optionalprops: MetricOptionsReturns Metric
Default
Parameters
Optionalprops: MetricOptionsReturns Metric
Default
StaticmetricMetric for the Duration executing all Lambdas
-Parameters
Optionalprops: MetricOptionsReturns Metric
Default
Parameters
Optionalprops: MetricOptionsReturns Metric
Default
StaticmetricMetric for the number of Errors executing all Lambdas
-Parameters
Optionalprops: MetricOptionsReturns Metric
Default
Parameters
Optionalprops: MetricOptionsReturns Metric
Default
StaticmetricMetric for the number of invocations of all Lambdas
-Parameters
Optionalprops: MetricOptionsReturns Metric
Default
Parameters
Optionalprops: MetricOptionsReturns Metric
Default
StaticmetricMetric for the number of throttled invocations of all Lambdas
-Parameters
Optionalprops: MetricOptionsReturns Metric
Default
Parameters
Optionalprops: MetricOptionsReturns Metric
Default
StaticmetricMetric for the number of unreserved concurrent executions across all Lambdas
-Parameters
Optionalprops: MetricOptionsReturns Metric
Default
Parameters
Optionalprops: MetricOptionsReturns Metric
Default
Settings
On This Page
Constructors
Properties
Accessors
Methods