├── apidocs ├── api │ ├── index.md │ └── .gitignore ├── images │ └── favicon.ico ├── toc.yml └── index.md ├── version.txt ├── .vscode └── settings.json ├── docs ├── getting-started │ ├── metrics │ │ ├── aot.md │ │ ├── aspnet.md │ │ └── simple.md │ ├── tracing │ │ ├── aot.md │ │ └── simple.md │ └── idempotency │ │ ├── aot.md │ │ └── simple.md ├── requirements.in ├── changelog.md ├── media │ ├── utilities_typing.png │ ├── metrics_terminology.png │ ├── metrics_utility_showcase.png │ ├── tracer_utility_showcase.png │ ├── utilities_data_classes.png │ └── we_made_this │ │ ├── rahul_nath_batch.png │ │ ├── rahul_nath_logging.png │ │ ├── rahul_nath_metrics.png │ │ ├── rahul_nath_tracing.png │ │ ├── rahul_nath_parameters.png │ │ └── rahul_nath_idempotency.png ├── overrides │ ├── assets │ │ └── images │ │ │ └── powertools_docs_thumbnail.png │ └── main.html ├── Dockerfile ├── javascript │ └── extra.js └── stylesheets │ └── extra.css ├── NOTICE ├── libraries ├── tests │ ├── AWS.Lambda.Powertools.JMESPath.Tests │ │ ├── GlobalUsings.cs │ │ └── test_files │ │ │ ├── test.json │ │ │ ├── current.json │ │ │ ├── cloud_watch_logs.json │ │ │ └── unicode.json │ ├── AWS.Lambda.Powertools.Idempotency.Tests │ │ ├── TestSetup.cs │ │ ├── Model │ │ │ ├── TestClass.cs │ │ │ └── TestJsonSerializerContext.cs │ │ └── Handlers │ │ │ ├── IdempotencyHandlerWithCustomKeyPrefix.cs │ │ │ └── IdempotencyAttributeWithCustomKeyPrefix.cs │ ├── e2e │ │ ├── Directory.Packages.props │ │ ├── Directory.Build.props │ │ ├── infra-aot │ │ │ ├── GlobalSuppressions.cs │ │ │ └── InfraAot.csproj │ │ ├── infra │ │ │ ├── GlobalSuppressions.cs │ │ │ ├── Program.cs │ │ │ └── Infra.csproj │ │ ├── functions │ │ │ ├── TestUtils │ │ │ │ └── TestUtils.csproj │ │ │ ├── payload.json │ │ │ ├── core │ │ │ │ ├── logging │ │ │ │ │ ├── Function │ │ │ │ │ │ └── src │ │ │ │ │ │ │ └── Function │ │ │ │ │ │ │ └── aws-lambda-tools-defaults.json │ │ │ │ │ ├── AOT-Function │ │ │ │ │ │ └── src │ │ │ │ │ │ │ └── AOT-Function │ │ │ │ │ │ │ └── aws-lambda-tools-defaults.json │ │ │ │ │ └── AOT-Function-ILogger │ │ │ │ │ │ └── src │ │ │ │ │ │ └── AOT-Function-ILogger │ │ │ │ │ │ └── aws-lambda-tools-defaults.json │ │ │ │ ├── metrics │ │ │ │ │ ├── Function │ │ │ │ │ │ └── src │ │ │ │ │ │ │ └── Function │ │ │ │ │ │ │ ├── aws-lambda-tools-defaults.json │ │ │ │ │ │ │ └── Function.cs │ │ │ │ │ └── AOT-Function │ │ │ │ │ │ └── src │ │ │ │ │ │ └── AOT-Function │ │ │ │ │ │ └── aws-lambda-tools-defaults.json │ │ │ │ └── tracing │ │ │ │ │ ├── Function │ │ │ │ │ └── src │ │ │ │ │ │ └── Function │ │ │ │ │ │ └── aws-lambda-tools-defaults.json │ │ │ │ │ └── AOT-Function │ │ │ │ │ └── src │ │ │ │ │ └── AOT-Function │ │ │ │ │ └── aws-lambda-tools-defaults.json │ │ │ └── idempotency │ │ │ │ ├── Function │ │ │ │ ├── src │ │ │ │ │ └── Function │ │ │ │ │ │ └── aws-lambda-tools-defaults.json │ │ │ │ └── test │ │ │ │ │ └── Function.Tests │ │ │ │ │ └── Helpers.cs │ │ │ │ └── AOT-Function │ │ │ │ └── src │ │ │ │ ├── AOT-FunctionHandlerTest │ │ │ │ └── aws-lambda-tools-defaults.json │ │ │ │ ├── AOT-FunctionMethodAttributeTest │ │ │ │ └── aws-lambda-tools-defaults.json │ │ │ │ └── AOT-FunctionPayloadSubsetTest │ │ │ │ └── aws-lambda-tools-defaults.json │ │ ├── InfraShared │ │ │ ├── InfraShared.csproj │ │ │ └── FunctionConstructProps.cs │ │ └── Readme.md │ ├── AWS.Lambda.Powertools.Kafka.Tests │ │ ├── Protobuf │ │ │ ├── Product.proto │ │ │ ├── Key.proto │ │ │ └── UserProfile.proto │ │ ├── Avro │ │ │ ├── AvroProduct.avsc │ │ │ ├── AvroKey.avsc │ │ │ └── AWS │ │ │ │ └── Lambda │ │ │ │ └── Powertools │ │ │ │ └── Kafka │ │ │ │ └── Tests │ │ │ │ └── Color.cs │ │ └── Readme.md │ ├── Directory.Build.props │ ├── AWS.Lambda.Powertools.Metrics.Tests │ │ ├── Utils.cs │ │ └── ClearDimensionsTests.cs │ ├── AWS.Lambda.Powertools.EventHandler.Tests │ │ └── BedrockAgentFunction │ │ │ └── bedrockFunctionEvent.json │ ├── AWS.Lambda.Powertools.Logging.Tests │ │ ├── TestSetup.cs │ │ └── Serializers │ │ │ └── TestJsonContext.cs │ ├── AWS.Lambda.Powertools.Tracing.Tests │ │ ├── Serializers │ │ │ ├── TracingSerializerExtensionsTests.cs │ │ │ └── TestJsonContext.cs │ │ └── XRayRecorderTestFixture.cs │ └── AWS.Lambda.Powertools.BatchProcessing.Tests │ │ └── Handlers │ │ ├── SQS │ │ └── Services.cs │ │ ├── Kinesis │ │ └── Services.cs │ │ └── DynamoDB │ │ └── Services.cs ├── src │ ├── AWS.Lambda.Powertools.Kafka │ │ ├── Readme.md │ │ ├── InternalsVisibleTo.cs │ │ ├── SchemaMetadata.cs │ │ └── AWS.Lambda.Powertools.Kafka.csproj │ ├── AWS.Lambda.Powertools.EventHandler │ │ ├── InternalsVisibleTo.cs │ │ ├── AppSyncEvents │ │ │ ├── ChannelNamespace.cs │ │ │ ├── AppSyncLambdaIdentity.cs │ │ │ ├── AppSyncEventsOperation.cs │ │ │ ├── RequestContext.cs │ │ │ ├── AppSyncOidcIdentity.cs │ │ │ ├── Channel.cs │ │ │ ├── AppSyncEventsResponse.cs │ │ │ ├── Information.cs │ │ │ └── AppSyncEvent.cs │ │ └── Internal │ │ │ ├── EnvWrapper.cs │ │ │ └── RouteHandlerOptions.cs │ ├── AWS.Lambda.Powertools.BatchProcessing │ │ ├── InternalsVisibleTo.cs │ │ ├── Sqs │ │ │ ├── ISqsRecordHandler.cs │ │ │ ├── ISqsBatchProcessor.cs │ │ │ └── SqsRecordDataExtractor.cs │ │ ├── Internal │ │ │ ├── IBatchProcessingAspectHandler.cs │ │ │ ├── EnvWrapper.cs │ │ │ └── BatchEventType.cs │ │ ├── Kinesis │ │ │ ├── IKinesisEventRecordHandler.cs │ │ │ └── IKinesisEventBatchProcessor.cs │ │ ├── DynamoDb │ │ │ ├── IDynamoDbStreamRecordHandler.cs │ │ │ └── IDynamoDbStreamBatchProcessor.cs │ │ ├── Exceptions │ │ │ ├── UnprocessedRecordException.cs │ │ │ ├── CircuitBreakerException.cs │ │ │ ├── RecordProcessingException.cs │ │ │ └── BatchProcessingException.cs │ │ ├── IRecordHandlerProvider.cs │ │ ├── ITypedRecordHandlerProvider.cs │ │ ├── IBatchProcessorProvider.cs │ │ ├── IRecordDataExtractor.cs │ │ ├── ITypedRecordHandlerWithContextProvider.cs │ │ ├── RecordFailure.cs │ │ ├── RecordSuccess.cs │ │ ├── IRecordHandler.cs │ │ ├── ITypedRecordHandler.cs │ │ ├── DeserializationErrorPolicy.cs │ │ ├── IDeserializationErrorHandler.cs │ │ ├── RecordHandlerResult.cs │ │ └── ITypedRecordHandlerWithContext.cs │ ├── AWS.Lambda.Powertools.Metrics.AspNetCore │ │ ├── InternalsVisibleTo.cs │ │ └── Http │ │ │ └── MetricsEndpointExtensions.cs │ ├── AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction │ │ ├── InternalsVisibleTo.cs │ │ ├── Models │ │ │ ├── TextBody.cs │ │ │ ├── ResponseBody.cs │ │ │ ├── Response.cs │ │ │ ├── Parameter.cs │ │ │ └── Agent.cs │ │ ├── BedrockFunctionResolverContext.cs │ │ ├── Internal │ │ │ └── EnvWrapper.cs │ │ └── DiBedrockAgentFunctionResolver.cs │ ├── AWS.Lambda.Powertools.Common │ │ ├── README.md │ │ ├── Utils │ │ │ └── RuntimeFeatureWrapper.cs │ │ ├── AWS.Lambda.Powertools.Common.csproj │ │ └── Core │ │ │ └── IConsoleWrapper.cs │ ├── AWS.Lambda.Powertools.Logging │ │ ├── Internal │ │ │ ├── Buffer │ │ │ │ └── BufferedLogEntry.cs │ │ │ ├── EnvWrapper.cs │ │ │ ├── LoggingAspectFactory.cs │ │ │ └── PowertoolsLoggerScope.cs │ │ ├── Logger.Sampling.cs │ │ ├── Serializers │ │ │ ├── LogLevelJsonConverter.cs │ │ │ └── LoggingSerializationContext.cs │ │ ├── PowertoolsLoggerFactoryExtensions.cs │ │ ├── InternalsVisibleTo.cs │ │ ├── Logger.Formatter.cs │ │ └── ILogFormatter.cs │ ├── AWS.Lambda.Powertools.JMESPath │ │ ├── AWS.Lambda.Powertools.JMESPath.csproj │ │ ├── Serializers │ │ │ ├── JMESPathSerializationContext.cs │ │ │ └── JMESPathSerializer.cs │ │ ├── InternalsVisibleTo.cs │ │ ├── Values │ │ │ ├── IArrayValueEnumerator.cs │ │ │ ├── IObjectValueEnumerator.cs │ │ │ ├── JmesPathType.cs │ │ │ └── NameValuePair.cs │ │ └── Expressions │ │ │ └── KeyExpressionPair.cs │ ├── AWS.Lambda.Powertools.Metrics │ │ ├── Internal │ │ │ └── EnvWrapper.cs │ │ ├── Model │ │ │ └── MetricResolution.cs │ │ ├── Serializer │ │ │ ├── DictionaryLookupNamingPolicy.cs │ │ │ └── MetricsSerializationContext.cs │ │ ├── InternalsVisibleTo.cs │ │ └── AWS.Lambda.Powertools.Metrics.csproj │ ├── AWS.Lambda.Powertools.Parameters │ │ ├── SecretsManager │ │ │ └── ISecretsProvider.cs │ │ ├── Internal │ │ │ └── EnvWrapper.cs │ │ ├── InternalsVisibleTo.cs │ │ ├── Cache │ │ │ └── IDateTimeWrapper.cs │ │ ├── Transform │ │ │ └── Transformation.cs │ │ └── SimpleSystemsManagement │ │ │ └── ISsmProvider.cs │ ├── AWS.Lambda.Powertools.Tracing │ │ ├── Internal │ │ │ ├── EnvWrapper.cs │ │ │ ├── TracingAspectFactory.cs │ │ │ └── Helpers.cs │ │ └── InternalsVisibleTo.cs │ ├── AWS.Lambda.Powertools.Idempotency │ │ ├── Internal │ │ │ ├── EnvWrapper.cs │ │ │ └── Serializers │ │ │ │ └── IdempotencySerializationContext.cs │ │ └── InternalsVisibleTo.cs │ ├── AWS.Lambda.Powertools.Kafka.Avro │ │ └── Internal │ │ │ └── EnvWrapper.cs │ ├── AWS.Lambda.Powertools.Kafka.Json │ │ └── Internal │ │ │ └── EnvWrapper.cs │ ├── AWS.Lambda.Powertools.Kafka.Protobuf │ │ └── Internal │ │ │ └── EnvWrapper.cs │ └── KafkaDependencies.props └── AWSLogo128x128.png ├── examples ├── ServerlessApi │ ├── src │ │ └── LambdaPowertoolsAPI │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── samconfig.toml │ │ │ ├── aws-lambda-tools-defaults.json │ │ │ └── LambdaPowertoolsAPI.csproj │ ├── events │ │ ├── event.json │ │ └── event_getById.json │ └── test │ │ └── LambdaPowertoolsAPI.Tests │ │ ├── appsettings.json │ │ └── SampleRequests │ │ └── ValuesController-Get.json ├── Event Handler │ └── BedrockAgentFunction │ │ ├── infra │ │ ├── .npmignore │ │ ├── .gitignore │ │ ├── jest.config.js │ │ ├── README.md │ │ ├── package.json │ │ └── tsconfig.json │ │ └── src │ │ └── aws-lambda-tools-defaults.json ├── Logging │ ├── omnisharp.json │ ├── src │ │ └── HelloWorld │ │ │ ├── aws-lambda-tools-defaults.json │ │ │ └── HelloWorld.csproj │ └── test │ │ └── HelloWorld.Test │ │ └── HelloWorld.Tests.csproj ├── Metrics │ ├── omnisharp.json │ ├── src │ │ └── HelloWorld │ │ │ ├── aws-lambda-tools-defaults.json │ │ │ └── HelloWorld.csproj │ └── test │ │ └── HelloWorld.Test │ │ └── HelloWorld.Tests.csproj ├── Tracing │ ├── omnisharp.json │ ├── src │ │ └── HelloWorld │ │ │ ├── aws-lambda-tools-defaults.json │ │ │ └── HelloWorld.csproj │ └── test │ │ └── HelloWorld.Test │ │ └── HelloWorld.Tests.csproj ├── Parameters │ ├── omnisharp.json │ ├── src │ │ └── HelloWorld │ │ │ ├── aws-lambda-tools-defaults.json │ │ │ └── HelloWorld.csproj │ ├── cfn │ │ └── HelloWorld.Cfn │ │ │ ├── aws-lambda-tools-defaults.json │ │ │ ├── HelloWorld.Cfn.csproj │ │ │ └── CfnRequest.cs │ └── test │ │ └── HelloWorld.Test │ │ └── HelloWorld.Tests.csproj ├── BatchProcessing │ ├── omnisharp.json │ └── src │ │ └── HelloWorld │ │ ├── aws-lambda-tools-defaults.json │ │ ├── Data │ │ └── Product.cs │ │ ├── HelloWorld.csproj │ │ └── Sqs │ │ └── CustomSqsRecordHandlerProvider.cs ├── Kafka │ ├── Json │ │ └── src │ │ │ ├── Models │ │ │ ├── PhoneNumber.cs │ │ │ ├── Email.cs │ │ │ ├── Preferences.cs │ │ │ ├── Address.cs │ │ │ └── CustomerProfile.cs │ │ │ ├── aws-lambda-tools-defaults.json │ │ │ ├── Function.cs │ │ │ └── template.yaml │ ├── Avro │ │ └── src │ │ │ ├── aws-lambda-tools-defaults.json │ │ │ ├── Function.cs │ │ │ ├── Generated │ │ │ └── com │ │ │ │ └── example │ │ │ │ ├── PhoneType.cs │ │ │ │ └── AccountStatus.cs │ │ │ ├── template.yaml │ │ │ └── kafka-avro-event.json │ ├── Protobuf │ │ └── src │ │ │ ├── aws-lambda-tools-defaults.json │ │ │ ├── Function.cs │ │ │ ├── template.yaml │ │ │ ├── CustomerProfile.proto │ │ │ └── kafka-protobuf-event.json │ └── JsonClassLibrary │ │ └── src │ │ ├── aws-lambda-tools-defaults.json │ │ ├── CustomerProfile.proto │ │ ├── template.yaml │ │ └── kafka-protobuf-event.json ├── AOT │ ├── AOT_Logging │ │ ├── test │ │ │ └── AOT_Logging.Tests │ │ │ │ ├── FunctionTest.cs │ │ │ │ └── AOT_Logging.Tests.csproj │ │ └── src │ │ │ └── AOT_Logging │ │ │ └── aws-lambda-tools-defaults.json │ ├── AOT_Metrics │ │ ├── test │ │ │ └── AOT_Metrics.Tests │ │ │ │ ├── FunctionTest.cs │ │ │ │ └── AOT_Metrics.Tests.csproj │ │ └── src │ │ │ └── AOT_Metrics │ │ │ └── aws-lambda-tools-defaults.json │ └── AOT_Tracing │ │ ├── test │ │ └── AOT_Tracing.Tests │ │ │ ├── FunctionTest.cs │ │ │ └── AOT_Tracing.Tests.csproj │ │ └── src │ │ └── AOT_Tracing │ │ └── aws-lambda-tools-defaults.json └── Idempotency │ ├── src │ └── HelloWorld │ │ ├── aws-lambda-tools-defaults.json │ │ └── HelloWorld.csproj │ └── test │ └── HelloWorld.Test │ └── HelloWorld.Tests.csproj ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ └── config.yml ├── scripts │ ├── save_pr_details.js │ └── download_pr_artifact.js ├── workflows │ ├── build_changelog.yml │ ├── release-drafter.yml │ ├── record_pr.yml │ ├── rebuild_latest_docs.yml │ ├── examples-tests.yml │ └── secure_workflows.yml ├── semantic.yml ├── stale.yml ├── auto_assign.yml ├── dependabot.yml └── release-drafter.yml ├── CODE_OF_CONDUCT.md ├── SECURITY.md ├── package.json ├── .gitignore ├── pyproject.toml ├── 404.html ├── Makefile ├── .chglog └── config.yml └── LICENSE /apidocs/api/index.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /version.txt: -------------------------------------------------------------------------------- 1 | 3.1.0 2 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /docs/getting-started/metrics/aot.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/getting-started/metrics/aspnet.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/getting-started/tracing/aot.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/getting-started/idempotency/aot.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.JMESPath.Tests/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; -------------------------------------------------------------------------------- /docs/requirements.in: -------------------------------------------------------------------------------- 1 | mkdocs-git-revision-date-plugin==0.3.2 2 | mkdocs-llmstxt==0.2.0 3 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Kafka/Readme.md: -------------------------------------------------------------------------------- 1 | # Powertools for AWS Lambda (.NET) - Kafka -------------------------------------------------------------------------------- /apidocs/api/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # temp file # 3 | ############### 4 | *.yml 5 | .manifest 6 | -------------------------------------------------------------------------------- /docs/changelog.md: -------------------------------------------------------------------------------- 1 | [comment]: <> (Includes Changelog content entire file as a snippet) 2 | --8<-- "CHANGELOG.md" 3 | -------------------------------------------------------------------------------- /docs/getting-started/metrics/simple.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Simple Logging 3 | description: Getting started with Logging 4 | --- -------------------------------------------------------------------------------- /docs/getting-started/tracing/simple.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Simple Logging 3 | description: Getting started with Logging 4 | --- -------------------------------------------------------------------------------- /apidocs/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/apidocs/images/favicon.ico -------------------------------------------------------------------------------- /docs/getting-started/idempotency/simple.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Simple Logging 3 | description: Getting started with Logging 4 | --- -------------------------------------------------------------------------------- /examples/ServerlessApi/src/LambdaPowertoolsAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "AWS": { 3 | "Region": "" 4 | } 5 | } -------------------------------------------------------------------------------- /libraries/AWSLogo128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/libraries/AWSLogo128x128.png -------------------------------------------------------------------------------- /docs/media/utilities_typing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/docs/media/utilities_typing.png -------------------------------------------------------------------------------- /docs/media/metrics_terminology.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/docs/media/metrics_terminology.png -------------------------------------------------------------------------------- /docs/media/metrics_utility_showcase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/docs/media/metrics_utility_showcase.png -------------------------------------------------------------------------------- /docs/media/tracer_utility_showcase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/docs/media/tracer_utility_showcase.png -------------------------------------------------------------------------------- /docs/media/utilities_data_classes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/docs/media/utilities_data_classes.png -------------------------------------------------------------------------------- /examples/Event Handler/BedrockAgentFunction/infra/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/TestSetup.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | [assembly: CollectionBehavior(DisableTestParallelization = true)] -------------------------------------------------------------------------------- /libraries/tests/e2e/Directory.Packages.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /docs/media/we_made_this/rahul_nath_batch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/docs/media/we_made_this/rahul_nath_batch.png -------------------------------------------------------------------------------- /docs/media/we_made_this/rahul_nath_logging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/docs/media/we_made_this/rahul_nath_logging.png -------------------------------------------------------------------------------- /docs/media/we_made_this/rahul_nath_metrics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/docs/media/we_made_this/rahul_nath_metrics.png -------------------------------------------------------------------------------- /docs/media/we_made_this/rahul_nath_tracing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/docs/media/we_made_this/rahul_nath_tracing.png -------------------------------------------------------------------------------- /docs/media/we_made_this/rahul_nath_parameters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/docs/media/we_made_this/rahul_nath_parameters.png -------------------------------------------------------------------------------- /docs/media/we_made_this/rahul_nath_idempotency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/docs/media/we_made_this/rahul_nath_idempotency.png -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Kafka/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.Kafka.Tests")] -------------------------------------------------------------------------------- /examples/Event Handler/BedrockAgentFunction/infra/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | 6 | # CDK asset staging directory 7 | .cdk.staging 8 | cdk.out 9 | -------------------------------------------------------------------------------- /docs/overrides/assets/images/powertools_docs_thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-powertools/powertools-lambda-dotnet/HEAD/docs/overrides/assets/images/powertools_docs_thumbnail.png -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.EventHandler.Tests")] -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners 2 | 3 | * @aws-powertools/lambda-dotnet 4 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System.Runtime.CompilerServices; 4 | 5 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.BatchProcessing.Tests")] -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Metrics.AspNetCore/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.Metrics.AspNetCore.Tests")] -------------------------------------------------------------------------------- /examples/ServerlessApi/src/LambdaPowertoolsAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /apidocs/toc.yml: -------------------------------------------------------------------------------- 1 | - name: API Documentation 2 | href: api/ 3 | homepage: api/index.md 4 | - name: Powertools for AWS Lambda (.NET) Documentation 5 | href: "https://docs.aws.amazon.com/powertools/dotnet/" 6 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.EventHandler.Tests")] -------------------------------------------------------------------------------- /docs/Dockerfile: -------------------------------------------------------------------------------- 1 | # v9.1.18 2 | FROM squidfunk/mkdocs-material@sha256:980e11fed03b8e7851e579be9f34b1210f516c9f0b4da1a1457f21a460bd6628 3 | 4 | COPY requirements.txt /tmp/ 5 | RUN pip install --require-hashes -r /tmp/requirements.txt 6 | -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Kafka.Tests/Protobuf/Product.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option csharp_namespace = "TestKafka"; 4 | 5 | message ProtobufProduct { 6 | int32 id = 1; 7 | string name = 2; 8 | double price = 3; 9 | } -------------------------------------------------------------------------------- /examples/Event Handler/BedrockAgentFunction/infra/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest' 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Model/TestClass.cs: -------------------------------------------------------------------------------- 1 | namespace AWS.Lambda.Powertools.Idempotency.Tests.Model; 2 | 3 | public class TestClass 4 | { 5 | public int Id { get; set; } 6 | public string Name { get; set; } 7 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | 6 | 7 | -------------------------------------------------------------------------------- /examples/Logging/omnisharp.json: -------------------------------------------------------------------------------- 1 | { 2 | "fileOptions": { 3 | "excludeSearchPatterns": [ 4 | "**/bin/**/*", 5 | "**/obj/**/*" 6 | ] 7 | }, 8 | "msbuild": { 9 | "Platform": "rhel.7.2-x64" 10 | } 11 | } -------------------------------------------------------------------------------- /examples/Metrics/omnisharp.json: -------------------------------------------------------------------------------- 1 | { 2 | "fileOptions": { 3 | "excludeSearchPatterns": [ 4 | "**/bin/**/*", 5 | "**/obj/**/*" 6 | ] 7 | }, 8 | "msbuild": { 9 | "Platform": "rhel.7.2-x64" 10 | } 11 | } -------------------------------------------------------------------------------- /examples/Tracing/omnisharp.json: -------------------------------------------------------------------------------- 1 | { 2 | "fileOptions": { 3 | "excludeSearchPatterns": [ 4 | "**/bin/**/*", 5 | "**/obj/**/*" 6 | ] 7 | }, 8 | "msbuild": { 9 | "Platform": "rhel.7.2-x64" 10 | } 11 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Ask a question 4 | url: https://github.com/aws-powertools/powertools-lambda-dotnet/discussions/new 5 | about: Ask a general question about Lambda Powertools 6 | -------------------------------------------------------------------------------- /examples/Parameters/omnisharp.json: -------------------------------------------------------------------------------- 1 | { 2 | "fileOptions": { 3 | "excludeSearchPatterns": [ 4 | "**/bin/**/*", 5 | "**/obj/**/*" 6 | ] 7 | }, 8 | "msbuild": { 9 | "Platform": "rhel.7.2-x64" 10 | } 11 | } -------------------------------------------------------------------------------- /examples/BatchProcessing/omnisharp.json: -------------------------------------------------------------------------------- 1 | { 2 | "fileOptions": { 3 | "excludeSearchPatterns": [ 4 | "**/bin/**/*", 5 | "**/obj/**/*" 6 | ] 7 | }, 8 | "msbuild": { 9 | "Platform": "rhel.7.2-x64" 10 | } 11 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/infra-aot/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Quality Issues", "RECS0026:Possible unassigned object created by 'new'", Justification = "Constructs add themselves to the scope in which they are created")] 2 | -------------------------------------------------------------------------------- /libraries/tests/e2e/infra/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Quality Issues", "RECS0026:Possible unassigned object created by 'new'", Justification = "Constructs add themselves to the scope in which they are created")] 2 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/Sqs/ISqsRecordHandler.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.SQSEvents; 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing.Sqs; 4 | 5 | /// 6 | public interface ISqsRecordHandler : IRecordHandler 7 | { 8 | 9 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Kafka.Tests/Protobuf/Key.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option csharp_namespace = "TestKafka"; 4 | 5 | message ProtobufKey { 6 | int32 id = 1; 7 | Color color = 2; 8 | } 9 | 10 | enum Color { 11 | UNKNOWN = 0; 12 | GREEN = 1; 13 | RED = 2; 14 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Common/README.md: -------------------------------------------------------------------------------- 1 | # AWS.Lambda.Powertools.Common 2 | 3 | Powertools for AWS Lambda (.NET) Common library 4 | 5 | ### As of release 1.7.0 of Powertools for AWS Lambda (.NET) this package is no longer required. For that reason It’s being deprecated and is no longer maintained. 6 | -------------------------------------------------------------------------------- /examples/Kafka/Json/src/Models/PhoneNumber.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace Json.Models; 4 | 5 | public partial class PhoneNumber 6 | { 7 | [JsonPropertyName("number")] public string Number { get; set; } 8 | 9 | [JsonPropertyName("type")] public string Type { get; set; } 10 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/Internal/IBatchProcessingAspectHandler.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System.Threading.Tasks; 4 | 5 | namespace AWS.Lambda.Powertools.BatchProcessing.Internal; 6 | 7 | internal interface IBatchProcessingAspectHandler 8 | { 9 | Task HandleAsync(object[] args); 10 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/Kinesis/IKinesisEventRecordHandler.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.KinesisEvents; 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing.Kinesis; 4 | 5 | /// 6 | public interface IKinesisEventRecordHandler : IRecordHandler 7 | { 8 | 9 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /examples/ServerlessApi/events/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "resource": "/{proxy+}", 3 | "path": "api/values", 4 | "httpMethod": "GET", 5 | "body": "{\r\n\t\"message\": \"Hello\"\r\n}", 6 | "isBase64Encoded": false, 7 | "requestContext": { 8 | "requestId": "4749a5a8-93ea-464e-8778-3bffc5f9a35d" 9 | } 10 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/DynamoDb/IDynamoDbStreamRecordHandler.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.DynamoDBEvents; 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing.DynamoDb; 4 | 5 | /// 6 | public interface IDynamoDbStreamRecordHandler : IRecordHandler 7 | { 8 | 9 | } -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | ## Reporting a Vulnerability 2 | 3 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security 4 | via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/) or directly via email to aws-security@amazon.com. 5 | Please do **not** create a public GitHub issue. -------------------------------------------------------------------------------- /examples/ServerlessApi/events/event_getById.json: -------------------------------------------------------------------------------- 1 | { 2 | "resource": "/{proxy+}", 3 | "path": "api/values/5", 4 | "httpMethod": "GET", 5 | "body": "{\r\n\t\"message\": \"Hello\"\r\n}", 6 | "isBase64Encoded": false, 7 | "requestContext": { 8 | "requestId": "4749a5a8-93ea-464e-8778-3bffc5f9a35d" 9 | } 10 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Kafka.Tests/Avro/AvroProduct.avsc: -------------------------------------------------------------------------------- 1 | { 2 | "namespace": "AWS.Lambda.Powertools.Kafka.Tests", 3 | "type": "record", 4 | "name": "AvroProduct", 5 | "fields": [ 6 | {"name": "id", "type": "int"}, 7 | {"name": "name", "type": "string"}, 8 | {"name": "price", "type": "double"} 9 | ] 10 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/Exceptions/UnprocessedRecordException.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System; 4 | 5 | namespace AWS.Lambda.Powertools.BatchProcessing.Exceptions; 6 | internal class UnprocessedRecordException : Exception 7 | { 8 | public UnprocessedRecordException(string message) : base(message) 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/ServerlessApi/test/LambdaPowertoolsAPI.Tests/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Lambda.Logging": { 3 | "IncludeCategory": false, 4 | "IncludeLogLevel": false, 5 | "IncludeNewline": true, 6 | "LogLevel": { 7 | "Default": "Debug", 8 | "Microsoft": "Information" 9 | } 10 | }, 11 | "AWS": { 12 | "Region": "" 13 | } 14 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/Exceptions/CircuitBreakerException.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System; 4 | 5 | namespace AWS.Lambda.Powertools.BatchProcessing.Exceptions; 6 | internal class CircuitBreakerException : Exception 7 | { 8 | internal CircuitBreakerException(string message, Exception inner) : base(message, inner) 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/Sqs/ISqsBatchProcessor.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.SQSEvents; 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing.Sqs; 4 | 5 | /// 6 | /// The default batch processor for SQS events. 7 | /// 8 | public interface ISqsBatchProcessor : IBatchProcessor 9 | { 10 | 11 | } -------------------------------------------------------------------------------- /examples/Kafka/Json/src/Models/Email.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace Json.Models; 4 | 5 | public partial class Email 6 | { 7 | [JsonPropertyName("address")] public string Address { get; set; } 8 | 9 | [JsonPropertyName("verified")] public bool Verified { get; set; } 10 | 11 | [JsonPropertyName("primary")] public bool Primary { get; set; } 12 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/Exceptions/RecordProcessingException.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System; 4 | 5 | namespace AWS.Lambda.Powertools.BatchProcessing.Exceptions; 6 | internal class RecordProcessingException : Exception 7 | { 8 | internal RecordProcessingException(string message, Exception inner) : base(message, inner) 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/ServerlessApi/src/LambdaPowertoolsAPI/samconfig.toml: -------------------------------------------------------------------------------- 1 | version = 0.1 2 | [default.deploy.parameters] 3 | stack_name = "aws-lambda-powertools-web-api-sample" 4 | resolve_s3 = true 5 | s3_prefix = "aws-lambda-powertools-web-api-sample" 6 | region = "eu-central-1" 7 | confirm_changeset = true 8 | capabilities = "CAPABILITY_IAM" 9 | disable_rollback = true 10 | image_repositories = [] 11 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Logging/Internal/Buffer/BufferedLogEntry.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace AWS.Lambda.Powertools.Logging.Internal; 3 | 4 | internal class BufferedLogEntry 5 | { 6 | public string Entry { get; } 7 | public int Size { get; } 8 | 9 | public BufferedLogEntry(string entry, int calculatedSize) 10 | { 11 | Entry = entry; 12 | Size = calculatedSize; 13 | } 14 | } -------------------------------------------------------------------------------- /examples/Kafka/Json/src/Models/Preferences.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace Json.Models; 4 | 5 | public partial class Preferences 6 | { 7 | [JsonPropertyName("language")] public string Language { get; set; } 8 | 9 | [JsonPropertyName("notifications")] public string Notifications { get; set; } 10 | 11 | [JsonPropertyName("timezone")] public string Timezone { get; set; } 12 | } -------------------------------------------------------------------------------- /libraries/tests/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | false 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/overrides/main.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block outdated %} 4 | You're not viewing the latest version. 5 | 6 | Click here to go to latest. 7 | 8 | {% endblock %} 9 | 10 | {% block extrahead %} 11 | 12 | 13 | {% endblock %} -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/Kinesis/IKinesisEventBatchProcessor.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.KinesisEvents; 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing.Kinesis; 4 | 5 | /// 6 | /// The default batch processor for Kinesis Data Stream events. 7 | /// 8 | public interface IKinesisEventBatchProcessor : IBatchProcessor 9 | { 10 | 11 | } -------------------------------------------------------------------------------- /.github/scripts/save_pr_details.js: -------------------------------------------------------------------------------- 1 | module.exports = async ({context, core}) => { 2 | const fs = require('fs'); 3 | const filename = "pr.txt"; 4 | 5 | try { 6 | fs.writeFileSync(`./${filename}`, JSON.stringify(context.payload)); 7 | 8 | return `PR successfully saved ${filename}` 9 | } catch (err) { 10 | core.setFailed("Failed to save PR details"); 11 | console.error(err); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Metrics.Tests/Utils.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | 4 | namespace AWS.Lambda.Powertools.Metrics.Tests; 5 | 6 | public class CustomConsoleWriter : StringWriter 7 | { 8 | public readonly List OutputValues = new(); 9 | 10 | public override void WriteLine(string value) 11 | { 12 | OutputValues.Add(value); 13 | base.WriteLine(value); 14 | } 15 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/Exceptions/BatchProcessingException.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace AWS.Lambda.Powertools.BatchProcessing.Exceptions; 7 | internal class BatchProcessingException : AggregateException 8 | { 9 | internal BatchProcessingException(string message, IEnumerable exceptions) : base(message, exceptions) 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/DynamoDb/IDynamoDbStreamBatchProcessor.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using Amazon.Lambda.DynamoDBEvents; 4 | 5 | namespace AWS.Lambda.Powertools.BatchProcessing.DynamoDb; 6 | 7 | /// 8 | /// The default batch processor for DynamoDB Stream events. 9 | /// 10 | public interface IDynamoDbStreamBatchProcessor : IBatchProcessor 11 | { 12 | 13 | } -------------------------------------------------------------------------------- /.github/workflows/build_changelog.yml: -------------------------------------------------------------------------------- 1 | # Standalone workflow to update changelog if necessary 2 | name: Build changelog 3 | 4 | on: 5 | workflow_dispatch: 6 | 7 | permissions: 8 | contents: read 9 | 10 | jobs: 11 | changelog: 12 | permissions: 13 | contents: write # create temporary branch to store changelog changes 14 | pull-requests: write # create PR with changelog changes 15 | uses: ./.github/workflows/reusable_publish_changelog.yml 16 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler/AppSyncEvents/ChannelNamespace.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.AppSyncEvents; 4 | 5 | /// 6 | /// Namespace configuration for the channel 7 | /// 8 | public class ChannelNamespace 9 | { 10 | /// 11 | /// Name of the channel namespace 12 | /// 13 | [JsonPropertyName("name")] 14 | public string? Name { get; set; } 15 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "powertools-lambda-dotnet", 3 | "version": "1.0.0", 4 | "description": "Powertools for AWS Lambda (.NET)", 5 | "main": "index.js", 6 | "directories": { 7 | "doc": "docs", 8 | "example": "examples" 9 | }, 10 | "scripts": { 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "author": "", 14 | "license": "MIT", 15 | "dependencies": { 16 | "aws-cdk": "^2.1100.0", 17 | "aws-cdk-lib": "^2.232.2" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/TestUtils/TestUtils.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | docs/node_modules 2 | docs/.cache 3 | docs/public 4 | 5 | apidocs/_site 6 | apidocs/obj 7 | 8 | deploy/** 9 | 10 | .idea 11 | .vscode 12 | .vs/ 13 | .aws-sam 14 | 15 | node_modules/* 16 | 17 | examples/SimpleLambda/.aws-sam 18 | examples/SimpleLambda/samconfig.toml 19 | 20 | AWS.Lambda.Powertools.sln.DotSettings.user 21 | [Oo]bj/** 22 | [Bb]in/** 23 | .DS_Store 24 | .cache 25 | 26 | dist/ 27 | site/ 28 | samconfig.toml 29 | 30 | .kiro 31 | .claude 32 | .amazonq 33 | .github/instructions 34 | -------------------------------------------------------------------------------- /.github/semantic.yml: -------------------------------------------------------------------------------- 1 | # conventional commit types: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json 2 | types: 3 | - feat 4 | - fix 5 | - docs 6 | - style 7 | - refactor 8 | - perf 9 | - test 10 | - build 11 | - ci 12 | - chore 13 | - revert 14 | - improv 15 | 16 | # Always validate the PR title 17 | # and ignore the commits to lower the entry bar for contribution 18 | # while titles make up the Release notes to ease maintenance overhead 19 | titleOnly: true 20 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Logging/Logger.Sampling.cs: -------------------------------------------------------------------------------- 1 | namespace AWS.Lambda.Powertools.Logging; 2 | 3 | public static partial class Logger 4 | { 5 | /// 6 | /// Refresh the sampling calculation and update the minimum log level if needed 7 | /// 8 | /// True if debug sampling was enabled, false otherwise 9 | public static bool RefreshSampleRateCalculation() 10 | { 11 | return _config.RefreshSampleRateCalculation(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/payload.json: -------------------------------------------------------------------------------- 1 | { 2 | "body": "hello world", 3 | "resource": "/{proxy+}", 4 | "path": "/path/to/resource", 5 | "httpMethod": "POST", 6 | "isBase64Encoded": false, 7 | "requestContext": { 8 | "accountId": "123456789012", 9 | "resourceId": "123456", 10 | "stage": "prod", 11 | "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", 12 | "path": "/prod/path/to/resource", 13 | "httpMethod": "POST", 14 | "apiId": "1234567890", 15 | "protocol": "HTTP/1.1" 16 | } 17 | } -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - develop 7 | workflow_dispatch: 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | update_release_draft: 14 | permissions: 15 | id-token: write 16 | contents: write 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v5.20.1 20 | env: 21 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 22 | -------------------------------------------------------------------------------- /examples/Kafka/Json/src/Models/Address.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace Json.Models; 4 | 5 | public partial class Address 6 | { 7 | [JsonPropertyName("street")] public string Street { get; set; } 8 | 9 | [JsonPropertyName("city")] public string City { get; set; } 10 | 11 | [JsonPropertyName("state")] public string State { get; set; } 12 | 13 | [JsonPropertyName("country")] public string Country { get; set; } 14 | 15 | [JsonPropertyName("zip_code")] public string ZipCode { get; set; } 16 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/Models/TextBody.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.Models; 4 | 5 | /// 6 | /// Represents the text body part of a ResponseBody. 7 | /// 8 | public class TextBody 9 | { 10 | /// 11 | /// Gets or sets the body text. 12 | /// 13 | [JsonPropertyName("body")] 14 | public string Body { get; set; } = string.Empty; 15 | } -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | only: issues 2 | daysUntilStale: 14 3 | daysUntilClose: 7 4 | exemptLabels: 5 | - bug 6 | - feature-request 7 | staleLabel: pending-close-response-required 8 | markComment: > 9 | This issue has been automatically marked as stale because it has not had 10 | recent activity. It will be closed if no further activity occurs. Thank you 11 | for your contributions. 12 | closeComment: > 13 | This issue has been automatically closed because of inactivity. 14 | Please open a new issue if you are still encountering problems. -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Kafka.Tests/Protobuf/UserProfile.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package com.example.protobuf; 3 | 4 | message Address { 5 | string street = 1; 6 | string city = 2; 7 | string zip = 3; 8 | } 9 | 10 | message UserProfile { 11 | string userId = 1; 12 | string name = 2; 13 | string email = 3; 14 | int32 age = 4; 15 | bool isActive = 5; 16 | string signupDate = 6; 17 | repeated string tags = 7; 18 | double score = 8; 19 | map preferences = 9; 20 | Address address = 10; 21 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/infra/Program.cs: -------------------------------------------------------------------------------- 1 | using Amazon.CDK; 2 | using InfraShared; 3 | 4 | namespace Infra 5 | { 6 | internal static class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | var app = new App(); 11 | 12 | _ = new CoreStack(app, "CoreStack", new StackProps { }); 13 | 14 | _ = new IdempotencyStack(app, "IdempotencyStack", new IdempotencyStackProps { TableName = "IdempotencyTable" }); 15 | 16 | app.Synth(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/Models/ResponseBody.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.Models; 4 | 5 | /// 6 | /// Represents the response body part of a FunctionResponse. 7 | /// 8 | public class ResponseBody 9 | { 10 | /// 11 | /// Gets or sets the text body. 12 | /// 13 | [JsonPropertyName("TEXT")] 14 | public TextBody Text { get; set; } = new TextBody(); 15 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Kafka.Tests/Avro/AvroKey.avsc: -------------------------------------------------------------------------------- 1 | { 2 | "namespace": "AWS.Lambda.Powertools.Kafka.Tests", 3 | "type": "record", 4 | "name": "AvroKey", 5 | "fields": [ 6 | { 7 | "name": "id", 8 | "type": "int" 9 | }, 10 | { 11 | "name": "color", 12 | "type": { 13 | "type": "enum", 14 | "name": "Color", 15 | "symbols": [ 16 | "UNKNOWN", 17 | "GREEN", 18 | "RED" 19 | ], 20 | "default": "UNKNOWN" 21 | } 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "aws-lambda-powertools-dotnet" 3 | version = "0.1.0" 4 | description = "Python utilities for AWS Lambda functions including but not limited to tracing, logging and custom metric" 5 | authors = ["Amazon Web Services"] 6 | 7 | [tool.poetry.dependencies] 8 | python = "^3.9" 9 | mike = "^1.0.1" 10 | mkdocs-git-revision-date-plugin = "^0.3.1" 11 | mkdocs-material = "^9.6.5" 12 | 13 | [tool.poetry.dev-dependencies] 14 | 15 | [build-system] 16 | requires = ["poetry-core>=1.0.0"] 17 | build-backend = "poetry.core.masonry.api" 18 | -------------------------------------------------------------------------------- /examples/AOT/AOT_Logging/test/AOT_Logging.Tests/FunctionTest.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Amazon.Lambda.Core; 3 | using Amazon.Lambda.TestUtilities; 4 | 5 | namespace AOT_Logging.Tests; 6 | 7 | public class FunctionTest 8 | { 9 | [Fact] 10 | public void TestToUpperFunction() 11 | { 12 | // Invoke the lambda function and confirm the string was upper cased. 13 | var context = new TestLambdaContext(); 14 | var upperCase = Function.FunctionHandler("hello world", context); 15 | 16 | Assert.Equal("HELLO WORLD", upperCase); 17 | } 18 | } -------------------------------------------------------------------------------- /examples/AOT/AOT_Metrics/test/AOT_Metrics.Tests/FunctionTest.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Amazon.Lambda.Core; 3 | using Amazon.Lambda.TestUtilities; 4 | 5 | namespace AOT_Metrics.Tests; 6 | 7 | public class FunctionTest 8 | { 9 | [Fact] 10 | public void TestToUpperFunction() 11 | { 12 | // Invoke the lambda function and confirm the string was upper cased. 13 | var context = new TestLambdaContext(); 14 | var upperCase = Function.FunctionHandler("hello world", context); 15 | 16 | Assert.Equal("HELLO WORLD", upperCase); 17 | } 18 | } -------------------------------------------------------------------------------- /examples/AOT/AOT_Tracing/test/AOT_Tracing.Tests/FunctionTest.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Amazon.Lambda.Core; 3 | using Amazon.Lambda.TestUtilities; 4 | 5 | namespace AOT_Tracing.Tests; 6 | 7 | public class FunctionTest 8 | { 9 | [Fact] 10 | public void TestToUpperFunction() 11 | { 12 | // Invoke the lambda function and confirm the string was upper cased. 13 | var context = new TestLambdaContext(); 14 | var upperCase = Function.FunctionHandler("hello world", context); 15 | 16 | Assert.Equal("HELLO WORLD", upperCase); 17 | } 18 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.JMESPath/AWS.Lambda.Powertools.JMESPath.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AWS.Lambda.Powertools.JMESPath 6 | Powertools for AWS Lambda (.NET) - JMESPath package. 7 | AWS.Lambda.Powertools.JMESPath 8 | AWS.Lambda.Powertools.JMESPath 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler/AppSyncEvents/AppSyncLambdaIdentity.cs: -------------------------------------------------------------------------------- 1 | namespace AWS.Lambda.Powertools.EventHandler.AppSyncEvents; 2 | 3 | /// 4 | /// Represents AWS Lambda authorization identity for AppSync 5 | /// 6 | public class AppSyncLambdaIdentity 7 | { 8 | /// 9 | /// Optional context information that will be passed to subsequent resolvers 10 | /// Can contain user information, claims, or any other contextual data 11 | /// 12 | public Dictionary? ResolverContext { get; set; } 13 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/IRecordHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing; 4 | 5 | /// 6 | /// The interface. 7 | /// 8 | /// Type of batch record. 9 | public interface IRecordHandlerProvider 10 | { 11 | /// 12 | /// Creates a record handler. 13 | /// 14 | /// The created record handler. 15 | IRecordHandler Create(); 16 | } 17 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/BedrockFunctionResolverContext.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace AWS.Lambda.Powertools.EventHandler.Resolvers; 5 | 6 | [JsonSerializable(typeof(string[]))] 7 | [JsonSerializable(typeof(int[]))] 8 | [JsonSerializable(typeof(long[]))] 9 | [JsonSerializable(typeof(double[]))] 10 | [JsonSerializable(typeof(bool[]))] 11 | [JsonSerializable(typeof(decimal[]))] 12 | internal partial class BedrockFunctionResolverContext : JsonSerializerContext 13 | { 14 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Handlers/IdempotencyHandlerWithCustomKeyPrefix.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Amazon.Lambda.Core; 3 | 4 | namespace AWS.Lambda.Powertools.Idempotency.Tests.Handlers; 5 | 6 | /// 7 | /// Simple Lambda function with Idempotent on handler with a custom prefix key 8 | /// 9 | public class IdempotencyHandlerWithCustomKeyPrefix 10 | { 11 | [Idempotent(KeyPrefix = "MyHandler")] 12 | public string HandleRequest(string input, ILambdaContext context) 13 | { 14 | return Guid.NewGuid().ToString(); 15 | } 16 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Logging/Internal/EnvWrapper.cs: -------------------------------------------------------------------------------- 1 | using AWS.Lambda.Powertools.Common; 2 | 3 | namespace AWS.Lambda.Powertools.Logging.Internal 4 | { 5 | /// 6 | /// Wrapper class to set the execution environment 7 | /// 8 | public static class EnvWrapper 9 | { 10 | /// 11 | /// Sets the execution environment 12 | /// 13 | public static void SetExecutionEnvironment() 14 | { 15 | PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper)); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Metrics/Internal/EnvWrapper.cs: -------------------------------------------------------------------------------- 1 | using AWS.Lambda.Powertools.Common; 2 | 3 | namespace AWS.Lambda.Powertools.Metrics.Internal 4 | { 5 | /// 6 | /// Wrapper class to set the execution environment 7 | /// 8 | public static class EnvWrapper 9 | { 10 | /// 11 | /// Sets the execution environment 12 | /// 13 | public static void SetExecutionEnvironment() 14 | { 15 | PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper)); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Parameters/SecretsManager/ISecretsProvider.cs: -------------------------------------------------------------------------------- 1 | using Amazon.SecretsManager; 2 | using AWS.Lambda.Powertools.Parameters.Internal.Provider; 3 | using AWS.Lambda.Powertools.Parameters.Provider; 4 | 5 | namespace AWS.Lambda.Powertools.Parameters.SecretsManager; 6 | 7 | /// 8 | /// Represents a type used to retrieve parameter values from SAWS Secrets Manager. 9 | /// 10 | public interface ISecretsProvider : IParameterProvider, 11 | IParameterProviderConfigurableClient 12 | { 13 | 14 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Tracing/Internal/EnvWrapper.cs: -------------------------------------------------------------------------------- 1 | using AWS.Lambda.Powertools.Common; 2 | 3 | namespace AWS.Lambda.Powertools.Tracing.Internal 4 | { 5 | /// 6 | /// Wrapper class to set the execution environment 7 | /// 8 | public static class EnvWrapper 9 | { 10 | /// 11 | /// Sets the execution environment 12 | /// 13 | public static void SetExecutionEnvironment() 14 | { 15 | PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper)); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Parameters/Internal/EnvWrapper.cs: -------------------------------------------------------------------------------- 1 | using AWS.Lambda.Powertools.Common; 2 | 3 | namespace AWS.Lambda.Powertools.Parameters.Internal 4 | { 5 | /// 6 | /// Wrapper class to set the execution environment 7 | /// 8 | public static class EnvWrapper 9 | { 10 | /// 11 | /// Sets the execution environment 12 | /// 13 | public static void SetExecutionEnvironment() 14 | { 15 | PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper)); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler/AppSyncEvents/AppSyncEventsOperation.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.AppSyncEvents; 4 | 5 | /// 6 | /// Represents the operation type for AppSync events. 7 | /// 8 | [JsonConverter(typeof(JsonStringEnumConverter))] 9 | public enum AppSyncEventsOperation 10 | { 11 | /// 12 | /// Represents a subscription operation. 13 | /// 14 | Subscribe, 15 | 16 | /// 17 | /// Represents a publish operation. 18 | /// 19 | Publish 20 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler/Internal/EnvWrapper.cs: -------------------------------------------------------------------------------- 1 | using AWS.Lambda.Powertools.Common; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.Internal 4 | { 5 | /// 6 | /// Wrapper class to set the execution environment 7 | /// 8 | public static class EnvWrapper 9 | { 10 | /// 11 | /// Sets the execution environment 12 | /// 13 | public static void SetExecutionEnvironment() 14 | { 15 | PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper)); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/EnvWrapper.cs: -------------------------------------------------------------------------------- 1 | using AWS.Lambda.Powertools.Common; 2 | 3 | namespace AWS.Lambda.Powertools.Idempotency.Internal 4 | { 5 | /// 6 | /// Wrapper class to set the execution environment 7 | /// 8 | public static class EnvWrapper 9 | { 10 | /// 11 | /// Sets the execution environment 12 | /// 13 | public static void SetExecutionEnvironment() 14 | { 15 | PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper)); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /examples/Logging/src/HelloWorld/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "template": "template.yaml" 12 | } -------------------------------------------------------------------------------- /examples/Metrics/src/HelloWorld/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "template": "template.yaml" 12 | } -------------------------------------------------------------------------------- /examples/Tracing/src/HelloWorld/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "template": "template.yaml" 12 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/Internal/EnvWrapper.cs: -------------------------------------------------------------------------------- 1 | using AWS.Lambda.Powertools.Common; 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing.Internal 4 | { 5 | /// 6 | /// Wrapper class to set the execution environment 7 | /// 8 | public static class EnvWrapper 9 | { 10 | /// 11 | /// Sets the execution environment 12 | /// 13 | public static void SetExecutionEnvironment() 14 | { 15 | PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper)); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /examples/Idempotency/src/HelloWorld/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "template": "template.yaml" 12 | } -------------------------------------------------------------------------------- /examples/Parameters/src/HelloWorld/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "template": "template.yaml" 12 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/Internal/BatchEventType.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing.Internal; 4 | 5 | /// 6 | /// Enum representing the different batch event types. 7 | /// 8 | internal enum BatchEventType 9 | { 10 | /// 11 | /// SQS event. 12 | /// 13 | Sqs, 14 | 15 | /// 16 | /// DynamoDB Stream event. 17 | /// 18 | DynamoDbStream, 19 | 20 | /// 21 | /// Kinesis Data Stream event. 22 | /// 23 | KinesisDataStream 24 | } 25 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Kafka.Avro/Internal/EnvWrapper.cs: -------------------------------------------------------------------------------- 1 | using AWS.Lambda.Powertools.Common; 2 | 3 | namespace AWS.Lambda.Powertools.Kafka.Avro.Internal 4 | { 5 | /// 6 | /// Wrapper class to set the execution environment 7 | /// 8 | public static class EnvWrapper 9 | { 10 | /// 11 | /// Sets the execution environment 12 | /// 13 | public static void SetExecutionEnvironment() 14 | { 15 | PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper), "Kafka.Avro"); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Kafka.Json/Internal/EnvWrapper.cs: -------------------------------------------------------------------------------- 1 | using AWS.Lambda.Powertools.Common; 2 | 3 | namespace AWS.Lambda.Powertools.Kafka.Json.Internal 4 | { 5 | /// 6 | /// Wrapper class to set the execution environment 7 | /// 8 | public static class EnvWrapper 9 | { 10 | /// 11 | /// Sets the execution environment 12 | /// 13 | public static void SetExecutionEnvironment() 14 | { 15 | PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper), "Kafka.Json"); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /docs/javascript/extra.js: -------------------------------------------------------------------------------- 1 | function copyToClipboard(e) { 2 | e.preventDefault(); 3 | navigator.clipboard.writeText(e.target.textContent); 4 | alert$.next('Copied to clipboard'); 5 | } 6 | 7 | function enableClipboardElements() { 8 | const copyElements = document.querySelectorAll('.copyMe'); 9 | copyElements.forEach((element) => { 10 | element.addEventListener('click', copyToClipboard); 11 | }); 12 | } 13 | 14 | const attachListeners = () => { 15 | enableSearchOnBlurElement(); 16 | enableClipboardElements(); 17 | }; 18 | 19 | const init = () => { 20 | attachListeners(); 21 | }; 22 | 23 | init(); -------------------------------------------------------------------------------- /examples/BatchProcessing/src/HelloWorld/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "template": "template.yaml" 12 | } -------------------------------------------------------------------------------- /examples/Parameters/cfn/HelloWorld.Cfn/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "template": "template.yaml" 12 | } -------------------------------------------------------------------------------- /examples/Event Handler/BedrockAgentFunction/infra/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to your CDK TypeScript project 2 | 3 | This is a blank project for CDK development with TypeScript. 4 | 5 | The `cdk.json` file tells the CDK Toolkit how to execute your app. 6 | 7 | ## Useful commands 8 | 9 | * `npm run build` compile typescript to js 10 | * `npm run watch` watch for changes and compile 11 | * `npm run test` perform the jest unit tests 12 | * `npx cdk deploy` deploy this stack to your default AWS account/region 13 | * `npx cdk diff` compare deployed stack with current state 14 | * `npx cdk synth` emits the synthesized CloudFormation template 15 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/ITypedRecordHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing; 4 | 5 | /// 6 | /// The interface for creating strongly-typed record handlers. 7 | /// 8 | /// Type of the deserialized data from the batch record. 9 | public interface ITypedRecordHandlerProvider 10 | { 11 | /// 12 | /// Creates a typed record handler. 13 | /// 14 | /// The created typed record handler. 15 | ITypedRecordHandler Create(); 16 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler/AppSyncEvents/RequestContext.cs: -------------------------------------------------------------------------------- 1 | namespace AWS.Lambda.Powertools.EventHandler.AppSyncEvents; 2 | 3 | /// 4 | /// Represents information about the HTTP request that triggered the event. 5 | /// 6 | public class RequestContext 7 | { 8 | /// 9 | /// Gets or sets the headers of the HTTP request. 10 | /// 11 | public Dictionary Headers { get; set; } = new(); 12 | 13 | /// 14 | /// Gets or sets the domain name associated with the request. 15 | /// 16 | public string? DomainName { get; set; } 17 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Kafka.Protobuf/Internal/EnvWrapper.cs: -------------------------------------------------------------------------------- 1 | using AWS.Lambda.Powertools.Common; 2 | 3 | namespace AWS.Lambda.Powertools.Kafka.Protobuf.Internal 4 | { 5 | /// 6 | /// Wrapper class to set the execution environment 7 | /// 8 | public static class EnvWrapper 9 | { 10 | /// 11 | /// Sets the execution environment 12 | /// 13 | public static void SetExecutionEnvironment() 14 | { 15 | PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper), "Kafka.Protobuf"); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /examples/Event Handler/BedrockAgentFunction/infra/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "infra", 3 | "version": "0.1.0", 4 | "bin": { 5 | "infra": "bin/infra.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/jest": "^29.5.14", 15 | "@types/node": "22.7.9", 16 | "jest": "^29.7.0", 17 | "ts-jest": "^29.2.5", 18 | "aws-cdk": "2.1017.1", 19 | "ts-node": "^10.9.2", 20 | "typescript": "~5.6.3" 21 | }, 22 | "dependencies": { 23 | "aws-cdk-lib": "2.198.0", 24 | "constructs": "^10.0.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Tracing/Internal/TracingAspectFactory.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | using AWS.Lambda.Powertools.Common; 4 | 5 | namespace AWS.Lambda.Powertools.Tracing.Internal; 6 | 7 | internal static class TracingAspectFactory 8 | { 9 | /// 10 | /// Get an instance of the TracingAspect class. 11 | /// 12 | /// The type of the class to be logged. 13 | /// An instance of the TracingAspect class. 14 | public static object GetInstance(Type type) 15 | { 16 | return new TracingAspect(PowertoolsConfigurations.Instance, XRayRecorder.Instance); 17 | } 18 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/IBatchProcessorProvider.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing; 4 | 5 | /// 6 | /// The interface. 7 | /// 8 | /// Type of batch event. 9 | /// Type of batch record. 10 | public interface IBatchProcessorProvider 11 | { 12 | /// 13 | /// Creates a batch processor. 14 | /// 15 | /// The created batch processor. 16 | IBatchProcessor Create(); 17 | } 18 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/Internal/EnvWrapper.cs: -------------------------------------------------------------------------------- 1 | using AWS.Lambda.Powertools.Common; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.Internal 4 | { 5 | /// 6 | /// Wrapper class to set the execution environment 7 | /// 8 | public static class EnvWrapper 9 | { 10 | /// 11 | /// Sets the execution environment 12 | /// 13 | public static void SetExecutionEnvironment() 14 | { 15 | PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper)); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/core/logging/Function/src/Function/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-memory-size": 512, 12 | "function-timeout": 30 13 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/core/metrics/Function/src/Function/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-memory-size": 512, 12 | "function-timeout": 30 13 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/core/tracing/Function/src/Function/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-memory-size": 512, 12 | "function-timeout": 30 13 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/idempotency/Function/src/Function/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-memory-size": 512, 12 | "function-timeout": 30 13 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.JMESPath/Serializers/JMESPathSerializationContext.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace AWS.Lambda.Powertools.JMESPath.Serializers; 5 | 6 | /// 7 | /// The source generated JsonSerializerContext to be used to Serialize JMESPath types 8 | /// 9 | [JsonSourceGenerationOptions(WriteIndented = false)] 10 | [JsonSerializable(typeof(string))] 11 | [JsonSerializable(typeof(object))] 12 | [JsonSerializable(typeof(decimal))] 13 | [JsonSerializable(typeof(double))] 14 | [JsonSerializable(typeof(JsonElement))] 15 | public partial class JmesPathSerializationContext : JsonSerializerContext 16 | { 17 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/IRecordDataExtractor.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing; 4 | 5 | /// 6 | /// Interface for extracting data from event records for deserialization. 7 | /// 8 | /// The type of the event record. 9 | public interface IRecordDataExtractor 10 | { 11 | /// 12 | /// Extracts the data string from the event record that should be deserialized. 13 | /// 14 | /// The event record to extract data from. 15 | /// The data string to be deserialized. 16 | string ExtractData(TRecord record); 17 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Handlers/IdempotencyAttributeWithCustomKeyPrefix.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Amazon.Lambda.Core; 3 | 4 | namespace AWS.Lambda.Powertools.Idempotency.Tests.Handlers; 5 | 6 | /// 7 | /// Simple Lambda function with Idempotent attribute on a sub method with a custom prefix key 8 | /// 9 | public class IdempotencyAttributeWithCustomKeyPrefix 10 | { 11 | public string HandleRequest(string input, ILambdaContext context) 12 | { 13 | return ReturnGuid(input); 14 | } 15 | 16 | [Idempotent(KeyPrefix = "MyMethod")] 17 | private string ReturnGuid(string p) 18 | { 19 | return Guid.NewGuid().ToString(); 20 | } 21 | } -------------------------------------------------------------------------------- /examples/Kafka/Json/src/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "Json" 15 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.EventHandler.Tests/BedrockAgentFunction/bedrockFunctionEvent.json: -------------------------------------------------------------------------------- 1 | { 2 | "messageVersion": "1.0", 3 | "function": "sum_numbers", 4 | "sessionId": "455081292773641", 5 | "agent": { 6 | "name": "powertools-test", 7 | "version": "DRAFT", 8 | "id": "WPMRGAPAPJ", 9 | "alias": "TSTALIASID" 10 | }, 11 | "parameters": [ 12 | { 13 | "name": "a", 14 | "type": "number", 15 | "value": "1" 16 | }, 17 | { 18 | "name": "b", 19 | "type": "number", 20 | "value": "1" 21 | } 22 | ], 23 | "actionGroup": "utility-tasks", 24 | "sessionAttributes": {}, 25 | "promptSessionAttributes": {}, 26 | "inputText": "Sum 1 and 1" 27 | } -------------------------------------------------------------------------------- /examples/Kafka/Avro/src/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "Avro.Example" 15 | } -------------------------------------------------------------------------------- /examples/Kafka/Protobuf/src/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "Protobuf" 15 | } -------------------------------------------------------------------------------- /examples/Parameters/src/HelloWorld/HelloWorld.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | true 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Logging.Tests/TestSetup.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Xunit; 4 | using Xunit.Abstractions; 5 | 6 | [assembly: TestCollectionOrderer("AWS.Lambda.Powertools.Logging.Tests.DisplayNameOrderer", "AWS.Lambda.Powertools.Logging.Tests")] 7 | [assembly: CollectionBehavior(DisableTestParallelization = true)] 8 | 9 | 10 | namespace AWS.Lambda.Powertools.Logging.Tests; 11 | 12 | public class DisplayNameOrderer : ITestCollectionOrderer 13 | { 14 | public IEnumerable OrderTestCollections(IEnumerable testCollections) 15 | { 16 | return testCollections.OrderBy(collection => collection.DisplayName); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/ITypedRecordHandlerWithContextProvider.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing; 4 | 5 | /// 6 | /// The interface for creating strongly-typed record handlers with Lambda context. 7 | /// 8 | /// Type of the deserialized data from the batch record. 9 | public interface ITypedRecordHandlerWithContextProvider 10 | { 11 | /// 12 | /// Creates a typed record handler with context. 13 | /// 14 | /// The created typed record handler with context. 15 | ITypedRecordHandlerWithContext Create(); 16 | } -------------------------------------------------------------------------------- /examples/Parameters/cfn/HelloWorld.Cfn/HelloWorld.Cfn.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | true 5 | enable 6 | HelloWorld.Cfn 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/ServerlessApi/src/LambdaPowertoolsAPI/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "s3-prefix": "LambdaPowertoolsAPI/", 12 | "template": "serverless.template", 13 | "template-parameters": "" 14 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler/AppSyncEvents/AppSyncOidcIdentity.cs: -------------------------------------------------------------------------------- 1 | namespace AWS.Lambda.Powertools.EventHandler.AppSyncEvents; 2 | 3 | /// 4 | /// Represents OpenID Connect authorization identity for AppSync 5 | /// 6 | public class AppSyncOidcIdentity 7 | { 8 | /// 9 | /// Claims from the OIDC token as key-value pairs 10 | /// 11 | public Dictionary? Claims { get; set; } 12 | 13 | /// 14 | /// The issuer of the OIDC token 15 | /// 16 | public string? Issuer { get; set; } 17 | 18 | /// 19 | /// The UUID of the authenticated user 20 | /// 21 | public string? Sub { get; set; } 22 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.JMESPath.Tests/test_files/test.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"given": 3 | { 4 | "people": [ 5 | {"age": 20, "age_str": "20", "bool": true, "name": "a", "extra": "foo"}, 6 | {"age": 40, "age_str": "40", "bool": false, "name": "b", "extra": "bar"}, 7 | {"age": 30, "age_str": "30", "bool": true, "name": "c"}, 8 | {"age": 50, "age_str": "50", "bool": false, "name": "d"}, 9 | {"age": 10, "age_str": "10", "bool": true, "name": 3} 10 | ] 11 | }, 12 | "cases": [ 13 | { 14 | "expression": "max_by(people, &age)", 15 | "result": {"age": 50, "age_str": "50", "bool": false, "name": "d"} 16 | } 17 | ] 18 | } 19 | ] 20 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler/AppSyncEvents/Channel.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.AppSyncEvents; 4 | 5 | /// 6 | /// Channel details including path and segments 7 | /// 8 | public class Channel 9 | { 10 | /// 11 | /// Provides direct access to the 'Path' attribute within the 'Channel' object. 12 | /// 13 | [JsonPropertyName("path")] 14 | public string? Path { get; set; } 15 | 16 | /// 17 | /// Provides direct access to the 'Segments' attribute within the 'Channel' object. 18 | /// 19 | [JsonPropertyName("segments")] 20 | public string[]? Segments { get; set; } 21 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Logging/Serializers/LogLevelJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json; 3 | using System.Text.Json.Serialization; 4 | using Microsoft.Extensions.Logging; 5 | 6 | namespace AWS.Lambda.Powertools.Logging.Serializers; 7 | 8 | internal class LogLevelJsonConverter : JsonConverter 9 | { 10 | public override LogLevel Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 11 | { 12 | return Enum.TryParse(reader.GetString(),true, out var val) ? val : default; 13 | } 14 | 15 | public override void Write(Utf8JsonWriter writer, LogLevel value, JsonSerializerOptions options) 16 | { 17 | writer.WriteStringValue(value.ToString()); 18 | } 19 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Metrics/Model/MetricResolution.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace AWS.Lambda.Powertools.Metrics; 4 | 5 | /// 6 | /// Enum MetricResolution 7 | /// 8 | [JsonConverter(typeof(MetricResolutionJsonConverter))] 9 | public enum MetricResolution 10 | { 11 | /// 12 | /// Standard resolution, with data having a one-minute granularity 13 | /// 14 | Standard = 60, 15 | 16 | /// 17 | /// High resolution, with data at a granularity of one second 18 | /// 19 | High = 1, 20 | 21 | /// 22 | /// When not set default to not sending metric resolution 23 | /// 24 | Default = 0 25 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.JMESPath.Tests/test_files/current.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "given": { 4 | "foo": [{"name": "a"}, {"name": "b"}], 5 | "bar": {"baz": "qux"} 6 | }, 7 | "cases": [ 8 | { 9 | "expression": "@", 10 | "result": { 11 | "foo": [{"name": "a"}, {"name": "b"}], 12 | "bar": {"baz": "qux"} 13 | } 14 | }, 15 | { 16 | "expression": "@.bar", 17 | "result": {"baz": "qux"} 18 | }, 19 | { 20 | "expression": "@.foo[0]", 21 | "result": {"name": "a"} 22 | } 23 | ] 24 | } 25 | ] 26 | -------------------------------------------------------------------------------- /.github/auto_assign.yml: -------------------------------------------------------------------------------- 1 | # Set to true to add reviewers to pull requests 2 | addReviewers: true 3 | 4 | # Set to true to add assignees to pull requests 5 | #addAssignees: true 6 | 7 | # A list of reviewers to be added to pull requests (GitHub user name) 8 | reviewers: 9 | - sliedig 10 | - amirkaws 11 | - hjgraca 12 | 13 | # A number of reviewers added to the pull request 14 | # Set 0 to add all the reviewers (default: 0) 15 | numberOfReviewers: 0 16 | 17 | 18 | # A number of assignees to add to the pull request 19 | # Set to 0 to add all of the assignees. 20 | # Uses numberOfReviewers if unset. 21 | # numberOfAssignees: 2 22 | 23 | # A list of keywords to be skipped the process that add reviewers if pull requests include it 24 | # skipKeywords: 25 | # - wip 26 | -------------------------------------------------------------------------------- /examples/Event Handler/BedrockAgentFunction/src/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "BedrockAgentFunction" 15 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Logging/Internal/LoggingAspectFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AWS.Lambda.Powertools.Common; 3 | 4 | namespace AWS.Lambda.Powertools.Logging.Internal; 5 | 6 | /// 7 | /// Class LoggingAspectFactory. For "dependency inject" Aspect 8 | /// 9 | internal static class LoggingAspectFactory 10 | { 11 | /// 12 | /// Get an instance of the LoggingAspect class. 13 | /// 14 | /// The type of the class to be logged. 15 | /// An instance of the LoggingAspect class. 16 | public static object GetInstance(Type type) 17 | { 18 | return new LoggingAspect(LoggerFactoryHolder.GetOrCreateFactory().CreatePowertoolsLogger()); 19 | } 20 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/InfraShared/InfraShared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | InfraShared 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/AOT/AOT_Logging/src/AOT_Logging/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "AOT_Logging", 15 | "msbuild-parameters": "--self-contained true" 16 | } -------------------------------------------------------------------------------- /examples/AOT/AOT_Metrics/src/AOT_Metrics/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "AOT_Metrics", 15 | "msbuild-parameters": "--self-contained true" 16 | } -------------------------------------------------------------------------------- /examples/AOT/AOT_Tracing/src/AOT_Tracing/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "AOT_Tracing", 15 | "msbuild-parameters": "--self-contained true" 16 | } -------------------------------------------------------------------------------- /examples/Logging/src/HelloWorld/HelloWorld.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | true 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.JMESPath/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright JsonCons.Net authors. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | using System.Runtime.CompilerServices; 17 | 18 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.JMESPath.Tests")] -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Logging/PowertoolsLoggerFactoryExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | 3 | namespace AWS.Lambda.Powertools.Logging; 4 | 5 | /// 6 | /// Extensions for ILoggerFactory 7 | /// 8 | public static class PowertoolsLoggerFactoryExtensions 9 | { 10 | /// 11 | /// Creates a new Powertools Logger instance using the Powertools full name. 12 | /// 13 | /// The factory. 14 | /// The that was created. 15 | public static ILogger CreatePowertoolsLogger(this ILoggerFactory factory) 16 | { 17 | return new PowertoolsLoggerFactory(factory).CreateLogger(PowertoolsLoggerConfiguration.ConfigurationSectionName); 18 | } 19 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/idempotency/Function/test/Function.Tests/Helpers.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | using System.Text; 3 | 4 | namespace Function.Tests; 5 | 6 | public static class Helpers 7 | { 8 | public static string HashRequest(string input) 9 | { 10 | using var hashAlgorithm = MD5.Create(); 11 | if (hashAlgorithm == null) 12 | { 13 | throw new ArgumentException("Invalid HashAlgorithm"); 14 | } 15 | 16 | var data = hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(input)); 17 | var sBuilder = new StringBuilder(); 18 | for (var i = 0; i < data.Length; i++) 19 | { 20 | sBuilder.Append(data[i].ToString("x2")); 21 | } 22 | 23 | return sBuilder.ToString(); 24 | } 25 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/RecordFailure.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System; 4 | 5 | namespace AWS.Lambda.Powertools.BatchProcessing; 6 | 7 | /// 8 | /// Represents a batch record that failed processing. 9 | /// 10 | /// Type of batch record. 11 | public class RecordFailure 12 | { 13 | /// 14 | /// The exception causing the failure. 15 | /// 16 | public Exception Exception { get; init; } 17 | 18 | /// 19 | /// The batch record. 20 | /// 21 | public TRecord Record { get; init; } 22 | 23 | /// 24 | /// The batch record identifier. 25 | /// 26 | public string RecordId { get; init; } 27 | } 28 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build-docs build-docs-website docs-local docs-local-docker 2 | 3 | build-docs: 4 | @$(MAKE) build-docs-website 5 | 6 | build-docs-website: 7 | mkdir -p dist 8 | docker build -t squidfunk/mkdocs-material ./docs/ 9 | docker run --rm -t -v ${PWD}:/docs squidfunk/mkdocs-material build 10 | cp -R site/* dist/ 11 | 12 | docs-local: 13 | poetry run mkdocs serve 14 | 15 | docs-local-docker: 16 | docker build -t squidfunk/mkdocs-material ./docs/ 17 | docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material 18 | 19 | changelog: 20 | git fetch --tags origin 21 | CURRENT_VERSION=$(shell git describe --abbrev=0 --tag) ;\ 22 | echo "[+] Pre-generating CHANGELOG for tag: $$CURRENT_VERSION" ;\ 23 | docker run -v "${PWD}":/workdir quay.io/git-chglog/git-chglog:0.15.4 > CHANGELOG.md -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.JMESPath.Tests/test_files/cloud_watch_logs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "given": { 4 | "awslogs": { 5 | "data": "H4sIAAAAAAAAAHWPwQqCQBCGX0Xm7EFtK+smZBEUgXoLCdMhFtKV3akI8d0bLYmibvPPN3wz00CJxmQnTO41whwWQRIctmEcB6sQbFC3CjW3XW8kxpOpP+OC22d1Wml1qZkQGtoMsScxaczKN3plG8zlaHIta5KqWsozoTYw3/djzwhpLwivWFGHGpAFe7DL68JlBUk+l7KSN7tCOEJ4M3/qOI49vMHj+zCKdlFqLaU2ZHV2a4Ct/an0/ivdX8oYc1UVX860fQDQiMdxRQEAAA==" 6 | } 7 | }, 8 | "cases": [ 9 | { 10 | "expression": "awslogs.powertools_base64_gzip(data) | powertools_json(@).logEvents[*]", 11 | "result": [{"id":"eventId1","timestamp":1440442987000,"message":"[ERROR] First test message"},{"id":"eventId2","timestamp":1440442987001,"message":"[ERROR] Second test message"}] 12 | } 13 | ] 14 | } 15 | ] -------------------------------------------------------------------------------- /.github/workflows/record_pr.yml: -------------------------------------------------------------------------------- 1 | name: Record PR details 2 | 3 | on: 4 | pull_request: 5 | types: [opened, edited, closed] 6 | 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | record_pr: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 17 | - name: "Extract PR details" 18 | uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 19 | with: 20 | script: | 21 | const script = require('.github/scripts/save_pr_details.js') 22 | await script({github, context, core}) 23 | - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 24 | with: 25 | name: pr 26 | path: pr.txt 27 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Metrics/Serializer/DictionaryLookupNamingPolicy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text.Json; 4 | 5 | namespace AWS.Lambda.Powertools.Metrics; 6 | 7 | internal class DictionaryLookupNamingPolicy : JsonNamingPolicyDecorator 8 | { 9 | private readonly Dictionary _dictionary; 10 | 11 | public DictionaryLookupNamingPolicy(Dictionary dictionary, JsonNamingPolicy underlyingNamingPolicy) 12 | : base(underlyingNamingPolicy) 13 | { 14 | _dictionary = dictionary ?? throw new ArgumentNullException(); 15 | } 16 | 17 | public override string ConvertName(string name) 18 | { 19 | return _dictionary.TryGetValue(name, out var value) ? value : base.ConvertName(name); 20 | } 21 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Tracing/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | using System.Runtime.CompilerServices; 17 | 18 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.Tracing.Tests")] -------------------------------------------------------------------------------- /apidocs/index.md: -------------------------------------------------------------------------------- 1 | # Powertools for AWS Lambda (.NET) API 2 | 3 | Welcome to the **Powertools for AWS Lambda (.NET) API** reference. This documentation contains the API details for all supported utilities. 4 | 5 | To get started use the `API Documentaion` menu on the navigation bar, or search for specific keywords on the search box on top-right corner of your screen. 6 | 7 | > [!NOTE] 8 | > Are you looking for documentation on how to use Powertools for AWS Lambda (.NET) utilities and code samples? 9 | > 10 | > 👉 [Here](https://docs.aws.amazon.com/powertools/dotnet/) is the perfect place to start. 11 | 12 | ## Feedback 13 | 14 | If you have any feedback, create a new issue in the *Powertools for AWS Lambda (.NET)* repository on [GitHub](https://github.com/aws-powertools/powertools-lambda-dotnet/issues). 15 | -------------------------------------------------------------------------------- /examples/Idempotency/src/HelloWorld/HelloWorld.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | true 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Parameters/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | using System.Runtime.CompilerServices; 17 | 18 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.Parameters.Tests")] -------------------------------------------------------------------------------- /examples/Kafka/Avro/src/Function.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.Core; 2 | using Amazon.Lambda.RuntimeSupport; 3 | using AWS.Lambda.Powertools.Kafka; 4 | using AWS.Lambda.Powertools.Kafka.Avro; 5 | using AWS.Lambda.Powertools.Logging; 6 | using com.example; 7 | 8 | string Handler(ConsumerRecords records, ILambdaContext context) 9 | { 10 | foreach (var record in records) 11 | { 12 | Logger.LogInformation("Record Value: {@record}", record.Value); 13 | } 14 | 15 | return "Processed " + records.Count() + " records"; 16 | } 17 | 18 | await LambdaBootstrapBuilder.Create((Func, ILambdaContext, string>?)Handler, 19 | new PowertoolsKafkaAvroSerializer()) // Use PowertoolsKafkaAvroSerializer for Avro serialization 20 | .Build() 21 | .RunAsync(); -------------------------------------------------------------------------------- /examples/Kafka/Json/src/Function.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.Core; 2 | using Amazon.Lambda.RuntimeSupport; 3 | using AWS.Lambda.Powertools.Kafka; 4 | using AWS.Lambda.Powertools.Kafka.Json; 5 | using AWS.Lambda.Powertools.Logging; 6 | using Json.Models; 7 | 8 | string Handler(ConsumerRecords records, ILambdaContext context) 9 | { 10 | foreach (var record in records) 11 | { 12 | Logger.LogInformation("Record Value: {@record}", record.Value); 13 | } 14 | 15 | return "Processed " + records.Count() + " records"; 16 | } 17 | 18 | await LambdaBootstrapBuilder.Create((Func, ILambdaContext, string>?)Handler, 19 | new PowertoolsKafkaJsonSerializer()) // Use PowertoolsKafkaJsonSerializer for Json serialization 20 | .Build() 21 | .RunAsync(); -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/core/logging/AOT-Function/src/AOT-Function/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "AOT-Function", 15 | "msbuild-parameters": "--self-contained true" 16 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/core/metrics/AOT-Function/src/AOT-Function/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "AOT-Function", 15 | "msbuild-parameters": "--self-contained true" 16 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/core/tracing/AOT-Function/src/AOT-Function/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "AOT-Function", 15 | "msbuild-parameters": "--self-contained true" 16 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/infra/Infra.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | Major 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /examples/Kafka/Json/src/Models/CustomerProfile.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace Json.Models; 4 | 5 | public partial class CustomerProfile 6 | { 7 | [JsonPropertyName("user_id")] public string UserId { get; set; } 8 | 9 | [JsonPropertyName("full_name")] public string FullName { get; set; } 10 | 11 | [JsonPropertyName("email")] public Email Email { get; set; } 12 | 13 | [JsonPropertyName("age")] public long Age { get; set; } 14 | 15 | [JsonPropertyName("address")] public Address Address { get; set; } 16 | 17 | [JsonPropertyName("phone_numbers")] public List PhoneNumbers { get; set; } 18 | 19 | [JsonPropertyName("preferences")] public Preferences Preferences { get; set; } 20 | 21 | [JsonPropertyName("account_status")] public string AccountStatus { get; set; } 22 | } -------------------------------------------------------------------------------- /examples/Kafka/JsonClassLibrary/src/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-architecture": "x86_64", 12 | "function-runtime": "dotnet8", 13 | "function-memory-size": 512, 14 | "function-timeout": 30, 15 | "function-handler": "ProtoBufClassLibrary::ProtoBufClassLibrary.Function::FunctionHandler" 16 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/RecordSuccess.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing; 4 | 5 | /// 6 | /// Represents a batch record that was successfully processed. 7 | /// 8 | /// Type of batch record. 9 | public class RecordSuccess 10 | { 11 | /// 12 | /// The result returned by the record handler processing the batch record. 13 | /// 14 | public RecordHandlerResult HandlerResult { get; init; } 15 | 16 | /// 17 | /// The batch record. 18 | /// 19 | public TRecord Record { get; init; } 20 | 21 | /// 22 | /// The batch record identifier. 23 | /// 24 | public string RecordId { get; init; } 25 | } 26 | -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/idempotency/AOT-Function/src/AOT-FunctionHandlerTest/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "AOT-Function", 15 | "msbuild-parameters": "--self-contained true" 16 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/core/logging/AOT-Function-ILogger/src/AOT-Function-ILogger/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "AOT-Function", 15 | "msbuild-parameters": "--self-contained true" 16 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/idempotency/AOT-Function/src/AOT-FunctionMethodAttributeTest/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "AOT-Function", 15 | "msbuild-parameters": "--self-contained true" 16 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/idempotency/AOT-Function/src/AOT-FunctionPayloadSubsetTest/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "Information": [ 3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 5 | "dotnet lambda help", 6 | "All the command line options for the Lambda command can be specified in this file." 7 | ], 8 | "profile": "", 9 | "region": "", 10 | "configuration": "Release", 11 | "function-runtime": "dotnet8", 12 | "function-memory-size": 512, 13 | "function-timeout": 30, 14 | "function-handler": "AOT-Function", 15 | "msbuild-parameters": "--self-contained true" 16 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Kafka.Tests/Readme.md: -------------------------------------------------------------------------------- 1 | # Avro 2 | 3 | ```bash 4 | dotnet tool install --global Apache.Avro.Tools 5 | 6 | cd tests/AWS.Lambda.Powertools.Kafka.Tests/Avro/ 7 | avrogen -s AvroProduct.avsc ./ 8 | ``` 9 | 10 | ```xml 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ``` 19 | 20 | # Protobuf 21 | 22 | ```xml 23 | 24 | 25 | 26 | PreserveNewest 27 | 28 | 29 | 30 | 31 | ``` -------------------------------------------------------------------------------- /examples/Kafka/Protobuf/src/Function.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.Core; 2 | using Amazon.Lambda.RuntimeSupport; 3 | using AWS.Lambda.Powertools.Kafka; 4 | using AWS.Lambda.Powertools.Kafka.Protobuf; 5 | using AWS.Lambda.Powertools.Logging; 6 | using Com.Example; 7 | 8 | string Handler(ConsumerRecords records, ILambdaContext context) 9 | { 10 | foreach (var record in records) 11 | { 12 | Logger.LogInformation("Record Value: {@record}", record.Value); 13 | } 14 | 15 | return "Processed " + records.Count() + " records"; 16 | } 17 | 18 | await LambdaBootstrapBuilder.Create((Func, ILambdaContext, string>?)Handler, 19 | new PowertoolsKafkaProtobufSerializer()) // Use PowertoolsKafkaProtobufSerializer for Protobuf serialization 20 | .Build() 21 | .RunAsync(); 22 | 23 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler/AppSyncEvents/AppSyncEventsResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.AppSyncEvents; 4 | 5 | /// 6 | /// Represents the response for AppSync events. 7 | /// 8 | public class AppSyncEventsResponse 9 | { 10 | /// 11 | /// Collection of event results 12 | /// 13 | [JsonPropertyName("events")] 14 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 15 | public List? Events { get; set; } 16 | 17 | /// 18 | /// When operation fails, this will contain the error message 19 | /// 20 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 21 | [JsonPropertyName("error")] 22 | public string? Error { get; set; } 23 | } -------------------------------------------------------------------------------- /examples/AOT/AOT_Logging/test/AOT_Logging.Tests/AOT_Logging.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | enable 5 | enable 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/AOT/AOT_Metrics/test/AOT_Metrics.Tests/AOT_Metrics.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | enable 5 | enable 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/AOT/AOT_Tracing/test/AOT_Tracing.Tests/AOT_Tracing.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | enable 5 | enable 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/Kafka/Avro/src/Generated/com/example/PhoneType.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // Generated by avrogen, version 1.12.0+8c27801dc8d42ccc00997f25c0b8f45f8d4a233e 4 | // Changes to this file may cause incorrect behavior and will be lost if code 5 | // is regenerated 6 | // 7 | // ------------------------------------------------------------------------------ 8 | namespace com.example 9 | { 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Text; 13 | using global::Avro; 14 | using global::Avro.Specific; 15 | 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("avrogen", "1.12.0+8c27801dc8d42ccc00997f25c0b8f45f8d4a233e")] 17 | public enum PhoneType 18 | { 19 | HOME, 20 | WORK, 21 | MOBILE, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler/Internal/RouteHandlerOptions.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.Core; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.Internal; 4 | 5 | /// 6 | /// Options for registering a route handler 7 | /// 8 | internal class RouteHandlerOptions 9 | { 10 | /// 11 | /// The path pattern to match against (e.g., "/default/*") 12 | /// 13 | public string Path { get; set; } = "/default/*"; 14 | 15 | /// 16 | /// The handler function to execute when path matches 17 | /// 18 | public required Func> Handler { get; set; } 19 | 20 | /// 21 | /// Whether to aggregate all events into a single handler call 22 | /// 23 | public bool Aggregate { get; set; } = false; 24 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Metrics/Serializer/MetricsSerializationContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace AWS.Lambda.Powertools.Metrics; 5 | 6 | /// 7 | /// Source generator for Metrics types 8 | /// 9 | [JsonSerializable(typeof(string))] 10 | [JsonSerializable(typeof(double))] 11 | [JsonSerializable(typeof(List))] 12 | [JsonSerializable(typeof(MetricUnit))] 13 | [JsonSerializable(typeof(MetricDefinition))] 14 | [JsonSerializable(typeof(DimensionSet))] 15 | [JsonSerializable(typeof(Metadata))] 16 | [JsonSerializable(typeof(MetricDirective))] 17 | [JsonSerializable(typeof(MetricResolution))] 18 | [JsonSerializable(typeof(MetricsContext))] 19 | [JsonSerializable(typeof(RootNode))] 20 | public partial class MetricsSerializationContext : JsonSerializerContext 21 | { 22 | 23 | } -------------------------------------------------------------------------------- /examples/BatchProcessing/src/HelloWorld/Data/Product.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | namespace HelloWorld.Data; 17 | 18 | public class Product 19 | { 20 | public int Id { get; set; } 21 | public string? Name { get; set; } 22 | public double Price { get; set; } 23 | } -------------------------------------------------------------------------------- /examples/Event Handler/BedrockAgentFunction/infra/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2022", 4 | "module": "NodeNext", 5 | "moduleResolution": "NodeNext", 6 | "lib": [ 7 | "es2022" 8 | ], 9 | "declaration": true, 10 | "strict": true, 11 | "noImplicitAny": true, 12 | "strictNullChecks": true, 13 | "noImplicitThis": true, 14 | "alwaysStrict": true, 15 | "noUnusedLocals": false, 16 | "noUnusedParameters": false, 17 | "noImplicitReturns": true, 18 | "noFallthroughCasesInSwitch": false, 19 | "inlineSourceMap": true, 20 | "inlineSources": true, 21 | "experimentalDecorators": true, 22 | "strictPropertyInitialization": false, 23 | "typeRoots": [ 24 | "./node_modules/@types" 25 | ] 26 | }, 27 | "exclude": [ 28 | "node_modules", 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /examples/Kafka/Avro/src/Generated/com/example/AccountStatus.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // Generated by avrogen, version 1.12.0+8c27801dc8d42ccc00997f25c0b8f45f8d4a233e 4 | // Changes to this file may cause incorrect behavior and will be lost if code 5 | // is regenerated 6 | // 7 | // ------------------------------------------------------------------------------ 8 | namespace com.example 9 | { 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Text; 13 | using global::Avro; 14 | using global::Avro.Specific; 15 | 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("avrogen", "1.12.0+8c27801dc8d42ccc00997f25c0b8f45f8d4a233e")] 17 | public enum AccountStatus 18 | { 19 | ACTIVE, 20 | INACTIVE, 21 | SUSPENDED, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /docs/stylesheets/extra.css: -------------------------------------------------------------------------------- 1 | .md-grid { 2 | max-width: 81vw 3 | } 4 | 5 | .highlight .hll { 6 | background-color: lavender 7 | 8 | [data-md-color-scheme="slate"] { 9 | background-color: rgb(69, 48, 164) 10 | } 11 | } 12 | 13 | .md-typeset table:not([class]) { 14 | font-size: 0.75rem 15 | } 16 | 17 | .md-typeset a { 18 | border-bottom: 0.1px dashed black 19 | } 20 | 21 | .md-typeset table:not([class]) { 22 | font-size: 0.75rem 23 | } 24 | 25 | .md-nav__link--active { 26 | font-weight: bold 27 | } 28 | 29 | .md-typeset .admonition, .md-typeset details { 30 | font-size: 0.70rem 31 | } 32 | 33 | [data-md-color-scheme="slate"] { 34 | --md-typeset-a-color: rgb(28, 152, 152) 35 | } 36 | 37 | /*.md-nav__link[for] {*/ 38 | /* font-weight: bold*/ 39 | /*}*/ 40 | .md-nav__link[for] { color: var(--md-default-fg-color) !important; } 41 | 42 | -------------------------------------------------------------------------------- /examples/Metrics/src/HelloWorld/HelloWorld.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | true 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/Tracing/src/HelloWorld/HelloWorld.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | true 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler/AppSyncEvents/Information.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.AppSyncEvents; 4 | 5 | /// 6 | /// Represents information about the AppSync event. 7 | /// 8 | public class Information 9 | { 10 | /// 11 | /// The channel being used for the operation 12 | /// 13 | [JsonPropertyName("channel")] 14 | public Channel? Channel { get; set; } 15 | 16 | /// 17 | /// The namespace of the channel 18 | /// 19 | public ChannelNamespace? ChannelNamespace { get; set; } 20 | 21 | /// 22 | /// The operation being performed (e.g., Publish, Subscribe) 23 | /// 24 | [JsonPropertyName("operation")] 25 | public AppSyncEventsOperation Operation { get; set; } 26 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Logging/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | using System.Runtime.CompilerServices; 17 | 18 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.Logging.Tests")] 19 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.ConcurrencyTests")] -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: weekly 7 | 8 | - package-ecosystem: docker 9 | directory: /docs 10 | schedule: 11 | interval: monthly 12 | 13 | - package-ecosystem: npm 14 | directories: 15 | - "/" 16 | labels: [ ] 17 | schedule: 18 | interval: monthly 19 | versioning-strategy: increase 20 | allow: 21 | - dependency-name: "@aws-cdk/toolkit-lib" 22 | - dependency-name: "aws-cdk-lib" 23 | - dependency-name: "aws-cdk" 24 | groups: 25 | aws-cdk: 26 | patterns: 27 | - "@aws-cdk/toolkit-lib" 28 | - "aws-cdk-lib" 29 | - "aws-cdk" 30 | 31 | - package-ecosystem: nuget 32 | directories: 33 | - "/" 34 | labels: [ ] 35 | schedule: 36 | interval: monthly 37 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Idempotency/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | using System.Runtime.CompilerServices; 17 | 18 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.Idempotency.Tests")] 19 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.ConcurrencyTests")] -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/IRecordHandler.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace AWS.Lambda.Powertools.BatchProcessing; 7 | 8 | /// 9 | /// The interface. 10 | /// 11 | /// Type of batch record. 12 | public interface IRecordHandler 13 | { 14 | /// 15 | /// Handles processing of a given batch record. 16 | /// 17 | /// The record to process. 18 | /// The cancellation token to monitor. 19 | /// An awaitable with a . 20 | Task HandleAsync(TRecord record, CancellationToken cancellationToken); 21 | } 22 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Kafka/SchemaMetadata.cs: -------------------------------------------------------------------------------- 1 | #if KAFKA_JSON 2 | namespace AWS.Lambda.Powertools.Kafka.Json; 3 | #elif KAFKA_AVRO 4 | namespace AWS.Lambda.Powertools.Kafka.Avro; 5 | #elif KAFKA_PROTOBUF 6 | namespace AWS.Lambda.Powertools.Kafka.Protobuf; 7 | #else 8 | namespace AWS.Lambda.Powertools.Kafka; 9 | #endif 10 | 11 | /// 12 | /// Represents metadata about the schema used for serializing the record's value or key. 13 | /// 14 | public class SchemaMetadata 15 | { 16 | /// 17 | /// Gets or sets the format of the data (e.g., "JSON", "AVRO" "Protobuf"). 18 | /// /// 19 | public string DataFormat { get; internal set; } = null!; 20 | 21 | /// 22 | /// Gets or sets the schema ID associated with the record's value or key. 23 | /// 24 | public string SchemaId { get; internal set; } = null!; 25 | } -------------------------------------------------------------------------------- /.chglog/config.yml: -------------------------------------------------------------------------------- 1 | style: github 2 | template: CHANGELOG.tpl.md 3 | info: 4 | title: CHANGELOG 5 | repository_url: https://github.com/aws-powertools/powertools-lambda-dotnet 6 | options: 7 | commits: 8 | filters: 9 | Type: 10 | - feat 11 | - fix 12 | - perf 13 | - refactor 14 | - docs 15 | - chore 16 | - revert 17 | commit_groups: 18 | title_maps: 19 | feat: Features 20 | fix: Bug Fixes 21 | perf: Performance Improvements 22 | refactor: Code Refactoring 23 | docs: Documentation 24 | chore: Maintenance 25 | revert: Regression 26 | header: 27 | pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$" 28 | pattern_maps: 29 | - Type 30 | - Scope 31 | - Subject 32 | notes: 33 | keywords: 34 | - BREAKING CHANGE 35 | # issues: 36 | # prefix: 37 | # - # -------------------------------------------------------------------------------- /libraries/tests/e2e/infra-aot/InfraAot.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | Major 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Kafka.Tests/Avro/AWS/Lambda/Powertools/Kafka/Tests/Color.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // Generated by avrogen, version 1.12.0+8c27801dc8d42ccc00997f25c0b8f45f8d4a233e 4 | // Changes to this file may cause incorrect behavior and will be lost if code 5 | // is regenerated 6 | // 7 | // ------------------------------------------------------------------------------ 8 | namespace AWS.Lambda.Powertools.Kafka.Tests 9 | { 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Text; 13 | using global::Avro; 14 | using global::Avro.Specific; 15 | 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("avrogen", "1.12.0+8c27801dc8d42ccc00997f25c0b8f45f8d4a233e")] 17 | public enum Color 18 | { 19 | UNKNOWN, 20 | GREEN, 21 | RED, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Logging/Logger.Formatter.cs: -------------------------------------------------------------------------------- 1 | namespace AWS.Lambda.Powertools.Logging; 2 | 3 | public static partial class Logger 4 | { 5 | /// 6 | /// Set the log formatter. 7 | /// 8 | /// The log formatter. 9 | /// WARNING: This method should not be called when using AOT. ILogFormatter should be passed to PowertoolsSourceGeneratorSerializer constructor 10 | public static void UseFormatter(ILogFormatter logFormatter) 11 | { 12 | Configure(config => { 13 | config.LogFormatter = logFormatter; 14 | }); 15 | } 16 | 17 | /// 18 | /// Set the log formatter to default. 19 | /// 20 | public static void UseDefaultFormatter() 21 | { 22 | Configure(config => { 23 | config.LogFormatter = null; 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /libraries/tests/e2e/InfraShared/FunctionConstructProps.cs: -------------------------------------------------------------------------------- 1 | using Amazon.CDK; 2 | using Amazon.CDK.AWS.Lambda; 3 | 4 | namespace InfraShared; 5 | 6 | public class FunctionConstructProps : PowertoolsDefaultStackProps 7 | { 8 | public required Architecture Architecture { get; set; } 9 | public required Runtime Runtime { get; set; } 10 | public required string Name { get; set; } 11 | public required string SourcePath { get; set; } 12 | public required string DistPath { get; set; } 13 | } 14 | 15 | public class PowertoolsDefaultStackProps : StackProps 16 | { 17 | public bool IsAot { get; set; } = false; 18 | public string? ArchitectureString { get; set; } 19 | public Dictionary? Environment { get; set; } 20 | public string? Handler { get; set; } 21 | } 22 | 23 | public class IdempotencyStackProps : PowertoolsDefaultStackProps 24 | { 25 | public required string TableName { get; set; } 26 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/Sqs/SqsRecordDataExtractor.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using Amazon.Lambda.SQSEvents; 4 | 5 | namespace AWS.Lambda.Powertools.BatchProcessing.Sqs; 6 | 7 | /// 8 | /// Extracts data from SQS message records for deserialization. 9 | /// 10 | public class SqsRecordDataExtractor : IRecordDataExtractor 11 | { 12 | /// 13 | /// The singleton instance of the SQS record data extractor. 14 | /// 15 | public static readonly SqsRecordDataExtractor Instance = new(); 16 | 17 | /// 18 | /// Extracts the message body from an SQS message record. 19 | /// 20 | /// The SQS message record. 21 | /// The message body string. 22 | public string ExtractData(SQSEvent.SQSMessage record) 23 | { 24 | return record?.Body ?? string.Empty; 25 | } 26 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/functions/core/metrics/Function/src/Function/Function.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.APIGatewayEvents; 2 | using Amazon.Lambda.Core; 3 | using AWS.Lambda.Powertools.Metrics; 4 | using Helpers; 5 | 6 | // Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. 7 | [assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))] 8 | 9 | namespace Function; 10 | 11 | public class Function 12 | { 13 | [Metrics(Namespace = "Test", Service = "Test", CaptureColdStart = true)] 14 | public APIGatewayProxyResponse FunctionHandler(APIGatewayProxyRequest apigwProxyEvent, ILambdaContext context) 15 | { 16 | TestHelper.TestMethod(apigwProxyEvent, context); 17 | 18 | return new APIGatewayProxyResponse() 19 | { 20 | StatusCode = 200, 21 | Body = apigwProxyEvent.Body.ToUpper() 22 | }; 23 | } 24 | } -------------------------------------------------------------------------------- /libraries/src/KafkaDependencies.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Kafka\%(RecursiveDir)%(Filename)%(Extension) 13 | 14 | 15 | Common\%(RecursiveDir)%(Filename)%(Extension) 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Common/Utils/RuntimeFeatureWrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | 4 | namespace AWS.Lambda.Powertools.Common.Utils; 5 | 6 | /// 7 | /// Wrapper for RuntimeFeature 8 | /// 9 | public static class RuntimeFeatureWrapper 10 | { 11 | private static Func _isDynamicCodeSupportedFunc = () => RuntimeFeature.IsDynamicCodeSupported; 12 | 13 | /// 14 | /// Check to see if IsDynamicCodeSupported 15 | /// 16 | public static bool IsDynamicCodeSupported => _isDynamicCodeSupportedFunc(); 17 | 18 | // For testing purposes 19 | internal static void SetIsDynamicCodeSupported(bool value) 20 | { 21 | _isDynamicCodeSupportedFunc = () => value; 22 | } 23 | 24 | // To reset after tests 25 | internal static void Reset() 26 | { 27 | _isDynamicCodeSupportedFunc = () => RuntimeFeature.IsDynamicCodeSupported; 28 | } 29 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 11 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 12 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/ITypedRecordHandler.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace AWS.Lambda.Powertools.BatchProcessing; 7 | 8 | /// 9 | /// The interface for strongly-typed record handling. 10 | /// 11 | /// Type of the deserialized data from the batch record. 12 | public interface ITypedRecordHandler 13 | { 14 | /// 15 | /// Handles processing of a given batch record with strongly-typed data. 16 | /// 17 | /// The deserialized data from the record to process. 18 | /// The cancellation token to monitor. 19 | /// An awaitable with a . 20 | Task HandleAsync(T data, CancellationToken cancellationToken); 21 | } -------------------------------------------------------------------------------- /examples/Kafka/Json/src/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Description: > 4 | kafka 5 | 6 | Sample SAM Template for kafka 7 | 8 | # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst 9 | Globals: 10 | Function: 11 | Timeout: 15 12 | MemorySize: 512 13 | Runtime: dotnet8 14 | 15 | Resources: 16 | JsonDeserializationFunction: 17 | Type: AWS::Serverless::Function 18 | Properties: 19 | Handler: Json 20 | Architectures: 21 | - x86_64 22 | Tracing: Active 23 | Environment: # Powertools env vars: https://awslabs.github.io/aws-lambda-powertools-python/#environment-variables 24 | Variables: 25 | POWERTOOLS_SERVICE_NAME: PowertoolsHelloWorld 26 | POWERTOOLS_LOG_LEVEL: Info 27 | POWERTOOLS_LOGGER_CASE: PascalCase # Allowed values are: CamelCase, PascalCase and SnakeCase (Default) -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.JMESPath/Values/IArrayValueEnumerator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright JsonCons.Net authors. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | using System.Collections.Generic; 17 | 18 | namespace AWS.Lambda.Powertools.JMESPath.Values; 19 | 20 | /// 21 | /// Represents an enumerator for an array value. 22 | /// 23 | internal interface IArrayValueEnumerator : IEnumerator, IEnumerable 24 | { 25 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Tracing/Internal/Helpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.RegularExpressions; 3 | 4 | namespace AWS.Lambda.Powertools.Tracing.Internal; 5 | 6 | /// 7 | /// Helper class 8 | /// 9 | public static class Helpers 10 | { 11 | /// 12 | /// Sanitize a string by removing any characters that are not alphanumeric, whitespace, or one of the following: _ . : / % & # = + - @ 13 | /// 14 | /// 15 | /// 16 | public static string SanitizeString(string input) 17 | { 18 | // Define a regular expression pattern to match allowed characters 19 | var pattern = @"[^a-zA-Z0-9\s_\.\:/%&#=+\-@]"; 20 | 21 | // Replace any character that does not match the pattern with an empty string, with a timeout 22 | return Regex.Replace(input, pattern, string.Empty, RegexOptions.None, TimeSpan.FromMilliseconds(100)); 23 | } 24 | } -------------------------------------------------------------------------------- /examples/Kafka/Avro/src/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Description: > 4 | kafka 5 | 6 | Sample SAM Template for kafka 7 | 8 | # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst 9 | Globals: 10 | Function: 11 | Timeout: 15 12 | MemorySize: 512 13 | Runtime: dotnet8 14 | 15 | Resources: 16 | AvroDeserializationFunction: 17 | Type: AWS::Serverless::Function 18 | Properties: 19 | Handler: Avro.Example 20 | Architectures: 21 | - x86_64 22 | Tracing: Active 23 | Environment: # Powertools env vars: https://awslabs.github.io/aws-lambda-powertools-python/#environment-variables 24 | Variables: 25 | POWERTOOLS_SERVICE_NAME: PowertoolsHelloWorld 26 | POWERTOOLS_LOG_LEVEL: Info 27 | POWERTOOLS_LOGGER_CASE: PascalCase # Allowed values are: CamelCase, PascalCase and SnakeCase (Default) -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.JMESPath/Values/IObjectValueEnumerator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright JsonCons.Net authors. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | using System.Collections.Generic; 17 | 18 | namespace AWS.Lambda.Powertools.JMESPath.Values; 19 | 20 | /// 21 | /// Interface for object value enumerator. 22 | /// 23 | internal interface IObjectValueEnumerator : IEnumerator, IEnumerable 24 | { 25 | } -------------------------------------------------------------------------------- /examples/Kafka/Protobuf/src/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Description: > 4 | kafka 5 | 6 | Sample SAM Template for kafka 7 | 8 | # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst 9 | Globals: 10 | Function: 11 | Timeout: 15 12 | MemorySize: 512 13 | Runtime: dotnet8 14 | 15 | Resources: 16 | ProtobufDeserializationFunction: 17 | Type: AWS::Serverless::Function 18 | Properties: 19 | Handler: Protobuf 20 | Architectures: 21 | - x86_64 22 | Tracing: Active 23 | Environment: # Powertools env vars: https://awslabs.github.io/aws-lambda-powertools-python/#environment-variables 24 | Variables: 25 | POWERTOOLS_SERVICE_NAME: PowertoolsHelloWorld 26 | POWERTOOLS_LOG_LEVEL: Info 27 | POWERTOOLS_LOGGER_CASE: PascalCase # Allowed values are: CamelCase, PascalCase and SnakeCase (Default) -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Common/AWS.Lambda.Powertools.Common.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AWS.Lambda.Powertools.Common 6 | Powertools for AWS Lambda (.NET) - Core package. 7 | AWS.Lambda.Powertools.Common 8 | AWS.Lambda.Powertools.Common 9 | false 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.JMESPath/Values/JmesPathType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright JsonCons.Net authors. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | namespace AWS.Lambda.Powertools.JMESPath.Values; 17 | 18 | /// 19 | /// Represents the type of a JMESPath value. 20 | /// 21 | internal enum JmesPathType 22 | { 23 | Null, 24 | Array, 25 | False, 26 | Number, 27 | Object, 28 | String, 29 | True, 30 | Expression 31 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.JMESPath.Tests/test_files/unicode.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "given": {"foo": [{"✓": "✓"}, {"✓": "✗"}]}, 4 | "cases": [ 5 | { 6 | "expression": "foo[].\"✓\"", 7 | "result": ["✓", "✗"] 8 | } 9 | ] 10 | }, 11 | { 12 | "given": {"☯": true}, 13 | "cases": [ 14 | { 15 | "expression": "\"☯\"", 16 | "result": true 17 | } 18 | ] 19 | }, 20 | { 21 | "given": {"♪♫•*¨*•.¸¸❤¸¸.•*¨*•♫♪": true}, 22 | "cases": [ 23 | { 24 | "expression": "\"♪♫•*¨*•.¸¸❤¸¸.•*¨*•♫♪\"", 25 | "result": true 26 | } 27 | ] 28 | }, 29 | { 30 | "given": {"☃": true}, 31 | "cases": [ 32 | { 33 | "expression": "\"☃\"", 34 | "result": true 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Serializers/TestJsonContext.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using Amazon.Lambda.APIGatewayEvents; 3 | using Amazon.Lambda.ApplicationLoadBalancerEvents; 4 | using Amazon.Lambda.CloudWatchEvents.S3Events; 5 | using Amazon.Lambda.TestUtilities; 6 | 7 | namespace AWS.Lambda.Powertools.Logging.Tests.Serializers; 8 | 9 | [JsonSerializable(typeof(S3ObjectCreateEvent))] 10 | [JsonSerializable(typeof(TestObject))] 11 | [JsonSerializable(typeof(TestLambdaContext))] 12 | [JsonSerializable(typeof(APIGatewayProxyRequest))] 13 | [JsonSerializable(typeof(ApplicationLoadBalancerRequest))] 14 | internal partial class TestJsonContext : JsonSerializerContext 15 | { 16 | } 17 | 18 | internal class TestObject 19 | { 20 | public string FullName { get; set; } 21 | public int Age { get; set; } 22 | 23 | public Header Headers { get; set; } 24 | } 25 | 26 | internal class Header 27 | { 28 | public string MyRequestIdHeader { get; set; } 29 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/DeserializationErrorPolicy.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing; 4 | 5 | /// 6 | /// Defines how deserialization errors should be handled during batch processing. 7 | /// 8 | public enum DeserializationErrorPolicy 9 | { 10 | /// 11 | /// Mark the record as failed when deserialization fails (default behavior). 12 | /// The record will be included in the batch failure response. 13 | /// 14 | FailRecord, 15 | 16 | /// 17 | /// Skip records that fail deserialization and continue processing other records. 18 | /// Failed records will not be included in the batch failure response. 19 | /// 20 | IgnoreRecord, 21 | 22 | /// 23 | /// Use a custom error handler to process deserialization failures. 24 | /// The custom handler determines how to handle the failed record. 25 | /// 26 | CustomHandler 27 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/Models/Response.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.Models; 4 | 5 | /// 6 | /// Represents the response part of an BedrockFunctionResponse. 7 | /// 8 | public class Response 9 | { 10 | /// 11 | /// Gets or sets the action group. 12 | /// 13 | [JsonPropertyName("actionGroup")] 14 | public string ActionGroup { get; internal set; } = string.Empty; 15 | 16 | /// 17 | /// Gets or sets the function. 18 | /// 19 | [JsonPropertyName("function")] 20 | public string Function { get; internal set; } = string.Empty; 21 | 22 | /// 23 | /// Gets or sets the function response. 24 | /// 25 | [JsonPropertyName("functionResponse")] 26 | public FunctionResponse FunctionResponse { get; set; } = new FunctionResponse(); 27 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler/AppSyncEvents/AppSyncEvent.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.AppSyncEvents; 4 | 5 | /// 6 | /// Represents an event from AWS AppSync. 7 | /// 8 | public class AppSyncEvent 9 | { 10 | /// 11 | /// Payload data when operation succeeds 12 | /// 13 | [JsonPropertyName("payload")] 14 | public Dictionary? Payload { get; set; } 15 | 16 | /// 17 | /// Error message when operation fails 18 | /// 19 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 20 | [JsonPropertyName("error")] 21 | public string? Error { get; set; } 22 | 23 | /// 24 | /// Unique identifier for the event 25 | /// This Id is provided by AppSync and needs to be preserved. 26 | /// 27 | [JsonPropertyName("id")] 28 | public string? Id { get; set; } 29 | } -------------------------------------------------------------------------------- /.github/scripts/download_pr_artifact.js: -------------------------------------------------------------------------------- 1 | module.exports = async ({github, context, core}) => { 2 | const fs = require('fs'); 3 | 4 | const workflowRunId = process.env.WORKFLOW_ID; 5 | core.info(`Listing artifacts for workflow run ${workflowRunId}`); 6 | 7 | const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ 8 | owner: context.repo.owner, 9 | repo: context.repo.repo, 10 | run_id: workflowRunId, 11 | }); 12 | 13 | const matchArtifact = artifacts.data.artifacts.filter(artifact => artifact.name == "pr")[0]; 14 | 15 | core.info(`Downloading artifacts for workflow run ${workflowRunId}`); 16 | const artifact = await github.rest.actions.downloadArtifact({ 17 | owner: context.repo.owner, 18 | repo: context.repo.repo, 19 | artifact_id: matchArtifact.id, 20 | archive_format: 'zip', 21 | }); 22 | 23 | core.info("Saving artifact found", artifact); 24 | 25 | fs.writeFileSync('pr.zip', Buffer.from(artifact.data)); 26 | } 27 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Metrics.AspNetCore/Http/MetricsEndpointExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Http; 3 | 4 | namespace AWS.Lambda.Powertools.Metrics.AspNetCore.Http; 5 | 6 | /// 7 | /// Provides extension methods for adding metrics to route handlers. 8 | /// 9 | public static class MetricsEndpointExtensions 10 | { 11 | /// 12 | /// Adds a metrics filter to the specified route handler builder. 13 | /// This will capture cold start (if CaptureColdStart is enabled) metrics and flush metrics on function exit. 14 | /// 15 | /// The route handler builder to add the metrics filter to. 16 | /// The route handler builder with the metrics filter added. 17 | public static RouteHandlerBuilder WithMetrics(this RouteHandlerBuilder builder) 18 | { 19 | builder.AddEndpointFilter(); 20 | return builder; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Parameters/Cache/IDateTimeWrapper.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | namespace AWS.Lambda.Powertools.Parameters.Cache; 17 | 18 | /// 19 | /// Represents a type used to wrap datetime. 20 | /// 21 | public interface IDateTimeWrapper 22 | { 23 | /// 24 | /// Gets the current UTC time. 25 | /// 26 | DateTime UtcNow { get; } 27 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Metrics.Tests/ClearDimensionsTests.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using AWS.Lambda.Powertools.Common; 3 | using AWS.Lambda.Powertools.Metrics.Tests.Handlers; 4 | using Xunit; 5 | 6 | namespace AWS.Lambda.Powertools.Metrics.Tests; 7 | 8 | [Collection("Sequential")] 9 | public class ClearDimensionsTests 10 | { 11 | [Fact] 12 | public void WhenClearAllDimensions_NoDimensionsInOutput() 13 | { 14 | // Arrange 15 | var consoleOut = new StringWriter(); 16 | ConsoleWrapper.SetOut(consoleOut); 17 | 18 | // Act 19 | var handler = new FunctionHandler(); 20 | handler.ClearDimensions(); 21 | 22 | var metricsOutput = consoleOut.ToString(); 23 | 24 | // Assert 25 | Assert.Contains("{\"Namespace\":\"dotnet-powertools-test\",\"Metrics\":[{\"Name\":\"Metric Name\",\"Unit\":\"Count\"}],\"Dimensions\":[[]]", metricsOutput); 26 | 27 | // Reset 28 | MetricsAspect.ResetForTest(); 29 | } 30 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/TracingSerializerExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | 2 | using Amazon.Lambda.Serialization.SystemTextJson; 3 | using AWS.Lambda.Powertools.Tracing.Serializers; 4 | using Xunit; 5 | 6 | namespace AWS.Lambda.Powertools.Tracing.Tests.Serializers; 7 | 8 | public class TracingSerializerExtensionsTests 9 | { 10 | [Fact] 11 | public void WithTracing_InitializesSerializer_Successfully() 12 | { 13 | // Arrange 14 | var serializer = new SourceGeneratorLambdaJsonSerializer(); 15 | 16 | // Act 17 | var result = serializer.WithTracing(); 18 | 19 | // Assert 20 | Assert.NotNull(result); 21 | 22 | // Verify the context was initialized by attempting to serialize 23 | var testObject = new TestPerson { Name = "Test", Age = 25 }; 24 | var serialized = PowertoolsTracingSerializer.Serialize(testObject); 25 | Assert.Contains("\"Name\":\"Test\"", serialized); 26 | } 27 | } -------------------------------------------------------------------------------- /examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | true 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/Idempotency/test/HelloWorld.Test/HelloWorld.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/Parameters/test/HelloWorld.Test/HelloWorld.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.github/workflows/rebuild_latest_docs.yml: -------------------------------------------------------------------------------- 1 | name: Rebuild latest docs 2 | 3 | # 4 | # === Documentation hotfix === 5 | # 6 | # 1. Trigger "Rebuild latest docs" workflow manually: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow 7 | # 2. Use the latest version released under Releases e.g. 2.0.0 8 | 9 | on: 10 | workflow_dispatch: 11 | inputs: 12 | latest_published_version: 13 | description: "Latest PyPi published version to rebuild latest docs for, e.g. 2.0.0" 14 | default: "2.0.0" 15 | required: true 16 | 17 | permissions: 18 | contents: read 19 | 20 | jobs: 21 | changelog: 22 | permissions: 23 | contents: write 24 | uses: ./.github/workflows/reusable_publish_changelog.yml 25 | 26 | release-docs: 27 | needs: changelog 28 | permissions: 29 | contents: write 30 | pages: write 31 | uses: ./.github/workflows/reusable_publish_docs.yml 32 | with: 33 | version: ${{ inputs.latest_published_version }} 34 | alias: latest 35 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Metrics/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | using System.Runtime.CompilerServices; 17 | 18 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.Metrics.Tests")] 19 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.Metrics.AspNetCore")] 20 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.Metrics.AspNetCore.Tests")] 21 | [assembly: InternalsVisibleTo("AWS.Lambda.Powertools.ConcurrencyTests")] -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/Handlers/SQS/Services.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AWS.Lambda.Powertools.BatchProcessing.Sqs; 3 | using AWS.Lambda.Powertools.BatchProcessing.Tests.Handlers.SQS.Custom; 4 | using Microsoft.Extensions.DependencyInjection; 5 | 6 | namespace AWS.Lambda.Powertools.BatchProcessing.Tests.Handlers.SQS; 7 | 8 | internal class Services 9 | { 10 | private static readonly Lazy LazyInstance = new(Build); 11 | 12 | private static ServiceCollection _services; 13 | public static IServiceProvider Provider => LazyInstance.Value; 14 | 15 | public static IServiceProvider Init() 16 | { 17 | return LazyInstance.Value; 18 | } 19 | 20 | private static IServiceProvider Build() 21 | { 22 | _services = new ServiceCollection(); 23 | _services.AddScoped(); 24 | _services.AddScoped(); 25 | return _services.BuildServiceProvider(); 26 | } 27 | } -------------------------------------------------------------------------------- /examples/Kafka/Avro/src/kafka-avro-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSource": "aws:kafka", 3 | "eventSourceArn": "arn:aws:kafka:us-east-1:0123456789019:cluster/CustomerCluster/abcd1234-abcd-cafe-abab-9876543210ab-4", 4 | "bootstrapServers": "b-2.demo-cluster-1.a1bcde.c1.kafka.us-east-1.amazonaws.com:9092,b-1.demo-cluster-1.a1bcde.c1.kafka.us-east-1.amazonaws.com:9092", 5 | "records": { 6 | "customer-topic-0": [ 7 | { 8 | "topic": "customer-topic", 9 | "partition": 0, 10 | "offset": 15, 11 | "timestamp": 1545084650987, 12 | "timestampType": "CREATE_TIME", 13 | "key": "dXNlcl85NzU0", 14 | "value": "EnVzZXJfOTc1NBxVc2VyIHVzZXJfOTc1NCh1c2VyXzk3NTRAaWNsb3VkLmNvbQABahg5MzQwIE1haW4gU3QQU2FuIEpvc2UEQ0EGVVNBCjM5NTk2AhgyNDQtNDA3LTg4NzECAAYQdGltZXpvbmUOZW5hYmxlZBBsYW5ndWFnZRBkaXNhYmxlZBpub3RpZmljYXRpb25zCGRhcmsABA==", 15 | "headers": [ 16 | { 17 | "headerKey": [104, 101, 97, 100, 101, 114, 86, 97, 108, 117, 101] 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/Models/Parameter.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace AWS.Lambda.Powertools.EventHandler.Resolvers 5 | { 6 | /// 7 | /// Represents a parameter for a Bedrock Agent function. 8 | /// 9 | public class Parameter 10 | { 11 | /// 12 | /// Gets or sets the name of the parameter. 13 | /// 14 | [JsonPropertyName("name")] 15 | public string Name { get; set; } = string.Empty; 16 | 17 | /// 18 | /// Gets or sets the type of the parameter. 19 | /// 20 | [JsonPropertyName("type")] 21 | public string Type { get; set; } = string.Empty; 22 | 23 | /// 24 | /// Gets or sets the value of the parameter. 25 | /// 26 | [JsonPropertyName("value")] 27 | public string Value { get; set; } = string.Empty; 28 | } 29 | } -------------------------------------------------------------------------------- /examples/Kafka/Protobuf/src/CustomerProfile.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package com.example; 4 | 5 | enum PhoneType { 6 | HOME = 0; 7 | WORK = 1; 8 | MOBILE = 2; 9 | } 10 | 11 | enum AccountStatus { 12 | ACTIVE = 0; 13 | INACTIVE = 1; 14 | SUSPENDED = 2; 15 | } 16 | 17 | // EmailAddress message 18 | message EmailAddress { 19 | string address = 1; 20 | bool verified = 2; 21 | bool primary = 3; 22 | } 23 | 24 | // Address message 25 | message Address { 26 | string street = 1; 27 | string city = 2; 28 | string state = 3; 29 | string country = 4; 30 | string zip_code = 5; 31 | } 32 | 33 | // PhoneNumber message 34 | message PhoneNumber { 35 | string number = 1; 36 | PhoneType type = 2; 37 | } 38 | 39 | // CustomerProfile message 40 | message CustomerProfile { 41 | string user_id = 1; 42 | string full_name = 2; 43 | EmailAddress email = 3; 44 | int32 age = 4; 45 | Address address = 5; 46 | repeated PhoneNumber phone_numbers = 6; 47 | map preferences = 7; 48 | AccountStatus account_status = 8; 49 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Common/Core/IConsoleWrapper.cs: -------------------------------------------------------------------------------- 1 | namespace AWS.Lambda.Powertools.Common; 2 | 3 | /// 4 | /// Wrapper for console operations to facilitate testing by abstracting system console interactions. 5 | /// 6 | public interface IConsoleWrapper 7 | { 8 | /// 9 | /// Writes the specified message followed by a line terminator to the standard output stream. 10 | /// 11 | /// The message to write. 12 | void WriteLine(string message); 13 | 14 | /// 15 | /// Writes a debug message to the trace listeners in the Debug.Listeners collection. 16 | /// 17 | /// The debug message to write. 18 | void Debug(string message); 19 | 20 | /// 21 | /// Writes the specified error message followed by a line terminator to the standard error stream. 22 | /// 23 | /// The error message to write. 24 | void Error(string message); 25 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/XRayRecorderTestFixture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AWS.Lambda.Powertools.Tracing.Internal; 3 | using Xunit; 4 | 5 | namespace AWS.Lambda.Powertools.Tracing.Tests; 6 | 7 | /// 8 | /// Test fixture to ensure proper cleanup of XRayRecorder singleton state between tests 9 | /// 10 | public class XRayRecorderTestFixture : IDisposable 11 | { 12 | public void Dispose() 13 | { 14 | // Reset the singleton instance after each test to prevent test pollution 15 | XRayRecorder.ResetInstance(); 16 | } 17 | } 18 | 19 | /// 20 | /// Collection definition for tests that need isolated XRayRecorder instances 21 | /// 22 | [CollectionDefinition("XRayRecorderTests")] 23 | public class XRayRecorderTestCollection : ICollectionFixture 24 | { 25 | // This class has no code, and is never created. Its purpose is simply 26 | // to be the place to apply [CollectionDefinition] and all the 27 | // ICollectionFixture<> interfaces. 28 | } -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | change-template: "* $TITLE (#$NUMBER) by @$AUTHOR" 2 | categories: 3 | - title: '⚡ Breaking Changes' 4 | labels: 5 | - 'breaking-change' 6 | - title: '🌟New features and non-breaking changes' 7 | labels: 8 | - 'major' 9 | - 'feature' 10 | - title: '🌟 Minor Changes' 11 | labels: 12 | - 'enhancement' 13 | - title: '📜 Documentation updates' 14 | labels: 15 | - 'documentation' 16 | - title: '🐛 Bug and hot fixes' 17 | labels: 18 | - 'bug' 19 | - 'fix' 20 | - title: '🚒 Deprecations' 21 | labels: 22 | - 'deprecated' 23 | - title: '🔧 Maintenance' 24 | labels: 25 | - 'internal' 26 | - 'dependencies' 27 | - 'chore' 28 | exclude-labels: 29 | - 'skip-changelog' 30 | tag-template: '$NEXT_PATCH_VERSION' 31 | template: | 32 | ## Summary 33 | 34 | **[Human readable summary of changes]** 35 | 36 | ## Changes 37 | 38 | $CHANGES 39 | 40 | ## This release was made possible by the following contributors: 41 | 42 | $CONTRIBUTORS 43 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Kafka/AWS.Lambda.Powertools.Kafka.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AWS.Lambda.Powertools.Kafka 6 | Powertools for AWS Lambda (.NET) - Kafka consumer package. 7 | AWS.Lambda.Powertools.Kafka 8 | AWS.Lambda.Powertools.Kafka 9 | net8.0 10 | false 11 | enable 12 | enable 13 | true 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/Kafka/JsonClassLibrary/src/CustomerProfile.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package com.example; 4 | 5 | enum PhoneType { 6 | HOME = 0; 7 | WORK = 1; 8 | MOBILE = 2; 9 | } 10 | 11 | enum AccountStatus { 12 | ACTIVE = 0; 13 | INACTIVE = 1; 14 | SUSPENDED = 2; 15 | } 16 | 17 | // EmailAddress message 18 | message EmailAddress { 19 | string address = 1; 20 | bool verified = 2; 21 | bool primary = 3; 22 | } 23 | 24 | // Address message 25 | message Address { 26 | string street = 1; 27 | string city = 2; 28 | string state = 3; 29 | string country = 4; 30 | string zip_code = 5; 31 | } 32 | 33 | // PhoneNumber message 34 | message PhoneNumber { 35 | string number = 1; 36 | PhoneType type = 2; 37 | } 38 | 39 | // CustomerProfile message 40 | message CustomerProfile { 41 | string user_id = 1; 42 | string full_name = 2; 43 | EmailAddress email = 3; 44 | int32 age = 4; 45 | Address address = 5; 46 | repeated PhoneNumber phone_numbers = 6; 47 | map preferences = 7; 48 | AccountStatus account_status = 8; 49 | } -------------------------------------------------------------------------------- /examples/Kafka/JsonClassLibrary/src/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Description: > 4 | kafka 5 | 6 | Sample SAM Template for kafka 7 | 8 | # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst 9 | Globals: 10 | Function: 11 | Timeout: 15 12 | MemorySize: 512 13 | Runtime: dotnet8 14 | 15 | Resources: 16 | ProtobufClassLibraryDeserializationFunction: 17 | Type: AWS::Serverless::Function 18 | Properties: 19 | Handler: ProtoBufClassLibrary::ProtoBufClassLibrary.Function::FunctionHandler 20 | Architectures: 21 | - x86_64 22 | Tracing: Active 23 | Environment: # Powertools env vars: https://awslabs.github.io/aws-lambda-powertools-python/#environment-variables 24 | Variables: 25 | POWERTOOLS_SERVICE_NAME: PowertoolsHelloWorld 26 | POWERTOOLS_LOG_LEVEL: Info 27 | POWERTOOLS_LOGGER_CASE: PascalCase # Allowed values are: CamelCase, PascalCase and SnakeCase (Default) -------------------------------------------------------------------------------- /examples/Kafka/Protobuf/src/kafka-protobuf-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSource": "aws:kafka", 3 | "eventSourceArn": "arn:aws:kafka:us-east-1:0123456789019:cluster/CustomerCluster/abcd1234-abcd-cafe-abab-9876543210ab-4", 4 | "bootstrapServers": "b-2.demo-cluster-1.a1bcde.c1.kafka.us-east-1.amazonaws.com:9092,b-1.demo-cluster-1.a1bcde.c1.kafka.us-east-1.amazonaws.com:9092", 5 | "records": { 6 | "customer-topic-0": [ 7 | { 8 | "topic": "customer-topic", 9 | "partition": 0, 10 | "offset": 15, 11 | "timestamp": 1545084650987, 12 | "timestampType": "CREATE_TIME", 13 | "key": "dXNlcl85NzU0", 14 | "value": "Cgl1c2VyXzk3NTQSDlVzZXIgdXNlcl85NzU0GhgKFHVzZXJfOTc1NEBpY2xvdWQuY29tGAEgNSooCgw5MzQwIE1haW4gU3QSCFNhbiBKb3NlGgJDQSIDVVNBKgUzOTU5NjIQCgwyNDQtNDA3LTg4NzEQAToUCghsYW5ndWFnZRIIZGlzYWJsZWQ6FQoNbm90aWZpY2F0aW9ucxIEZGFyazoTCgh0aW1lem9uZRIHZW5hYmxlZEAC", 15 | "headers": [ 16 | { 17 | "headerKey": [104, 101, 97, 100, 101, 114, 86, 97, 108, 117, 101] 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/Handlers/Kinesis/Services.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AWS.Lambda.Powertools.BatchProcessing.Kinesis; 3 | using AWS.Lambda.Powertools.BatchProcessing.Tests.Handlers.Kinesis.Custom; 4 | using Microsoft.Extensions.DependencyInjection; 5 | 6 | namespace AWS.Lambda.Powertools.BatchProcessing.Tests.Handlers.Kinesis; 7 | 8 | internal class Services 9 | { 10 | private static readonly Lazy LazyInstance = new(Build); 11 | 12 | private static ServiceCollection _services; 13 | public static IServiceProvider Provider => LazyInstance.Value; 14 | 15 | public static IServiceProvider Init() 16 | { 17 | return LazyInstance.Value; 18 | } 19 | 20 | private static IServiceProvider Build() 21 | { 22 | _services = new ServiceCollection(); 23 | _services.AddScoped(); 24 | _services.AddScoped(); 25 | return _services.BuildServiceProvider(); 26 | } 27 | } -------------------------------------------------------------------------------- /.github/workflows/examples-tests.yml: -------------------------------------------------------------------------------- 1 | name: Examples Tests 2 | 3 | on: 4 | push: 5 | paths: 6 | - "examples/**" 7 | branches: [develop] 8 | pull_request: 9 | paths: 10 | - "examples/**" 11 | branches: [develop] 12 | 13 | defaults: 14 | run: 15 | working-directory: ./examples 16 | 17 | permissions: 18 | contents: read 19 | 20 | jobs: 21 | build: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 25 | 26 | - name: Setup .NET SDK 27 | uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # 5.0.1 28 | with: 29 | dotnet-version: | 30 | 8.0.x 31 | 32 | - name: Install dependencies 33 | run: dotnet restore 34 | 35 | - name: Install global tools 36 | run: dotnet tool install --global Apache.Avro.Tools 37 | 38 | - name: Build 39 | run: dotnet build --configuration Release --no-restore /tl 40 | 41 | - name: Test Examples 42 | run: dotnet test --no-restore --verbosity normal 43 | -------------------------------------------------------------------------------- /examples/Kafka/JsonClassLibrary/src/kafka-protobuf-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSource": "aws:kafka", 3 | "eventSourceArn": "arn:aws:kafka:us-east-1:0123456789019:cluster/CustomerCluster/abcd1234-abcd-cafe-abab-9876543210ab-4", 4 | "bootstrapServers": "b-2.demo-cluster-1.a1bcde.c1.kafka.us-east-1.amazonaws.com:9092,b-1.demo-cluster-1.a1bcde.c1.kafka.us-east-1.amazonaws.com:9092", 5 | "records": { 6 | "customer-topic-0": [ 7 | { 8 | "topic": "customer-topic", 9 | "partition": 0, 10 | "offset": 15, 11 | "timestamp": 1545084650987, 12 | "timestampType": "CREATE_TIME", 13 | "key": "dXNlcl85NzU0", 14 | "value": "Cgl1c2VyXzk3NTQSDlVzZXIgdXNlcl85NzU0GhgKFHVzZXJfOTc1NEBpY2xvdWQuY29tGAEgNSooCgw5MzQwIE1haW4gU3QSCFNhbiBKb3NlGgJDQSIDVVNBKgUzOTU5NjIQCgwyNDQtNDA3LTg4NzEQAToUCghsYW5ndWFnZRIIZGlzYWJsZWQ6FQoNbm90aWZpY2F0aW9ucxIEZGFyazoTCgh0aW1lem9uZRIHZW5hYmxlZEAC", 15 | "headers": [ 16 | { 17 | "headerKey": [104, 101, 97, 100, 101, 114, 86, 97, 108, 117, 101] 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | } -------------------------------------------------------------------------------- /examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLoggerScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace AWS.Lambda.Powertools.Logging.Internal; 5 | 6 | /// 7 | /// Class PowertoolsLoggerScope. 8 | /// 9 | internal class PowertoolsLoggerScope : IDisposable 10 | { 11 | /// 12 | /// The associated logger 13 | /// 14 | private readonly PowertoolsLogger _logger; 15 | 16 | /// 17 | /// The provided extra keys 18 | /// 19 | internal Dictionary ExtraKeys { get; } 20 | 21 | /// 22 | /// Creates a PowertoolsLoggerScope object 23 | /// 24 | internal PowertoolsLoggerScope(PowertoolsLogger logger, Dictionary extraKeys) 25 | { 26 | _logger = logger; 27 | ExtraKeys = extraKeys; 28 | } 29 | 30 | /// 31 | /// Implements IDisposable interface 32 | /// 33 | public void Dispose() 34 | { 35 | _logger?.EndScope(); 36 | } 37 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/Handlers/DynamoDB/Services.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AWS.Lambda.Powertools.BatchProcessing.DynamoDb; 3 | using AWS.Lambda.Powertools.BatchProcessing.Tests.Handlers.DynamoDB.Custom; 4 | using Microsoft.Extensions.DependencyInjection; 5 | 6 | namespace AWS.Lambda.Powertools.BatchProcessing.Tests.Handlers.DynamoDB; 7 | 8 | internal class Services 9 | { 10 | private static readonly Lazy LazyInstance = new(Build); 11 | 12 | private static ServiceCollection _services; 13 | public static IServiceProvider Provider => LazyInstance.Value; 14 | 15 | public static IServiceProvider Init() 16 | { 17 | return LazyInstance.Value; 18 | } 19 | 20 | private static IServiceProvider Build() 21 | { 22 | _services = new ServiceCollection(); 23 | _services.AddScoped(); 24 | _services.AddScoped(); 25 | return _services.BuildServiceProvider(); 26 | } 27 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Serializers/TestJsonContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace AWS.Lambda.Powertools.Tracing.Tests.Serializers; 5 | 6 | [JsonSourceGenerationOptions(WriteIndented = true)] 7 | [JsonSerializable(typeof(TestPerson))] 8 | [JsonSerializable(typeof(TestComplexObject))] 9 | [JsonSerializable(typeof(TestResponse))] 10 | [JsonSerializable(typeof(TestBooleanObject))] 11 | [JsonSerializable(typeof(TestNullableObject))] 12 | [JsonSerializable(typeof(TestArrayObject))] 13 | public partial class TestJsonContext : JsonSerializerContext { } 14 | 15 | public class TestPerson 16 | { 17 | public string Name { get; set; } 18 | public int Age { get; set; } 19 | } 20 | 21 | public class TestComplexObject 22 | { 23 | public string StringValue { get; set; } 24 | public int NumberValue { get; set; } 25 | public bool BoolValue { get; set; } 26 | public Dictionary NestedObject { get; set; } 27 | } 28 | 29 | public class TestResponse 30 | { 31 | public string Message { get; set; } 32 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/DiBedrockAgentFunctionResolver.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization.Metadata; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.Resolvers; 4 | 5 | /// 6 | /// Extended Bedrock Agent Function Resolver with dependency injection support. 7 | /// 8 | internal class DiBedrockAgentFunctionResolver : BedrockAgentFunctionResolver 9 | { 10 | /// 11 | /// Gets the service provider used for dependency injection. 12 | /// 13 | public IServiceProvider ServiceProvider { get; } 14 | 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The service provider for dependency injection. 19 | /// 20 | public DiBedrockAgentFunctionResolver(IServiceProvider serviceProvider, IJsonTypeInfoResolver? typeResolver = null) 21 | : base(typeResolver) 22 | { 23 | ServiceProvider = serviceProvider; 24 | } 25 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/IDeserializationErrorHandler.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace AWS.Lambda.Powertools.BatchProcessing; 8 | 9 | /// 10 | /// Interface for handling deserialization errors during batch processing. 11 | /// 12 | /// The type of the record being processed. 13 | public interface IDeserializationErrorHandler 14 | { 15 | /// 16 | /// Handles a deserialization error for a specific record. 17 | /// 18 | /// The record that failed to deserialize. 19 | /// The exception that occurred during deserialization. 20 | /// The cancellation token. 21 | /// A task that represents the asynchronous operation. The task result contains the record handler result. 22 | Task HandleDeserializationError(TRecord record, Exception exception, CancellationToken cancellationToken); 23 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.JMESPath/Expressions/KeyExpressionPair.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright JsonCons.Net authors. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | namespace AWS.Lambda.Powertools.JMESPath.Expressions; 17 | 18 | /// 19 | /// A pair of a JMESPath key and an expression. 20 | /// 21 | internal struct KeyExpressionPair 22 | { 23 | internal string Key {get;} 24 | internal Expression Expression {get;} 25 | 26 | internal KeyExpressionPair(string key, Expression expression) 27 | { 28 | Key = key; 29 | Expression = expression; 30 | } 31 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Parameters/Transform/Transformation.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | namespace AWS.Lambda.Powertools.Parameters.Transform; 17 | 18 | /// 19 | /// Enum Transformation 20 | /// 21 | public enum Transformation 22 | { 23 | /// 24 | /// Auto 25 | /// 26 | Auto, 27 | 28 | /// 29 | /// Json 30 | /// 31 | Json, 32 | 33 | /// 34 | /// Base64 35 | /// 36 | Base64 37 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.JMESPath/Values/NameValuePair.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright JsonCons.Net authors. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | namespace AWS.Lambda.Powertools.JMESPath.Values 17 | { 18 | /// 19 | /// Represents a name-value pair. 20 | /// 21 | internal readonly struct NameValuePair 22 | { 23 | public string Name { get; } 24 | public IValue Value { get; } 25 | 26 | public NameValuePair(string name, IValue value) 27 | { 28 | Name = name; 29 | Value = value; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Logging/ILogFormatter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | namespace AWS.Lambda.Powertools.Logging; 17 | 18 | /// 19 | /// Represents a type used to format Powertools log entries. 20 | /// 21 | public interface ILogFormatter 22 | { 23 | /// 24 | /// Formats a log entry 25 | /// 26 | /// The log entry. 27 | /// Formatted log entry as object. 28 | object FormatLogEntry(LogEntry logEntry); 29 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/RecordHandlerResult.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace AWS.Lambda.Powertools.BatchProcessing; 4 | 5 | /// 6 | /// The result of the record handler processing the batch record. 7 | /// 8 | public class RecordHandlerResult 9 | { 10 | /// 11 | /// Returns an empty value. 12 | /// 13 | public static RecordHandlerResult None { get; } = null!; 14 | 15 | /// 16 | /// Convenience method for the creation of a . 17 | /// 18 | /// The result of the record handler. 19 | /// A with the provided data. 20 | public static RecordHandlerResult FromData(object data) 21 | { 22 | return new RecordHandlerResult 23 | { 24 | Data = data 25 | }; 26 | } 27 | 28 | /// 29 | /// The data returned from processing the batch record. 30 | /// 31 | public object Data { get; init; } 32 | } 33 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/Serializers/IdempotencySerializationContext.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | using System.Text.Json.Serialization; 17 | 18 | namespace AWS.Lambda.Powertools.Idempotency.Internal.Serializers; 19 | 20 | /// 21 | /// The source generated JsonSerializerContext to be used to Serialize Idempotency types 22 | /// 23 | [JsonSerializable(typeof(string))] 24 | [JsonSerializable(typeof(object))] 25 | public partial class IdempotencySerializationContext : JsonSerializerContext 26 | { 27 | 28 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Logging/Serializers/LoggingSerializationContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text.Json.Serialization; 5 | 6 | namespace AWS.Lambda.Powertools.Logging.Serializers; 7 | 8 | /// 9 | /// Custom JSON serializer context for AWS.Lambda.Powertools.Logging 10 | /// 11 | [JsonSourceGenerationOptions(WriteIndented = true)] 12 | [JsonSerializable(typeof(Dictionary))] 13 | [JsonSerializable(typeof(bool))] 14 | [JsonSerializable(typeof(string))] 15 | [JsonSerializable(typeof(Int32))] 16 | [JsonSerializable(typeof(Double))] 17 | [JsonSerializable(typeof(DateOnly))] 18 | [JsonSerializable(typeof(TimeOnly))] 19 | [JsonSerializable(typeof(IEnumerable))] 20 | [JsonSerializable(typeof(Dictionary))] 21 | [JsonSerializable(typeof(IEnumerable))] 22 | [JsonSerializable(typeof(Dictionary))] 23 | [JsonSerializable(typeof(Byte[]))] 24 | [JsonSerializable(typeof(MemoryStream))] 25 | [JsonSerializable(typeof(LogEntry))] 26 | public partial class PowertoolsLoggingSerializationContext : JsonSerializerContext 27 | { 28 | } -------------------------------------------------------------------------------- /libraries/tests/e2e/Readme.md: -------------------------------------------------------------------------------- 1 | # E2E Tests Workflow 2 | 3 | This document provides instructions on how to set up, deploy, run tests, and destroy the infrastructure for E2E tests. 4 | 5 | ## Prerequisites 6 | 7 | Ensure you have the following tools installed: 8 | - .NET SDK 9 | - AWS CDK 10 | - AWS CLI 11 | 12 | ## Steps 13 | 14 | ### 1. Set up your environment 15 | 16 | Ensure you have the necessary tools installed, such as .NET SDK, AWS CDK, and AWS CLI. 17 | 18 | ### 2. Deploy the infrastructure 19 | 20 | Navigate to the directory containing your CDK stacks and deploy them: 21 | 22 | ```sh 23 | cd infra 24 | cdk deploy --require-approval never 25 | cd ../infra-aot 26 | cdk deploy CoreStack --require-approval never --context architecture=arm64 27 | ``` 28 | ### 3. Run the tests 29 | 30 | Navigate to the test project directory and run the tests: 31 | 32 | ```sh 33 | # example for Core utilities 34 | cd libraries/tests/e2e/functions/core 35 | dotnet test 36 | ``` 37 | 38 | ### 4. Destroy 39 | 40 | After running the tests, destroy the infrastructure: 41 | 42 | ```sh 43 | cd infra 44 | cdk destroy --force 45 | cd ../infra-aot 46 | cdk destroy --force 47 | ``` 48 | 49 | -------------------------------------------------------------------------------- /.github/workflows/secure_workflows.yml: -------------------------------------------------------------------------------- 1 | name: Lockdown untrusted workflows 2 | 3 | on: 4 | push: 5 | paths: 6 | - ".github/workflows/**" 7 | pull_request: 8 | paths: 9 | - ".github/workflows/**" 10 | 11 | permissions: 12 | contents: read 13 | 14 | jobs: 15 | enforce_pinned_workflows: 16 | name: Harden Security 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout code 20 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 21 | - name: Ensure 3rd party workflows have SHA pinned 22 | uses: zgosalvez/github-actions-ensure-sha-pinned-actions@6124774845927d14c601359ab8138699fa5b70c3 # v4.0.1 23 | with: 24 | # Trusted GitHub Actions and/or organizations 25 | allowlist: | 26 | aws-actions/ 27 | actions/checkout 28 | actions/github-script 29 | actions/setup-dotnet 30 | actions/setup-python 31 | actions/upload-artifact 32 | actions/download-artifact 33 | github/codeql-action/init 34 | github/codeql-action/analyze 35 | dependabot/fetch-metadata 36 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/Models/Agent.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.Models; 4 | 5 | /// 6 | /// Contains information about the name, ID, alias, and version of the agent that the action group belongs to. 7 | /// 8 | public class Agent 9 | { 10 | /// 11 | /// Gets or sets the name of the agent. 12 | /// 13 | [JsonPropertyName("name")] 14 | public string Name { get; set; } = string.Empty; 15 | 16 | /// 17 | /// Gets or sets the version of the agent. 18 | /// 19 | [JsonPropertyName("version")] 20 | public string Version { get; set; } = string.Empty; 21 | 22 | /// 23 | /// Gets or sets the ID of the agent. 24 | /// 25 | [JsonPropertyName("id")] 26 | public string Id { get; set; } = string.Empty; 27 | 28 | /// 29 | /// Gets or sets the alias of the agent. 30 | /// 31 | [JsonPropertyName("alias")] 32 | public string Alias { get; set; } = string.Empty; 33 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.JMESPath/Serializers/JMESPathSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json; 3 | 4 | namespace AWS.Lambda.Powertools.JMESPath.Serializers; 5 | 6 | /// 7 | /// Class used to serialize JMESPath types 8 | /// 9 | internal static class JmesPathSerializer 10 | { 11 | /// 12 | /// Serializes the specified value. 13 | /// 14 | /// The value. 15 | /// Type of the input. 16 | /// System.String. 17 | internal static string Serialize(object value, Type inputType) 18 | { 19 | return JsonSerializer.Serialize(value, inputType, JmesPathSerializationContext.Default); 20 | } 21 | 22 | /// 23 | /// Deserializes the specified value. 24 | /// 25 | /// 26 | /// The value. 27 | /// T. 28 | internal static T Deserialize(string value) 29 | { 30 | return (T)JsonSerializer.Deserialize(value, typeof(T), JmesPathSerializationContext.Default); 31 | } 32 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Metrics/AWS.Lambda.Powertools.Metrics.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AWS.Lambda.Powertools.Metrics 5 | Powertools for AWS Lambda (.NET) - Metrics package. 6 | AWS.Lambda.Powertools.Metrics 7 | AWS.Lambda.Powertools.Metrics 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.BatchProcessing/ITypedRecordHandlerWithContext.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Amazon.Lambda.Core; 6 | 7 | namespace AWS.Lambda.Powertools.BatchProcessing; 8 | 9 | /// 10 | /// The interface for strongly-typed record handling with Lambda context. 11 | /// 12 | /// Type of the deserialized data from the batch record. 13 | public interface ITypedRecordHandlerWithContext 14 | { 15 | /// 16 | /// Handles processing of a given batch record with strongly-typed data and Lambda context. 17 | /// 18 | /// The deserialized data from the record to process. 19 | /// The Lambda context for the current invocation. 20 | /// The cancellation token to monitor. 21 | /// An awaitable with a . 22 | Task HandleAsync(T data, ILambdaContext context, CancellationToken cancellationToken); 23 | } -------------------------------------------------------------------------------- /libraries/src/AWS.Lambda.Powertools.Parameters/SimpleSystemsManagement/ISsmProvider.cs: -------------------------------------------------------------------------------- 1 | using Amazon.SimpleSystemsManagement; 2 | using AWS.Lambda.Powertools.Parameters.Internal.Provider; 3 | using AWS.Lambda.Powertools.Parameters.Provider; 4 | 5 | namespace AWS.Lambda.Powertools.Parameters.SimpleSystemsManagement; 6 | 7 | /// 8 | /// Represents a type used to retrieve parameter values from AWS Systems Manager Parameter Store. 9 | /// 10 | public interface ISsmProvider : IParameterProvider, 11 | IParameterProviderConfigurableClient 12 | { 13 | /// 14 | /// Automatically decrypt the parameter. 15 | /// 16 | /// The provider configuration builder. 17 | SsmProviderConfigurationBuilder WithDecryption(); 18 | 19 | /// 20 | /// Fetches all parameter values recursively based on a path prefix. 21 | /// For GetMultiple() only. 22 | /// 23 | /// The provider configuration builder. 24 | SsmProviderConfigurationBuilder Recursive(); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /examples/ServerlessApi/test/LambdaPowertoolsAPI.Tests/SampleRequests/ValuesController-Get.json: -------------------------------------------------------------------------------- 1 | { 2 | "resource": "/{proxy+}", 3 | "path": "/api/values", 4 | "httpMethod": "GET", 5 | "headers": null, 6 | "queryStringParameters": null, 7 | "pathParameters": { 8 | "proxy": "api/values" 9 | }, 10 | "stageVariables": null, 11 | "requestContext": { 12 | "accountId": "AAAAAAAAAAAA", 13 | "resourceId": "5agfss", 14 | "stage": "test-invoke-stage", 15 | "requestId": "test-invoke-request", 16 | "identity": { 17 | "cognitoIdentityPoolId": null, 18 | "accountId": "AAAAAAAAAAAA", 19 | "cognitoIdentityId": null, 20 | "caller": "BBBBBBBBBBBB", 21 | "apiKey": "test-invoke-api-key", 22 | "sourceIp": "test-invoke-source-ip", 23 | "cognitoAuthenticationType": null, 24 | "cognitoAuthenticationProvider": null, 25 | "userArn": "arn:aws:iam::AAAAAAAAAAAA:root", 26 | "userAgent": "Apache-HttpClient/4.5.x (Java/1.8.0_102)", 27 | "user": "AAAAAAAAAAAA" 28 | }, 29 | "resourcePath": "/{proxy+}", 30 | "httpMethod": "GET", 31 | "apiId": "t2yh6sjnmk" 32 | }, 33 | "body": null 34 | } -------------------------------------------------------------------------------- /libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Model/TestJsonSerializerContext.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | using System.Text.Json.Serialization; 17 | using Amazon.Lambda.APIGatewayEvents; 18 | 19 | namespace AWS.Lambda.Powertools.Idempotency.Tests.Model; 20 | 21 | [JsonSerializable(typeof(Basket))] 22 | [JsonSerializable(typeof(APIGatewayProxyRequest))] 23 | [JsonSerializable(typeof(APIGatewayProxyResponse))] 24 | [JsonSerializable(typeof(Product))] 25 | [JsonSerializable(typeof(TestClass))] 26 | public partial class TestJsonSerializerContext : JsonSerializerContext 27 | { 28 | 29 | } -------------------------------------------------------------------------------- /examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exe 4 | net8.0 5 | enable 6 | enable 7 | true 8 | Lambda 9 | 10 | true 11 | 12 | true 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/BatchProcessing/src/HelloWorld/Sqs/CustomSqsRecordHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | using Amazon.Lambda.SQSEvents; 17 | using AWS.Lambda.Powertools.BatchProcessing; 18 | using AWS.Lambda.Powertools.BatchProcessing.Sqs; 19 | using Microsoft.Extensions.DependencyInjection; 20 | 21 | namespace HelloWorld.Sqs; 22 | internal class CustomSqsRecordHandlerProvider : IRecordHandlerProvider 23 | { 24 | public IRecordHandler Create() 25 | { 26 | return Services.Provider.GetRequiredService(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /examples/Parameters/cfn/HelloWorld.Cfn/CfnRequest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | using System; 17 | 18 | namespace HelloWorld.Cfn; 19 | 20 | /// 21 | /// CloudFormation Custom Resource Request 22 | /// 23 | [Serializable] 24 | public class CfnRequest 25 | { 26 | public string? RequestType { get; set; } 27 | 28 | public string? ResponseURL { get; set; } 29 | 30 | public string? StackId { get; set; } 31 | 32 | public string? RequestId { get; set; } 33 | 34 | public string? ResourceType { get; set; } 35 | 36 | public string? LogicalResourceId { get; set; } 37 | } --------------------------------------------------------------------------------