diff --git a/.github/workflows/publish_v2_layer.yml b/.github/workflows/publish_v2_layer.yml new file mode 100644 index 00000000000..469a94ad876 --- /dev/null +++ b/.github/workflows/publish_v2_layer.yml @@ -0,0 +1,92 @@ +name: Deploy v2 layer to all regions + +permissions: + id-token: write + contents: read + +on: + workflow_dispatch: + inputs: + latest_published_version: + description: "Latest PyPi published version to rebuild latest docs for, e.g. v1.22.0" + default: "v2.0.0" + required: true + # workflow_run: + # workflows: ["Publish to PyPi"] + # types: + # - completed + +jobs: + build-layer: + runs-on: ubuntu-latest + if: ${{ (github.event.workflow_run.conclusion == 'success') || (github.event_name == 'workflow_dispatch') }} + defaults: + run: + working-directory: ./layer + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Install poetry + run: pipx install poetry + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "16.12" + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: "3.9" + cache: "pip" + - name: Resolve and install project dependencies + # CDK spawns system python when compiling stack + # therefore it ignores both activated virtual env and cached interpreter by GH + run: | + poetry export --format requirements.txt --output requirements.txt + pip install -r requirements.txt + - name: Set release notes tag + run: | + RELEASE_INPUT=${{ inputs.latest_published_version }} + LATEST_TAG=$(git describe --tag --abbrev=0) + RELEASE_TAG_VERSION=${RELEASE_INPUT:-$LATEST_TAG} + echo RELEASE_TAG_VERSION="${RELEASE_TAG_VERSION:1}" >> "$GITHUB_ENV" + - name: Set up QEMU + uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 # v2.0.0 + # NOTE: we need QEMU to build Layer against a different architecture (e.g., ARM) + - name: Set up Docker Buildx + id: builder + uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v2.0.0 + - name: install cdk and deps + run: | + npm install -g aws-cdk@2.44.0 + cdk --version + - name: CDK build + run: cdk synth --context version="$RELEASE_TAG_VERSION" -o cdk.out + - name: zip output + run: zip -r cdk.out.zip cdk.out + - name: Archive CDK artifacts + uses: actions/upload-artifact@v3 + with: + name: cdk-layer-artefact + path: layer/cdk.out.zip + + deploy-beta: + needs: + - build-layer + uses: ./.github/workflows/reusable_deploy_v2_layer_stack.yml + secrets: inherit + with: + stage: "BETA" + artefact-name: "cdk-layer-artefact" + environment: "layer-beta" + + # deploy-prod: + # needs: + # - deploy-beta + # uses: ./.github/workflows/reusable_deploy_layer_stack.yml + # secrets: inherit + # with: + # stage: "PROD" + # artefact-name: "cdk-layer-artefact" + # environment: "layer-prod" diff --git a/.github/workflows/reusable_deploy_v2_layer_stack.yml b/.github/workflows/reusable_deploy_v2_layer_stack.yml new file mode 100644 index 00000000000..8c4d45c7708 --- /dev/null +++ b/.github/workflows/reusable_deploy_v2_layer_stack.yml @@ -0,0 +1,102 @@ +name: Deploy CDK Layer v2 stack + +permissions: + id-token: write + contents: read + +env: + CDK_VERSION: 2.44.0 + +on: + workflow_call: + inputs: + stage: + description: "Deployment stage (BETA, PROD)" + required: true + type: string + artefact-name: + description: "CDK Layer Artefact name to download" + required: true + type: string + environment: + description: "GitHub Environment to use for encrypted secrets" + required: true + type: string + +jobs: + deploy-cdk-stack: + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + defaults: + run: + working-directory: ./layer + strategy: + fail-fast: false + matrix: + region: + [ + "af-south-1", + "eu-central-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + "ap-east-1", + "ap-south-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "eu-south-1", + "eu-north-1", + "sa-east-1", + "ap-southeast-3", + "ap-northeast-3", + "me-south-1", + ] + steps: + - name: checkout + uses: actions/checkout@v3 + - name: Install poetry + run: pipx install poetry + - name: aws credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-region: ${{ matrix.region }} + role-to-assume: ${{ secrets.AWS_LAYERS_ROLE_ARN }} + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "16.12" + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: "3.9" + cache: "pip" + - name: Resolve and install project dependencies + # CDK spawns system python when compiling stack + # therefore it ignores both activated virtual env and cached interpreter by GH + run: | + poetry export --format requirements.txt --output requirements.txt + pip install -r requirements.txt + - name: install cdk and deps + run: | + npm install -g "aws-cdk@$CDK_VERSION" + cdk --version + - name: install deps + run: poetry install + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.artefact-name }} + path: layer + - name: unzip artefact + run: unzip cdk.out.zip + - name: CDK Deploy Layer + run: cdk deploy --app cdk.out --context region=${{ matrix.region }} 'LayerStack' --require-approval never --verbose + - name: CDK Deploy Canary + run: cdk deploy --app cdk.out --context region=${{ matrix.region}} --parameters DeployStage="${{ inputs.stage }}" 'CanaryStack' --require-approval never --verbose diff --git a/Makefile b/Makefile index 7a212738c53..ba4c2943f84 100644 --- a/Makefile +++ b/Makefile @@ -6,12 +6,12 @@ target: dev: pip install --upgrade pip pre-commit poetry - poetry install --extras "pydantic" + poetry install --extras "all" pre-commit install dev-gitpod: pip install --upgrade pip poetry - poetry install --extras "pydantic" + poetry install --extras "all" pre-commit install format: diff --git a/layer/app.py b/layer/app.py index 50f8090482e..e44b05d453d 100644 --- a/layer/app.py +++ b/layer/app.py @@ -8,7 +8,8 @@ app = cdk.App() POWERTOOLS_VERSION: str = app.node.try_get_context("version") -SSM_PARAM_LAYER_ARN: str = "/layers/powertools-layer-arn" +SSM_PARAM_LAYER_ARN: str = "/layers/powertools-layer-v2-arn" +SSM_PARAM_LAYER_ARM64_ARN: str = "/layers/powertools-layer-v2-arm64-arn" if not POWERTOOLS_VERSION: raise ValueError( @@ -21,6 +22,7 @@ "LayerStack", powertools_version=POWERTOOLS_VERSION, ssm_paramter_layer_arn=SSM_PARAM_LAYER_ARN, + ssm_parameter_layer_arm64_arn=SSM_PARAM_LAYER_ARM64_ARN, ) CanaryStack( @@ -28,6 +30,7 @@ "CanaryStack", powertools_version=POWERTOOLS_VERSION, ssm_paramter_layer_arn=SSM_PARAM_LAYER_ARN, + ssm_parameter_layer_arm64_arn=SSM_PARAM_LAYER_ARM64_ARN, ) app.synth() diff --git a/layer/layer/canary/app.py b/layer/layer/canary/app.py index 1011fc654c2..b577eff7fa5 100644 --- a/layer/layer/canary/app.py +++ b/layer/layer/canary/app.py @@ -1,14 +1,19 @@ import datetime import json import os +import platform from importlib.metadata import version import boto3 +from pydantic import EmailStr from aws_lambda_powertools import Logger, Metrics, Tracer +from aws_lambda_powertools.utilities.parser import BaseModel, envelopes, event_parser +from aws_lambda_powertools.utilities.typing import LambdaContext +from aws_lambda_powertools.utilities.validation import validator logger = Logger(service="version-track") -tracer = Tracer() +tracer = Tracer() # this checks for aws-xray-sdk presence metrics = Metrics(namespace="powertools-layer-canary", service="PowertoolsLayerCanary") layer_arn = os.getenv("POWERTOOLS_LAYER_ARN") @@ -17,6 +22,26 @@ event_bus_arn = os.getenv("VERSION_TRACKING_EVENT_BUS_ARN") +# Model to check parser imports correctly, tests for pydantic and email-validator +class OrderItem(BaseModel): + order_id: int + quantity: int + description: str + email: EmailStr + + +# Tests for jmespath presence +@event_parser(model=OrderItem, envelope=envelopes.EventBridgeEnvelope) +def envelope_handler(event: OrderItem, context: LambdaContext): + assert event.order_id != 1 + + +# Tests for fastjsonschema presence +@validator(inbound_schema={}, envelope="detail") +def validator_handler(event, context: LambdaContext): + pass + + def handler(event): logger.info("Running checks") check_envs() @@ -42,9 +67,7 @@ def on_create(event): def check_envs(): - logger.info( - 'Checking required envs ["POWERTOOLS_LAYER_ARN", "AWS_REGION", "STAGE"]' - ) + logger.info('Checking required envs ["POWERTOOLS_LAYER_ARN", "AWS_REGION", "STAGE"]') if not layer_arn: raise ValueError("POWERTOOLS_LAYER_ARN is not set. Aborting...") if not powertools_version: @@ -66,9 +89,9 @@ def verify_powertools_version() -> None: current_version = version("aws_lambda_powertools") if powertools_version != current_version: raise ValueError( - f'Expected powertoosl version is "{powertools_version}", but layer contains version "{current_version}"' + f'Expected Powertools version is "{powertools_version}", but layer contains version "{current_version}"' ) - logger.info(f"Current Powertools version is: {current_version}") + logger.info(f"Current Powertools version is: {current_version} [{_get_architecture()}]") def send_notification(): @@ -76,10 +99,9 @@ def send_notification(): sends an event to version tracking event bridge """ if stage != "PROD": - logger.info( - "Not sending notification to event bus, because this is not the PROD stage" - ) + logger.info("Not sending notification to event bus, because this is not the PROD stage") return + event = { "Time": datetime.datetime.now(), "Source": "powertools.layer.canary", @@ -90,6 +112,7 @@ def send_notification(): "version": powertools_version, "region": os.environ["AWS_REGION"], "layerArn": layer_arn, + "architecture": _get_architecture(), } ), } @@ -102,3 +125,8 @@ def send_notification(): if resp["FailedEntryCount"] != 0: logger.error(resp) raise ValueError("Failed to send deployment notification to version tracking") + + +def _get_architecture() -> str: + """Returns aarch64, x86_64""" + return platform.uname()[4] diff --git a/layer/layer/canary_stack.py b/layer/layer/canary_stack.py index 426b3a4c87c..fda9ebff3ad 100644 --- a/layer/layer/canary_stack.py +++ b/layer/layer/canary_stack.py @@ -2,12 +2,16 @@ from aws_cdk import CfnParameter, CustomResource, Duration, Stack from aws_cdk.aws_iam import Effect, ManagedPolicy, PolicyStatement, Role, ServicePrincipal -from aws_cdk.aws_lambda import Code, Function, LayerVersion, Runtime +from aws_cdk.aws_lambda import Architecture, Code, Function, LayerVersion, Runtime from aws_cdk.aws_logs import RetentionDays from aws_cdk.aws_ssm import StringParameter from aws_cdk.custom_resources import Provider from constructs import Construct +VERSION_TRACKING_EVENT_BUS_ARN: str = ( + "arn:aws:events:eu-central-1:027876851704:event-bus/VersionTrackingEventBus" +) + class CanaryStack(Stack): def __init__( @@ -16,29 +20,74 @@ def __init__( construct_id: str, powertools_version: str, ssm_paramter_layer_arn: str, + ssm_parameter_layer_arm64_arn: str, **kwargs, ) -> None: super().__init__(scope, construct_id, **kwargs) - VERSION_TRACKING_EVENT_BUS_ARN: str = ( - "arn:aws:events:eu-central-1:027876851704:event-bus/VersionTrackingEventBus" - ) + deploy_stage = CfnParameter( + self, "DeployStage", description="Deployment stage for canary" + ).value_as_string layer_arn = StringParameter.from_string_parameter_attributes( self, "LayerVersionArnParam", parameter_name=ssm_paramter_layer_arn ).string_value + Canary( + self, + "Canary-x86-64", + layer_arn=layer_arn, + powertools_version=powertools_version, + architecture=Architecture.X86_64, + stage=deploy_stage, + ) + + layer_arm64_arn = StringParameter.from_string_parameter_attributes( + self, + "LayerArm64VersionArnParam", + parameter_name=ssm_parameter_layer_arm64_arn, + ).string_value + Canary( + self, + "Canary-arm64", + layer_arn=layer_arm64_arn, + powertools_version=powertools_version, + architecture=Architecture.ARM_64, + stage=deploy_stage, + ) + + +class Canary(Construct): + def __init__( + self, + scope: Construct, + construct_id: str, + layer_arn: str, + powertools_version: str, + architecture: Architecture, + stage: str, + ): + super().__init__(scope, construct_id) - layer = LayerVersion.from_layer_version_arn(self, "PowertoolsLayer", layer_version_arn=layer_arn) - deploy_stage = CfnParameter(self, "DeployStage", description="Deployment stage for canary").value_as_string + layer = LayerVersion.from_layer_version_arn( + self, "PowertoolsLayer", layer_version_arn=layer_arn + ) - execution_role = Role(self, "LambdaExecutionRole", assumed_by=ServicePrincipal("lambda.amazonaws.com")) + execution_role = Role( + self, + "LambdaExecutionRole", + assumed_by=ServicePrincipal("lambda.amazonaws.com"), + ) execution_role.add_managed_policy( - ManagedPolicy.from_aws_managed_policy_name("service-role/AWSLambdaBasicExecutionRole") + ManagedPolicy.from_aws_managed_policy_name( + "service-role/AWSLambdaBasicExecutionRole" + ) ) execution_role.add_to_policy( - PolicyStatement(effect=Effect.ALLOW, actions=["lambda:GetFunction"], resources=["*"]) + PolicyStatement( + effect=Effect.ALLOW, actions=["lambda:GetFunction"], resources=["*"] + ) ) canary_lambda = Function( @@ -50,25 +99,35 @@ def __init__( memory_size=512, timeout=Duration.seconds(10), runtime=Runtime.PYTHON_3_9, + architecture=architecture, log_retention=RetentionDays.ONE_MONTH, role=execution_role, environment={ "POWERTOOLS_VERSION": powertools_version, "POWERTOOLS_LAYER_ARN": layer_arn, "VERSION_TRACKING_EVENT_BUS_ARN": VERSION_TRACKING_EVENT_BUS_ARN, - "LAYER_PIPELINE_STAGE": deploy_stage, + "LAYER_PIPELINE_STAGE": stage, }, ) canary_lambda.add_to_role_policy( PolicyStatement( - effect=Effect.ALLOW, actions=["events:PutEvents"], resources=[VERSION_TRACKING_EVENT_BUS_ARN] + effect=Effect.ALLOW, + actions=["events:PutEvents"], + resources=[VERSION_TRACKING_EVENT_BUS_ARN], ) ) # custom resource provider configuration provider = Provider( - self, "CanaryCustomResource", on_event_handler=canary_lambda, log_retention=RetentionDays.ONE_MONTH + self, + "CanaryCustomResource", + on_event_handler=canary_lambda, + log_retention=RetentionDays.ONE_MONTH, ) # force to recreate resource on each deployment with randomized name - CustomResource(self, f"CanaryTrigger-{str(uuid.uuid4())[0:7]}", service_token=provider.service_token) + CustomResource( + self, + f"CanaryTrigger-{str(uuid.uuid4())[0:7]}", + service_token=provider.service_token, + ) diff --git a/layer/layer/layer_stack.py b/layer/layer/layer_stack.py index f15232eb560..6a92e1fa408 100644 --- a/layer/layer/layer_stack.py +++ b/layer/layer/layer_stack.py @@ -1,18 +1,38 @@ from aws_cdk import CfnOutput, RemovalPolicy, Stack -from aws_cdk.aws_lambda import CfnLayerVersionPermission +from aws_cdk.aws_lambda import Architecture, CfnLayerVersionPermission from aws_cdk.aws_ssm import StringParameter -from cdk_lambda_powertools_python_layer import LambdaPowertoolsLayer +from cdk_aws_lambda_powertools_layer import LambdaPowertoolsLayer from constructs import Construct class LayerStack(Stack): def __init__( - self, scope: Construct, construct_id: str, powertools_version: str, ssm_paramter_layer_arn: str, **kwargs + self, + scope: Construct, + construct_id: str, + powertools_version: str, + ssm_paramter_layer_arn: str, + ssm_parameter_layer_arm64_arn: str, + **kwargs ) -> None: super().__init__(scope, construct_id, **kwargs) layer = LambdaPowertoolsLayer( - self, "Layer", layer_version_name="AWSLambdaPowertoolsPython", version=powertools_version + self, + "Layer", + layer_version_name="AWSLambdaPowertoolsPythonV2", + version=powertools_version, + include_extras=True, + compatible_architectures=[Architecture.X86_64], + ) + + layer_arm64 = LambdaPowertoolsLayer( + self, + "Layer-ARM64", + layer_version_name="AWSLambdaPowertoolsPythonV2-Arm64", + version=powertools_version, + include_extras=True, + compatible_architectures=[Architecture.ARM_64], ) layer_permission = CfnLayerVersionPermission( @@ -23,9 +43,32 @@ def __init__( principal="*", ) + layer_permission_arm64 = CfnLayerVersionPermission( + self, + "PublicLayerAccessArm64", + action="lambda:GetLayerVersion", + layer_version_arn=layer_arm64.layer_version_arn, + principal="*", + ) + layer_permission.apply_removal_policy(RemovalPolicy.RETAIN) + layer_permission_arm64.apply_removal_policy(RemovalPolicy.RETAIN) + layer.apply_removal_policy(RemovalPolicy.RETAIN) + layer_arm64.apply_removal_policy(RemovalPolicy.RETAIN) - StringParameter(self, "VersionArn", parameter_name=ssm_paramter_layer_arn, string_value=layer.layer_version_arn) + StringParameter( + self, + "VersionArn", + parameter_name=ssm_paramter_layer_arn, + string_value=layer.layer_version_arn, + ) + StringParameter( + self, + "Arm64VersionArn", + parameter_name=ssm_parameter_layer_arm64_arn, + string_value=layer_arm64.layer_version_arn, + ) CfnOutput(self, "LatestLayerArn", value=layer.layer_version_arn) + CfnOutput(self, "LatestLayerArm64Arn", value=layer_arm64.layer_version_arn) diff --git a/layer/poetry.lock b/layer/poetry.lock index 182094a8b9d..6720fc5b96a 100644 --- a/layer/poetry.lock +++ b/layer/poetry.lock @@ -1,28 +1,20 @@ -[[package]] -name = "atomicwrites" -version = "1.4.1" -description = "Atomic file writes." -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" - [[package]] name = "attrs" -version = "21.4.0" +version = "22.1.0" description = "Classes Without Boilerplate" category = "main" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +python-versions = ">=3.5" [package.extras] -dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"] +dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "mypy (>=0.900,!=0.940)", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"] docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"] -tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"] -tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"] +tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "mypy (>=0.900,!=0.940)", "pytest-mypy-plugins", "zope.interface", "cloudpickle"] +tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "mypy (>=0.900,!=0.940)", "pytest-mypy-plugins", "cloudpickle"] [[package]] name = "aws-cdk-lib" -version = "2.35.0" +version = "2.45.0" description = "Version 2 of the AWS Cloud Development Kit library" category = "main" optional = false @@ -30,20 +22,20 @@ python-versions = "~=3.7" [package.dependencies] constructs = ">=10.0.0,<11.0.0" -jsii = ">=1.63.2,<2.0.0" +jsii = ">=1.68.0,<2.0.0" publication = ">=0.0.3" typeguard = ">=2.13.3,<2.14.0" [[package]] name = "boto3" -version = "1.24.46" +version = "1.24.88" description = "The AWS SDK for Python" category = "dev" optional = false python-versions = ">= 3.7" [package.dependencies] -botocore = ">=1.27.46,<1.28.0" +botocore = ">=1.27.88,<1.28.0" jmespath = ">=0.7.1,<2.0.0" s3transfer = ">=0.6.0,<0.7.0" @@ -52,7 +44,7 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.27.46" +version = "1.27.88" description = "Low-level, data-driven core of boto 3." category = "dev" optional = false @@ -64,7 +56,7 @@ python-dateutil = ">=2.1,<3.0.0" urllib3 = ">=1.25.4,<1.27" [package.extras] -crt = ["awscrt (==0.13.8)"] +crt = ["awscrt (==0.14.0)"] [[package]] name = "cattrs" @@ -79,18 +71,19 @@ attrs = ">=20" exceptiongroup = {version = "*", markers = "python_version <= \"3.10\""} [[package]] -name = "cdk-lambda-powertools-python-layer" -version = "2.0.49" -description = "A lambda layer for AWS Powertools for python" +name = "cdk-aws-lambda-powertools-layer" +version = "3.1.0" +description = "A lambda layer for AWS Powertools for python and typescript" category = "main" optional = false python-versions = "~=3.7" [package.dependencies] -aws-cdk-lib = ">=2.2.0,<3.0.0" +aws-cdk-lib = ">=2.44.0,<3.0.0" constructs = ">=10.0.5,<11.0.0" -jsii = ">=1.61.0,<2.0.0" +jsii = ">=1.69.0,<2.0.0" publication = ">=0.0.3" +typeguard = ">=2.13.3,<2.14.0" [[package]] name = "colorama" @@ -102,20 +95,20 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "constructs" -version = "10.1.67" +version = "10.1.124" description = "A programming model for software-defined state" category = "main" optional = false python-versions = "~=3.7" [package.dependencies] -jsii = ">=1.63.2,<2.0.0" +jsii = ">=1.69.0,<2.0.0" publication = ">=0.0.3" typeguard = ">=2.13.3,<2.14.0" [[package]] name = "exceptiongroup" -version = "1.0.0rc8" +version = "1.0.0rc9" description = "Backport of PEP 654 (exception groups)" category = "main" optional = false @@ -142,14 +135,14 @@ python-versions = ">=3.7" [[package]] name = "jsii" -version = "1.63.2" +version = "1.69.0" description = "Python client for jsii runtime" category = "main" optional = false python-versions = "~=3.7" [package.dependencies] -attrs = ">=21.2,<22.0" +attrs = ">=21.2,<23.0" cattrs = ">=1.8,<22.2" publication = ">=0.0.3" python-dateutil = "*" @@ -176,8 +169,8 @@ optional = false python-versions = ">=3.6" [package.extras] -dev = ["pre-commit", "tox"] -testing = ["pytest", "pytest-benchmark"] +testing = ["pytest-benchmark", "pytest"] +dev = ["tox", "pre-commit"] [[package]] name = "publication" @@ -208,14 +201,13 @@ diagrams = ["railroad-diagrams", "jinja2"] [[package]] name = "pytest" -version = "7.1.2" +version = "7.1.3" description = "pytest: simple powerful testing with Python" category = "dev" optional = false python-versions = ">=3.7" [package.dependencies] -atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} attrs = ">=19.2.0" colorama = {version = "*", markers = "sys_platform == \"win32\""} iniconfig = "*" @@ -277,12 +269,12 @@ optional = false python-versions = ">=3.5.3" [package.extras] -doc = ["sphinx-rtd-theme", "sphinx-autodoc-typehints (>=1.2.0)"] -test = ["pytest", "typing-extensions", "mypy"] +test = ["mypy", "typing-extensions", "pytest"] +doc = ["sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] [[package]] name = "typing-extensions" -version = "4.3.0" +version = "4.4.0" description = "Backported and Experimental Type Hints for Python 3.7+" category = "main" optional = false @@ -290,7 +282,7 @@ python-versions = ">=3.7" [[package]] name = "urllib3" -version = "1.26.11" +version = "1.26.12" description = "HTTP library with thread-safe connection pooling, file post, and more." category = "dev" optional = false @@ -298,94 +290,64 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, [package.extras] brotli = ["brotlicffi (>=0.8.0)", "brotli (>=1.0.9)", "brotlipy (>=0.6.0)"] -secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] +secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "urllib3-secure-extra", "ipaddress"] socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "a68a9649808efb49529ace7d990559e6569be096bf2d86234f3bd056bae0fdc3" +content-hash = "cceb24edf99719274b946c811ad41ebbbdc0181593d4f07555c0977767cdd19a" [metadata.files] -atomicwrites = [ - {file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"}, -] attrs = [ - {file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"}, - {file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"}, + {file = "attrs-22.1.0-py2.py3-none-any.whl", hash = "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c"}, + {file = "attrs-22.1.0.tar.gz", hash = "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6"}, ] aws-cdk-lib = [ - {file = "aws-cdk-lib-2.35.0.tar.gz", hash = "sha256:fc9cba4df0b60a9ab7f17ceb3b1c447d27e96cec9eb9e8c5b7ecfd1275878930"}, - {file = "aws_cdk_lib-2.35.0-py3-none-any.whl", hash = "sha256:ee481dca9335c32b5871e58ba697e27e2f1e92d9b81cf9341cfc6cc36127a2b0"}, + {file = "aws-cdk-lib-2.45.0.tar.gz", hash = "sha256:ed4166498205a6507666a9fdb69f5dbeffa11cd69bf7e98b279ec305e4970374"}, + {file = "aws_cdk_lib-2.45.0-py3-none-any.whl", hash = "sha256:9463fe6d84563c4c23ae96810be0ea0ff0a260eebb85a4a7afe0c3747eca18a8"}, ] boto3 = [ - {file = "boto3-1.24.46-py3-none-any.whl", hash = "sha256:44026e44549148dbc5b261ead5f6b339e785680c350ef621bf85f7e2fca05b49"}, - {file = "boto3-1.24.46.tar.gz", hash = "sha256:b2d9d55f123a9a91eea2fd8e379d90abf37634420fbb45c22d67e10b324ec71b"}, + {file = "boto3-1.24.88-py3-none-any.whl", hash = "sha256:6b4cf1cd0be65202c4cf0e4c69099bac3620bcd4049ca25a5e223c668401dd69"}, + {file = "boto3-1.24.88.tar.gz", hash = "sha256:93934343cac76084600a520e5be70c52152364d0c410681c2e25c2290f0e151c"}, ] botocore = [ - {file = "botocore-1.27.46-py3-none-any.whl", hash = "sha256:747b7e94aef41498f063fc0be79c5af102d940beea713965179e1ead89c7e9ec"}, - {file = "botocore-1.27.46.tar.gz", hash = "sha256:f66d8305d1f59d83334df9b11b6512bb1e14698ec4d5d6d42f833f39f3304ca7"}, -] -cattrs = [ - {file = "cattrs-22.1.0-py3-none-any.whl", hash = "sha256:d55c477b4672f93606e992049f15d526dc7867e6c756cd6256d4af92e2b1e364"}, - {file = "cattrs-22.1.0.tar.gz", hash = "sha256:94b67b64cf92c994f8784c40c082177dc916e0489a73a9a36b24eb18a9db40c6"}, + {file = "botocore-1.27.88-py3-none-any.whl", hash = "sha256:de4e087b24cd3bc369eb2e27f8fe94a6499f7dea08c919fba13cefb2496bd2bb"}, + {file = "botocore-1.27.88.tar.gz", hash = "sha256:ded0a4035baf91eb358ef501c92a8512543f5ab7658f459df3077a70a555b5cd"}, ] -cdk-lambda-powertools-python-layer = [ - {file = "cdk-lambda-powertools-python-layer-2.0.49.tar.gz", hash = "sha256:8055fc691539f16e22a40e3d3df9c3f59fb28012437b08c47c639aefb001f1b2"}, - {file = "cdk_lambda_powertools_python_layer-2.0.49-py3-none-any.whl", hash = "sha256:9b0a7b7344f9ccb486564af728cefeac743687bfb131631e6d9171a55800dbac"}, -] -colorama = [ - {file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"}, - {file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"}, +cattrs = [] +cdk-aws-lambda-powertools-layer = [ + {file = "cdk-aws-lambda-powertools-layer-3.1.0.tar.gz", hash = "sha256:1e1457edbebfbb62ab2d21ae0f9b991db1b6c8508730fab8c99c3a7d3dfd99cb"}, + {file = "cdk_aws_lambda_powertools_layer-3.1.0-py3-none-any.whl", hash = "sha256:c66cc722c924a50458418600df4060a1396e134df25b3cc85de59d5914541b31"}, ] +colorama = [] constructs = [ - {file = "constructs-10.1.67-py3-none-any.whl", hash = "sha256:d597d8d5387328c1e95fa674d5d64969b1c1a479e63544e53a067a5d95b5c46b"}, - {file = "constructs-10.1.67.tar.gz", hash = "sha256:8b9fdf5040dde63545c08b8cc86fcd019512e0d16ee599c82b1201a5806f0066"}, + {file = "constructs-10.1.124-py3-none-any.whl", hash = "sha256:76ef2e6776cfdd1c4131a18b0e83c1b154d462b3ebb37ddbeaf3043b3b0de301"}, + {file = "constructs-10.1.124.tar.gz", hash = "sha256:5e4bfcca275867e5cfb4636ef65ed334c861a816f287ce1136f082ad0e0c1c2c"}, ] exceptiongroup = [ - {file = "exceptiongroup-1.0.0rc8-py3-none-any.whl", hash = "sha256:ab0a968e1ef769e55d9a596f4a89f7be9ffedbc9fdefdb77cc68cf5c33ce1035"}, - {file = "exceptiongroup-1.0.0rc8.tar.gz", hash = "sha256:6990c24f06b8d33c8065cfe43e5e8a4bfa384e0358be036af9cc60b6321bd11a"}, -] -iniconfig = [ - {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, - {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, + {file = "exceptiongroup-1.0.0rc9-py3-none-any.whl", hash = "sha256:2e3c3fc1538a094aab74fad52d6c33fc94de3dfee3ee01f187c0e0c72aec5337"}, + {file = "exceptiongroup-1.0.0rc9.tar.gz", hash = "sha256:9086a4a21ef9b31c72181c77c040a074ba0889ee56a7b289ff0afb0d97655f96"}, ] +iniconfig = [] jmespath = [ {file = "jmespath-1.0.1-py3-none-any.whl", hash = "sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980"}, {file = "jmespath-1.0.1.tar.gz", hash = "sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe"}, ] jsii = [ - {file = "jsii-1.63.2-py3-none-any.whl", hash = "sha256:ae8cbc84c633382c317dc367e1441bb2afd8b74ed82b3557b8df15e05316b14d"}, - {file = "jsii-1.63.2.tar.gz", hash = "sha256:6f68dcd82395ccd12606b31383f611adfefd246082750350891a2a277562f34b"}, -] -packaging = [ - {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, - {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, -] -pluggy = [ - {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, - {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, -] -publication = [ - {file = "publication-0.0.3-py2.py3-none-any.whl", hash = "sha256:0248885351febc11d8a1098d5c8e3ab2dabcf3e8c0c96db1e17ecd12b53afbe6"}, - {file = "publication-0.0.3.tar.gz", hash = "sha256:68416a0de76dddcdd2930d1c8ef853a743cc96c82416c4e4d3b5d901c6276dc4"}, -] -py = [ - {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, - {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, -] -pyparsing = [ - {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, - {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, + {file = "jsii-1.69.0-py3-none-any.whl", hash = "sha256:f3ae5cdf5e854b4d59256dc1f8818cd3fabb8eb43fbd3134a8e8aef962643005"}, + {file = "jsii-1.69.0.tar.gz", hash = "sha256:7c7ed2a913372add17d63322a640c6435324770eb78c6b89e4c701e07d9c84db"}, ] +packaging = [] +pluggy = [] +publication = [] +py = [] +pyparsing = [] pytest = [ - {file = "pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"}, - {file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"}, -] -python-dateutil = [ - {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, - {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, + {file = "pytest-7.1.3-py3-none-any.whl", hash = "sha256:1377bda3466d70b55e3f5cecfa55bb7cfcf219c7964629b967c37cf0bda818b7"}, + {file = "pytest-7.1.3.tar.gz", hash = "sha256:4f365fec2dff9c1162f834d9f18af1ba13062db0c708bf7b946f8a5c76180c39"}, ] +python-dateutil = [] s3transfer = [ {file = "s3transfer-0.6.0-py3-none-any.whl", hash = "sha256:06176b74f3a15f61f1b4f25a1fc29a4429040b7647133a463da8fa5bd28d5ecd"}, {file = "s3transfer-0.6.0.tar.gz", hash = "sha256:2ed07d3866f523cc561bf4a00fc5535827981b117dd7876f036b0c1aca42c947"}, @@ -403,7 +365,10 @@ typeguard = [ {file = "typeguard-2.13.3.tar.gz", hash = "sha256:00edaa8da3a133674796cf5ea87d9f4b4c367d77476e185e80251cc13dfbb8c4"}, ] typing-extensions = [ - {file = "typing_extensions-4.3.0-py3-none-any.whl", hash = "sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02"}, - {file = "typing_extensions-4.3.0.tar.gz", hash = "sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"}, + {file = "typing_extensions-4.4.0-py3-none-any.whl", hash = "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e"}, + {file = "typing_extensions-4.4.0.tar.gz", hash = "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa"}, +] +urllib3 = [ + {file = "urllib3-1.26.12-py2.py3-none-any.whl", hash = "sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997"}, + {file = "urllib3-1.26.12.tar.gz", hash = "sha256:3fa96cf423e6987997fc326ae8df396db2a8b7c667747d47ddd8ecba91f4a74e"}, ] -urllib3 = [] diff --git a/layer/pyproject.toml b/layer/pyproject.toml index 7f219453a72..4b0cada589f 100644 --- a/layer/pyproject.toml +++ b/layer/pyproject.toml @@ -1,14 +1,14 @@ [tool.poetry] name = "aws-lambda-powertools-python-layer" -version = "0.1.0" +version = "1.1.0" description = "AWS Lambda Powertools for Python Lambda Layers" authors = ["DevAx "] license = "MIT" [tool.poetry.dependencies] python = "^3.9" -cdk-lambda-powertools-python-layer = "^2.0.49" -aws-cdk-lib = "^2.35.0" +cdk-aws-lambda-powertools-layer = "^3.1.0" +aws-cdk-lib = "^2.44.0" [tool.poetry.dev-dependencies] pytest = "^7.1.2" diff --git a/package-lock.json b/package-lock.json index 5a72aa1ad10..1764eda669e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,13 +8,14 @@ "name": "aws-lambda-powertools-python-e2e", "version": "1.0.0", "devDependencies": { - "aws-cdk": "2.40.0" + "aws-cdk": "2.44.0" } }, "node_modules/aws-cdk": { - "version": "2.40.0", - "resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.40.0.tgz", - "integrity": "sha512-oHacGkLFDELwhpJsZSAhFHWDxIeZW3DgKkwiXlNO81JxNfjcHgPR2rsbh/Gz+n4ErAEzOV6WfuWVMe68zv+iPg==", + "version": "2.44.0", + "resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.44.0.tgz", + "integrity": "sha512-9hbK4Yc1GQ28zSjZE2ajidt7sRrTLYpijkI7HT7JcDhXLe2ZGP9EOZrqKy5EEsOv0wDQ7cdXB3/oMiMGSmSQ5A==", + "dev": true, "bin": { "cdk": "bin/cdk" }, @@ -29,6 +30,7 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, "hasInstallScript": true, "optional": true, "os": [ @@ -41,9 +43,10 @@ }, "dependencies": { "aws-cdk": { - "version": "2.40.0", - "resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.40.0.tgz", - "integrity": "sha512-oHacGkLFDELwhpJsZSAhFHWDxIeZW3DgKkwiXlNO81JxNfjcHgPR2rsbh/Gz+n4ErAEzOV6WfuWVMe68zv+iPg==", + "version": "2.44.0", + "resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.44.0.tgz", + "integrity": "sha512-9hbK4Yc1GQ28zSjZE2ajidt7sRrTLYpijkI7HT7JcDhXLe2ZGP9EOZrqKy5EEsOv0wDQ7cdXB3/oMiMGSmSQ5A==", + "dev": true, "requires": { "fsevents": "2.3.2" } @@ -52,6 +55,7 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, "optional": true } } diff --git a/package.json b/package.json index 6e3a2c1b216..6d5eb3f5bee 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,6 @@ "name": "aws-lambda-powertools-python-e2e", "version": "1.0.0", "devDependencies": { - "aws-cdk": "2.40.0" + "aws-cdk": "2.44.0" } } diff --git a/poetry.lock b/poetry.lock index dce35f097e6..696df3610b7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -14,7 +14,7 @@ tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (> [[package]] name = "aws-cdk-lib" -version = "2.44.0" +version = "2.45.0" description = "Version 2 of the AWS Cloud Development Kit library" category = "dev" optional = false @@ -28,14 +28,14 @@ typeguard = ">=2.13.3,<2.14.0" [[package]] name = "aws-cdk.aws-apigatewayv2-alpha" -version = "2.44.0a0" +version = "2.45.0a0" description = "The CDK Construct Library for AWS::APIGatewayv2" category = "dev" optional = false python-versions = "~=3.7" [package.dependencies] -aws-cdk-lib = ">=2.44.0,<3.0.0" +aws-cdk-lib = ">=2.45.0,<3.0.0" constructs = ">=10.0.0,<11.0.0" jsii = ">=1.68.0,<2.0.0" publication = ">=0.0.3" @@ -43,15 +43,15 @@ typeguard = ">=2.13.3,<2.14.0" [[package]] name = "aws-cdk.aws-apigatewayv2-integrations-alpha" -version = "2.44.0a0" +version = "2.45.0a0" description = "Integrations for AWS APIGateway V2" category = "dev" optional = false python-versions = "~=3.7" [package.dependencies] -aws-cdk-lib = ">=2.44.0,<3.0.0" -"aws-cdk.aws-apigatewayv2-alpha" = "2.44.0.a0" +aws-cdk-lib = ">=2.45.0,<3.0.0" +"aws-cdk.aws-apigatewayv2-alpha" = "2.45.0.a0" constructs = ">=10.0.0,<11.0.0" jsii = ">=1.68.0,<2.0.0" publication = ">=0.0.3" @@ -62,7 +62,7 @@ name = "aws-xray-sdk" version = "2.10.0" description = "The AWS X-Ray SDK for Python (the SDK) enables Python developers to record and emit information from within their applications to the AWS X-Ray service." category = "main" -optional = false +optional = true python-versions = "*" [package.dependencies] @@ -90,11 +90,11 @@ yaml = ["pyyaml"] [[package]] name = "black" -version = "22.8.0" +version = "22.10.0" description = "The uncompromising code formatter." category = "dev" optional = false -python-versions = ">=3.6.2" +python-versions = ">=3.7" [package.dependencies] click = ">=8.0.0" @@ -113,14 +113,14 @@ uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "boto3" -version = "1.24.85" +version = "1.24.88" description = "The AWS SDK for Python" category = "main" optional = false python-versions = ">= 3.7" [package.dependencies] -botocore = ">=1.27.85,<1.28.0" +botocore = ">=1.27.88,<1.28.0" jmespath = ">=0.7.1,<2.0.0" s3transfer = ">=0.6.0,<0.7.0" @@ -129,7 +129,7 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.27.85" +version = "1.27.88" description = "Low-level, data-driven core of boto 3." category = "main" optional = false @@ -205,7 +205,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "constructs" -version = "10.1.121" +version = "10.1.124" description = "A programming model for software-defined state" category = "dev" optional = false @@ -301,7 +301,7 @@ name = "fastjsonschema" version = "2.16.2" description = "Fastest Python implementation of JSON schema" category = "main" -optional = false +optional = true python-versions = "*" [package.extras] @@ -479,7 +479,7 @@ smmap = ">=3.0.1,<6" [[package]] name = "gitpython" -version = "3.1.27" +version = "3.1.28" description = "GitPython is a python library used to interact with Git repositories" category = "dev" optional = false @@ -1095,7 +1095,7 @@ pytest = ">=3.10" [[package]] name = "pytest-mock" -version = "3.9.0" +version = "3.10.0" description = "Thin-wrapper around the mock package for easier use with pytest" category = "dev" optional = false @@ -1278,7 +1278,7 @@ doc = ["sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] [[package]] name = "types-requests" -version = "2.28.11.1" +version = "2.28.11.2" description = "Typing stubs for requests" category = "dev" optional = false @@ -1297,7 +1297,7 @@ python-versions = "*" [[package]] name = "typing-extensions" -version = "4.3.0" +version = "4.4.0" description = "Backported and Experimental Type Hints for Python 3.7+" category = "main" optional = false @@ -1343,7 +1343,7 @@ name = "wrapt" version = "1.14.1" description = "Module for decorators, wrappers and monkey patching." category = "main" -optional = false +optional = true python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" [[package]] @@ -1372,12 +1372,16 @@ docs = ["sphinx", "jaraco.packaging (>=9)", "rst.linker (>=1.9)", "jaraco.tideli testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.3)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)"] [extras] -pydantic = ["pydantic", "email-validator"] +all = ["pydantic", "email-validator", "aws-xray-sdk", "fastjsonschema"] +aws-sdk = ["boto3"] +parser = ["pydantic", "email-validator"] +tracer = ["aws-xray-sdk"] +validation = ["fastjsonschema"] [metadata] lock-version = "1.1" python-versions = "^3.7.4" -content-hash = "8e6f77254a423026d119eab852c8774f47dab8b656d6e2e1aa25533ae9479fd1" +content-hash = "4de2ae11dc9d1b41c4a8518ce4067703a2fe32bffd1c8729e37e9a03f3c20b67" [metadata.files] attrs = [ @@ -1385,16 +1389,16 @@ attrs = [ {file = "attrs-22.1.0.tar.gz", hash = "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6"}, ] aws-cdk-lib = [ - {file = "aws-cdk-lib-2.44.0.tar.gz", hash = "sha256:92eb87d6576a8be20bf8c359e25dbfd8c8890b53be54be57b71fbcdd16886eea"}, - {file = "aws_cdk_lib-2.44.0-py3-none-any.whl", hash = "sha256:f0de47d4a6e84391d2ec9f551e514c0f4f9be822d17695a305307f2f31751387"}, + {file = "aws-cdk-lib-2.45.0.tar.gz", hash = "sha256:ed4166498205a6507666a9fdb69f5dbeffa11cd69bf7e98b279ec305e4970374"}, + {file = "aws_cdk_lib-2.45.0-py3-none-any.whl", hash = "sha256:9463fe6d84563c4c23ae96810be0ea0ff0a260eebb85a4a7afe0c3747eca18a8"}, ] "aws-cdk.aws-apigatewayv2-alpha" = [ - {file = "aws-cdk.aws-apigatewayv2-alpha-2.44.0a0.tar.gz", hash = "sha256:df570880ef6089d40ae7e61c5377d6516a54ac28ee96e26810bc034dce45871e"}, - {file = "aws_cdk.aws_apigatewayv2_alpha-2.44.0a0-py3-none-any.whl", hash = "sha256:9cc0eb04c2589616b31b1f9eaf878287adfe6a2d9786b672078c8f658381f6e4"}, + {file = "aws-cdk.aws-apigatewayv2-alpha-2.45.0a0.tar.gz", hash = "sha256:1539f66d4c4ca18c83e7cbc929595f583a006c62afa74e901b091bdb3ede30d6"}, + {file = "aws_cdk.aws_apigatewayv2_alpha-2.45.0a0-py3-none-any.whl", hash = "sha256:7f92c3fc6146b8bb7ae9ef353c42485b8ca40ce6c8001827c233de3833e03a6e"}, ] "aws-cdk.aws-apigatewayv2-integrations-alpha" = [ - {file = "aws-cdk.aws-apigatewayv2-integrations-alpha-2.44.0a0.tar.gz", hash = "sha256:8ef1897ae1872cc27f8f8c35c47f67bdc61cb60e9cdc5e75c045eec20923f5f3"}, - {file = "aws_cdk.aws_apigatewayv2_integrations_alpha-2.44.0a0-py3-none-any.whl", hash = "sha256:3b89793b3b9ffb1136c4f063dc5cf7bf76cfd5305212a24ce662efa82993dd06"}, + {file = "aws-cdk.aws-apigatewayv2-integrations-alpha-2.45.0a0.tar.gz", hash = "sha256:a3a3413c34e444d752d44d7bbe8891d5c1af6d64e10185eaa21885710c12b33a"}, + {file = "aws_cdk.aws_apigatewayv2_integrations_alpha-2.45.0a0-py3-none-any.whl", hash = "sha256:d8ed1c1f0b1ea29255c561f528f494e3e8a85ebc7373234a58872c558408acbc"}, ] aws-xray-sdk = [] bandit = [ @@ -1402,37 +1406,26 @@ bandit = [ {file = "bandit-1.7.4.tar.gz", hash = "sha256:2d63a8c573417bae338962d4b9b06fbc6080f74ecd955a092849e1e65c717bd2"}, ] black = [ - {file = "black-22.8.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:ce957f1d6b78a8a231b18e0dd2d94a33d2ba738cd88a7fe64f53f659eea49fdd"}, - {file = "black-22.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:5107ea36b2b61917956d018bd25129baf9ad1125e39324a9b18248d362156a27"}, - {file = "black-22.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e8166b7bfe5dcb56d325385bd1d1e0f635f24aae14b3ae437102dedc0c186747"}, - {file = "black-22.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd82842bb272297503cbec1a2600b6bfb338dae017186f8f215c8958f8acf869"}, - {file = "black-22.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:d839150f61d09e7217f52917259831fe2b689f5c8e5e32611736351b89bb2a90"}, - {file = "black-22.8.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:a05da0430bd5ced89176db098567973be52ce175a55677436a271102d7eaa3fe"}, - {file = "black-22.8.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a098a69a02596e1f2a58a2a1c8d5a05d5a74461af552b371e82f9fa4ada8342"}, - {file = "black-22.8.0-cp36-cp36m-win_amd64.whl", hash = "sha256:5594efbdc35426e35a7defa1ea1a1cb97c7dbd34c0e49af7fb593a36bd45edab"}, - {file = "black-22.8.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:a983526af1bea1e4cf6768e649990f28ee4f4137266921c2c3cee8116ae42ec3"}, - {file = "black-22.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3b2c25f8dea5e8444bdc6788a2f543e1fb01494e144480bc17f806178378005e"}, - {file = "black-22.8.0-cp37-cp37m-win_amd64.whl", hash = "sha256:78dd85caaab7c3153054756b9fe8c611efa63d9e7aecfa33e533060cb14b6d16"}, - {file = "black-22.8.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:cea1b2542d4e2c02c332e83150e41e3ca80dc0fb8de20df3c5e98e242156222c"}, - {file = "black-22.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5b879eb439094751185d1cfdca43023bc6786bd3c60372462b6f051efa6281a5"}, - {file = "black-22.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:0a12e4e1353819af41df998b02c6742643cfef58282915f781d0e4dd7a200411"}, - {file = "black-22.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c3a73f66b6d5ba7288cd5d6dad9b4c9b43f4e8a4b789a94bf5abfb878c663eb3"}, - {file = "black-22.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:e981e20ec152dfb3e77418fb616077937378b322d7b26aa1ff87717fb18b4875"}, - {file = "black-22.8.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:8ce13ffed7e66dda0da3e0b2eb1bdfc83f5812f66e09aca2b0978593ed636b6c"}, - {file = "black-22.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:32a4b17f644fc288c6ee2bafdf5e3b045f4eff84693ac069d87b1a347d861497"}, - {file = "black-22.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0ad827325a3a634bae88ae7747db1a395d5ee02cf05d9aa7a9bd77dfb10e940c"}, - {file = "black-22.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:53198e28a1fb865e9fe97f88220da2e44df6da82b18833b588b1883b16bb5d41"}, - {file = "black-22.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:bc4d4123830a2d190e9cc42a2e43570f82ace35c3aeb26a512a2102bce5af7ec"}, - {file = "black-22.8.0-py3-none-any.whl", hash = "sha256:d2c21d439b2baf7aa80d6dd4e3659259be64c6f49dfd0f32091063db0e006db4"}, - {file = "black-22.8.0.tar.gz", hash = "sha256:792f7eb540ba9a17e8656538701d3eb1afcb134e3b45b71f20b25c77a8db7e6e"}, + {file = "black-22.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14ff67aec0a47c424bc99b71005202045dc09270da44a27848d534600ac64fc7"}, + {file = "black-22.10.0-cp310-cp310-win_amd64.whl", hash = "sha256:819dc789f4498ecc91438a7de64427c73b45035e2e3680c92e18795a839ebb66"}, + {file = "black-22.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b8b49776299fece66bffaafe357d929ca9451450f5466e997a7285ab0fe28e3b"}, + {file = "black-22.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:21199526696b8f09c3997e2b4db8d0b108d801a348414264d2eb8eb2532e540d"}, + {file = "black-22.10.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1e464456d24e23d11fced2bc8c47ef66d471f845c7b7a42f3bd77bf3d1789650"}, + {file = "black-22.10.0-cp37-cp37m-win_amd64.whl", hash = "sha256:9311e99228ae10023300ecac05be5a296f60d2fd10fff31cf5c1fa4ca4b1988d"}, + {file = "black-22.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:915ace4ff03fdfff953962fa672d44be269deb2eaf88499a0f8805221bc68c87"}, + {file = "black-22.10.0-cp38-cp38-win_amd64.whl", hash = "sha256:444ebfb4e441254e87bad00c661fe32df9969b2bf224373a448d8aca2132b395"}, + {file = "black-22.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:72ef3925f30e12a184889aac03d77d031056860ccae8a1e519f6cbb742736383"}, + {file = "black-22.10.0-cp39-cp39-win_amd64.whl", hash = "sha256:432247333090c8c5366e69627ccb363bc58514ae3e63f7fc75c54b1ea80fa7de"}, + {file = "black-22.10.0-py3-none-any.whl", hash = "sha256:c957b2b4ea88587b46cf49d1dc17681c1e672864fd7af32fc1e9664d572b3458"}, + {file = "black-22.10.0.tar.gz", hash = "sha256:f513588da599943e0cde4e32cc9879e825d58720d6557062d1098c5ad80080e1"}, ] boto3 = [ - {file = "boto3-1.24.85-py3-none-any.whl", hash = "sha256:714b06755bd76b2001f7099a8e406604c0a0e76a8ff0425480bf1555bcbecee1"}, - {file = "boto3-1.24.85.tar.gz", hash = "sha256:2c9004c1f0a47807c73247abe8cb2b8a7054c34b9cf6e90f448d51560de20ca1"}, + {file = "boto3-1.24.88-py3-none-any.whl", hash = "sha256:6b4cf1cd0be65202c4cf0e4c69099bac3620bcd4049ca25a5e223c668401dd69"}, + {file = "boto3-1.24.88.tar.gz", hash = "sha256:93934343cac76084600a520e5be70c52152364d0c410681c2e25c2290f0e151c"}, ] botocore = [ - {file = "botocore-1.27.85-py3-none-any.whl", hash = "sha256:06b3ebacbe9a532074db4ad68040235e3c7bd52741e3ff6710cef8ab144ecdfe"}, - {file = "botocore-1.27.85.tar.gz", hash = "sha256:2b4c86178b5a5a2baa0a065aaf9ef9d33a7ac67bf3f30e39005de151b0408cac"}, + {file = "botocore-1.27.88-py3-none-any.whl", hash = "sha256:de4e087b24cd3bc369eb2e27f8fe94a6499f7dea08c919fba13cefb2496bd2bb"}, + {file = "botocore-1.27.88.tar.gz", hash = "sha256:ded0a4035baf91eb358ef501c92a8512543f5ab7658f459df3077a70a555b5cd"}, ] cattrs = [] certifi = [ @@ -1453,8 +1446,8 @@ click = [ ] colorama = [] constructs = [ - {file = "constructs-10.1.121-py3-none-any.whl", hash = "sha256:16758d45bc4b44ad880405d3b74738a1437fb2748659e95bd0f80358b42bc466"}, - {file = "constructs-10.1.121.tar.gz", hash = "sha256:63641b80db2435a7f5d4fa33af077703e8e1114c89210a1fa4d10c1cc7b9a6e6"}, + {file = "constructs-10.1.124-py3-none-any.whl", hash = "sha256:76ef2e6776cfdd1c4131a18b0e83c1b154d462b3ebb37ddbeaf3043b3b0de301"}, + {file = "constructs-10.1.124.tar.gz", hash = "sha256:5e4bfcca275867e5cfb4636ef65ed334c861a816f287ce1136f082ad0e0c1c2c"}, ] coverage = [ {file = "coverage-6.5.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ef8674b0ee8cc11e2d574e3e2998aea5df5ab242e012286824ea3c6970580e53"}, @@ -1572,8 +1565,8 @@ ghp-import = [ ] gitdb = [] gitpython = [ - {file = "GitPython-3.1.27-py3-none-any.whl", hash = "sha256:5b68b000463593e05ff2b261acff0ff0972df8ab1b70d3cdbd41b546c8b8fc3d"}, - {file = "GitPython-3.1.27.tar.gz", hash = "sha256:1c885ce809e8ba2d88a29befeb385fcea06338d3640712b59ca623c220bb5704"}, + {file = "GitPython-3.1.28-py3-none-any.whl", hash = "sha256:77bfbd299d8709f6af7e0c70840ef26e7aff7cf0c1ed53b42dd7fc3a310fcb02"}, + {file = "GitPython-3.1.28.tar.gz", hash = "sha256:6bd3451b8271132f099ceeaf581392eaf6c274af74bb06144307870479d0697c"}, ] idna = [ {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, @@ -1788,8 +1781,8 @@ pytest-benchmark = [] pytest-cov = [] pytest-forked = [] pytest-mock = [ - {file = "pytest-mock-3.9.0.tar.gz", hash = "sha256:c899a0dcc8a5f22930acd020b500abd5f956911f326864a3b979e4866e14da82"}, - {file = "pytest_mock-3.9.0-py3-none-any.whl", hash = "sha256:1a1b9264224d026932d6685a0f9cef3b61d91563c3e74af9fe5afb2767e13812"}, + {file = "pytest-mock-3.10.0.tar.gz", hash = "sha256:fbbdb085ef7c252a326fd8cdcac0aa3b1333d8811f131bdcc701002e1be7ed4f"}, + {file = "pytest_mock-3.10.0-py3-none-any.whl", hash = "sha256:f4c973eeae0282963eb293eb173ce91b091a79c1334455acfac9ddee8a1c784b"}, ] pytest-xdist = [] python-dateutil = [] @@ -1927,16 +1920,16 @@ typeguard = [ {file = "typeguard-2.13.3.tar.gz", hash = "sha256:00edaa8da3a133674796cf5ea87d9f4b4c367d77476e185e80251cc13dfbb8c4"}, ] types-requests = [ - {file = "types-requests-2.28.11.1.tar.gz", hash = "sha256:02b1806c5b9904edcd87fa29236164aea0e6cdc4d93ea020cd615ef65cb43d65"}, - {file = "types_requests-2.28.11.1-py3-none-any.whl", hash = "sha256:1ff2c1301f6fe58b5d1c66cdf631ca19734cb3b1a4bbadc878d75557d183291a"}, + {file = "types-requests-2.28.11.2.tar.gz", hash = "sha256:fdcd7bd148139fb8eef72cf4a41ac7273872cad9e6ada14b11ff5dfdeee60ed3"}, + {file = "types_requests-2.28.11.2-py3-none-any.whl", hash = "sha256:14941f8023a80b16441b3b46caffcbfce5265fd14555844d6029697824b5a2ef"}, ] types-urllib3 = [ {file = "types-urllib3-1.26.25.tar.gz", hash = "sha256:5aef0e663724eef924afa8b320b62ffef2c1736c1fa6caecfc9bc6c8ae2c3def"}, {file = "types_urllib3-1.26.25-py3-none-any.whl", hash = "sha256:c1d78cef7bd581e162e46c20a57b2e1aa6ebecdcf01fd0713bb90978ff3e3427"}, ] typing-extensions = [ - {file = "typing_extensions-4.3.0-py3-none-any.whl", hash = "sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02"}, - {file = "typing_extensions-4.3.0.tar.gz", hash = "sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"}, + {file = "typing_extensions-4.4.0-py3-none-any.whl", hash = "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e"}, + {file = "typing_extensions-4.4.0.tar.gz", hash = "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa"}, ] urllib3 = [ {file = "urllib3-1.26.12-py2.py3-none-any.whl", hash = "sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997"}, diff --git a/pyproject.toml b/pyproject.toml index 411e36d0d6a..9a0f5a3ff38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,18 +20,17 @@ license = "MIT-0" [tool.poetry.dependencies] python = "^3.7.4" -aws-xray-sdk = "^2.8.0" -fastjsonschema = "^2.14.5" -boto3 = "^1.18" -pydantic = {version = "^1.8.2", optional = true } -email-validator = {version = "*", optional = true } +aws-xray-sdk = { version = "^2.8.0", optional = true } +fastjsonschema = { version = "^2.14.5", optional = true } +pydantic = { version = "^1.8.2", optional = true } +email-validator = { version = "^1.3.0", optional = true } +boto3 = { version = "^1.20.32", optional = true } [tool.poetry.dev-dependencies] -# Maintenance: 2022-04-21 jmespath was removed, to be re-added once we drop python 3.6. -# issue #1148 coverage = {extras = ["toml"], version = "^6.2"} pytest = "^7.0.1" black = "^22.8" +boto3 = "^1.18" flake8-builtins = "^1.5.3" flake8-comprehensions = "^3.7.0" flake8-debugger = "^4.0.0" @@ -77,8 +76,12 @@ checksumdir = "^1.2.0" importlib-metadata = "^4.13" [tool.poetry.extras] -pydantic = ["pydantic", "email-validator"] - +parser = ["pydantic", "email-validator"] +validation = ["fastjsonschema"] +tracer = ["aws-xray-sdk"] +all = ["pydantic", "email-validator", "aws-xray-sdk", "fastjsonschema"] +# allow customers to run code locally without emulators (SAM CLI, etc.) +aws-sdk = ["boto3"] [tool.coverage.run] source = ["aws_lambda_powertools"] omit = ["tests/*", "aws_lambda_powertools/exceptions/*", "aws_lambda_powertools/utilities/parser/types.py", "aws_lambda_powertools/utilities/jmespath_utils/envelopes.py"] diff --git a/tests/e2e/utils/infrastructure.py b/tests/e2e/utils/infrastructure.py index 82d0463b2aa..67f2af623f8 100644 --- a/tests/e2e/utils/infrastructure.py +++ b/tests/e2e/utils/infrastructure.py @@ -11,7 +11,7 @@ import boto3 import pytest from aws_cdk import App, CfnOutput, Environment, RemovalPolicy, Stack, aws_logs -from aws_cdk.aws_lambda import Code, Function, LayerVersion, Runtime, Tracing +from aws_cdk.aws_lambda import Architecture, Code, Function, LayerVersion, Runtime, Tracing from filelock import FileLock from mypy_boto3_cloudformation import CloudFormationClient @@ -53,7 +53,9 @@ def __init__(self) -> None: "You must have your infrastructure defined in 'tests/e2e//infrastructure.py'." ) - def create_lambda_functions(self, function_props: Optional[Dict] = None) -> Dict[str, Function]: + def create_lambda_functions( + self, function_props: Optional[Dict] = None, architecture: Architecture = Architecture.X86_64 + ) -> Dict[str, Function]: """Create Lambda functions available under handlers_dir It creates CloudFormation Outputs for every function found in PascalCase. For example, @@ -65,6 +67,9 @@ def create_lambda_functions(self, function_props: Optional[Dict] = None) -> Dict function_props: Optional[Dict] Dictionary representing CDK Lambda FunctionProps to override defaults + architecture: Architecture + Used to create Lambda Layer and functions in a different architecture. Defaults to x86_64. + Returns ------- output: Dict[str, Function] @@ -90,7 +95,7 @@ def create_lambda_functions(self, function_props: Optional[Dict] = None) -> Dict if not self._handlers_dir.exists(): raise RuntimeError(f"Handlers dir '{self._handlers_dir}' must exist for functions to be created.") - layer_build = LocalLambdaPowertoolsLayer().build() + layer_build = LocalLambdaPowertoolsLayer(architecture=architecture).build() layer = LayerVersion( self.stack, "aws-lambda-powertools-e2e-test", @@ -100,6 +105,7 @@ def create_lambda_functions(self, function_props: Optional[Dict] = None) -> Dict Runtime.PYTHON_3_8, Runtime.PYTHON_3_9, ], + compatible_architectures=[architecture], code=Code.from_asset(path=layer_build), ) @@ -123,6 +129,7 @@ def create_lambda_functions(self, function_props: Optional[Dict] = None) -> Dict "tracing": Tracing.ACTIVE, "runtime": Runtime.PYTHON_3_9, "layers": [layer], + "architecture": architecture, **function_settings_override, } @@ -156,7 +163,8 @@ def deploy(self) -> Dict[str, str]: stack_file = self._create_temp_cdk_app() synth_command = f"npx cdk synth --app 'python {stack_file}' -o {self._cdk_out_dir}" deploy_command = ( - f"npx cdk deploy --app '{self._cdk_out_dir}' -O {self._stack_outputs_file} --require-approval=never" + f"npx cdk deploy --app '{self._cdk_out_dir}' -O {self._stack_outputs_file} " + "--require-approval=never --method=direct" ) # CDK launches a background task, so we must wait diff --git a/tests/e2e/utils/lambda_layer/powertools_layer.py b/tests/e2e/utils/lambda_layer/powertools_layer.py index 45a22547715..23eae521696 100644 --- a/tests/e2e/utils/lambda_layer/powertools_layer.py +++ b/tests/e2e/utils/lambda_layer/powertools_layer.py @@ -2,6 +2,7 @@ import subprocess from pathlib import Path +from aws_cdk.aws_lambda import Architecture from checksumdir import dirhash from aws_lambda_powertools import PACKAGE_PATH @@ -14,11 +15,21 @@ class LocalLambdaPowertoolsLayer(BaseLocalLambdaLayer): IGNORE_EXTENSIONS = ["pyc"] - def __init__(self, output_dir: Path = CDK_OUT_PATH): + def __init__(self, output_dir: Path = CDK_OUT_PATH, architecture: Architecture = Architecture.X86_64): super().__init__(output_dir) - self.package = f"{SOURCE_CODE_ROOT_PATH}[pydantic]" - self.build_args = "--platform manylinux1_x86_64 --only-binary=:all: --upgrade" + self.package = f"{SOURCE_CODE_ROOT_PATH}[all]" + + platform_name = self._resolve_platform(architecture) + self.build_args = f"--platform {platform_name} --only-binary=:all: --upgrade" self.build_command = f"python -m pip install {self.package} {self.build_args} --target {self.target_dir}" + self.cleanup_command = ( + f"rm -rf {self.target_dir}/boto* {self.target_dir}/s3transfer* && " + f"rm -rf {self.target_dir}/*dateutil* {self.target_dir}/urllib3* {self.target_dir}/six* && " + f"rm -rf {self.target_dir}/jmespath* && " + f"find {self.target_dir} -name '*.so' -type f -exec strip '{{}}' \\; && " + f"find {self.target_dir} -wholename '*/tests/*' -type f -delete && " + f"find {self.target_dir} -regex '^.*\\(__pycache__\\|\\.py[co]\\)$' -delete" + ) self.source_diff_file: Path = CDK_OUT_PATH / "layer_build.diff" def build(self) -> str: @@ -31,6 +42,9 @@ def build(self) -> str: return str(self.output_dir) + def after_build(self): + subprocess.run(self.cleanup_command, shell=True) + def _has_source_changed(self) -> bool: """Hashes source code and @@ -46,3 +60,18 @@ def _has_source_changed(self) -> bool: return True return False + + def _resolve_platform(self, architecture: Architecture) -> str: + """Returns the correct plaform name for the manylinux project (see PEP 599) + + Returns + ------- + platform_name : str + The platform tag + """ + if architecture.name == Architecture.X86_64.name: + return "manylinux1_x86_64" + elif architecture.name == Architecture.ARM_64.name: + return "manylinux2014_aarch64" + else: + raise ValueError(f"unknown architecture {architecture.name}")