From 72a8e57ade7cbb1afffd759b69a95bc27b094db7 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Fri, 9 Apr 2021 09:49:48 +0200 Subject: [PATCH 1/5] docs(idempotency): add default configuration for those not using CFN --- docs/utilities/idempotency.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/utilities/idempotency.md b/docs/utilities/idempotency.md index dcdff21953e..ecadbe530ae 100644 --- a/docs/utilities/idempotency.md +++ b/docs/utilities/idempotency.md @@ -30,19 +30,26 @@ times with the same parameters**. This makes idempotent operations safe to retry ### Required resources -Before getting started, you need to create a persistent storage layer where the idempotency utility can store its -state - your lambda functions will need read and write access to it. +Before getting started, you need to create a persistent storage layer where the idempotency utility can store its state - your lambda functions will need read and write access to it. As of now, Amazon DynamoDB is the only supported persistent storage layer, so you'll need to create a table first. -> Example using AWS Serverless Application Model (SAM) +**Default table configuration** + +If you're not [changing the default configuration for the DynamoDB persistence layer](#dynamodbpersistencelayer), this is the expected default configuration: + +Configuration | Value | Notes +------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------- +Partition key | `id` | +TTL attribute name | `expiration` | This can only be configured after your table is created if you're using AWS Console -=== "template.yml" - !!! tip "You can share a single state table for all functions" - > New in 1.12.0 +!!! tip "You can share a single state table for all functions" + You can reuse the same DynamoDB table to store idempotency state. We add your `function_name` in addition to the idempotency key as a hash key. - You can reuse the same DynamoDB table to store idempotency state. We add your function_name in addition to the idempotency key as a hash key. +> Example using AWS Serverless Application Model (SAM) + +=== "template.yml" ```yaml hl_lines="5-13 21-23" Resources: From 5ac2ca31ea1f17f82c37d811ca1a4cc74d88adbf Mon Sep 17 00:00:00 2001 From: Heitor Lessa Date: Fri, 9 Apr 2021 10:11:38 +0200 Subject: [PATCH 2/5] docs(logger): add example on how to set UTC timestamp (#392) Signed-off-by: heitorlessa --- docs/core/logger.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/core/logger.md b/docs/core/logger.md index c7ef2f467e4..ae842d6a613 100644 --- a/docs/core/logger.md +++ b/docs/core/logger.md @@ -531,6 +531,7 @@ Service is what defines the Logger name, including what the Lambda function is r For Logger, the `service` is the logging key customers can use to search log operations for one or more functions - For example, **search for all errors, or messages like X, where service is payment**. ??? tip "Logging output example" + ```json hl_lines="5" { "timestamp": "2020-05-24 18:17:33,774", @@ -571,6 +572,7 @@ A common issue when migrating from other Loggers is that `service` might be defi logger = Logger(child=True) ``` + === "correct_logger_inheritance.py" ```python hl_lines="4 10" @@ -652,6 +654,26 @@ You can also change the order of the following log record keys via the `log_reco } ``` +#### Setting timestamp to UTC + +By default, this Logger and standard logging library emits records using local time timestamp. You can override this behaviour by updating the current converter set in our formatter: + +=== "app.py" + + ```python hl_lines="1 3 9" + from aws_lambda_powertools import Logger + + import time + + logger = Logger(service="sample_service") + + logger.info("Local time") + + logger._logger.handlers[0].formatter.converter = time.gmtime + + logger.info("GMT time") + ``` + ## Testing your code When unit testing your code that makes use of `inject_lambda_context` decorator, you need to pass a dummy Lambda Context, or else Logger will fail. From 52fb845efd0359416810e20c80105787a1a54851 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Fri, 9 Apr 2021 11:32:44 +0200 Subject: [PATCH 3/5] chore: bump to 1.14.0 --- CHANGELOG.md | 22 ++++++++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e1430a3c78..bfa5085a13d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,28 @@ This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) fo ## [Unreleased] +## [1.14.0] - 2021-04-09 + +### Added + +* **Event handlers**: New core utility to easily handle incoming requests tightly integrated with Data Classes; AppSync being the first as we gauge from the community what additional ones would be helpful +* **Documentation**: Enabled versioning to access docs on a per release basis or staging docs (`develop` branch) +* **Documentation**: Links now open in a new tab and improved snippet line highlights +* **Documentation(validation)**: JSON Schema snippets and more complete examples +* **Documentation(idempotency)**: Table with expected configuration values for hash key and TTL attribute name when using the default behaviour +* **Documentation(logger)**: New example on how to set logging record timestamps in UTC +* **Parser(S3)**: Support for the new S3 Object Lambda Event model (`S3ObjectLambdaEvent`) +* **Parameters**: Support for DynamoDB Local via `endpoint_url` parameter, including docs +* **Internal**: Include `make pr` in pre-commit hooks when contributing to shorten feedback loop on pre-commit specific linting + +### Fixed + +* **Parser**: S3Model now supports keys with 0 length +* **Tracer**: Lock X-Ray SDK to 2.6.0 as there's been a regression upstream in 2.7.0 on serializing & capturing exceptions +* **Data Classes(API Gateway)**: Add missing property `operationName` within request context +* **Misc.**: Numerous typing fixes to better to support MyPy across all utilities +* **Internal**: Downgraded poetry to 1.1.4 as there's been a regression with `importlib-metadata` in 1.1.5 not yet fixed + ## [1.13.0] - 2021-03-23 ### Added diff --git a/pyproject.toml b/pyproject.toml index 8c89bc6e13f..3c16f373756 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "aws_lambda_powertools" -version = "1.13.0" +version = "1.14.0" description = "Python utilities for AWS Lambda functions including but not limited to tracing, logging and custom metric" authors = ["Amazon Web Services"] include = ["aws_lambda_powertools/py.typed"] From f976947a773facc36eccb22ad180e88d81d8fdcc Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Fri, 9 Apr 2021 11:54:09 +0200 Subject: [PATCH 4/5] fix(workflow): github actions depends on for release --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fdce088db17..489a5ccccc2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -88,7 +88,7 @@ jobs: destination_dir: ${{ env.RELEASE_TAG_VERSION }}/api sync_master: - needs: upload + needs: release runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 9a8ad58a1d72b355dceec3e0be20a01f32bceef8 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Tue, 13 Apr 2021 17:56:18 +0200 Subject: [PATCH 5/5] fix(workflow): add API dir to latest Signed-off-by: heitorlessa --- .github/workflows/publish.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 489a5ccccc2..246992ec244 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -79,13 +79,20 @@ jobs: run: | make release-docs VERSION=${RELEASE_TAG_VERSION} ALIAS="latest" poetry run mike set-default --push latest - - name: Deploy all docs + - name: Release API docs to release version uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./api keep_files: true destination_dir: ${{ env.RELEASE_TAG_VERSION }}/api + - name: Release API docs to latest + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./api + keep_files: true + destination_dir: latest/api sync_master: needs: release