Skip to content

Releases: aws-powertools/powertools-lambda-dotnet

1.12

25 Jul 13:40
aef100c
Compare
Choose a tag to compare

Summary

We are excited to announce GA support for Ahead-of-time (AOT) compilation for Tracing version 1.5.0. This means, you can now use Tracing in your AOT published .NET AWS Lambda functions without any AOT warnings.

You can follow progress on AOT support here.

Tip

New to AOT?
Checkout this tutorial in the AWS Lambda documentation.

Caveats

Docs

By default, Tracing uses AWS X-Ray SDK. That means, you must include TrimmerRootAssemblies as part of your .csproj file:

image

Changes

🚀 Features

📜 Documentation updates

🔧 Maintenance

This release was made possible by the following contributors:

@hjgraca

1.11.1

12 Jul 09:47
a1ae03a
Compare
Choose a tag to compare

Summary

This release we fix a regression caused by release 1.7.0.
This bug caused the Metrics to not capture the Lambda context when in an AOT published Lambda.

Version 1.7.0 was removed from NuGet

Changes

{
    "_aws": {
        "Timestamp": 1720714102216,
        "CloudWatchMetrics": [
            {
                "Namespace": "ns",
                "Metrics": [
                    {
                        "Name": "ColdStart",
                        "Unit": "Count"
                    }
                ],
                "Dimensions": [
                    [
                        "FunctionName"
                    ],
                    [
                        "Service"
                    ]
                ]
            }
        ]
    },
    "FunctionName": null, <--- should not be null
    "Service": "svc",
    "ColdStart": 1
}

🔧 Maintenance

  • chore: Fix metrics lambda context and storage resolution (#613) by @hjgraca

This release was made possible by the following contributors:

@hjgraca

1.11

11 Jul 13:33
33546b4
Compare
Choose a tag to compare

Summary

In this release we are happy to announce GA support for Ahead-of-time (AOT) compilation for Metrics version 1.7.0.
Now it is possible to use Metrics on your AOT published .NET AWS Lambda functions without any AOT warnings.

We have been working on this support for the last few months and before going GA we made the version 1.7.0-alpha available for users to test and no issues were reported.

We continue hard at work on adding AOT support to all utilities by the end of this year.

The following example shows how to use Metrics in an AOT-enabled Lambda function.

image

If you want to get started or learn more about AOT go to the following tutorial on how to build .NET Lambda functions with Native AOT compilation.

🚀 Features

📜 Documentation updates

🔧 Maintenance

This release was made possible by the following contributors:

@hjgraca

1.10.1

23 May 10:28
dfd31d4
Compare
Choose a tag to compare

Summary

In this release we fix a bug in Metrics caused when using Metrics utility in Multi threaded scenarios and the PowertoolsConfigurations.MaxMetrics was a lower number. #593

Fix release in version 1.6.2 of Metrics

Thanks to @jessepoulton-mydeal for reporting the issue.

Changes

🐛 Bug and hot fixes

  • chore: Metrics - Add thread safety to AddMetric (#594) by @hjgraca

🔧 Maintenance

  • chore: Fix jmespath dependency (#590) by @hjgraca
  • chore: Update idempotency examples for release 1..10.0 (#589) by @hjgraca

This release was made possible by the following contributors:

@hjgraca @jessepoulton-mydeal

1.10.0

09 May 11:33
7a10387
Compare
Choose a tag to compare

Summary

In this release we introduce built in JMESPath support for Powertools Idempotency utility.
With this release we remove the need for 3rd party dependencies and move from the old Newtonsoft.Json to the new System.Text.Json also is fully JMESPath spec compliant.

Fully backwards compatible, there are no changes to the way you having been using Idempotency before.

Nuget verstion: Idempotency 1.2.1

Powertools JMESPath functions

You can use our built-in JMESPath functions within your envelope expression. They handle deserialization for common data formats found in AWS Lambda event sources such as JSON strings, base64, and uncompress gzip data.

powertools_json function idempotency example

Use powertools_json function to decode any JSON string anywhere a JMESPath expression is allowed.

Example of using JMESPath with Idempotency to create the idempotent key

Idempotency.Configure(builder =>
        builder
            .WithOptions(optionsBuilder =>
                optionsBuilder.WithEventKeyJmesPath("powertools_json(Body).[\"user_id\", \"product_id\"]"))
            .UseDynamoDb("idempotency_table"));
{
  "version": "2.0",
  "routeKey": "ANY /createpayment",
  "rawPath": "/createpayment",
  "rawQueryString": "",
  "headers": {
    "Header1": "value1",
    "Header2": "value2"
  },
  "requestContext": {
    "accountId": "123456789012",
    "apiId": "api-id",
    "domainName": "id.execute-api.us-east-1.amazonaws.com",
    "domainPrefix": "id",
    "http": {
      "method": "POST",
      "path": "/createpayment",
      "protocol": "HTTP/1.1",
      "sourceIp": "ip",
      "userAgent": "agent"
    },
    "requestId": "id",
    "routeKey": "ANY /createpayment",
    "stage": "$default",
    "time": "10/Feb/2021:13:40:43 +0000",
    "timeEpoch": 1612964443723
  },
  "body": "{\"user_id\":\"xyz\",\"product_id\":\"123456789\"}",
  "isBase64Encoded": false
}

Changes

🌟New features and non-breaking changes

  • feat(idempotency): add internal powertools JMESPath support (#578) by @hjgraca

📜 Documentation updates

  • feat(idempotency): add internal powertools JMESPath support (#578) by @hjgraca

🔧 Maintenance

This release was made possible by the following contributors:

Code and inspiration from jdevillard/JmesPath.Net and danielaparker/JsonCons.Net

@hjgraca and @amirkaws

1.9.1

21 Mar 11:08
ff53f97
Compare
Choose a tag to compare

Summary

In this release we fix an issue that was causing a System.InvalidCastException exception when decorating with the Tracing attribute generic methods that would be called with different T as parameters or return T.

Thank you @Kuling for reporting the issue.

using Amazon.Lambda.APIGatewayEvents;
using Amazon.Lambda.Core;
using AWS.Lambda.Powertools.Tracing;

[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]

namespace MyFunction
{
    public interface ISampleService
    {
        Task<T> LoadAsync<T>(T query);
    }

    [Tracing]
    public class SampleService : ISampleService
    {
        public async Task<T> LoadAsync<T>(T query)
        {
            return default;
        }
    }

    [Tracing]
    public class Function
    {
        public async Task<APIGatewayProxyResponse> FunctionHandlerAsync(APIGatewayProxyRequest request, ILambdaContext context)
        {
            var target = new SampleService();
            await target.LoadAsync<double>(3.4);
            await target.LoadAsync<int>(5); // Bug

            return null;
        }
    }
}

Changes

📜 Documentation updates

  • chore(docs): Update docs and add supported runtimes (#569) by @hjgraca

🐛 Bug and hot fixes

  • fix: Error when decorating duplicate generic method - Tracing (#572) by @hjgraca

🔧 Maintenance

  • chore(docs): Update docs and add supported runtimes (#569) by @hjgraca

This release was made possible by the following contributors:

@Kuling and @hjgraca

1.9.0

11 Mar 09:50
9288404
Compare
Choose a tag to compare

Summary

With this release, we add feature to existing Parameters to retrieve values from AWS AppConfig.

using AWS.Lambda.Powertools.Parameters;
using AWS.Lambda.Powertools.Parameters.AppConfig;

public class Function
{
    public async Task<APIGatewayProxyResponse> FunctionHandler
        (APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
    {
        // Get AppConfig Provider instance
        IAppConfigProvider appConfigProvider = ParametersManager.AppConfigProvider
            .DefaultApplication("MyApplicationId")
            .DefaultEnvironment("MyEnvironmentId")
            .DefaultConfigProfile("MyConfigProfileId");
        
        // Retrieve a single configuration, latest version
        IDictionary<string, string?> value = await appConfigProvider
            .GetAsync()
            .ConfigureAwait(false);

        //Working with feature flags
        
        // Check if feature flag is enabled
        var isFeatureFlagEnabled = await appConfigProvider
            .IsFeatureFlagEnabledAsync("MyFeatureFlag")
            .ConfigureAwait(false);
        
        if (isFeatureFlagEnabled)
        {
            // Retrieve an attribute value of the feature flag
            var strAttValue = await appConfigProvider
                .GetFeatureFlagAttributeValueAsync<string>("MyFeatureFlag", "StringAttribute")
                .ConfigureAwait(false);
            
            // Retrieve another attribute value of the feature flag
            var numberAttValue = await appConfigProvider
                .GetFeatureFlagAttributeValueAsync<int>("MyFeatureFlag", "NumberAttribute")
                .ConfigureAwait(false);
        }
    }
}

Changes

🌟New features and non-breaking changes

AWS.Lambda.Powertools.Logging - 1.5.1
AWS.Lambda.Powertools.Metrics - 1.6.1
AWS.Lambda.Powertools.Tracing - 1.4.1
AWS.Lambda.Powertools.Parameters - 1.3.0
AWS.Lambda.Powertools.Idempotency - 1.1.1
AWS.Lambda.Powertools.BatchProcessing - 1.1.1

📜 Documentation updates

🔧 Maintenance

This release was made possible by the following contributors:

@amirkaws and @hjgraca

1.8.5

16 Feb 20:11
6286cad
Compare
Choose a tag to compare

Summary

In this release we added a "global" exception handler to Logging utility, so that when using the utility the exceptions inside are not sent to the client and break their applications. Instead we write the error message to the logs so the client can act on it.

We also added support for dotnet 8. Now Powertools supports dotnet 6 and dotnet 8, we build packages for both versions.

Changes

AWS.Lambda.Powertools.Logging - 1.5.0
AWS.Lambda.Powertools.Tracing - 1.4.0
AWS.Lambda.Powertools.Metrics - 1.6.0
AWS.Lambda.Powertools.Parameters - 1.2.0
AWS.Lambda.Powertools.Idempotency - 1.1.0
AWS.Lambda.Powertools.BatchProcessing - 1.1.0

📜 Documentation updates

  • chore: Update batch-processing docs (#547) by @hjgraca
  • chore(docs): fix upper snake case to camel case. (#548) by @H1Gdev
  • chore: Update tracing.md - Auto-disable when not running in AWS Lambda environment (#544) by @hjgraca
  • docs: we made this section update (#536) by @sliedig

🐛 Bug and hot fixes

  • fix: Handle Exceptions and Prevent application from crashing when using Logger (#538) by @hjgraca

🔧 Maintenance

  • chore: Update batch-processing docs (#547) by @hjgraca
  • chore(docs): fix upper snake case to camel case. (#548) by @H1Gdev
  • chore: dotnet 8 support (#542) by @hjgraca
  • chore(deps): bump gitpython from 3.1.37 to 3.1.41 (#539) by @dependabot
  • chore(deps): bump jinja2 from 3.1.2 to 3.1.3 (#540) by @dependabot
  • chore: Update tracing.md - Auto-disable when not running in AWS Lambda environment (#544) by @hjgraca

This release was made possible by the following contributors:

@H1Gdev, @hjgraca and @sliedig

1.8.4

12 Dec 15:52
7205022
Compare
Choose a tag to compare

Summary

In this release we are excited to announce the General Availability of Batch Processing utility.

Batch Processing

The batch processing utility handles partial failures when processing batches from Amazon SQS, Amazon Kinesis Data Streams, and Amazon DynamoDB Streams.

Documentation

Key features

  • Reports batch item failures to reduce number of retries for a record upon errors
  • Simple interface to process each batch record
  • Bring your own batch processor
  • Parallel processing

Problem Statement

When using SQS, Kinesis Data Streams, or DynamoDB Streams as a Lambda event source, your Lambda functions are triggered with a batch of messages.

If your function fails to process any message from the batch, the entire batch returns to your queue or stream. This same batch is then retried until either condition happens first: a) your Lambda function returns a successful response, b) record reaches maximum retry attempts, or c) when records expire.

With this utility, batch records are processed individually – only messages that failed to be processed return to the queue or stream for a further retry.

Getting started

To get started add the NuGet package

dotnet add package AWS.Lambda.Powertools.BatchProcessing

Example of processing batches from SQS using Lambda handler decorator in three stages:

  • Decorate your handler with BatchProcessor attribute
  • Create a class that implements ISqsRecordHandler interface and the HandleAsync method.
  • Pass the type of that class to RecordHandler property of the BatchProcessor attribute
  • Return BatchItemFailuresResponse from Lambda handler using SqsBatchProcessor.Result.BatchItemFailuresResponse

image

Changes

📜 Documentation updates

🔧 Maintenance

This release was made possible by the following contributors:

@hjgraca and @lachriz-aws

1.8.3

21 Nov 16:13
4394755
Compare
Choose a tag to compare

Summary

In this release we are happy to announce the General Availability of Idempotency utility 🚀.
The Idempotency utility provides a simple solution to convert your Lambda functions into idempotent operations which are safe to retry.
During developer preview we have taken a lot of feedback. Better documentation, support for Idempotency InProgressExpiration timestamp, register the Lambda context in your handler.

Idempotency 1.0.0 Nuget package

🌟Key features

  • Prevent Lambda handler function from executing more than once on the same event payload during a time window.
  • Use DynamoDB as a persistence layer for state with bring your own persistence store provider.
  • Select a subset of the event as the idempotency key using JMESPath expressions.
  • Payload validation to provide an additional JMESPath expression to specify which part of the event body should be validated against previous idempotent invocations.
  • Set a time window in which records with the same payload should be considered duplicates
  • Expires in-progress executions if the Lambda function times out halfway through

Implementation example

image

Here is an example on how you register the Lambda context in your handler:

image

Lambda request timeout diagram

image

Quick links: 📜 Documentation | ⬇️ NuGet | 🐛 Bug Report

Changes

📜 Documentation updates

  • chore: Update version and docs for Idempotency GA (#525) by @hjgraca
  • chore: update examples for 1.8.2 release (#523) by @hjgraca

🐛 Bug and hot fixes

  • fix: logging null reference when batch processing (#521) by @hjgraca

🔧 Maintenance

  • chore: Update version and docs for Idempotency GA (#525) by @hjgraca
  • chore: update examples for 1.8.2 release (#523) by @hjgraca
  • chore: add e2e tests for idempotency method (#513) by @hjgraca

This release was made possible by the following contributors:

@hjgraca @amirkaws @hossambarakat