Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aws-powertools/powertools-lambda-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.6.1
Choose a base ref
...
head repository: aws-powertools/powertools-lambda-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.7.0
Choose a head ref

Commits on Aug 22, 2020

  1. Copy the full SHA
    913e310 View commit details

Commits on Aug 23, 2020

  1. Merge branch 'develop' into pydantic

    * develop: (26 commits)
      docs: move tenets; remove extra space
      docs: use table for clarity
      docs: add blog post, and quick example
      docs: subtle rewording for better clarity
      docs: fix typos, log_event & sampling wording
      docs: make sensitive info more explicit with an example
      docs: create Patching modules section; cleanup response wording
      docs: move concurrent asynchronous under escape hatch
      chore: update internal docstrings for consistency
      fix: remove actual response from debug logs
      docs: grammar
      docs: bring new feature upfront when returning sensitive info
      chore: update changelog to reflect new feature
      chore: clarify changelog bugfix vs breaking change
      chore: remove/correct unnecessary debug logs
      chore: fix debug log adding unused obj
      fix: naming and staticmethod consistency
      improv: naming consistency
      fix: correct in_subsegment assertion
      feat: capture_response as metadata option #127
      ...
    heitorlessa committed Aug 23, 2020
    Copy the full SHA
    3f9865a View commit details

Commits on Aug 26, 2020

  1. Merge branch 'develop' into pydantic

    * develop:
      docs: Fix doc for log sampling (#135)
      fix(logging): Don't include `json_default` in logs (#132)
      chore: bump to 1.4.0
      docs: add Lambda Layer SAR App url and ARN
      fix: upgrade dot-prop, serialize-javascript
      fix heading error due to merge
      formatting for bash script
      add layer to docs and how to use it from SAR
      moved publish step to publish workflow after pypi push
      fix(ssm): Make decrypt an explicit option and refactoring (#123)
      change to eu-west-1 default region
      remove tmp release flag and set trigger to release published
      add overwrite flag for ssm
      add relase tag simulation
      more typos
      fix typo in branch trigger
      fix indent, yaml ...
      line endings
    heitorlessa committed Aug 26, 2020
    Copy the full SHA
    7c55154 View commit details
  2. Copy the full SHA
    d50e261 View commit details
  3. added SQS schema & tests and sns skeleton

    Ran Isenberg committed Aug 26, 2020
    Copy the full SHA
    bce7aab View commit details
  4. Add validate function, fix flake8 issues

    Ran Isenberg committed Aug 26, 2020
    Copy the full SHA
    dc64b8a View commit details

Commits on Sep 21, 2020

  1. refactor: change to advanced parser

    Ran Isenberg committed Sep 21, 2020
    Copy the full SHA
    637a696 View commit details
  2. Merge branch 'develop' of github.com:risenberg-cyberark/aws-lambda-po…

    …wertools-python into pydantic
    
    # Conflicts:
    #	pyproject.toml
    Ran Isenberg committed Sep 21, 2020
    Copy the full SHA
    f986512 View commit details
  3. Copy the full SHA
    3418767 View commit details

Commits on Sep 22, 2020

  1. feat: Advanced parser utility (pydantic)

    Ran Isenberg committed Sep 22, 2020
    Copy the full SHA
    47cd711 View commit details

Commits on Sep 24, 2020

  1. Merge branch 'develop' of github.com:risenberg-cyberark/aws-lambda-po…

    …wertools-python into pydantic
    Ran Isenberg committed Sep 24, 2020
    Copy the full SHA
    b7cb539 View commit details
  2. fix: remove jmespath extras in Make

    Signed-off-by: heitorlessa <lessa@amazon.co.uk>
    heitorlessa committed Sep 24, 2020
    1
    Copy the full SHA
    738e261 View commit details
  3. Merge branch 'develop' of github.com:risenberg-cyberark/aws-lambda-po…

    …wertools-python into pydantic
    Ran Isenberg committed Sep 24, 2020
    Copy the full SHA
    0edaf9a View commit details
  4. feat(data_classes): Cognito custom auth triggers

    Add support for "Custom Authentication Challenge Lambda Triggers":
    * Add response helpers
    * Implement "Define auth challenge", "Create auth challenge" and "Verify
      auth challenge response"
    Michael Brewer committed Sep 24, 2020
    Copy the full SHA
    9b836e0 View commit details
  5. Merge branch 'develop' into cognito-custom-auth

    Michael Brewer committed Sep 24, 2020
    Copy the full SHA
    248ea65 View commit details
  6. build: temp fix to allow the pr to build

    Michael Brewer committed Sep 24, 2020
    Copy the full SHA
    5d0932e View commit details

Commits on Sep 25, 2020

  1. Revert "fix: remove jmespath extras in Make"

    This reverts commit 738e261.
    heitorlessa committed Sep 25, 2020
    Copy the full SHA
    7174bc3 View commit details
  2. Copy the full SHA
    8ff6bc9 View commit details
  3. 2
    Copy the full SHA
    2aed9db View commit details
  4. Copy the full SHA
    b10af63 View commit details
  5. fix: Correct typo

    Co-authored-by: Joris Conijn <jco@woodwing.com>
    Michael Brewer and Joris Conijn authored Sep 25, 2020
    Copy the full SHA
    7497543 View commit details
  6. Merge branch 'develop' into cognito-custom-auth

    Michael Brewer committed Sep 25, 2020
    Copy the full SHA
    51a9091 View commit details
  7. Merge pull request #180 from heitorlessa/chore/remove-example

    chore: remove kitchen sink example
    heitorlessa authored Sep 25, 2020
    Copy the full SHA
    eac89af View commit details
  8. Copy the full SHA
    117b19e View commit details
  9. Copy the full SHA
    ea3fb0f View commit details
  10. chore: upgrade gatsby

    heitorlessa committed Sep 25, 2020
    Copy the full SHA
    7081f44 View commit details
  11. fix: add only pydantic (+1 squashed commit)

    Squashed commits:
    [804f251] fix poetry.lock, revert changes
    Ran Isenberg committed Sep 25, 2020
    Copy the full SHA
    6ae1769 View commit details
  12. Revert "fix: remove jmespath extras in Make"

    This reverts commit 738e261.
    heitorlessa authored and Ran Isenberg committed Sep 25, 2020
    Copy the full SHA
    19a597f View commit details
  13. poetry update (+2 squashed commits)

    Squashed commits:
    [85de91d] fix: pydantic as optional
    [8ff6bc9] fix: remove only dev extras
    heitorlessa authored and Ran Isenberg committed Sep 25, 2020
    Copy the full SHA
    57b6d23 View commit details
  14. chore: remove kitchen sink example

    heitorlessa authored and Ran Isenberg committed Sep 25, 2020
    Copy the full SHA
    ad80cd3 View commit details
  15. chore: remove dev deps from example project

    heitorlessa authored and Ran Isenberg committed Sep 25, 2020
    Copy the full SHA
    f1d39e1 View commit details
  16. Copy the full SHA
    38e1582 View commit details
  17. Copy the full SHA
    b1b7fb3 View commit details
  18. fix: reduce complexity of dynamo envelope

    Ran Isenberg committed Sep 25, 2020
    Copy the full SHA
    a47056f View commit details

Commits on Sep 26, 2020

  1. test(data_classes): correct some of the unit tests

    Michael Brewer committed Sep 26, 2020
    Copy the full SHA
    4846b77 View commit details
  2. Merge branch 'develop' into cognito-custom-auth

    Michael Brewer committed Sep 26, 2020
    Copy the full SHA
    d9b94ae View commit details

Commits on Sep 27, 2020

  1. Merge pull request #181 from awslabs/fix/docs-sec-vuln

    chore: docs npm security node-forge
    heitorlessa authored Sep 27, 2020
    Copy the full SHA
    d08de0b View commit details

Commits on Sep 28, 2020

  1. Merge branch 'develop' into cognito-custom-auth

    Michael Brewer committed Sep 28, 2020
    Copy the full SHA
    802324f View commit details

Commits on Oct 1, 2020

  1. feat(data_classes): case insensitive header lookup

    Update BaseProxyEvent `get_header_value` method to be case insensitive
    by default and add a flag for case sensitive lookups
    
    Closes #185
    Michael Brewer committed Oct 1, 2020
    Copy the full SHA
    4c77c78 View commit details

Commits on Oct 2, 2020

  1. fix: CR fixes

    Ran Isenberg committed Oct 2, 2020
    Copy the full SHA
    10d0079 View commit details
  2. Merge pull request #118 from risenberg-cyberark/pydantic

    feat: Advanced parser utility (pydantic)
    heitorlessa authored Oct 2, 2020
    Copy the full SHA
    c7a584f View commit details
  3. Merge pull request #178 from gyft/cognito-custom-auth

    feat(data_classes): Cognito custom auth triggers
    heitorlessa authored Oct 2, 2020
    Copy the full SHA
    9661f13 View commit details
  4. chore: upgrade docs dep

    heitorlessa committed Oct 2, 2020
    Copy the full SHA
    80de2b4 View commit details
  5. docs: update examples in README

    Signed-off-by: heitorlessa <lessa@amazon.co.uk>
    heitorlessa committed Oct 2, 2020
    Copy the full SHA
    bb2e7d7 View commit details
  6. Copy the full SHA
    6a1ea1b View commit details

Commits on Oct 3, 2020

  1. tests(pydantic): Add missing coverage

    Changes:
    * Make some methods static
    * Run code formatter
    * Some lint based changes
    * Add missing test cases
    Michael Brewer committed Oct 3, 2020
    Copy the full SHA
    7d1abf0 View commit details
  2. Merge branch 'develop' into feat-case-insensitive-dict

    Michael Brewer committed Oct 3, 2020
    Copy the full SHA
    3a3e716 View commit details

Commits on Oct 4, 2020

  1. Merge pull request #188 from gyft/tests-pydantic

    test(parser): Add missing test coverage and lint changes
    heitorlessa authored Oct 4, 2020
    Copy the full SHA
    42c84fc View commit details
  2. Merge pull request #186 from gyft/feat-case-insensitive-dict

    feat(data_classes): case insensitive header lookup
    heitorlessa authored Oct 4, 2020
    Copy the full SHA
    585f708 View commit details
  3. Copy the full SHA
    8539002 View commit details
Showing with 20,079 additions and 22,973 deletions.
  1. +40 −0 .github/workflows/codeql-analysis.yml
  2. +4 −1 .github/workflows/python_docs.yml
  3. +10 −0 CHANGELOG.md
  4. +8 −8 Makefile
  5. +7 −5 README.md
  6. +16 −0 aws_lambda_powertools/logging/filters.py
  7. +8 −7 aws_lambda_powertools/logging/logger.py
  8. +274 −11 aws_lambda_powertools/utilities/data_classes/cognito_user_pool_event.py
  9. +9 −2 aws_lambda_powertools/utilities/data_classes/common.py
  10. +1 −1 aws_lambda_powertools/utilities/data_classes/ses_event.py
  11. +18 −0 aws_lambda_powertools/utilities/parser/__init__.py
  12. +6 −0 aws_lambda_powertools/utilities/parser/envelopes/__init__.py
  13. +63 −0 aws_lambda_powertools/utilities/parser/envelopes/base.py
  14. +44 −0 aws_lambda_powertools/utilities/parser/envelopes/dynamodb.py
  15. +32 −0 aws_lambda_powertools/utilities/parser/envelopes/event_bridge.py
  16. +42 −0 aws_lambda_powertools/utilities/parser/envelopes/sqs.py
  17. +6 −0 aws_lambda_powertools/utilities/parser/exceptions.py
  18. +12 −0 aws_lambda_powertools/utilities/parser/models/__init__.py
  19. +46 −0 aws_lambda_powertools/utilities/parser/models/dynamodb.py
  20. +16 −0 aws_lambda_powertools/utilities/parser/models/event_bridge.py
  21. +65 −0 aws_lambda_powertools/utilities/parser/models/sqs.py
  22. +154 −0 aws_lambda_powertools/utilities/parser/parser.py
  23. +8 −0 aws_lambda_powertools/utilities/parser/pydantic.py
  24. +6 −0 aws_lambda_powertools/utilities/parser/types.py
  25. +9 −3 docs/content/core/logger.mdx
  26. +3 −0 docs/content/utilities/data_classes.mdx
  27. +573 −0 docs/content/utilities/parser.mdx
  28. +2 −1 docs/gatsby-config.js
  29. +0 −21,581 docs/package-lock.json
  30. +14 −8 docs/package.json
  31. +17,585 −0 docs/yarn.lock
  32. +0 −244 example/.gitignore
  33. +0 −136 example/README.md
  34. +0 −62 example/events/event.json
  35. +0 −132 example/hello_world/app.py
  36. +0 −4 example/hello_world/requirements.txt
  37. +0 −3 example/pytest.ini
  38. +0 −2 example/requirements-dev.txt
  39. +0 −9 example/samconfig.toml
  40. +0 −57 example/template.yaml
  41. 0 example/tests/__init__.py
  42. +0 −117 example/tests/test_handler.py
  43. +365 −555 poetry.lock
  44. +8 −5 pyproject.toml
  45. +1 −1 pytest.ini
  46. +29 −0 tests/events/cognitoCreateAuthChallengeEvent.json
  47. +32 −0 tests/events/cognitoDefineAuthChallengeEvent.json
  48. +1 −1 tests/events/cognitoPostAuthenticationEvent.json
  49. +1 −1 tests/events/cognitoPreAuthenticationEvent.json
  50. +28 −0 tests/events/cognitoVerifyAuthChallengeResponseEvent.json
  51. +3 −3 tests/events/eventBridgeEvent.json
  52. +2 −2 tests/events/sqsEvent.json
  53. 0 {example/hello_world → tests/functional/parser}/__init__.py
  54. +43 −0 tests/functional/parser/conftest.py
  55. +53 −0 tests/functional/parser/schemas.py
  56. +69 −0 tests/functional/parser/test_dynamodb.py
  57. +61 −0 tests/functional/parser/test_eventbridge.py
  58. +68 −0 tests/functional/parser/test_parser.py
  59. +92 −0 tests/functional/parser/test_sqs.py
  60. +13 −0 tests/functional/parser/utils.py
  61. +121 −3 tests/functional/test_lambda_trigger_events.py
  62. +8 −8 tests/functional/test_logger.py
40 changes: 40 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "CodeQL"

on:
push:
branches: [develop]
pull_request:
branches: [develop]
schedule:
- cron: '0 21 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['python']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
5 changes: 4 additions & 1 deletion .github/workflows/python_docs.yml
Original file line number Diff line number Diff line change
@@ -13,14 +13,17 @@ on:
types: [published] # update Docs upon new release

jobs:
docs:
api-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.8"
- uses: actions/setup-node@v1
with:
node-version: '12'
- name: Capture branch and tag
id: branch_name
run: |
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.7.0] - 2020-10-26

### Added
- **Utilities**: Add new `Parser` utility to provide parsing and deep data validation using Pydantic Models
- **Utilities**: Add case insensitive header lookup, and Cognito custom auth triggers to `Event source data classes`

### Fixed
- **Logger**: keeps Lambda root logger handler, and add log filter instead to prevent child log records duplication
- **Docs**: Improve wording on adding log keys conditionally

## [1.6.1] - 2020-09-23

### Fixed
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -4,18 +4,18 @@ target:

dev:
pip install --upgrade pip poetry pre-commit
poetry install --extras "jmespath"
poetry install --extras "pydantic"
pre-commit install

dev-docs:
cd docs && npm install
cd docs && yarn install

format:
poetry run isort -rc aws_lambda_powertools tests example
poetry run isort -rc aws_lambda_powertools tests
poetry run black aws_lambda_powertools tests

lint: format
poetry run flake8 aws_lambda_powertools/* tests/* example/*
poetry run flake8 aws_lambda_powertools/* tests/*

test:
poetry run pytest -vvv --cov=./ --cov-report=xml
@@ -26,7 +26,7 @@ coverage-html:
pr: lint test security-baseline complexity-baseline

build: pr
poetry run build
poetry build

build-docs:
@$(MAKE) build-docs-website
@@ -40,11 +40,11 @@ build-docs-api: dev

build-docs-website: dev-docs
mkdir -p dist
cd docs && npm run build
cd docs && yarn build
cp -R docs/public/* dist/

docs-local:
cd docs && npm run start
docs-local: dev-docs
cd docs && yarn start

docs-api-local:
poetry run pdoc --http : aws_lambda_powertools
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# AWS Lambda Powertools
# AWS Lambda Powertools (Python)

![Build](https://github.com/awslabs/aws-lambda-powertools/workflows/Powertools%20Python/badge.svg?branch=master)
![PythonSupport](https://img.shields.io/static/v1?label=python&message=3.6%20|%203.7|%203.8&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)

A suite of utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more.
A suite of Python utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. ([AWS Lambda Powertools Java](https://github.com/awslabs/aws-lambda-powertools-java) is also available).

**[📜Documentation](https://awslabs.github.io/aws-lambda-powertools-python/)** | **[API Docs](https://awslabs.github.io/aws-lambda-powertools-python/api/)** | **[🐍PyPi](https://pypi.org/project/aws-lambda-powertools/)** | **[Feature request](https://github.com/awslabs/aws-lambda-powertools-python/issues/new?assignees=&labels=feature-request%2C+triage&template=feature_request.md&title=)** | **[🐛Bug Report](https://github.com/awslabs/aws-lambda-powertools-python/issues/new?assignees=&labels=bug%2C+triage&template=bug_report.md&title=)** | **[Kitchen sink example](https://github.com/awslabs/aws-lambda-powertools-python/tree/develop/example)** | **[Detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-lambda-powertools/)**
**[📜Documentation](https://awslabs.github.io/aws-lambda-powertools-python/)** | **[API Docs](https://awslabs.github.io/aws-lambda-powertools-python/api/)** | **[🐍PyPi](https://pypi.org/project/aws-lambda-powertools/)** | **[Feature request](https://github.com/awslabs/aws-lambda-powertools-python/issues/new?assignees=&labels=feature-request%2C+triage&template=feature_request.md&title=)** | **[🐛Bug Report](https://github.com/awslabs/aws-lambda-powertools-python/issues/new?assignees=&labels=bug%2C+triage&template=bug_report.md&title=)** | **[Hello world example](https://github.com/aws-samples/cookiecutter-aws-sam-python)** | **[Detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-lambda-powertools/)**

> **Join us on the AWS Developers Slack at `#lambda-powertools`** - **[Invite, if you don't have an account](https://join.slack.com/t/awsdevelopers/shared_invite/zt-gu30gquv-EhwIYq3kHhhysaZ2aIX7ew)**
@@ -21,9 +21,11 @@ A suite of utilities for AWS Lambda functions to ease adopting best practices su

With [pip](https://pip.pypa.io/en/latest/index.html) installed, run: ``pip install aws-lambda-powertools``

## Example
## Examples

See **[example](./example/README.md)** of all features, testing, and a SAM template with all Powertools env vars. All features also provide full docs, and code completion for VSCode and PyCharm.
* [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)

## Credits

16 changes: 16 additions & 0 deletions aws_lambda_powertools/logging/filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import logging


class SuppressFilter(logging.Filter):
def __init__(self, logger):
self.logger = logger

def filter(self, record): # noqa: A003
"""Suppress Log Records from registered logger
It rejects log records from registered logger e.g. a child logger
otherwise it honours log propagation from any log record
created by loggers who don't have a handler.
"""
logger = record.name
return False if self.logger in logger else True
15 changes: 8 additions & 7 deletions aws_lambda_powertools/logging/logger.py
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
from typing import Any, Callable, Dict, Union

from .exceptions import InvalidLoggerSamplingRateError
from .filters import SuppressFilter
from .formatter import JsonFormatter
from .lambda_context import build_lambda_context_model

@@ -147,13 +148,6 @@ def _get_logger(self):
def _init_logger(self, **kwargs):
"""Configures new logger"""

# Lambda by default configures the root logger handler
# therefore, we need to remove it to prevent messages being logged twice
# when customers use our Logger
logger.debug("Removing Lambda root handler whether it exists")
root_logger = logging.getLogger()
root_logger.handlers.clear()

# Skip configuration if it's a child logger to prevent
# multiple handlers being attached as well as different sampling mechanisms
# and multiple messages from being logged as handlers can be duplicated
@@ -163,6 +157,13 @@ def _init_logger(self, **kwargs):
self._logger.addHandler(self._handler)
self.structure_logs(**kwargs)

logger.debug("Adding filter in root logger to suppress child logger records to bubble up")
for handler in logging.root.handlers:
# It'll add a filter to suppress any child logger from self.service
# Where service is Order, it'll reject parent logger Order,
# and child loggers such as Order.checkout, Order.shared
handler.addFilter(SuppressFilter(self.service))

def _configure_sampling(self):
"""Dynamically set log level based on sampling rate
Loading