From 1af2af44de6b333b7d8dbec04f7d19f9a788f974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Fonseca?= Date: Mon, 17 Oct 2022 11:52:37 +0200 Subject: [PATCH 01/12] fix(docs): added v2 layer and SAR --- .pre-commit-config.yaml | 2 +- docs/index.md | 424 +++++++++++++++++++++++++++------------- 2 files changed, 293 insertions(+), 133 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 71b1125cf54..0ffeed560f4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: - id: cfn-python-lint files: examples/.*\.(yaml|yml)$ - repo: https://github.com/rhysd/actionlint - rev: v1.6.16 + rev: v1.6.21 hooks: - id: actionlint-docker args: [-pyflakes=] diff --git a/docs/index.md b/docs/index.md index 3626a13b47f..3250926983e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,8 @@ A suite of utilities for AWS Lambda functions to ease adopting best practices su Powertools is available in the following formats: -* **Lambda Layer**: [**arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPython:38**](#){: .copyMe}:clipboard: +* **Lambda Layer (x86_64)**: [**arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV2:1**](#){: .copyMe}:clipboard: +* **Lambda Layer (arm64)**: [**arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1**](#){: .copyMe}:clipboard: * **PyPi**: **`pip install aws-lambda-powertools`** ???+ info "Some utilities require additional dependencies" @@ -51,160 +52,322 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https: ??? note "Note: Expand to copy any regional Lambda Layer ARN" - | Region | Layer ARN | - | ---------------- | -------------------------------------------------------------------------------------------------------- | - | `af-south-1` | [arn:aws:lambda:af-south-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `ap-east-1` | [arn:aws:lambda:ap-east-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `ap-northeast-1` | [arn:aws:lambda:ap-northeast-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `ap-northeast-2` | [arn:aws:lambda:ap-northeast-2:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `ap-northeast-3` | [arn:aws:lambda:ap-northeast-3:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `ap-south-1` | [arn:aws:lambda:ap-south-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `ap-southeast-1` | [arn:aws:lambda:ap-southeast-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `ap-southeast-2` | [arn:aws:lambda:ap-southeast-2:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `ap-southeast-3` | [arn:aws:lambda:ap-southeast-3:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `ca-central-1` | [arn:aws:lambda:ca-central-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `eu-central-1` | [arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `eu-north-1` | [arn:aws:lambda:eu-north-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `eu-south-1` | [arn:aws:lambda:eu-south-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `eu-west-1` | [arn:aws:lambda:eu-west-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `eu-west-2` | [arn:aws:lambda:eu-west-2:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `eu-west-3` | [arn:aws:lambda:eu-west-3:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `me-south-1` | [arn:aws:lambda:me-south-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `sa-east-1` | [arn:aws:lambda:sa-east-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `us-east-1` | [arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `us-east-2` | [arn:aws:lambda:us-east-2:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `us-west-1` | [arn:aws:lambda:us-west-1:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | - | `us-west-2` | [arn:aws:lambda:us-west-2:017000801446:layer:AWSLambdaPowertoolsPython:38](#){: .copyMe}:clipboard: | + === "x86_64" + + | Region | Layer ARN | + | ---------------- | -------------------------------------------------------------------------------------------------------- | + | `af-south-1` | [arn:aws:lambda:af-south-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `ap-east-1` | [arn:aws:lambda:ap-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `ap-northeast-1` | [arn:aws:lambda:ap-northeast-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `ap-northeast-2` | [arn:aws:lambda:ap-northeast-2:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `ap-northeast-3` | [arn:aws:lambda:ap-northeast-3:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `ap-south-1` | [arn:aws:lambda:ap-south-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `ap-southeast-1` | [arn:aws:lambda:ap-southeast-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `ap-southeast-2` | [arn:aws:lambda:ap-southeast-2:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `ap-southeast-3` | [arn:aws:lambda:ap-southeast-3:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `ca-central-1` | [arn:aws:lambda:ca-central-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `eu-central-1` | [arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `eu-north-1` | [arn:aws:lambda:eu-north-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `eu-south-1` | [arn:aws:lambda:eu-south-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `eu-west-1` | [arn:aws:lambda:eu-west-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `eu-west-2` | [arn:aws:lambda:eu-west-2:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `eu-west-3` | [arn:aws:lambda:eu-west-3:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `me-south-1` | [arn:aws:lambda:me-south-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `sa-east-1` | [arn:aws:lambda:sa-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `us-east-1` | [arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `us-east-2` | [arn:aws:lambda:us-east-2:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `us-west-1` | [arn:aws:lambda:us-west-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + | `us-west-2` | [arn:aws:lambda:us-west-2:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: | + + === "arm64" + + | Region | Layer ARN | + | ---------------- | -------------------------------------------------------------------------------------------------------- | + | `af-south-1` | [arn:aws:lambda:af-south-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `ap-east-1` | [arn:aws:lambda:ap-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `ap-northeast-1` | [arn:aws:lambda:ap-northeast-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `ap-northeast-2` | [arn:aws:lambda:ap-northeast-2:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `ap-northeast-3` | [arn:aws:lambda:ap-northeast-3:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `ap-south-1` | [arn:aws:lambda:ap-south-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `ap-southeast-1` | [arn:aws:lambda:ap-southeast-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `ap-southeast-2` | [arn:aws:lambda:ap-southeast-2:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `ap-southeast-3` | [arn:aws:lambda:ap-southeast-3:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `ca-central-1` | [arn:aws:lambda:ca-central-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `eu-central-1` | [arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `eu-north-1` | [arn:aws:lambda:eu-north-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `eu-south-1` | [arn:aws:lambda:eu-south-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `eu-west-1` | [arn:aws:lambda:eu-west-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `eu-west-2` | [arn:aws:lambda:eu-west-2:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `eu-west-3` | [arn:aws:lambda:eu-west-3:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `me-south-1` | [arn:aws:lambda:me-south-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `sa-east-1` | [arn:aws:lambda:sa-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `us-east-1` | [arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `us-east-2` | [arn:aws:lambda:us-east-2:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `us-west-1` | [arn:aws:lambda:us-west-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | + | `us-west-2` | [arn:aws:lambda:us-west-2:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | ??? question "Can't find our Lambda Layer for your preferred AWS region?" You can use [Serverless Application Repository (SAR)](#sar) method, our [CDK Layer Construct](https://github.com/aws-samples/cdk-lambda-powertools-python-layer){target="_blank"}, or PyPi like you normally would for any other library. Please do file a feature request with the region you'd want us to prioritize making our Lambda Layer available. -=== "SAM" +=== "x86_64" - ```yaml hl_lines="5" - MyLambdaFunction: - Type: AWS::Serverless::Function - Properties: - Layers: - - !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:38 - ``` + === "SAM" -=== "Serverless framework" + ```yaml hl_lines="5" + MyLambdaFunction: + Type: AWS::Serverless::Function + Properties: + Layers: + - !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPythonV2:1 + ``` - ```yaml hl_lines="5" - functions: - hello: - handler: lambda_function.lambda_handler - layers: - - arn:aws:lambda:${aws:region}:017000801446:layer:AWSLambdaPowertoolsPython:38 - ``` + === "Serverless framework" -=== "CDK" + ```yaml hl_lines="5" + functions: + hello: + handler: lambda_function.lambda_handler + layers: + - arn:aws:lambda:${aws:region}:017000801446:layer:AWSLambdaPowertoolsPythonV2:1 + ``` - ```python hl_lines="11 16" - from aws_cdk import core, aws_lambda + === "CDK" - class SampleApp(core.Construct): + ```python hl_lines="11 16" + from aws_cdk import core, aws_lambda - def __init__(self, scope: core.Construct, id_: str, env: core.Environment) -> None: - super().__init__(scope, id_) + class SampleApp(core.Construct): - powertools_layer = aws_lambda.LayerVersion.from_layer_version_arn( - self, - id="lambda-powertools", - layer_version_arn=f"arn:aws:lambda:{env.region}:017000801446:layer:AWSLambdaPowertoolsPython:38" - ) - aws_lambda.Function(self, - 'sample-app-lambda', - runtime=aws_lambda.Runtime.PYTHON_3_9, - layers=[powertools_layer] - # other props... - ) - ``` + def __init__(self, scope: core.Construct, id_: str, env: core.Environment) -> None: + super().__init__(scope, id_) -=== "Terraform" + powertools_layer = aws_lambda.LayerVersion.from_layer_version_arn( + self, + id="lambda-powertools", + layer_version_arn=f"arn:aws:lambda:{env.region}:017000801446:layer:AWSLambdaPowertoolsPythonV2:1" + ) + aws_lambda.Function(self, + 'sample-app-lambda', + runtime=aws_lambda.Runtime.PYTHON_3_9, + layers=[powertools_layer] + # other props... + ) + ``` - ```terraform hl_lines="9 38" - terraform { - required_version = "~> 1.0.5" - required_providers { - aws = "~> 3.50.0" - } - } + === "Terraform" - provider "aws" { - region = "{region}" - } + ```terraform hl_lines="9 38" + terraform { + required_version = "~> 1.0.5" + required_providers { + aws = "~> 3.50.0" + } + } - resource "aws_iam_role" "iam_for_lambda" { - name = "iam_for_lambda" + provider "aws" { + region = "{region}" + } - assume_role_policy = < + ? Choose the runtime that you want to use: Python + ? Do you want to configure advanced settings? Yes + ... + ? Do you want to enable Lambda layers for this function? Yes + ? Enter up to 5 existing Lambda layer ARNs (comma-separated): arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1 + ❯ amplify push -y + + + # Updating an existing function and add the layer + ❯ amplify update function + ? Select the Lambda function you want to update test2 + General information + - Name: + ? Which setting do you want to update? Lambda layers configuration + ? Do you want to enable Lambda layers for this function? Yes + ? Enter up to 5 existing Lambda layer ARNs (comma-separated): arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1 + ? Do you want to edit the local lambda function now? No + ``` - ``` + === "Get the Layer .zip contents" + Change {region} to your AWS region, e.g. `eu-west-1` -=== "Amplify" - - ```zsh - # Create a new one with the layer - ❯ amplify add function - ? Select which capability you want to add: Lambda function (serverless function) - ? Provide an AWS Lambda function name: - ? Choose the runtime that you want to use: Python - ? Do you want to configure advanced settings? Yes - ... - ? Do you want to enable Lambda layers for this function? Yes - ? Enter up to 5 existing Lambda layer ARNs (comma-separated): arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPython:38 - ❯ amplify push -y - - - # Updating an existing function and add the layer - ❯ amplify update function - ? Select the Lambda function you want to update test2 - General information - - Name: - ? Which setting do you want to update? Lambda layers configuration - ? Do you want to enable Lambda layers for this function? Yes - ? Enter up to 5 existing Lambda layer ARNs (comma-separated): arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPython:38 - ? Do you want to edit the local lambda function now? No - ``` + ```bash title="AWS CLI" + aws lambda get-layer-version-by-arn --arn arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV2:1 --region {region} + ``` -=== "Get the Layer .zip contents" - Change {region} to your AWS region, e.g. `eu-west-1` + The pre-signed URL to download this Lambda Layer will be within `Location` key. - ```bash title="AWS CLI" - aws lambda get-layer-version-by-arn --arn arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPython:38 --region {region} - ``` +=== "arm64" + + === "SAM" + + ```yaml hl_lines="6" + MyLambdaFunction: + Type: AWS::Serverless::Function + Properties: + Architectures: [arm64] + Layers: + - !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1 + ``` + + === "Serverless framework" + + ```yaml hl_lines="6" + functions: + hello: + handler: lambda_function.lambda_handler + architecture: arm64 + layers: + - arn:aws:lambda:${aws:region}:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1 + ``` + + === "CDK" + + ```python hl_lines="11 17" + from aws_cdk import core, aws_lambda + + class SampleApp(core.Construct): + + def __init__(self, scope: core.Construct, id_: str, env: core.Environment) -> None: + super().__init__(scope, id_) - The pre-signed URL to download this Lambda Layer will be within `Location` key. + powertools_layer = aws_lambda.LayerVersion.from_layer_version_arn( + self, + id="lambda-powertools", + layer_version_arn=f"arn:aws:lambda:{env.region}:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1" + ) + aws_lambda.Function(self, + 'sample-app-lambda', + runtime=aws_lambda.Runtime.PYTHON_3_9, + architecture=aws_lambda.Architecture.ARM_64, + layers=[powertools_layer] + # other props... + ) + ``` + + === "Terraform" + + ```terraform hl_lines="9 37" + terraform { + required_version = "~> 1.0.5" + required_providers { + aws = "~> 3.50.0" + } + } + + provider "aws" { + region = "{region}" + } + + resource "aws_iam_role" "iam_for_lambda" { + name = "iam_for_lambda" + + assume_role_policy = < + ? Choose the runtime that you want to use: Python + ? Do you want to configure advanced settings? Yes + ... + ? Do you want to enable Lambda layers for this function? Yes + ? Enter up to 5 existing Lambda layer ARNs (comma-separated): arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1 + ❯ amplify push -y + + + # Updating an existing function and add the layer + ❯ amplify update function + ? Select the Lambda function you want to update test2 + General information + - Name: + ? Which setting do you want to update? Lambda layers configuration + ? Do you want to enable Lambda layers for this function? Yes + ? Enter up to 5 existing Lambda layer ARNs (comma-separated): arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1 + ? Do you want to edit the local lambda function now? No + ``` + + === "Get the Layer .zip contents" + Change {region} to your AWS region, e.g. `eu-west-1` + + ```bash title="AWS CLI" + aws lambda get-layer-version-by-arn --arn arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1 --region {region} + ``` + + The pre-signed URL to download this Lambda Layer will be within `Location` key. ???+ warning "Warning: Limitations" @@ -218,13 +381,10 @@ Serverless Application Repository (SAR) App deploys a CloudFormation stack with Despite having more steps compared to the [public Layer ARN](#lambda-layer) option, the benefit is that you can specify a semantic version you want to use. -| App | ARN | Description | -| ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | -| [aws-lambda-powertools-python-layer](https://serverlessrepo.aws.amazon.com/applications/eu-west-1/057560766410/aws-lambda-powertools-python-layer) | [arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer](#){: .copyMe}:clipboard: | Core dependencies only; sufficient for nearly all utilities. | -| [aws-lambda-powertools-python-layer-extras](https://serverlessrepo.aws.amazon.com/applications/eu-west-1/057560766410/aws-lambda-powertools-python-layer-extras) | [arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-extras](#){: .copyMe}:clipboard: | Core plus extra dependencies such as `pydantic` that is required by `parser` utility. | - -???+ warning - **Layer-extras** does not support Python 3.6 runtime. This layer also includes all extra dependencies: `22.4MB zipped`, `~155MB unzipped`. +| App | ARN | Description | +|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------| +| [aws-lambda-powertools-python-layer-v2](https://serverlessrepo.aws.amazon.com/applications/eu-west-1/057560766410/aws-lambda-powertools-python-layer-v2) | [arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-v2](#){: .copyMe}:clipboard: | Contains all extra dependencies (e.g: pydantic). | +| [aws-lambda-powertools-python-layer-v2-arm64](https://serverlessrepo.aws.amazon.com/applications/eu-west-1/057560766410/aws-lambda-powertools-python-layer-v2-arm64) | [arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-v2-arm64](#){: .copyMe}:clipboard: | Contains all extra dependencies (e.g: pydantic). For arm64 functions. | ???+ tip You can create a shared Lambda Layers stack and make this along with other account level layers stack. From 933bf0d40e275787584ce94fcb16bbd04986266b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Fonseca?= Date: Mon, 17 Oct 2022 11:52:49 +0200 Subject: [PATCH 02/12] feat: automate layer version publishing when deploying --- .github/workflows/publish_v2_layer.yml | 4 +- .../reusable_deploy_v2_layer_stack.yml | 23 ++++++- .../reusable_publish_v2_layer_arn.yml | 60 +++++++++++++++++++ layer/scripts/update_layer_arn.sh | 59 ++++++++++++++++++ 4 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/reusable_publish_v2_layer_arn.yml create mode 100755 layer/scripts/update_layer_arn.sh diff --git a/.github/workflows/publish_v2_layer.yml b/.github/workflows/publish_v2_layer.yml index de04566c79e..77f1f9dc627 100644 --- a/.github/workflows/publish_v2_layer.yml +++ b/.github/workflows/publish_v2_layer.yml @@ -82,6 +82,7 @@ jobs: stage: "BETA" artefact-name: "cdk-layer-artefact" environment: "layer-beta" + latest_published_version: ${{ inputs.latest_published_version }} # deploy-prod: # needs: @@ -92,6 +93,7 @@ jobs: # stage: "PROD" # artefact-name: "cdk-layer-artefact" # environment: "layer-prod" + # latest_published_version: ${{ inputs.latest_published_version }} deploy-sar-beta: needs: build-layer @@ -104,7 +106,7 @@ jobs: package-version: ${{ needs.build-layer.outputs.release-tag-version }} deploy-sar-prod: - needs: deploy-sar-beta + needs: [build-layer, deploy-sar-beta] uses: ./.github/workflows/reusable_deploy_v2_sar.yml secrets: inherit with: diff --git a/.github/workflows/reusable_deploy_v2_layer_stack.yml b/.github/workflows/reusable_deploy_v2_layer_stack.yml index 1a5eb83cd23..67d06687383 100644 --- a/.github/workflows/reusable_deploy_v2_layer_stack.yml +++ b/.github/workflows/reusable_deploy_v2_layer_stack.yml @@ -22,6 +22,10 @@ on: description: "GitHub Environment to use for encrypted secrets" required: true type: string + latest_published_version: + description: "Latest version that is published" + required: true + type: string jobs: deploy-cdk-stack: @@ -97,6 +101,23 @@ jobs: - name: unzip artefact run: unzip cdk.out.zip - name: CDK Deploy Layer - run: cdk deploy --app cdk.out --context region=${{ matrix.region }} 'LayerV2Stack' --require-approval never --verbose + run: cdk deploy --app cdk.out --context region=${{ matrix.region }} 'LayerV2Stack' --require-approval never --verbose --outputs-file cdk-outputs.json + - name: Store latest Layer ARN + if: ${{ inputs.stage == 'PROD' }} + run: | + jq -c '.LayerV2Stack.VersionArn' cdk-outputs.json > cdk-layer-stack-${{ matrix.region }}-layer-version.txt + jq -c '.LayerV2Stack.Arm64VersionArn' cdk-outputs.json >> cdk-layer-stack-${{ matrix.region }}-layer-version.txt - name: CDK Deploy Canary run: cdk deploy --app cdk.out --context region=${{ matrix.region}} --parameters DeployStage="${{ inputs.stage }}" 'CanaryV2Stack' --require-approval never --verbose + - name: Save Layer ARN artifact + uses: actions/upload-artifacts@v3 + with: + name: cdk-layer-stack + path: cdk-layer-stack* + + publish_v2_layer_arn: + permissions: + contents: write + uses: ./.github/workflows/reusable_publish_v2_layer_arn.yml + with: + latest_published_version: ${{ inputs.latest_published_version }} diff --git a/.github/workflows/reusable_publish_v2_layer_arn.yml b/.github/workflows/reusable_publish_v2_layer_arn.yml new file mode 100644 index 00000000000..d4964a2d14a --- /dev/null +++ b/.github/workflows/reusable_publish_v2_layer_arn.yml @@ -0,0 +1,60 @@ +name: Publish V2 Layer ARN + +on: + workflow_call: + inputs: + latest_published_version: + description: "Latest PyPi published version to rebuild latest docs for, e.g. v2.0.0" + type: string + required: true + +permissions: + contents: write + +env: + BRANCH: v2 + +jobs: + publish_v2_layer_arn: + # Force Github action to run only a single job at a time (based on the group name) + # This is to prevent race-condition and inconsistencies with changelog push + concurrency: + group: changelog-build + runs-on: ubuntu-latest + steps: + - name: Checkout repository # reusable workflows start clean, so we need to checkout again + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Git client setup and refresh tip + run: | + git config user.name "Release bot" + git config user.email "aws-devax-open-source@amazon.com" + git config pull.rebase true + git config remote.origin.url >&- || git remote add origin https://github.com/"${origin}" # Git Detached mode (release notes) doesn't have origin + git pull origin "${BRANCH}" + - name: Download CDK layer artifact + uses: actions/download-artifact@v3 + with: + name: cdk-layer-stack + path: cdk-layer-stack + - name: Replace layer versions in documentation + run: ./layer/scripts/update_layer_arn.sh cdk-layer-stack + - name: Update documentation in trunk + run: | + HAS_CHANGE=$(git status --porcelain) + test -z "${HAS_CHANGE}" && echo "Nothing to update" && exit 0 + git add CHANGELOG.md + git commit -m "chore: update v2 layer ARN on documentation" + git pull origin "${BRANCH}" # prevents concurrent branch update failing push + git push origin HEAD:refs/heads/"${BRANCH}" + + release-docs: + needs: publish_v2_layer_arn + permissions: + contents: write + pages: write + uses: ./.github/workflows/reusable_publish_docs.yml + with: + version: ${{ inputs.latest_published_version }} + alias: alpha diff --git a/layer/scripts/update_layer_arn.sh b/layer/scripts/update_layer_arn.sh new file mode 100755 index 00000000000..4ba8ecff322 --- /dev/null +++ b/layer/scripts/update_layer_arn.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# This script is run during the reusable_publish_v2_layer_arn CI job, +# and it is responsible for replacing the layer ARN in our documentation, +# based on the output files generated by CDK when deploying to each region. +# +# see .github/workflows/reusable_deploy_v2_layer_stack.yml + +set -eo pipefail + +if [[ $# -ne 1 ]]; then + cat < Date: Mon, 17 Oct 2022 15:08:02 +0200 Subject: [PATCH 03/12] fix: increase the width of the documentation main column --- docs/stylesheets/extra.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index 194e4e2ba08..ca6ab06903d 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -1,5 +1,5 @@ .md-grid { - max-width: 81vw + max-width: 90vw } .highlight .hll { From c5efc7cfc507b11214218f75c6ea8b76a8582a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Fonseca?= Date: Mon, 17 Oct 2022 15:08:27 +0200 Subject: [PATCH 04/12] fix(docs): remove old SAR section --- docs/index.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/index.md b/docs/index.md index 3250926983e..166c4632ea6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -106,11 +106,6 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https: | `us-west-1` | [arn:aws:lambda:us-west-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | | `us-west-2` | [arn:aws:lambda:us-west-2:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: | -??? question "Can't find our Lambda Layer for your preferred AWS region?" - You can use [Serverless Application Repository (SAR)](#sar) method, our [CDK Layer Construct](https://github.com/aws-samples/cdk-lambda-powertools-python-layer){target="_blank"}, or PyPi like you normally would for any other library. - - Please do file a feature request with the region you'd want us to prioritize making our Lambda Layer available. - === "x86_64" === "SAM" From 45cf0810f3be904815b9152a027ada5961b9fb44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Fonseca?= Date: Mon, 17 Oct 2022 15:08:39 +0200 Subject: [PATCH 05/12] fix(docs): update references to SAR and v2 Layer --- docs/index.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/index.md b/docs/index.md index 166c4632ea6..58bf74bf223 100644 --- a/docs/index.md +++ b/docs/index.md @@ -393,8 +393,8 @@ If using SAM, you can include this SAR App as part of your shared Layers stack, Type: AWS::Serverless::Application Properties: Location: - ApplicationId: arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer - SemanticVersion: 1.30.0 # change to latest semantic version available in SAR + ApplicationId: arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-v2 + SemanticVersion: 2.0.0 # change to latest semantic version available in SAR MyLambdaFunction: Type: AWS::Serverless::Function @@ -420,9 +420,9 @@ If using SAM, you can include this SAR App as part of your shared Layers stack, Type: AWS::Serverless::Application Properties: Location: - ApplicationId: arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer + ApplicationId: arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-v2 # Find latest from github.com/awslabs/aws-lambda-powertools-python/releases - SemanticVersion: 1.30.0 + SemanticVersion: 2.0.0 ``` === "CDK" @@ -432,8 +432,8 @@ If using SAM, you can include this SAR App as part of your shared Layers stack, POWERTOOLS_BASE_NAME = 'AWSLambdaPowertools' # Find latest from github.com/awslabs/aws-lambda-powertools-python/releases - POWERTOOLS_VER = '1.30.0' - POWERTOOLS_ARN = 'arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer' + POWERTOOLS_VER = '2.0.0' + POWERTOOLS_ARN = 'arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-v2' class SampleApp(core.Construct): @@ -490,13 +490,13 @@ If using SAM, you can include this SAR App as part of your shared Layers stack, } data "aws_serverlessapplicationrepository_application" "sar_app" { - application_id = "arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer" + application_id = "arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-v2" semantic_version = var.aws_powertools_version } variable "aws_powertools_version" { type = string - default = "1.30.0" + default = "2.0.0" description = "The AWS Powertools release version" } @@ -553,7 +553,7 @@ If using SAM, you can include this SAR App as part of your shared Layers stack, - serverlessrepo:GetCloudFormationTemplate Resource: # this is arn of the powertools SAR app - - arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer + - arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-v2 - Sid: S3AccessLayer Effect: Allow Action: @@ -570,7 +570,7 @@ If using SAM, you can include this SAR App as part of your shared Layers stack, - lambda:PublishLayerVersion - lambda:GetLayerVersion Resource: - - !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:layer:aws-lambda-powertools-python-layer* + - !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:layer:aws-lambda-powertools-python-layer-v2* Roles: - Ref: "PowertoolsLayerIamRole" ``` @@ -579,7 +579,7 @@ You can fetch available versions via SAR ListApplicationVersions API: ```bash title="AWS CLI example" aws serverlessrepo list-application-versions \ - --application-id arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer + --application-id arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-v2 ``` ## Quick getting started From c727fb89df69ca49fab0ee877f88659509048587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Fonseca?= Date: Mon, 17 Oct 2022 15:11:06 +0200 Subject: [PATCH 06/12] chore: rename workflow --- .github/workflows/reusable_deploy_v2_layer_stack.yml | 2 +- ...v2_layer_arn.yml => reusable_update_v2_layer_arn_docs.yml} | 4 ++-- layer/scripts/update_layer_arn.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename .github/workflows/{reusable_publish_v2_layer_arn.yml => reusable_update_v2_layer_arn_docs.yml} (97%) diff --git a/.github/workflows/reusable_deploy_v2_layer_stack.yml b/.github/workflows/reusable_deploy_v2_layer_stack.yml index 67d06687383..40aaf352567 100644 --- a/.github/workflows/reusable_deploy_v2_layer_stack.yml +++ b/.github/workflows/reusable_deploy_v2_layer_stack.yml @@ -118,6 +118,6 @@ jobs: publish_v2_layer_arn: permissions: contents: write - uses: ./.github/workflows/reusable_publish_v2_layer_arn.yml + uses: ./.github/workflows/reusable_update_v2_layer_arn_docs.yml with: latest_published_version: ${{ inputs.latest_published_version }} diff --git a/.github/workflows/reusable_publish_v2_layer_arn.yml b/.github/workflows/reusable_update_v2_layer_arn_docs.yml similarity index 97% rename from .github/workflows/reusable_publish_v2_layer_arn.yml rename to .github/workflows/reusable_update_v2_layer_arn_docs.yml index d4964a2d14a..c37a954afdc 100644 --- a/.github/workflows/reusable_publish_v2_layer_arn.yml +++ b/.github/workflows/reusable_update_v2_layer_arn_docs.yml @@ -1,4 +1,4 @@ -name: Publish V2 Layer ARN +name: Update V2 Layer ARN Docs on: workflow_call: @@ -57,4 +57,4 @@ jobs: uses: ./.github/workflows/reusable_publish_docs.yml with: version: ${{ inputs.latest_published_version }} - alias: alpha + alias: latest diff --git a/layer/scripts/update_layer_arn.sh b/layer/scripts/update_layer_arn.sh index 4ba8ecff322..db2e108bcc6 100755 --- a/layer/scripts/update_layer_arn.sh +++ b/layer/scripts/update_layer_arn.sh @@ -1,6 +1,6 @@ #!/bin/bash -# This script is run during the reusable_publish_v2_layer_arn CI job, +# This script is run during the reusable_update_v2_layer_arn_docs CI job, # and it is responsible for replacing the layer ARN in our documentation, # based on the output files generated by CDK when deploying to each region. # From 27a682df47bf0cc458fcfac116d7f18583d907c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Fonseca?= Date: Mon, 17 Oct 2022 15:20:37 +0200 Subject: [PATCH 07/12] fix: add docs to update layer arn script --- layer/scripts/update_layer_arn.sh | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/layer/scripts/update_layer_arn.sh b/layer/scripts/update_layer_arn.sh index db2e108bcc6..4d48a2ff221 100755 --- a/layer/scripts/update_layer_arn.sh +++ b/layer/scripts/update_layer_arn.sh @@ -2,7 +2,7 @@ # This script is run during the reusable_update_v2_layer_arn_docs CI job, # and it is responsible for replacing the layer ARN in our documentation, -# based on the output files generated by CDK when deploying to each region. +# based on the output files generated by CDK when deploying to each pseudo_region. # # see .github/workflows/reusable_deploy_v2_layer_stack.yml @@ -36,22 +36,35 @@ do for line in $lines do echo -e "\t- $line" + # line = arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPython:49 + + # From the full ARN, extract everything but the version at the end. This prefix + # will later be used to find/replace the ARN on the documentation file. prefix=$(echo "$line" | cut -d ':' -f 1-7) + # prefix = arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPython - # Sed doesn't support \d+ in a portable way, so we cheat with (:digit: :digit: *) + # Now replace the all "prefix"s in the file with the full new Layer ARN (line) + # prefix:\d+ ==> line + # sed doesn't support \d+ in a portable way, so we cheat with (:digit: :digit: *) sed -i '' -e "s/$prefix:[[:digit:]][[:digit:]]*/$line/g" docs/index.md - # We use the eu-central-1 layer as the canonical version for all the generic examples + # We use the eu-central-1 layer as the version for all the frameworks (SAM, CDK, SLS, etc) # arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPython:39 # arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:39 # arn:aws:lambda:${aws:region}:017000801446:layer:AWSLambdaPowertoolsPython:39 # arn:aws:lambda:{env.region}:017000801446:layer:AWSLambdaPowertoolsPython:39 if [[ "$line" == *"eu-central-1"* ]]; then - for region in '{region}' '${AWS::Region}' '${aws:region}' '{env.region}' + # These are all the framework pseudo parameters currently found in the docs + for pseudo_region in '{region}' '${AWS::Region}' '${aws:region}' '{env.region}' do - generic_prefix=$(echo "$prefix" | sed "s/eu-central-1/${region}/") - generic_line=$(echo "$line" | sed "s/eu-central-1/${region}/") + generic_prefix=$(echo "$prefix" | sed "s/eu-central-1/${pseudo_region}/") + # generic_prefix = arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython + + generic_line=$(echo "$line" | sed "s/eu-central-1/${pseudo_region}/") + # generic_line = arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:49 + # Replace all the "generic_prefix"'s in the file + # generic_prefix:\d+ ==> generic_line sed -i '' -e "s/$generic_prefix:[[:digit:]][[:digit:]]*/$generic_line/g" docs/index.md done fi From f925a761ed172cd2949c31a64e0732975d985fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Fonseca?= Date: Mon, 17 Oct 2022 15:22:04 +0200 Subject: [PATCH 08/12] fix: more docs --- layer/scripts/update_layer_arn.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/layer/scripts/update_layer_arn.sh b/layer/scripts/update_layer_arn.sh index 4d48a2ff221..32dc4eeebb1 100755 --- a/layer/scripts/update_layer_arn.sh +++ b/layer/scripts/update_layer_arn.sh @@ -49,6 +49,9 @@ do sed -i '' -e "s/$prefix:[[:digit:]][[:digit:]]*/$line/g" docs/index.md # We use the eu-central-1 layer as the version for all the frameworks (SAM, CDK, SLS, etc) + # We could have used any other region. What's important is the version at the end. + + # Examples of strings found in the documentation with pseudo regions: # arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPython:39 # arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:39 # arn:aws:lambda:${aws:region}:017000801446:layer:AWSLambdaPowertoolsPython:39 From b0f4806b61a32addedd863b31b4b25abb558a89f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Fonseca?= Date: Mon, 17 Oct 2022 15:22:54 +0200 Subject: [PATCH 09/12] fix: add the correct file to git --- .github/workflows/reusable_update_v2_layer_arn_docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_update_v2_layer_arn_docs.yml b/.github/workflows/reusable_update_v2_layer_arn_docs.yml index c37a954afdc..857c8001bf9 100644 --- a/.github/workflows/reusable_update_v2_layer_arn_docs.yml +++ b/.github/workflows/reusable_update_v2_layer_arn_docs.yml @@ -44,7 +44,7 @@ jobs: run: | HAS_CHANGE=$(git status --porcelain) test -z "${HAS_CHANGE}" && echo "Nothing to update" && exit 0 - git add CHANGELOG.md + git add docs/index.md git commit -m "chore: update v2 layer ARN on documentation" git pull origin "${BRANCH}" # prevents concurrent branch update failing push git push origin HEAD:refs/heads/"${BRANCH}" From caf752ec55204951ffa8ac0b1e8edfe73edd69b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Fonseca?= Date: Mon, 17 Oct 2022 15:24:12 +0200 Subject: [PATCH 10/12] chore: rename job --- .github/workflows/reusable_deploy_v2_layer_stack.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_deploy_v2_layer_stack.yml b/.github/workflows/reusable_deploy_v2_layer_stack.yml index 40aaf352567..69b99fc3f9a 100644 --- a/.github/workflows/reusable_deploy_v2_layer_stack.yml +++ b/.github/workflows/reusable_deploy_v2_layer_stack.yml @@ -115,7 +115,7 @@ jobs: name: cdk-layer-stack path: cdk-layer-stack* - publish_v2_layer_arn: + update_v2_layer_arn_docs: permissions: contents: write uses: ./.github/workflows/reusable_update_v2_layer_arn_docs.yml From 818fdae88f2daff618a3b314b659a81abb9b2f59 Mon Sep 17 00:00:00 2001 From: Ruben Fonseca Date: Tue, 18 Oct 2022 10:38:58 +0200 Subject: [PATCH 11/12] fix: apply suggestions from code review Co-authored-by: Heitor Lessa --- layer/scripts/update_layer_arn.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/layer/scripts/update_layer_arn.sh b/layer/scripts/update_layer_arn.sh index 32dc4eeebb1..e17ebc20b00 100755 --- a/layer/scripts/update_layer_arn.sh +++ b/layer/scripts/update_layer_arn.sh @@ -60,13 +60,13 @@ do # These are all the framework pseudo parameters currently found in the docs for pseudo_region in '{region}' '${AWS::Region}' '${aws:region}' '{env.region}' do - generic_prefix=$(echo "$prefix" | sed "s/eu-central-1/${pseudo_region}/") - # generic_prefix = arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython + prefix_pseudo_region=$(echo "$prefix" | sed "s/eu-central-1/${pseudo_region}/") + # prefix_pseudo_region = arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython - generic_line=$(echo "$line" | sed "s/eu-central-1/${pseudo_region}/") - # generic_line = arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:49 + line_pseudo_region=$(echo "$line" | sed "s/eu-central-1/${pseudo_region}/") + # line_pseudo_region = arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:49 - # Replace all the "generic_prefix"'s in the file + # Replace all the "prefix_pseudo_region"'s in the file # generic_prefix:\d+ ==> generic_line sed -i '' -e "s/$generic_prefix:[[:digit:]][[:digit:]]*/$generic_line/g" docs/index.md done From f7a67272bd8dfd39ada8276cf3a30f5347534e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Fonseca?= Date: Tue, 18 Oct 2022 10:43:08 +0200 Subject: [PATCH 12/12] fix: typo --- layer/scripts/update_layer_arn.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layer/scripts/update_layer_arn.sh b/layer/scripts/update_layer_arn.sh index e17ebc20b00..b007b2d35cc 100755 --- a/layer/scripts/update_layer_arn.sh +++ b/layer/scripts/update_layer_arn.sh @@ -67,8 +67,8 @@ do # line_pseudo_region = arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:49 # Replace all the "prefix_pseudo_region"'s in the file - # generic_prefix:\d+ ==> generic_line - sed -i '' -e "s/$generic_prefix:[[:digit:]][[:digit:]]*/$generic_line/g" docs/index.md + # prefix_pseudo_region:\d+ ==> line_pseudo_region + sed -i '' -e "s/$prefix_pseudo_region:[[:digit:]][[:digit:]]*/$line_pseudo_region/g" docs/index.md done fi done