Releases: aws-powertools/powertools-lambda-dotnet
1.12
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
By default, Tracing uses AWS X-Ray SDK. That means, you must include TrimmerRootAssemblies as part of your .csproj file:
Changes
🚀 Features
📜 Documentation updates
🔧 Maintenance
- chore(deps-dev): bump zipp from 3.11.0 to 3.19.1 (#610) by @dependabot
- chore: update examples for release 1.11.1 (#617) by @hjgraca
This release was made possible by the following contributors:
1.11.1
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
This release was made possible by the following contributors:
1.11
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.
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
- chore(deps): bump jinja2 from 3.1.3 to 3.1.4 (#579) by @dependabot
- chore: Update codecov (#605) by @hjgraca
- chore: Update examples for release 1.10.1 (#600) by @hjgraca
This release was made possible by the following contributors:
1.10.1
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
🔧 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:
1.10.0
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
📜 Documentation updates
🔧 Maintenance
- docs: add link to Powertools for AWS Lambda workshop (#581) by @dreamorosi
- chore: Update build pipeline (#584) by @hjgraca
This release was made possible by the following contributors:
Code and inspiration from jdevillard/JmesPath.Net and danielaparker/JsonCons.Net
1.9.1
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
🐛 Bug and hot fixes
🔧 Maintenance
This release was made possible by the following contributors:
1.9.0
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
- chore: Update nuget examples (#565) by @hjgraca
- chore: update package versions for examples (#564) by @hjgraca
- chore: Update version for release 1.9.0 (#563) by @amirkaws
- chore: Update NuGet packages to the latest (#561) by @amirkaws
- chore: Update examples to latest release (#555) by @hjgraca
This release was made possible by the following contributors:
1.8.5
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
🔧 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:
1.8.4
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.
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
Changes
📜 Documentation updates
🔧 Maintenance
- chore: Update version for batch GA (#532) by @hjgraca
- chore: Update examples idempotency (#528) by @hjgraca
This release was made possible by the following contributors:
@hjgraca and @lachriz-aws
1.8.3
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
Here is an example on how you register the Lambda context in your handler:
Lambda request timeout diagram
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
🔧 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