From c999f4069ab423577cd214d0ca16c9022ba9346b Mon Sep 17 00:00:00 2001 From: Heitor Lessa Date: Thu, 7 Oct 2021 13:21:16 +0200 Subject: [PATCH 01/10] revert(metrics): typing regression on log_metrics callable (#744) --- aws_lambda_powertools/metrics/metrics.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/aws_lambda_powertools/metrics/metrics.py b/aws_lambda_powertools/metrics/metrics.py index 23e9f542eea..927b6873648 100644 --- a/aws_lambda_powertools/metrics/metrics.py +++ b/aws_lambda_powertools/metrics/metrics.py @@ -2,9 +2,8 @@ import json import logging import warnings -from typing import Any, Callable, Dict, Optional, Union, cast +from typing import Any, Callable, Dict, Optional, Union -from ..shared.types import AnyCallableT from .base import MetricManager, MetricUnit from .metric import single_metric @@ -130,7 +129,7 @@ def log_metrics( capture_cold_start_metric: bool = False, raise_on_empty_metrics: bool = False, default_dimensions: Optional[Dict[str, str]] = None, - ) -> AnyCallableT: + ): """Decorator to serialize and publish metrics at the end of a function execution. Be aware that the log_metrics **does call* the decorated function (e.g. lambda_handler). @@ -170,14 +169,11 @@ def handler(event, context): # Return a partial function with args filled if lambda_handler is None: logger.debug("Decorator called with parameters") - return cast( - AnyCallableT, - functools.partial( - self.log_metrics, - capture_cold_start_metric=capture_cold_start_metric, - raise_on_empty_metrics=raise_on_empty_metrics, - default_dimensions=default_dimensions, - ), + return functools.partial( + self.log_metrics, + capture_cold_start_metric=capture_cold_start_metric, + raise_on_empty_metrics=raise_on_empty_metrics, + default_dimensions=default_dimensions, ) @functools.wraps(lambda_handler) @@ -198,7 +194,7 @@ def decorate(event, context): return response - return cast(AnyCallableT, decorate) + return decorate def __add_cold_start_metric(self, context: Any) -> None: """Add cold start metric and function_name dimension From 51d15bb67d4c5ca4dcca99a492f346dafb3c11a2 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 7 Oct 2021 13:41:46 +0200 Subject: [PATCH 02/10] chore: add support for publishing fallback --- .github/workflows/publish.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 95296da6565..69416cb52fe 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,9 +23,21 @@ name: Publish to PyPi # 9. Push latest release source code to master using release title as the commit message # 10. Builds latest documentation for new release, and update latest alias pointing to the new release tag +# +# === Fallback mechanism due to external failures === +# +# 1. Trigger "Publish to PyPi" workflow manually: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow +# 2. Use the version released under Releases e.g. v1.13.0 +# + on: release: types: [published] + workflow_dispatch: + inputs: + publish_version: + description: 'Version to publish, e.g. v1.13.0' + required: true jobs: release: @@ -40,7 +52,9 @@ jobs: python-version: "3.8" - name: Set release notes tag run: | - export RELEASE_TAG_VERSION=${{ github.event.release.tag_name }} + RELEASE_TAG_VERSION=${{ github.event.release.tag_name }} + # Replace publishing version if the workflow was triggered manually + test -n $RELEASE_TAG_VERSION && RELEASE_TAG_VERSION=${{ github.event.inputs.publish_version }} echo "RELEASE_TAG_VERSION=${RELEASE_TAG_VERSION:1}" >> $GITHUB_ENV - name: Ensure new version is also set in pyproject and CHANGELOG run: | From b1f890815ef3fcc06ef9875366dc8690eba383cd Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 7 Oct 2021 13:57:20 +0200 Subject: [PATCH 03/10] chore: ignore constants in tests cov --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index abcff627870..92d0f306e89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,7 +61,7 @@ pydantic = ["pydantic", "email-validator"] [tool.coverage.run] source = ["aws_lambda_powertools"] -omit = ["tests/*", "aws_lambda_powertools/exceptions/*", "aws_lambda_powertools/utilities/parser/types.py"] +omit = ["tests/*", "aws_lambda_powertools/exceptions/*", "aws_lambda_powertools/utilities/parser/types.py", "aws_lambda_powertools/utilities/jmespath_utils/envelopes.py"] branch = true [tool.coverage.html] From 721eacddf68b77dab1f78b0d2477f9e0d05a1b26 Mon Sep 17 00:00:00 2001 From: Heitor Lessa Date: Thu, 7 Oct 2021 14:10:10 +0200 Subject: [PATCH 04/10] chore: ignore constants in test cov (#745) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index abcff627870..92d0f306e89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,7 +61,7 @@ pydantic = ["pydantic", "email-validator"] [tool.coverage.run] source = ["aws_lambda_powertools"] -omit = ["tests/*", "aws_lambda_powertools/exceptions/*", "aws_lambda_powertools/utilities/parser/types.py"] +omit = ["tests/*", "aws_lambda_powertools/exceptions/*", "aws_lambda_powertools/utilities/parser/types.py", "aws_lambda_powertools/utilities/jmespath_utils/envelopes.py"] branch = true [tool.coverage.html] From fc91f4218d6df0e235e5108abe797b3d7fa8a04b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Oct 2021 12:11:03 +0000 Subject: [PATCH 05/10] chore(deps-dev): bump mkdocs-material from 7.3.1 to 7.3.2 (#741) Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 7.3.1 to 7.3.2.
Release notes

Sourced from mkdocs-material's releases.

mkdocs-material-7.3.2

  • Deprecated prebuilding of search index
  • Improved graceful handling of broken search for file://
  • Added minimum Jinja version to list of requirements
  • Fixed #3071: section index pages render empty directories
  • Fixed margin issues when using navigation tabs (7.3.1 regression)
  • Fixed search placeholder sometimes being shown too early
Changelog

Sourced from mkdocs-material's changelog.

7.3.2 _ October 6, 2021

  • Deprecated prebuilding of search index
  • Improved graceful handling of broken search for file://
  • Added minimum Jinja version to list of requirements
  • Fixed #3071: section index pages render empty directories
  • Fixed margin issues when using navigation tabs (7.3.1 regression)
  • Fixed search placeholder sometimes being shown too early
Commits
  • 792a425 Prepare 7.3.2 release
  • 8779d78 Fixed race condition ehen displaying search result metadata
  • 905c8b7 Added Jinja to list of dependencies (see #3085)
  • 36fac52 Updated dependencies
  • e7c799f Fixed top margin of navigation when using navigation.tabs (7.3.1 regression)
  • 88ed401 Improved graceful handling of broken search when browsing locally
  • 149b0db Fixed rendering of section index pages with no other pages
  • e229280 Updated Insiders video
  • eb4afa0 Deprecated prebuilding of search index
  • aaba4cb Updated content tabs documentation
  • See full diff in compare view

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=mkdocs-material&package-manager=pip&previous-version=7.3.1&new-version=7.3.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- poetry.lock | 11 ++++++----- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/poetry.lock b/poetry.lock index 8e6806f9848..063cded6efb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -577,17 +577,18 @@ mkdocs = ">=0.17" [[package]] name = "mkdocs-material" -version = "7.3.1" +version = "7.3.2" description = "A Material Design theme for MkDocs" category = "dev" optional = false python-versions = "*" [package.dependencies] +jinja2 = ">=2.11.1" markdown = ">=3.2" mkdocs = ">=1.2.2" mkdocs-material-extensions = ">=1.0" -Pygments = ">=2.4" +pygments = ">=2.4" pymdown-extensions = ">=9.0" [[package]] @@ -1054,7 +1055,7 @@ pydantic = ["pydantic", "email-validator"] [metadata] lock-version = "1.1" python-versions = "^3.6.1" -content-hash = "a0358de807bcf4fe1af43ac28f40f41552d559b11cfc5ebd099a4e3842f87a8d" +content-hash = "829128c92690e9cfa6ed3387bb6927fcca65a5478baadb59db5c489b99f71bfd" [metadata.files] appdirs = [ @@ -1327,8 +1328,8 @@ mkdocs-git-revision-date-plugin = [ {file = "mkdocs_git_revision_date_plugin-0.3.1-py3-none-any.whl", hash = "sha256:8ae50b45eb75d07b150a69726041860801615aae5f4adbd6b1cf4d51abaa03d5"}, ] mkdocs-material = [ - {file = "mkdocs-material-7.3.1.tar.gz", hash = "sha256:d1ab269da2025f22b8fba079d7eadc05cd97ac2a21d87b09d414e69915f247a7"}, - {file = "mkdocs_material-7.3.1-py2.py3-none-any.whl", hash = "sha256:8d59c8ac241d59eef1a883c49ca685c8d8446eb054675a212fb748daff24099c"}, + {file = "mkdocs-material-7.3.2.tar.gz", hash = "sha256:02aeb2f9d9826b5c5ba4e320b4008bdc89f7b30ca00ded72ee43385a1690eaa4"}, + {file = "mkdocs_material-7.3.2-py2.py3-none-any.whl", hash = "sha256:a9b7c6432ebadd0e192e3b341b25bd41bd1c1b167061ea629a9887a1e4129176"}, ] mkdocs-material-extensions = [ {file = "mkdocs-material-extensions-1.0.1.tar.gz", hash = "sha256:6947fb7f5e4291e3c61405bad3539d81e0b3cd62ae0d66ced018128af509c68f"}, diff --git a/pyproject.toml b/pyproject.toml index 92d0f306e89..b02f9576c14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ radon = "^5.1.0" xenon = "^0.8.0" flake8-eradicate = "^1.1.0" flake8-bugbear = "^21.9.2" -mkdocs-material = "^7.3.1" +mkdocs-material = "^7.3.2" mkdocs-git-revision-date-plugin = "^0.3.1" mike = "^0.6.0" mypy = "^0.910" From 54ab069f003503244679d5b6b209fa4800b44b63 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Oct 2021 12:12:28 +0000 Subject: [PATCH 06/10] chore(deps): bump boto3 from 1.18.54 to 1.18.56 (#742) Bumps [boto3](https://github.com/boto/boto3) from 1.18.54 to 1.18.56.
Changelog

Sourced from boto3's changelog.

1.18.56

  • api-change:sagemaker: [botocore] This release adds a new TrainingInputMode FastFile for SageMaker Training APIs.
  • api-change:amplifybackend: [botocore] Adding a new field 'AmplifyFeatureFlags' to the response of the GetBackend operation. It will return a stringified version of the cli.json file for the given Amplify project.
  • api-change:fsx: [botocore] This release adds support for Lustre 2.12 to FSx for Lustre.
  • api-change:kendra: [botocore] Amazon Kendra now supports integration with AWS SSO

1.18.55

  • api-change:workmail: [botocore] This release allows customers to change their inbound DMARC settings in Amazon WorkMail.
  • api-change:location: [botocore] Add support for PositionFiltering.
  • api-change:application-autoscaling: [botocore] With this release, Application Auto Scaling adds support for Amazon Neptune. Customers can now automatically add or remove Read Replicas of their Neptune clusters to keep the average CPU Utilization at the target value specified by the customers.
  • api-change:ec2: [botocore] Released Capacity Reservation Fleet, a feature of Amazon EC2 Capacity Reservations, which provides a way to manage reserved capacity across instance types. For more information: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/cr-fleets.html
  • api-change:glue: [botocore] This release adds tag as an input of CreateConnection
  • api-change:backup: [botocore] AWS Backup Audit Manager framework report.
Commits
  • c2fe784 Merge branch 'release-1.18.56'
  • afb6b72 Bumping version to 1.18.56
  • f8156ab Add changelog entries from botocore
  • 7890ec6 Merge branch 'release-1.18.55'
  • d682c56 Merge branch 'release-1.18.55' into develop
  • b34c969 Bumping version to 1.18.55
  • 1cfb183 Add changelog entries from botocore
  • 91a6dad Merge branch 'release-1.18.54' into develop
  • See full diff in compare view

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=boto3&package-manager=pip&previous-version=1.18.54&new-version=1.18.56)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- poetry.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/poetry.lock b/poetry.lock index 063cded6efb..1d1e5366e12 100644 --- a/poetry.lock +++ b/poetry.lock @@ -81,14 +81,14 @@ d = ["aiohttp (>=3.3.2)", "aiohttp-cors"] [[package]] name = "boto3" -version = "1.18.54" +version = "1.18.56" description = "The AWS SDK for Python" category = "main" optional = false python-versions = ">= 3.6" [package.dependencies] -botocore = ">=1.21.54,<1.22.0" +botocore = ">=1.21.56,<1.22.0" jmespath = ">=0.7.1,<1.0.0" s3transfer = ">=0.5.0,<0.6.0" @@ -97,7 +97,7 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.21.54" +version = "1.21.56" description = "Low-level, data-driven core of boto 3." category = "main" optional = false @@ -1082,12 +1082,12 @@ black = [ {file = "black-20.8b1.tar.gz", hash = "sha256:1c02557aa099101b9d21496f8a914e9ed2222ef70336404eeeac8edba836fbea"}, ] boto3 = [ - {file = "boto3-1.18.54-py3-none-any.whl", hash = "sha256:f22a77098cd70ddf848df6981ec57b92178e9d8eb74637edbdf4173bfa9279fa"}, - {file = "boto3-1.18.54.tar.gz", hash = "sha256:2d81dc484020059fc738165984304107d4db1c6774b6310d08c892a1751f6980"}, + {file = "boto3-1.18.56-py3-none-any.whl", hash = "sha256:42828d83acddfa2361411b13683eedf7c1c0a15e896b45960ed04a26efe7adfb"}, + {file = "boto3-1.18.56.tar.gz", hash = "sha256:d43e3651ad1b0b5de6f77df82df27e0f1e6cd854f725c808c70a1fb956f0b699"}, ] botocore = [ - {file = "botocore-1.21.54-py3-none-any.whl", hash = "sha256:56b74a5186bec835baf580b2d062ea1738d3ff5a573653d41b3ad1598a5b77c4"}, - {file = "botocore-1.21.54.tar.gz", hash = "sha256:46127b3a385d0ec73d1994b8958b23b79e0613e12c486371a100df992b72a1b9"}, + {file = "botocore-1.21.56-py3-none-any.whl", hash = "sha256:d712f572022670916bd77fbe421155dcf575398b9dced88035ed3658679883bd"}, + {file = "botocore-1.21.56.tar.gz", hash = "sha256:43fab79905e3dfe56f92a137314ef1afbf040f7c06516a003351c24322cbfd7c"}, ] certifi = [ {file = "certifi-2020.12.5-py2.py3-none-any.whl", hash = "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"}, From 225947e329fd84f64be560fcd38b8eb47ea71d54 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 7 Oct 2021 14:19:14 +0200 Subject: [PATCH 07/10] chore: include regression in changelog --- .chglog/CHANGELOG.tpl.md | 2 +- .chglog/config.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.chglog/CHANGELOG.tpl.md b/.chglog/CHANGELOG.tpl.md index ed0c0f823f6..b1fa7de1f58 100755 --- a/.chglog/CHANGELOG.tpl.md +++ b/.chglog/CHANGELOG.tpl.md @@ -1,6 +1,6 @@ {{ if .Versions -}} -## [Unreleased] +## Unreleased {{ if .Unreleased.CommitGroups -}} {{ range .Unreleased.CommitGroups -}} diff --git a/.chglog/config.yml b/.chglog/config.yml index 035aa04e2fa..3392563d445 100755 --- a/.chglog/config.yml +++ b/.chglog/config.yml @@ -13,6 +13,7 @@ options: - refactor - docs - chore + - revert commit_groups: title_maps: feat: Features @@ -21,6 +22,7 @@ options: refactor: Code Refactoring docs: Documentation chore: Maintenance + revert: Regression header: pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$" pattern_maps: From 03349841a29313327b53f6bb158727f92a889107 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 7 Oct 2021 14:19:33 +0200 Subject: [PATCH 08/10] chore: bump to 1.21.1 --- CHANGELOG.md | 13 +++++++++++++ pyproject.toml | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70b8d32c004..1491639500a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,19 @@ This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) fo ## [Unreleased] +## 1.21.1 - 2021-10-07 + +### Regression + +* **metrics:** typing regression on log_metrics callable ([#744](https://github.com/awslabs/aws-lambda-powertools-python/issues/744)) + +### Maintenance + +* ignore constants in test cov ([#745](https://github.com/awslabs/aws-lambda-powertools-python/issues/745)) +* github-actions: add support for publishing fallback +* **deps:** bump boto3 from 1.18.54 to 1.18.56 ([#742](https://github.com/awslabs/aws-lambda-powertools-python/issues/742)) +* **deps-dev:** bump mkdocs-material from 7.3.1 to 7.3.2 ([#741](https://github.com/awslabs/aws-lambda-powertools-python/issues/741)) + ## 1.21.0 - 2021-10-05 ### Bug Fixes diff --git a/pyproject.toml b/pyproject.toml index b02f9576c14..19797484c8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "aws_lambda_powertools" -version = "1.21.0" +version = "1.21.1" description = "A suite of utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, batching, idempotency, feature flags, and more." authors = ["Amazon Web Services"] include = ["aws_lambda_powertools/py.typed", "THIRD-PARTY-LICENSES"] From 767987cddd3fcee247008b0c9bceaefa471a0944 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 7 Oct 2021 17:12:07 +0200 Subject: [PATCH 09/10] docs: add new public layer ARNs (#746) Co-authored-by: heitorlessa --- docs/index.md | 121 ++++++++++++++++++++++++++++++++++++- docs/javascript/extra.js | 20 +++++- docs/stylesheets/extra.css | 5 ++ mkdocs.yml | 1 + 4 files changed, 145 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index b79a2e7074f..7f58de4fe8a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -36,7 +36,126 @@ Powertools is available in PyPi. You can use your favourite dependency managemen ### Lambda Layer -Powertools is also available as a Lambda Layer, and it is distributed via the [AWS Serverless Application Repository (SAR)](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html) to support semantic versioning. +Powertools is also available as a Lambda Layer with public ARNs in each region or distributed via the [AWS Serverless Application Repository (SAR)](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html) to support semantic versioning. + +#### Public ARNs + +We build, release and distribute packaged Lambda Powertools layers for each region. This means you can copy a specific ARN and use it in your Lambda deployment. The layer region must be equal to the region of your lambda function. The public layers do not contain the `pydantic` library that is required for the `parser` utility. + + +=== "SAM" + + ```yaml hl_lines="5" + MyLambdaFunction: + Type: AWS::Serverless::Function + Properties: + Layers: + - arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3 + ``` + +=== "Serverless framework" + + ```yaml hl_lines="5" + functions: + main: + handler: lambda_function.lambda_handler + layers: + - arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3 + ``` + +=== "CDK" + + ```python hl_lines="14" + from aws_cdk import core, aws_lambda + + class SampleApp(core.Construct): + + def __init__(self, scope: core.Construct, id_: str) -> None: + super().__init__(scope, id_) + + aws_lambda.Function(self, + 'sample-app-lambda', + runtime=aws_lambda.Runtime.PYTHON_3_8, + function_name='sample-lambda', + code=aws_lambda.Code.asset('./src'), + handler='app.handler', + layers: ["arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3"] + ) + ``` + +=== "Terraform" + + ```terraform hl_lines="9 38" + terraform { + required_version = "~> 1.0.5" + required_providers { + aws = "~> 3.50.0" + } + } + + provider "aws" { + region = "us-east-1" + } + + resource "aws_iam_role" "iam_for_lambda" { + name = "iam_for_lambda" + + assume_role_policy = < { +function copyToClipboard(e) { + e.preventDefault() + navigator.clipboard.writeText(e.target.textContent) + alert$.next("Copied to clipboard") +} + +function enableSearchOnBlurElement() { /* Register handler to log search on blur */ document.addEventListener("DOMContentLoaded", function () { recordPageView({ @@ -41,6 +47,18 @@ const attachListeners = () => { }; } +function enableClipboardElements() { + let copyElements = document.querySelectorAll('.copyMe'); + copyElements.forEach(element => { + element.addEventListener('click', copyToClipboard); + }) +} + +const attachListeners = () => { + enableSearchOnBlurElement() + enableClipboardElements() +} + const init = () => { Analytics.addPluggable(new KinesisFirehoseProvider()) Amplify.configure(awsconfig); diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index f24b32faa14..0d37af692cb 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -33,3 +33,8 @@ [data-md-color-scheme="slate"] { --md-typeset-a-color: rgb(28, 152, 152) } + +.copyMe { + cursor: pointer; + border-bottom: 0.1px dashed black; +} diff --git a/mkdocs.yml b/mkdocs.yml index b90ba4376de..fc51acb8b47 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -69,6 +69,7 @@ markdown_extensions: - attr_list - pymdownx.emoji - pymdownx.inlinehilite + - attr_list copyright: Copyright © 2021 Amazon Web Services From eff5a17376855e957e65caa309735620c1525970 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 7 Oct 2021 17:14:01 +0200 Subject: [PATCH 10/10] chore: include public layers changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1491639500a..41065b6c722 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) fo * **metrics:** typing regression on log_metrics callable ([#744](https://github.com/awslabs/aws-lambda-powertools-python/issues/744)) +### Documentation + +* add new public layer ARNs ([#746](https://github.com/awslabs/aws-lambda-powertools-python/issues/746)) ### Maintenance * ignore constants in test cov ([#745](https://github.com/awslabs/aws-lambda-powertools-python/issues/745))