diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 4f34e76517d..07fbd55af26 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -79,7 +79,7 @@ body: id: logs attributes: label: Debugging logs - description: If available, please share [debugging logs](https://docs.powertools.aws.dev/lambda-python/#debug-mode) + description: If available, please share [debugging logs](https://docs.powertools.aws.dev/lambda/python/#debug-mode) render: python validations: required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index f0db1477324..a39fb211ac1 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -36,7 +36,7 @@ body: attributes: label: Acknowledgment options: - - label: This feature request meets [Powertools for AWS Lambda (Python) Tenets](https://docs.powertools.aws.dev/lambda-python/latest/#tenets) + - label: This feature request meets [Powertools for AWS Lambda (Python) Tenets](https://docs.powertools.aws.dev/lambda/python/latest/#tenets) required: true - label: Should this be considered in other Powertools for AWS Lambda languages? i.e. [Java](https://github.com/aws-powertools/powertools-lambda-java/), [TypeScript](https://github.com/aws-powertools/powertools-lambda-typescript/), and [.NET](https://github.com/aws-powertools/powertools-lambda-dotnet/) required: false diff --git a/.github/ISSUE_TEMPLATE/maintenance.yml b/.github/ISSUE_TEMPLATE/maintenance.yml index 41dc4b46ec6..bbc3ff3b3d8 100644 --- a/.github/ISSUE_TEMPLATE/maintenance.yml +++ b/.github/ISSUE_TEMPLATE/maintenance.yml @@ -53,7 +53,7 @@ body: attributes: label: Acknowledgment options: - - label: This request meets [Powertools for AWS Lambda (Python) Tenets](https://docs.powertools.aws.dev/lambda-python/latest/#tenets) + - label: This request meets [Powertools for AWS Lambda (Python) Tenets](https://docs.powertools.aws.dev/lambda/python/latest/#tenets) required: true - label: Should this be considered in other Powertools for AWS Lambda languages? i.e. [Java](https://github.com/aws-powertools/powertools-lambda-java/), [TypeScript](https://github.com/aws-powertools/powertools-lambda-typescript/), and [.NET](https://github.com/aws-powertools/powertools-lambda-dotnet/) required: false diff --git a/.github/ISSUE_TEMPLATE/rfc.yml b/.github/ISSUE_TEMPLATE/rfc.yml index c1d951d7ed2..31d8d7fe0c6 100644 --- a/.github/ISSUE_TEMPLATE/rfc.yml +++ b/.github/ISSUE_TEMPLATE/rfc.yml @@ -91,7 +91,7 @@ body: attributes: label: Acknowledgment options: - - label: This feature request meets [Powertools for AWS Lambda (Python) Tenets](https://docs.powertools.aws.dev/lambda-python/latest/#tenets) + - label: This feature request meets [Powertools for AWS Lambda (Python) Tenets](https://docs.powertools.aws.dev/lambda/python/latest/#tenets) required: true - label: Should this be considered in other Powertools for AWS Lambda languages? i.e. [Java](https://github.com/aws-powertools/powertools-lambda-java/), [TypeScript](https://github.com/aws-powertools/powertools-lambda-typescript/), and [.NET](https://github.com/aws-powertools/powertools-lambda-dotnet/) required: false diff --git a/.github/ISSUE_TEMPLATE/tech_debt.yml b/.github/ISSUE_TEMPLATE/tech_debt.yml index 1dcd3ab1d9f..064c118ba20 100644 --- a/.github/ISSUE_TEMPLATE/tech_debt.yml +++ b/.github/ISSUE_TEMPLATE/tech_debt.yml @@ -50,7 +50,7 @@ body: attributes: label: Acknowledgment options: - - label: This request meets [Powertools for AWS Lambda (Python) Tenets](https://docs.powertools.aws.dev/lambda-python/latest/#tenets) + - label: This request meets [Powertools for AWS Lambda (Python) Tenets](https://docs.powertools.aws.dev/lambda/python/latest/#tenets) required: true - label: Should this be considered in other Powertools for AWS Lambda languages? i.e. [Java](https://github.com/aws-powertools/powertools-lambda-java/), [TypeScript](https://github.com/aws-powertools/powertools-lambda-typescript/), and [.NET](https://github.com/aws-powertools/powertools-lambda-dotnet/) required: false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 219f31ba6d7..5265d390063 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -15,7 +15,7 @@ If your change doesn't seem to apply, please leave them unchecked. -* [ ] [Meet tenets criteria](https://docs.powertools.aws.dev/lambda-python/#tenets) +* [ ] [Meet tenets criteria](https://docs.powertools.aws.dev/lambda/python/#tenets) * [ ] I have performed a self-review of this change * [ ] Changes have been tested * [ ] Changes are documented diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e859fd162e1..3b3dc07c55a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,7 +78,7 @@ You might find useful to run both the documentation website and the API referenc | **Docstring** | We use a slight variation of Numpy convention with markdown to help generate more readable API references. | | **Style guide** | We use black as well as flake8 extensions to enforce beyond good practices [PEP8](https://pep8.org/). We use type annotations and enforce static type checking at CI (mypy). | | **Core utilities** | Core utilities use a Class, always accept `service` as a constructor parameter, can work in isolation, and are also available in other languages implementation. | -| **Utilities** | Utilities are not as strict as core and focus on solving a developer experience problem while following the project [Tenets](https://docs.powertools.aws.dev/lambda-python/#tenets). | +| **Utilities** | Utilities are not as strict as core and focus on solving a developer experience problem while following the project [Tenets](https://docs.powertools.aws.dev/lambda/python/#tenets). | | **Exceptions** | Specific exceptions live within utilities themselves and use `Error` suffix e.g. `MetricUnitError`. | | **Git commits** | We follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). We do not enforce conventional commits on contributors to lower the entry bar. Instead, we enforce a conventional PR title so our label automation and changelog are generated correctly. | | **API documentation** | API reference docs are generated from docstrings which should have Examples section to allow developers to have what they need within their own IDE. Documentation website covers the wider usage, tips, and strive to be concise. | @@ -106,7 +106,7 @@ Looking at the existing issues is a great way to find something to contribute on This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact -opensource-codeofconduct@amazon.com with any additional questions or comments. + with any additional questions or comments. ## Security issue notifications diff --git a/MAINTAINERS.md b/MAINTAINERS.md index b008e0f639c..2a2631e91fc 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -145,7 +145,7 @@ Manage [labels](#labels), review issues regularly, and create new labels as need > TODO: This is an area we want to automate using the new GitHub GraphQL API. -Make sure issues are assigned to our [board of activities](https://github.com/orgs/awslabs/projects/51/) and have the right [status](https://docs.powertools.aws.dev/lambda-python/latest/roadmap/#roadmap-status-definition). +Make sure issues are assigned to our [board of activities](https://github.com/orgs/awslabs/projects/51/) and have the right [status](https://docs.powertools.aws.dev/lambda/python/latest/roadmap/#roadmap-status-definition). Use our [labels](#labels) to signal good first issues to new community members, and to set expectation that this might need additional feedback from the author, other customers, experienced community members and/or maintainers. @@ -170,7 +170,7 @@ RFC is a collaborative process to help us get to the most optimal solution given Make sure you ask these questions in mind when reviewing: - Does it use our [RFC template](https://github.com/aws-powertools/powertools-lambda-python/issues/new?assignees=&labels=RFC%2Ctriage&template=rfc.yml&title=RFC%3A+TITLE)? -- Does the match our [Tenets](https://docs.powertools.aws.dev/lambda-python/latest/#tenets)? +- Does the match our [Tenets](https://docs.powertools.aws.dev/lambda/python/latest/#tenets)? - Does the proposal address the use case? If so, is the recommended usage explicit? - Does it focus on the mechanics to solve the use case over fine-grained implementation details? - Can anyone familiar with the code base implement it? @@ -308,7 +308,7 @@ Keep the `develop` branch at production quality at all times. Backport features ### Manage Roadmap -See [Roadmap section](https://docs.powertools.aws.dev/lambda-python/latest/roadmap/) +See [Roadmap section](https://docs.powertools.aws.dev/lambda/python/latest/roadmap/) Ensure the repo highlights features that should be elevated to the project roadmap. Be clear about the feature’s status, priority, target version, and whether or not it should be elevated to the roadmap. diff --git a/README.md b/README.md index 5f584980c76..da04598d2e5 100644 --- a/README.md +++ b/README.md @@ -3,35 +3,35 @@ [![Build](https://github.com/aws-powertools/powertools-lambda-python/actions/workflows/quality_check.yml/badge.svg)](https://github.com/aws-powertools/powertools-lambda-python/actions/workflows/python_build.yml) [![codecov.io](https://codecov.io/github/aws-powertools/powertools-lambda-python/branch/develop/graphs/badge.svg)](https://app.codecov.io/gh/aws-powertools/powertools-lambda-python) -![PythonSupport](https://img.shields.io/static/v1?label=python&message=%203.7|%203.8|%203.9|%203.10&color=blue?style=flat-square&logo=python) ![PyPI version](https://badge.fury.io/py/aws-lambda-powertools.svg) ![PyPi monthly downloads](https://img.shields.io/pypi/dm/aws-lambda-powertools) [![Join our Discord](https://dcbadge.vercel.app/api/server/B8zZKbbyET)](https://discord.gg/B8zZKbbyET) +![PythonSupport](https://img.shields.io/static/v1?label=python&message=%203.7|%203.8|%203.9|%203.10&color=blue?style=flat-square&logo=python) ![PyPI version](https://badge.fury.io/py/aws-lambda-powertools.svg) ![PyPi monthly downloads](https://img.shields.io/pypi/dm/aws-lambda-powertools) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/aws-powertools/powertools-lambda-python/badge)](https://api.securityscorecards.dev/projects/github.com/aws-powertools/powertools-lambda-python) [![Join our Discord](https://dcbadge.vercel.app/api/server/B8zZKbbyET)](https://discord.gg/B8zZKbbyET) -Powertools for AWS Lambda (Python) is a developer toolkit to implement Serverless [best practices and increase developer velocity](https://docs.powertools.aws.dev/lambda-python/latest/#features). +Powertools for AWS Lambda (Python) is a developer toolkit to implement Serverless [best practices and increase developer velocity](https://docs.powertools.aws.dev/lambda/python/latest/#features). > Also available in [Java](https://github.com/aws-powertools/powertools-lambda-java), [Typescript](https://github.com/aws-powertools/powertools-lambda-typescript), and [.NET](https://docs.powertools.aws.dev/lambda-dotnet/). -**[📜Documentation](https://docs.powertools.aws.dev/lambda-python/)** | **[🐍PyPi](https://pypi.org/project/aws-lambda-powertools/)** | **[Roadmap](https://docs.powertools.aws.dev/lambda-python/latest/roadmap/)** | **[Detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-lambda-powertools/)** +**[📜Documentation](https://docs.powertools.aws.dev/lambda/python/)** | **[🐍PyPi](https://pypi.org/project/aws-lambda-powertools/)** | **[Roadmap](https://docs.powertools.aws.dev/lambda/python/latest/roadmap/)** | **[Detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-lambda-powertools/)** -> **An AWS Developer Acceleration (DevAx) initiative by Specialist Solution Architects | aws-devax-open-source@amazon.com** +> **An AWS Developer Acceleration (DevAx) initiative by Specialist Solution Architects | ** ![hero-image](https://user-images.githubusercontent.com/3340292/198254617-d0fdb672-86a6-4988-8a40-adf437135e0a.png) ## Features -* **[Tracing](https://docs.powertools.aws.dev/lambda-python/latest/core/tracer/)** - Decorators and utilities to trace Lambda function handlers, and both synchronous and asynchronous functions -* **[Logging](https://docs.powertools.aws.dev/lambda-python/latest/core/logger/)** - Structured logging made easier, and decorator to enrich structured logging with key Lambda context details -* **[Metrics](https://docs.powertools.aws.dev/lambda-python/latest/core/metrics/)** - Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF) -* **[Event handler: AppSync](https://docs.powertools.aws.dev/lambda-python/latest/core/event_handler/appsync/)** - AWS AppSync event handler for Lambda Direct Resolver and Amplify GraphQL Transformer function -* **[Event handler: API Gateway and ALB](https://docs.powertools.aws.dev/lambda-python/latest/core/event_handler/api_gateway/)** - Amazon API Gateway REST/HTTP API and ALB event handler for Lambda functions invoked using Proxy integration -* **[Bring your own middleware](https://docs.powertools.aws.dev/lambda-python/latest/utilities/middleware_factory/)** - Decorator factory to create your own middleware to run logic before, and after each Lambda invocation -* **[Parameters utility](https://docs.powertools.aws.dev/lambda-python/latest/utilities/parameters/)** - Retrieve and cache parameter values from Parameter Store, Secrets Manager, or DynamoDB -* **[Batch processing](https://docs.powertools.aws.dev/lambda-python/latest/utilities/batch/)** - Handle partial failures for AWS SQS batch processing -* **[Typing](https://docs.powertools.aws.dev/lambda-python/latest/utilities/typing/)** - Static typing classes to speedup development in your IDE -* **[Validation](https://docs.powertools.aws.dev/lambda-python/latest/utilities/validation/)** - JSON Schema validator for inbound events and responses -* **[Event source data classes](https://docs.powertools.aws.dev/lambda-python/latest/utilities/data_classes/)** - Data classes describing the schema of common Lambda event triggers -* **[Parser](https://docs.powertools.aws.dev/lambda-python/latest/utilities/parser/)** - Data parsing and deep validation using Pydantic -* **[Idempotency](https://docs.powertools.aws.dev/lambda-python/latest/utilities/idempotency/)** - Convert your Lambda functions into idempotent operations which are safe to retry -* **[Feature Flags](https://docs.powertools.aws.dev/lambda-python/latest/utilities/feature_flags/)** - A simple rule engine to evaluate when one or multiple features should be enabled depending on the input -* **[Streaming](https://docs.powertools.aws.dev/lambda-python/latest/utilities/streaming/)** - Streams datasets larger than the available memory as streaming data. +* **[Tracing](https://docs.powertools.aws.dev/lambda/python/latest/core/tracer/)** - Decorators and utilities to trace Lambda function handlers, and both synchronous and asynchronous functions +* **[Logging](https://docs.powertools.aws.dev/lambda/python/latest/core/logger/)** - Structured logging made easier, and decorator to enrich structured logging with key Lambda context details +* **[Metrics](https://docs.powertools.aws.dev/lambda/python/latest/core/metrics/)** - Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF) +* **[Event handler: AppSync](https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/appsync/)** - AWS AppSync event handler for Lambda Direct Resolver and Amplify GraphQL Transformer function +* **[Event handler: API Gateway and ALB](https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/api_gateway/)** - Amazon API Gateway REST/HTTP API and ALB event handler for Lambda functions invoked using Proxy integration +* **[Bring your own middleware](https://docs.powertools.aws.dev/lambda/python/latest/utilities/middleware_factory/)** - Decorator factory to create your own middleware to run logic before, and after each Lambda invocation +* **[Parameters utility](https://docs.powertools.aws.dev/lambda/python/latest/utilities/parameters/)** - Retrieve and cache parameter values from Parameter Store, Secrets Manager, or DynamoDB +* **[Batch processing](https://docs.powertools.aws.dev/lambda/python/latest/utilities/batch/)** - Handle partial failures for AWS SQS batch processing +* **[Typing](https://docs.powertools.aws.dev/lambda/python/latest/utilities/typing/)** - Static typing classes to speedup development in your IDE +* **[Validation](https://docs.powertools.aws.dev/lambda/python/latest/utilities/validation/)** - JSON Schema validator for inbound events and responses +* **[Event source data classes](https://docs.powertools.aws.dev/lambda/python/latest/utilities/data_classes/)** - Data classes describing the schema of common Lambda event triggers +* **[Parser](https://docs.powertools.aws.dev/lambda/python/latest/utilities/parser/)** - Data parsing and deep validation using Pydantic +* **[Idempotency](https://docs.powertools.aws.dev/lambda/python/latest/utilities/idempotency/)** - Convert your Lambda functions into idempotent operations which are safe to retry +* **[Feature Flags](https://docs.powertools.aws.dev/lambda/python/latest/utilities/feature_flags/)** - A simple rule engine to evaluate when one or multiple features should be enabled depending on the input +* **[Streaming](https://docs.powertools.aws.dev/lambda/python/latest/utilities/streaming/)** - Streams datasets larger than the available memory as streaming data. ### Installation @@ -39,7 +39,7 @@ With [pip](https://pip.pypa.io/en/latest/index.html) installed, run: ``pip insta ## Tutorial and Examples -* [Tutorial](https://docs.powertools.aws.dev/lambda-python/latest/tutorial) +* [Tutorial](https://docs.powertools.aws.dev/lambda/python/latest/tutorial) * [Serverless Shopping cart](https://github.com/aws-samples/aws-serverless-shopping-cart) * [Serverless Airline](https://github.com/aws-samples/aws-serverless-airline-booking) * [Serverless E-commerce platform](https://github.com/aws-samples/aws-serverless-ecommerce-platform) @@ -65,11 +65,11 @@ The following companies, among others, use Powertools: ### Sharing your work -Share what you did with Powertools for AWS Lambda (Python) 💞💞. Blog post, workshops, presentation, sample apps and others. Check out what the community has already shared about Powertools for AWS Lambda (Python) [here](https://docs.powertools.aws.dev/lambda-python/latest/we_made_this/). +Share what you did with Powertools for AWS Lambda (Python) 💞💞. Blog post, workshops, presentation, sample apps and others. Check out what the community has already shared about Powertools for AWS Lambda (Python) [here](https://docs.powertools.aws.dev/lambda/python/latest/we_made_this/). ### Using Lambda Layer or SAR -This helps us understand who uses Powertools for AWS Lambda (Python) in a non-intrusive way, and helps us gain future investments for other Powertools for AWS Lambda languages. When [using Layers](https://docs.powertools.aws.dev/lambda-python/latest/#lambda-layer), you can add Powertools for AWS Lambda (Python) as a dev dependency (or as part of your virtual env) to not impact the development process. +This helps us understand who uses Powertools for AWS Lambda (Python) in a non-intrusive way, and helps us gain future investments for other Powertools for AWS Lambda languages. When [using Layers](https://docs.powertools.aws.dev/lambda/python/latest/#lambda-layer), you can add Powertools for AWS Lambda (Python) as a dev dependency (or as part of your virtual env) to not impact the development process. ## Credits @@ -79,7 +79,7 @@ This helps us understand who uses Powertools for AWS Lambda (Python) in a non-in ## Connect * **Powertools for AWS Lambda on Discord**: `#python` - **[Invite link](https://discord.gg/B8zZKbbyET)** -* **Email**: aws-lambda-powertools-feedback@amazon.com +* **Email**: ## Security disclosures diff --git a/aws_lambda_powertools/utilities/batch/decorators.py b/aws_lambda_powertools/utilities/batch/decorators.py index 36b9e75a8f2..356342fb83f 100644 --- a/aws_lambda_powertools/utilities/batch/decorators.py +++ b/aws_lambda_powertools/utilities/batch/decorators.py @@ -173,7 +173,7 @@ def handler(event, context): records: List[Dict] = event.get("Records", []) except AttributeError: event_types = ", ".join(list(EventType.__members__)) - docs = "https://docs.powertools.aws.dev/lambda-python/latest/utilities/batch/#processing-messages-from-sqs" # noqa: E501 # long-line + docs = "https://docs.powertools.aws.dev/lambda/python/latest/utilities/batch/#processing-messages-from-sqs" # noqa: E501 # long-line raise ValueError( f"Invalid event format. Please ensure batch event is a valid {processor.event_type.value} event. \n" f"See sample events in our documentation for either {event_types}: \n {docs}" @@ -237,7 +237,7 @@ def handler(event, context): records: List[Dict] = event.get("Records", []) except AttributeError: event_types = ", ".join(list(EventType.__members__)) - docs = "https://docs.powertools.aws.dev/lambda-python/latest/utilities/batch/#processing-messages-from-sqs" # noqa: E501 # long-line + docs = "https://docs.powertools.aws.dev/lambda/python/latest/utilities/batch/#processing-messages-from-sqs" # noqa: E501 # long-line raise ValueError( f"Invalid event format. Please ensure batch event is a valid {processor.event_type.value} event. \n" f"See sample events in our documentation for either {event_types}: \n {docs}" diff --git a/docs/index.md b/docs/index.md index ccc02d61417..cd7c5c65227 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,7 +8,7 @@ description: Powertools for AWS Lambda (Python) Powertools for AWS Lambda (Python) is a developer toolkit to implement Serverless best practices and increase developer velocity. ???+ tip - Powertools for AWS Lambda (Python) is also available for [Java](https://docs.powertools.aws.dev/lambda-java/){target="_blank"}, [TypeScript](https://docs.powertools.aws.dev/lambda-typescript/latest/){target="_blank"}, and [.NET](https://docs.powertools.aws.dev/lambda-dotnet/){target="_blank"} + Powertools for AWS Lambda (Python) is also available for [Java](https://docs.powertools.aws.dev/lambda/java/){target="_blank"}, [TypeScript](https://docs.powertools.aws.dev/lambda/typescript/latest/){target="_blank"}, and [.NET](https://docs.powertools.aws.dev/lambda/dotnet/){target="_blank"} ??? hint "Support this project by becoming a reference customer, sharing your work, or using Layers/SAR :heart:" @@ -460,8 +460,8 @@ Serverless Application Repository (SAR) App deploys a CloudFormation stack with Compared with the [public Layer ARN](#lambda-layer) option, SAR allows you to choose a semantic version and deploys a Layer in your target account. -| App | ARN | Description | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- | +| App | ARN | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- | | [aws-lambda-powertools-python-layer](https://serverlessrepo.aws.amazon.com/applications/eu-west-1/057560766410/aws-lambda-powertools-python-layer){target="_blank"} | [arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer](#){: .copyMe}:clipboard: | Contains all extra dependencies (e.g: pydantic). | | [aws-lambda-powertools-python-layer-arm64](https://serverlessrepo.aws.amazon.com/applications/eu-west-1/057560766410/aws-lambda-powertools-python-layer-arm64){target="_blank"} | [arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-arm64](#){: .copyMe}:clipboard: | Contains all extra dependencies (e.g: pydantic). For arm64 functions. | @@ -677,44 +677,44 @@ sam init --app-template hello-world-powertools-python --name sam-app --package-t Core utilities such as Tracing, Logging, Metrics, and Event Handler will be available across all Powertools for AWS Lambda languages. Additional utilities are subjective to each language ecosystem and customer demand. -| Utility | Description | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [**Tracing**](./core/tracer.md){target="_blank"} | Decorators and utilities to trace Lambda function handlers, and both synchronous and asynchronous functions | -| [**Logger**](./core/logger.md){target="_blank"} | Structured logging made easier, and decorator to enrich structured logging with key Lambda context details | -| [**Metrics**](./core/metrics.md){target="_blank"} | Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF) | -| [**Event handler: AppSync**](./core/event_handler/appsync.md){target="_blank"} | AppSync event handler for Lambda Direct Resolver and Amplify GraphQL Transformer function | -| [**Event handler: API Gateway, ALB and Lambda Function URL**](https://docs.powertools.aws.dev/lambda-python/latest/core/event_handler/api_gateway/) | Amazon API Gateway REST/HTTP API and ALB event handler for Lambda functions invoked using Proxy integration, and Lambda Function URL | -| [**Middleware factory**](./utilities/middleware_factory.md){target="_blank"} | Decorator factory to create your own middleware to run logic before, and after each Lambda invocation | -| [**Parameters**](./utilities/parameters.md){target="_blank"} | Retrieve parameter values from AWS Systems Manager Parameter Store, AWS Secrets Manager, or Amazon DynamoDB, and cache them for a specific amount of time | -| [**Batch processing**](./utilities/batch.md){target="_blank"} | Handle partial failures for AWS SQS batch processing | -| [**Typing**](./utilities/typing.md){target="_blank"} | Static typing classes to speedup development in your IDE | -| [**Validation**](./utilities/validation.md){target="_blank"} | JSON Schema validator for inbound events and responses | -| [**Event source data classes**](./utilities/data_classes.md){target="_blank"} | Data classes describing the schema of common Lambda event triggers | -| [**Parser**](./utilities/parser.md){target="_blank"} | Data parsing and deep validation using Pydantic | -| [**Idempotency**](./utilities/idempotency.md){target="_blank"} | Idempotent Lambda handler | -| [**Feature Flags**](./utilities/feature_flags.md){target="_blank"} | A simple rule engine to evaluate when one or multiple features should be enabled depending on the input | -| [**Streaming**](./utilities/streaming.md){target="_blank"} | Streams datasets larger than the available memory as streaming data. | +| Utility | Description | +| --------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [**Tracing**](./core/tracer.md){target="_blank"} | Decorators and utilities to trace Lambda function handlers, and both synchronous and asynchronous functions | +| [**Logger**](./core/logger.md){target="_blank"} | Structured logging made easier, and decorator to enrich structured logging with key Lambda context details | +| [**Metrics**](./core/metrics.md){target="_blank"} | Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF) | +| [**Event handler: AppSync**](./core/event_handler/appsync.md){target="_blank"} | AppSync event handler for Lambda Direct Resolver and Amplify GraphQL Transformer function | +| [**Event handler: API Gateway, ALB and Lambda Function URL**](https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/api_gateway/) | Amazon API Gateway REST/HTTP API and ALB event handler for Lambda functions invoked using Proxy integration, and Lambda Function URL | +| [**Middleware factory**](./utilities/middleware_factory.md){target="_blank"} | Decorator factory to create your own middleware to run logic before, and after each Lambda invocation | +| [**Parameters**](./utilities/parameters.md){target="_blank"} | Retrieve parameter values from AWS Systems Manager Parameter Store, AWS Secrets Manager, or Amazon DynamoDB, and cache them for a specific amount of time | +| [**Batch processing**](./utilities/batch.md){target="_blank"} | Handle partial failures for AWS SQS batch processing | +| [**Typing**](./utilities/typing.md){target="_blank"} | Static typing classes to speedup development in your IDE | +| [**Validation**](./utilities/validation.md){target="_blank"} | JSON Schema validator for inbound events and responses | +| [**Event source data classes**](./utilities/data_classes.md){target="_blank"} | Data classes describing the schema of common Lambda event triggers | +| [**Parser**](./utilities/parser.md){target="_blank"} | Data parsing and deep validation using Pydantic | +| [**Idempotency**](./utilities/idempotency.md){target="_blank"} | Idempotent Lambda handler | +| [**Feature Flags**](./utilities/feature_flags.md){target="_blank"} | A simple rule engine to evaluate when one or multiple features should be enabled depending on the input | +| [**Streaming**](./utilities/streaming.md){target="_blank"} | Streams datasets larger than the available memory as streaming data. | ## Environment variables ???+ info Explicit parameters take precedence over environment variables -| Environment variable | Description | Utility | Default | -| ----------------------------------------- | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | --------------------- | -| **POWERTOOLS_SERVICE_NAME** | Sets service name used for tracing namespace, metrics dimension and structured logging | All | `"service_undefined"` | -| **POWERTOOLS_METRICS_NAMESPACE** | Sets namespace used for metrics | [Metrics](./core/metrics){target="_blank"} | `None` | -| **POWERTOOLS_TRACE_DISABLED** | Explicitly disables tracing | [Tracing](./core/tracer){target="_blank"} | `false` | -| **POWERTOOLS_TRACER_CAPTURE_RESPONSE** | Captures Lambda or method return as metadata. | [Tracing](./core/tracer){target="_blank"} | `true` | -| **POWERTOOLS_TRACER_CAPTURE_ERROR** | Captures Lambda or method exception as metadata. | [Tracing](./core/tracer){target="_blank"} | `true` | -| **POWERTOOLS_TRACE_MIDDLEWARES** | Creates sub-segment for each custom middleware | [Middleware factory](./utilities/middleware_factory){target="_blank"} | `false` | -| **POWERTOOLS_LOGGER_LOG_EVENT** | Logs incoming event | [Logging](./core/logger){target="_blank"} | `false` | -| **POWERTOOLS_LOGGER_SAMPLE_RATE** | Debug log sampling | [Logging](./core/logger){target="_blank"} | `0` | -| **POWERTOOLS_LOG_DEDUPLICATION_DISABLED** | Disables log deduplication filter protection to use Pytest Live Log feature | [Logging](./core/logger){target="_blank"} | `false` | -| **POWERTOOLS_PARAMETERS_MAX_AGE** | Adjust how long values are kept in cache (in seconds) | [Parameters](./utilities/parameters/#adjusting-cache-ttl){target="_blank"} | `5` | -| **POWERTOOLS_PARAMETERS_SSM_DECRYPT** | Sets whether to decrypt or not values retrieved from AWS SSM Parameters Store | [Parameters](./utilities/parameters/#ssmprovider){target="_blank"} | `false` | -| **POWERTOOLS_DEV** | Increases verbosity across utilities | Multiple; see [POWERTOOLS_DEV effect below](#increasing-verbosity-across-utilities) | `false` | -| **LOG_LEVEL** | Sets logging level | [Logging](./core/logger){target="_blank"} | `INFO` | +| Environment variable | Description | Utility | Default | +| ----------------------------------------- | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | --------------------- | +| **POWERTOOLS_SERVICE_NAME** | Sets service name used for tracing namespace, metrics dimension and structured logging | All | `"service_undefined"` | +| **POWERTOOLS_METRICS_NAMESPACE** | Sets namespace used for metrics | [Metrics](./core/metrics){target="_blank"} | `None` | +| **POWERTOOLS_TRACE_DISABLED** | Explicitly disables tracing | [Tracing](./core/tracer){target="_blank"} | `false` | +| **POWERTOOLS_TRACER_CAPTURE_RESPONSE** | Captures Lambda or method return as metadata. | [Tracing](./core/tracer){target="_blank"} | `true` | +| **POWERTOOLS_TRACER_CAPTURE_ERROR** | Captures Lambda or method exception as metadata. | [Tracing](./core/tracer){target="_blank"} | `true` | +| **POWERTOOLS_TRACE_MIDDLEWARES** | Creates sub-segment for each custom middleware | [Middleware factory](./utilities/middleware_factory){target="_blank"} | `false` | +| **POWERTOOLS_LOGGER_LOG_EVENT** | Logs incoming event | [Logging](./core/logger){target="_blank"} | `false` | +| **POWERTOOLS_LOGGER_SAMPLE_RATE** | Debug log sampling | [Logging](./core/logger){target="_blank"} | `0` | +| **POWERTOOLS_LOG_DEDUPLICATION_DISABLED** | Disables log deduplication filter protection to use Pytest Live Log feature | [Logging](./core/logger){target="_blank"} | `false` | +| **POWERTOOLS_PARAMETERS_MAX_AGE** | Adjust how long values are kept in cache (in seconds) | [Parameters](./utilities/parameters/#adjusting-cache-ttl){target="_blank"} | `5` | +| **POWERTOOLS_PARAMETERS_SSM_DECRYPT** | Sets whether to decrypt or not values retrieved from AWS SSM Parameters Store | [Parameters](./utilities/parameters/#ssmprovider){target="_blank"} | `false` | +| **POWERTOOLS_DEV** | Increases verbosity across utilities | Multiple; see [POWERTOOLS_DEV effect below](#optimizing-for-non-production-environments) | `false` | +| **LOG_LEVEL** | Sets logging level | [Logging](./core/logger){target="_blank"} | `INFO` | ### Optimizing for non-production environments @@ -757,11 +757,11 @@ The following companies, among others, use Powertools: ### Sharing your work -Share what you did with Powertools for AWS Lambda (Python) 💞💞. Blog post, workshops, presentation, sample apps and others. Check out what the community has already shared about Powertools for AWS Lambda (Python) [here](https://docs.powertools.aws.dev/lambda-python/latest/we_made_this/){target="_blank"}. +Share what you did with Powertools for AWS Lambda (Python) 💞💞. Blog post, workshops, presentation, sample apps and others. Check out what the community has already shared about Powertools for AWS Lambda (Python) [here](https://docs.powertools.aws.dev/lambda/python/latest/we_made_this/){target="_blank"}. ### Using Lambda Layer or SAR -This helps us understand who uses Powertools for AWS Lambda (Python) in a non-intrusive way, and helps us gain future investments for other Powertools for AWS Lambda languages. When [using Layers](https://docs.powertools.aws.dev/lambda-python/latest/#lambda-layer), you can add Powertools for AWS Lambda (Python) as a dev dependency (or as part of your virtual env) to not impact the development process. +This helps us understand who uses Powertools for AWS Lambda (Python) in a non-intrusive way, and helps us gain future investments for other Powertools for AWS Lambda languages. When [using Layers](https://docs.powertools.aws.dev/lambda/python/latest/#lambda-layer), you can add Powertools for AWS Lambda (Python) as a dev dependency (or as part of your virtual env) to not impact the development process. ## Tenets diff --git a/docs/upgrade.md b/docs/upgrade.md index 8e48b943f43..064c6a9657a 100644 --- a/docs/upgrade.md +++ b/docs/upgrade.md @@ -24,7 +24,7 @@ We've made minimal breaking changes to make your transition to v2 as smooth as p | **Event Handler** | Updated [headers response format](#event-handler-headers-response-format) due to [multi-value headers and cookie support](./core/event_handler/api_gateway.md#fine-grained-responses){target="_blank"}. | Tests only | - | | **Event Source Data Classes** | Replaced [DynamoDBStreamEvent](#dynamodbstreamevent-in-event-source-data-classes) `AttributeValue` with native Python types. | Yes | - | | **Feature Flags** / **Parameters** | Updated [AppConfig API calls](#feature-flags-and-appconfig-parameter-utility) due to **`GetConfiguration`** API deprecation. | - | Yes | -| **Idempotency** | Updated [partition key](#idempotency-key-format) to include fully qualified function/method names. | - | - | +| **Idempotency** | Updated [partition key](#idempotency-partition-key-format) to include fully qualified function/method names. | - | - | ### First Steps @@ -151,7 +151,7 @@ In V2, we add all headers under `multiValueHeaders` key. This enables seamless s ## DynamoDBStreamEvent in Event Source Data Classes -!!! info "This also applies if you're using [**DynamoDB BatchProcessor**](https://docs.powertools.aws.dev/lambda-python/latest/utilities/batch/#processing-messages-from-dynamodb){target="_blank"}." +!!! info "This also applies if you're using [**DynamoDB BatchProcessor**](https://docs.powertools.aws.dev/lambda/python/latest/utilities/batch/#processing-messages-from-dynamodb){target="_blank"}." You will now receive native Python types when accessing DynamoDB records via `keys`, `new_image`, and `old_image` attributes in `DynamoDBStreamEvent`. diff --git a/examples/event_handler_graphql/sam/template.yaml b/examples/event_handler_graphql/sam/template.yaml index 8e1e0760797..ae2bd50f9f2 100644 --- a/examples/event_handler_graphql/sam/template.yaml +++ b/examples/event_handler_graphql/sam/template.yaml @@ -9,7 +9,7 @@ Globals: Tracing: Active Environment: Variables: - # Powertools for AWS Lambda (Python) env vars: https://docs.powertools.aws.dev/lambda-python/latest/#environment-variables + # Powertools for AWS Lambda (Python) env vars: https://docs.powertools.aws.dev/lambda/python/latest/#environment-variables LOG_LEVEL: INFO POWERTOOLS_LOGGER_SAMPLE_RATE: 0.1 POWERTOOLS_LOGGER_LOG_EVENT: true @@ -75,7 +75,7 @@ Resources: cfn-lint: config: ignore_checks: - - W3002 # allow relative path in DefinitionS3Location + - W3002 # allow relative path in DefinitionS3Location # Lambda Direct Data Source and Resolver diff --git a/examples/feature_flags/src/getting_all_enabled_features.py b/examples/feature_flags/src/getting_all_enabled_features.py index b15d24857ee..49877512578 100644 --- a/examples/feature_flags/src/getting_all_enabled_features.py +++ b/examples/feature_flags/src/getting_all_enabled_features.py @@ -12,7 +12,7 @@ @app.get("/products") def list_products(): # getting fields from request - # https://docs.powertools.aws.dev/lambda-python/latest/core/event_handler/api_gateway/#accessing-request-details + # https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/api_gateway/#accessing-request-details json_body = app.current_event.json_body headers = app.current_event.headers diff --git a/examples/logger/sam/template.yaml b/examples/logger/sam/template.yaml index 45e80fe39e1..588b46f5824 100644 --- a/examples/logger/sam/template.yaml +++ b/examples/logger/sam/template.yaml @@ -13,7 +13,7 @@ Globals: LOG_LEVEL: INFO Layers: # Find the latest Layer version in the official documentation - # https://docs.powertools.aws.dev/lambda-python/latest/#lambda-layer + # https://docs.powertools.aws.dev/lambda/python/latest/#lambda-layer - !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPythonV2:35 Resources: diff --git a/examples/logger/src/powertools_formatter_setup.py b/examples/logger/src/powertools_formatter_setup.py index 46be1e661eb..7aad787abd6 100644 --- a/examples/logger/src/powertools_formatter_setup.py +++ b/examples/logger/src/powertools_formatter_setup.py @@ -2,7 +2,7 @@ from aws_lambda_powertools.logging.formatter import LambdaPowertoolsFormatter # NOTE: Check docs for all available options -# https://docs.powertools.aws.dev/lambda-python/latest/core/logger/#lambdapowertoolsformatter +# https://docs.powertools.aws.dev/lambda/python/latest/core/logger/#lambdapowertoolsformatter formatter = LambdaPowertoolsFormatter(utc=True, log_record_order=["message"]) logger = Logger(service="example", logger_formatter=formatter) diff --git a/examples/metrics/sam/template.yaml b/examples/metrics/sam/template.yaml index 28ceb09d20d..9eaff55a7bb 100644 --- a/examples/metrics/sam/template.yaml +++ b/examples/metrics/sam/template.yaml @@ -14,7 +14,7 @@ Globals: Layers: # Find the latest Layer version in the official documentation - # https://docs.powertools.aws.dev/lambda-python/latest/#lambda-layer + # https://docs.powertools.aws.dev/lambda/python/latest/#lambda-layer - !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPythonV2:35 Resources: diff --git a/examples/middleware_factory/src/combining_powertools_utilities_function.py b/examples/middleware_factory/src/combining_powertools_utilities_function.py index 4ba282202cf..6f4935ec9c3 100644 --- a/examples/middleware_factory/src/combining_powertools_utilities_function.py +++ b/examples/middleware_factory/src/combining_powertools_utilities_function.py @@ -27,7 +27,6 @@ @lambda_handler_decorator(trace_execution=True) def middleware_custom(handler: Callable, event: dict, context: LambdaContext): - # validating the INPUT with the given schema # X-Customer-Id header must be informed in all requests try: @@ -66,10 +65,9 @@ def middleware_custom(handler: Callable, event: dict, context: LambdaContext): @tracer.capture_method def save_api_execution_history(path: str, headers: dict, request_context: dict) -> None: - try: # using the feature flags utility to check if the new feature "save api call to history" is enabled by default - # see: https://docs.powertools.aws.dev/lambda-python/latest/utilities/feature_flags/#static-flags + # see: https://docs.powertools.aws.dev/lambda/python/latest/utilities/feature_flags/#static-flags save_history: JSONType = feature_flags.evaluate(name="save_history", default=False) if save_history: # saving history in dynamodb table diff --git a/examples/tracer/sam/template.yaml b/examples/tracer/sam/template.yaml index 447dca0c416..026714cd66a 100644 --- a/examples/tracer/sam/template.yaml +++ b/examples/tracer/sam/template.yaml @@ -12,7 +12,7 @@ Globals: POWERTOOLS_SERVICE_NAME: payment Layers: # Find the latest Layer version in the official documentation - # https://docs.powertools.aws.dev/lambda-python/latest/#lambda-layer + # https://docs.powertools.aws.dev/lambda/python/latest/#lambda-layer - !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPythonV2:35 Resources: diff --git a/examples/validation/src/getting_started_validator_decorator_function.py b/examples/validation/src/getting_started_validator_decorator_function.py index 4ef1a135245..1e9b1bd2a09 100644 --- a/examples/validation/src/getting_started_validator_decorator_function.py +++ b/examples/validation/src/getting_started_validator_decorator_function.py @@ -8,7 +8,7 @@ from aws_lambda_powertools.utilities.validation import validator # we can get list of allowed IPs from AWS Parameter Store using Parameters Utility -# See: https://docs.powertools.aws.dev/lambda-python/latest/utilities/parameters/ +# See: https://docs.powertools.aws.dev/lambda/python/latest/utilities/parameters/ ALLOWED_IPS = parameters.get_parameter("/lambda-powertools/allowed_ips") @@ -27,7 +27,6 @@ class User: # using a decorator to validate input and output data @validator(inbound_schema=schemas.INPUT, outbound_schema=schemas.OUTPUT) def lambda_handler(event, context: LambdaContext) -> dict: - try: user_details: dict = {} diff --git a/examples/validation/src/getting_started_validator_standalone_function.py b/examples/validation/src/getting_started_validator_standalone_function.py index 60c35acc3ff..95fc3ecdf5d 100644 --- a/examples/validation/src/getting_started_validator_standalone_function.py +++ b/examples/validation/src/getting_started_validator_standalone_function.py @@ -5,7 +5,7 @@ from aws_lambda_powertools.utilities.validation import SchemaValidationError, validate # we can get list of allowed IPs from AWS Parameter Store using Parameters Utility -# See: https://docs.powertools.aws.dev/lambda-python/latest/utilities/parameters/ +# See: https://docs.powertools.aws.dev/lambda/python/latest/utilities/parameters/ ALLOWED_IPS = parameters.get_parameter("/lambda-powertools/allowed_ips") diff --git a/examples/validation/src/unwrapping_popular_event_source_function.py b/examples/validation/src/unwrapping_popular_event_source_function.py index 551ea2e4a8c..952e949647a 100644 --- a/examples/validation/src/unwrapping_popular_event_source_function.py +++ b/examples/validation/src/unwrapping_popular_event_source_function.py @@ -10,7 +10,7 @@ # extracting detail from EventBridge custom event -# see: https://docs.powertools.aws.dev/lambda-python/latest/utilities/jmespath_functions/#built-in-envelopes +# see: https://docs.powertools.aws.dev/lambda/python/latest/utilities/jmespath_functions/#built-in-envelopes @validator(inbound_schema=schemas.INPUT, envelope=envelopes.EVENTBRIDGE) def lambda_handler(event: dict, context: LambdaContext) -> dict: my_event = EventBridgeEvent(event) diff --git a/pyproject.toml b/pyproject.toml index cec186b92ec..d722db2b647 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ classifiers=[ "Programming Language :: Python :: 3.10", ] repository = "https://github.com/aws-powertools/powertools-lambda-python" -documentation = "https://docs.powertools.aws.dev/lambda-python/" +documentation = "https://docs.powertools.aws.dev/lambda/python/" readme = "README.md" keywords = ["aws_lambda_powertools", "aws", "tracing", "logging", "lambda", "powertools", "feature_flags", "idempotency", "middleware"] # MIT-0 is not recognized as an existing license from poetry.