Skip to content

Releases: aws-powertools/powertools-lambda-typescript

v1.6.0

02 Mar 17:29

Choose a tag to compare

Summary

This minor release fixes some bugs on the Logger as well as bringing some improvements on how log levels are accepted and handled. As a part of the release we have also published our public Lambda Layers to 3 new AWS Regions.

Logger

The first of two bugs addressed was affecting functions using Logger together with the injectLambdaContext Middy middleware. When enabling both the clearState and logEvent flags, attributes attached to logs within the function's scope were not cleared properly. This caused values set during an invocation to appear in the event log emitted at the beginning of the next invocation. We have fixed the bug and revisited our unit and integration tests to prevent future regressions.

The second bug was instead related to the createChild method and caused children of a Logger instance to not inherit all attributes of their parents. We have fixed the issue, improved our unit tests around the feature, and clarified the documentation.

Finally, we have made the types of the logLevel construct option of Logger more strict, so that typos in the log level names can be caught at compile time rather than fail silently at runtime.

image

Lambda Layers

You can now use our Lambda Layers in three new AWS Regions: Spain (eu-south-2), Zurich (eu-central-2), and Asia Pacific (Melbourne) (ap-southeast-4). Find the full list of regional ARNs here.

With this release we can finally consider the roadmap item related to this topic complete 🚀.

Acknowledgments

A big thanks also to @Muthuveerappanv for getting their first PR merged into the repo, as well as @shdq and @niko-achilles for the contributions around Logger and documentation.

Finally as you can see from the full list of changes below, the team has been hard at work to bring you new utilities, so keep an eye on the next releases!

Changes

  • tests(logger): revisited integration tests (#1342) by @dreamorosi
  • tests(logger): revisit Logger unit tests (#1339) by @dreamorosi
  • tests(parameters): update package to run as part of e2e tests (#1318) by @dreamorosi
  • tests(parameters): integration tests for AppConfigProvider (#1287) by @dreamorosi
  • tests(parameters): integration tests for SSMProvider (#1257) by @dreamorosi
  • tests(parameters): added missing tests for DynamoDBProvider (#1285) by @dreamorosi
  • tests(parameters): add comments to SecretsProvider e2e test (#1282) by @am29d
  • tests(parameters): integration tests for SecretsProvider (#1263) by @am29d
  • build(deps): bump http-cache-semantics from 4.1.0 to 4.1.1 (#1270) by @dependabot
  • tests(parameters): end to end tests for DynamoDBProvider (#1244) by @dreamorosi

🌟New features and non-breaking changes

  • feat(logger): make loglevel types stricter (#1313) by @dreamorosi
  • feat(layers): add new regions (#1322) by @am29d
  • refactor(parameters): moved ssm resource creation to AwsCustomResource (#1319) by @dreamorosi
  • refactor(parameters): move table seeding into AwsCustomResource (#1317) by @dreamorosi
  • feat(idempotency): Add function wrapper and decorator (#1262) by @KevenFuentes9
  • feat(parameters): add support for custom AWS SDK v3 clients for providers (#1260) by @shdq

📜 Documentation updates

🐛 Bug and hot fixes

  • fix(logger): middleware stores initial persistent attributes correctly (#1329) by @dreamorosi
  • fix(parameters): handle base64/binaries in transformer (#1326) by @dreamorosi
  • fix(logger): fix a bug when child logger didn't get all the parent's attributes (#1267) by @shdq
  • fix(docs): logger bringYourOwnFormatter snippet (#1254) by @niko-achilles
  • fix(parameters): Tokenize attribute names in DynamoDBProvider (#1239) by @dreamorosi

🔧 Maintenance

This release was made possible by the following contributors:

@KevenFuentes9, @Muthuveerappanv, @am29d, @dreamorosi, @heitorlessa, @niko-achilles and @shdq

v1.5.1

13 Jan 14:50

Choose a tag to compare

Summary

This first release for 2023 updates the AWS Lambda runtimes officially supported by Powertools for TypeScript, as well as bug fixes.

Node.js 12 deprecation

With AWS Lambda deprecating the nodejs12.x runtime at the end of March this year, we have decided to drop support for the runtime as well. Node.js 12 has reached end-of-life a few months ago, so we recommend anyone still using this runtime to upgrade their functions to Node.js 14 or later.

Node.js 18 support

With one runtime going away, we now add support for the nodejs18.x runtime. In the past few weeks we have updated our CI workflows to continuously run unit and integration tests to include the new runtime. This has given us enough confidence to announce that the project is compatible with the runtime.

Bug fixes

Logger

This release adds support for BigInt to Logger. This type of objects cannot be natively serialized, so before to this release Logger would throw an error.

Now, if you try to log an object that contains a BigInt, Logger will automatically convert it to a string and log it for you:

import { Logger } from "@aws-lambda-powertools/logger";

const logger = new Logger();
logger.info('Object with bigint value', { myBigInt: BigInt(1234) })

will result in:

{
  "level": "INFO",
  "message": "Object with bigint value",
  "service": "service_undefined",
  "timestamp": "2022-10-12T22:27:17.067Z",
  "myBigInt": "1234"
}

Thanks @shdq for the fix!

Bundling with tsc

Prior to this release, customers using tsc to bundle their functions but not using any of the Powertools middleware, were experiencing build-time errors due to one of our dependencies not being tree-shaken correctly. This release introduces a change to the internals of our packages that allow those customers to use tsc without having to install an extra devDependency only to please the compiler.

Acknowledgments

A big thank you to @shdq for the continuous generous contributions 🙏, and a congrats to @niko-achilles for landing your first batch of PR merged 🎉

Finally, while still not published on npm, there's a lot of work being done on the upcoming Idempotency and Parameters utilities that the team and community are doing. You can follow the progress in the respective milestones here and here.

Changes

  • build(layers): aligned aws cdk versions in layer-publisher to main workspace (#1228) by @dreamorosi
  • build(deps): bump json5 from 1.0.1 to 1.0.2 (#1212) by @dependabot
  • build(deps): bump json5 from 1.0.1 to 1.0.2 in /layer-publisher (#1209) by @dependabot
  • build(deps): bump json5 from 1.0.1 to 1.0.2 in /examples/sam (#1210) by @dependabot
  • build(deps): bump json5 from 1.0.1 to 1.0.2 in /examples/cdk (#1211) by @dependabot
  • build(deps): bump decode-uri-component from 0.2.0 to 0.2.2 (#1185) by @dependabot

🌟New features and non-breaking changes

📜 Documentation updates

🐛 Bug and hot fixes

  • fix(logger): logger throws TypeError when log item has BigInt value (#1201) by @shdq

🔧 Maintenance

This release was made possible by the following contributors:

@bpauwels, @dreamorosi, @niko-achilles and @shdq

v1.5.0

25 Nov 10:54

Choose a tag to compare

Summary

This release includes some bug fixes and quality of life improvements on the Logger utility as well as improvements on the bundle size of our public Lambda Layers.

Logger

Prior to this release, when creating child loggers, Logger was affected by a bug that caused some of the settings to not be properly reflected in its children. This release corrects the issue by reworking the logic used to create child loggers.

Additionally, thanks to @shdq's contribution, those who use jest and Logger can now leverage the --silent flag to silence logs emitted by Logger in their unit tests.

Lambda Layer

Thanks to a report from @Muthuveerappanv, we were able to shave ~3MB from the deployment package of our public Lambda Layers by removing @types from the node_modules folder. This will give you back some valuable space when using the layers.

Upcoming Utilities

The release also includes unreleased work on two new upcoming utilities: Idempotency and Parameters. On both fronts we have finished laying the foundations for the utilities and we will now start gradually adding features. Stay tuned for more updates on this topic in the next releases.

Governance

As part of this release we have also published a new and improved GitHub Project that you can use to stay updated with the team's progress as well as finding contributing opportunities. We also have added a new "Roadmap" section to the docs, use this page to learn about the team's priorities for the upcoming months.

Acknowledgements

A big thank you to @shdq who has been a big part of this release, to @ConnorKirk for his first contribution to the project, and to @jeffrey-baker-vg and the rest of the team for the hard work on Idempotency.

Changes

  • tests(idempotency): add utility to workspace unit tests and CI (#1160) by @dreamorosi
  • feat(idempotency): Add persistence layer and DynamoDB implementation (#1110) by @jeffrey-baker-vg
  • feat(logger): pretty printing logs in local and non-prod environment (#1141) by @shdq

🌟New features and non-breaking changes

🌟 Minor Changes

  • feat(logger): disable logs while testing with jest --silent in dev env (#1165) by @shdq

📜 Documentation updates

🐛 Bug and hot fixes

  • fix(logger): merge child logger options correctly (#1178) by @shdq

🔧 Maintenance

This release was made possible by the following contributors:

@ConnorKirk, @dreamorosi, @flochaz, @jeffrey-baker-vg and @shdq

v1.4.1

09 Nov 14:30

Choose a tag to compare

Summary

This patch release fixes a bug in Metrics as well as introducing some improvements in the documentation and jsdoc examples that accompany all public APIs of the utilities.

The bug in Metrics caused the service name to be cleared from the default dimensions after metrics were published or after the first function invocation when using the middleware or decorator. The service name is automatically added to metrics emitted by the utility and should always be present as dimension.

Finally, thank you to @niko-achilles for helping raise the bar on the documentation. Below an example of the jsdoc string rendered in VS Code:
image

Changes

📜 Documentation updates

🐛 Bug and hot fixes

  • fix(metrics): store service name in defaultDimensions to avoid clearing it (#1146) by @dreamorosi

🔧 Maintenance

This release was made possible by the following contributors:

@dreamorosi and @github-actions[bot]

v1.4.0

27 Oct 13:04

Choose a tag to compare

Summary

This release introduces a new feature in Tracer that allows customers to access the AWS X-Ray Root Trace ID. The release also includes a bug fix for Metrics where an issue prevented dimensions and metadata to be cleared on metrics publish. Finally, it also includes some updates to the docs, one of which introduces an example of how to use the Powertools layer with Pulumi.

Tracer

The Tracer utility now has a new public method called getRootXrayTraceId() (docs). With this method you can access the root trace id and use it in your responses or downstream processing as correlation id.

carbon-2

Thank you @misterjoshua for suggesting the feature and helping review the PR.

Metrics

Prior to this release a bug in the Metrics utility prevented metadata and dimensions of metrics to leak between function executions. This was due to a faulty logic that didn't clear properly the two objects when metrics were published. Thanks to @shdq the bug has been fixed and unit tests around the behavior were added. Congrats @shdq for your first PR merged 🎉

Docs

Finally, thanks to @pierskarsenbarg's first contribution to this repo (💯) , the documentation now has an example of how to use the Powertools layer with Pulumi!

carbon

Changes

🌟New features and non-breaking changes

  • feat(all): moved EnvService to commons + exposed getXrayTraceId in tracer (#1123) by @dreamorosi

📜 Documentation updates

🐛 Bug and hot fixes

  • fix(metrics): metadata and dimensions not cleared on publish (#1129) by @shdq

🔧 Maintenance

This release was made possible by the following contributors:

@dreamorosi, @pierskarsenbarg and @shdq

v1.3.0

17 Oct 16:00

Choose a tag to compare

Summary

This release adds public AWS Lambda Layers, a new feature for Tracer, and bug fixes on all utilities.

AWS Lambda Layers

You can now use AWS Lambda Powertools for TypeScript by adding just a few lines to your configs and using our public AWS Lambda Layers.

Lambda Layer is a .zip file archive that can contain additional code, pre-packaged dependencies, data, or configuration files. Layers promote code sharing and separation of responsibilities so that you can iterate faster on writing business logic.

You can include Lambda Powertools Lambda Layer using AWS Lambda Console, or your preferred deployment framework. Lambda Layers also allow us to understand who uses this library in a non-intrusive way. This helps us justify and gain future investments for other Lambda Powertools languages.

When using AWS SAM or Serverless Framework:

carbon-6

With CDK:

carbon-7

New Features

Tracer

When using the captureMethod decorator on your class method you can now specify a custom name for the subsegment that Tracer generates for you.

You can do so by passing a newly added subSegmentName parameter to the decorator. This is useful for those cases in which the decorated method has an long or non-meaningful name but also in cases in which you want to nest method calls and represent this nesting in the segment names by using different levels of ###/####.

carbon-5

Bug Fixes

Metrics

The Metrics utility has two parameters captureColdStartMetric and throwOnEmptyMetrics that allow respectively to create a cold start metric for those invocations that had an initialization phase, and to throw an error before flushing metrics to ensure that at least one metric is emitted.

Prior to this release there was a bug that caused the parameters to be misinterpreted when passed to the logMetrics middleware. This release ensures that the parameters are parsed correctly and adds additional tests to verify and maintain the behavior.

Logger

The indectLambdaContext decorator allows you to enrich your structured logs with key Lambda context information. The appendKeys method instead allows you to append additional keys and values to logs while within the function handler's scope.

Prior to this release there was a bug that caused some of these additional keys and values to be cleared too soon due to the decorator not awaiting for the decorated method to return. This release fixes the issue and adds tests to prevent future regressions.

Tracer

The captureMethod decorator allows you to trace Class methods and create segments for its operations.

Prior to this release, when using captureMethod with certain 3rd party decorators the name of the decorated method was not detected correctly causing the segment name and its annotation to be mislabeled. This release changes the logic around name detection to ensure names are properly annotated.

Changes

  • Chore(tracer): unit tests to verify decorators await decorated class methods (#1108) by @dreamorosi
  • Fix: standardized and consistent linting strategy across Lerna targets (#1105) by @saragerion

🌟New features and non-breaking changes

📜 Documentation updates

  • docs: update layer version in docs (#1120) by @dreamorosi
  • doc(layer): bump layer version to 2 to match the one built for latest version (1.2.1) (#1113) by @flochaz

🐛 Bug and hot fixes

  • fix(all): update version command to use lint-fix (#1119) by @dreamorosi
  • fix(tracer): captureMethod detects proper method name when used with external decorators (#1109) by @dreamorosi
  • fix(metrics): captureColdStartMetric and throwOnEmptyMetrics when set to false was interpreted as true (#1090) by @flochaz
  • fix(logger): wait for decorated method return before clearing out state (#1087) by @dreamorosi
  • fix(build): remove leftover code in action that labels issues on merge (#1078) by @dreamorosi

🔧 Maintenance

  • fix(all): update version command to use lint-fix (#1119) by @dreamorosi
  • chore(layer): fix bundling and e2e tests by manually setting hash of asset (#1116) by @flochaz
  • chore(build): fix ts-node version for layer-publisher (#1112) by @flochaz
  • build(deps): bump vm2 from 3.9.9 to 3.9.11 (#1094) by @dependabot
  • improv(build): allow to specify PR number when running e2e tests (#1079) by @dreamorosi
  • fix(build): remove leftover code in action that labels issues on merge (#1078) by @dreamorosi
  • chore(build): update make-release.yml to remove redundant publish step (#1075) by @dreamorosi

This release was made possible by the following contributors:

@dreamorosi, @flochaz, @jeffrey-baker-vg and @saragerion

v1.2.1

25 Aug 08:06

Choose a tag to compare

Summary

We are thrilled to share that we have a new home on Discord!
We hope that this new chapter will allow us to connect and learn from each other, as well as shape together the feature of Powertools.

Join us here: https://discord.gg/B8zZKbbyET

Thanks @sthuber90 for opening the PR to update our docs and adding the new link.

Changes

📜 Documentation updates

This release was made possible by the following contributors:

@sthuber90

v1.2.0

23 Aug 15:24

Choose a tag to compare

Summary

In this patch release we are updating the Metrics utility to support 3x more dimensions (up to 30) per metric, as well as adding a new way to suppress response capture to Tracer.

Metrics

A few weeks ago Amazon CloudWatch increased metric throughput. This release takes advantage of the new metric dimension to increase our validation limit to 30.

Thank you @sthuber90 for taking this feature and congrats for your first PR in this repo 🎉

Tracer

By default, when using the Tracer as a middleware or as a decorator, the utility captures the response returned by a method or Lambda handler and adds it as metadata on the current segment. This allows you to gain insights about the execution and the results in the context of your traces.

In some instances, for example if the response is too big (> 64 kB), or if it contains sensitive informations, you might want to disable this behavior.

With this release you can use the captureResponse: false option in both tracer.captureLambdaHandler() and tracer.captureMethod() decorators, or use the same option in the Middy captureLambdaHander middleware to instruct Tracer not to serialize function responses as metadata.

carbon

Once again, thank you @misterjoshua for proposing and implementing this behavior 🙌

🌟New features and non-breaking changes

  • feat(metrics): increase maximum dimensions to 29 (#1072) by @sthuber90
  • feat(tracer): allow disabling result capture for decorators and middleware (#1065) by @misterjoshua

🐛 Bug and hot fixes

  • fix(docs): docs published with incorrect version number + api docs missing after release (#1066) by @dreamorosi

This release was made possible by the following contributors:

@dreamorosi, @misterjoshua and @sthuber90

v1.1.1

18 Aug 14:45

Choose a tag to compare

Summary

This patch release addresses an issue with Lambda handlers written as a class and that uses the Powertools utilities to decorate some of its methods. The defect prevented class members from accessing the class instance and calling other methods or reading attributes.

Thanks to @misterjoshua, we have modified the implementation of the decorator and also improved our documentation to make sure that classes implementing LambdaInterface can work properly. To learn more, check out this issue that contains a more detailed explanation.

import { Tracer } from '@aws-lambda-powertools/tracer';
import { LambdaInterface } from '@aws-lambda-powertools/commons';

const tracer = new Tracer({ serviceName: 'serverlessAirline' });

class Lambda implements LambdaInterface {
    @tracer.captureLambdaHandler()
    public async handler(_event: any, _context: any): Promise<void> {
        /* ... */
    }
}

const handlerClass = new Lambda();
export const handler = handlerClass.handler.bind(handlerClass); // <- Binding your handler method allows your handler to access `this`.

Finally, a big thank you to @misterjoshua who reported the bug, collaborated to the triaging, and submitted a PR proposing a fix 🎉

Changes

📜 Documentation updates

  • chore(tracer): remove redundant export in docs & examples (#1062) by @dreamorosi

🐛 Bug and hot fixes

🔧 Maintenance

  • chore(tracer): remove redundant export in docs & examples (#1062) by @dreamorosi

This release was made possible by the following contributors:

@dreamorosi and @misterjoshua

v1.1.0

12 Aug 12:15

Choose a tag to compare

Summary

This release contains two bug fixes that were reported by community members:

Over the past weeks the team has also been working on improving and strengthening the security of the CI/CD pipelines that allow to run unit and integration tests, as well as publishing the packages on NPM and the documentation.

Additionally, it contains some initial groundwork that will allow us to publish the libraries as Lambda layers - so stay tuned for news on this topic in the coming weeks!

Finally, a big thank you also to first-time contributors: @tsop14 and @ratscrew 🎉 Thank you for helping improving the library!

Changes

🌟New features and non-breaking changes

  • feat(build): publish lib as a Lambda Layer (#884) by @flochaz

📜 Documentation updates

🐛 Bug and hot fixes

🔧 Maintenance

  • feat(build): publish lib as a Lambda Layer (#884) by @flochaz
  • chore(build): broke up pr workflow & measure package size (#1031) by @dreamorosi
  • chore(ci): housekeeping scripts & workflows related to PRs (#1023) by @dreamorosi

This release was made possible by the following contributors:

@dreamorosi, @flochaz, @ratscrew, @saragerion and @tsop14