From 1f43ce4c26756dfe59d3bfa06a57b8aa97457501 Mon Sep 17 00:00:00 2001 From: Alex Melnyk Date: Sun, 23 Aug 2020 11:47:04 +0200 Subject: [PATCH 01/12] line endings --- .github/workflows/publish_layer.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/publish_layer.yml diff --git a/.github/workflows/publish_layer.yml b/.github/workflows/publish_layer.yml new file mode 100644 index 00000000000..0f9c7d0e183 --- /dev/null +++ b/.github/workflows/publish_layer.yml @@ -0,0 +1,26 @@ +name: Publish lambda layer to SAR + +on: + push: + branches: + - feat/lambda-layer +env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: eu-central-1 + AWS_DEFAULT_OUTPUT: json + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Set release notes tag + run: | + export RELEASE_TAG_VERSION=${{ github.event.release.tag_name }} + echo ::set-env name=RELEASE_TAG_VERSION::${RELEASE_TAG_VERSION:1} + - name: write version to ssm + run: | + aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_TAG_VERSION + - name: trigger lamber layer publish pipeline + run: | + aws codepipeline start-pipeline-execution --name ${{ secret.CODEPIPELINE_NAME }} From eea437548771e637cdfe1bd1f4462e7b0c0b6c99 Mon Sep 17 00:00:00 2001 From: Alex Melnyk Date: Sun, 23 Aug 2020 11:55:16 +0200 Subject: [PATCH 02/12] fix indent, yaml ... --- .github/workflows/publish_layer.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/publish_layer.yml b/.github/workflows/publish_layer.yml index 0f9c7d0e183..94fc3da984e 100644 --- a/.github/workflows/publish_layer.yml +++ b/.github/workflows/publish_layer.yml @@ -11,16 +11,16 @@ env: AWS_DEFAULT_OUTPUT: json jobs: - build: + publish: runs-on: ubuntu-latest steps: - - name: Set release notes tag - run: | - export RELEASE_TAG_VERSION=${{ github.event.release.tag_name }} - echo ::set-env name=RELEASE_TAG_VERSION::${RELEASE_TAG_VERSION:1} - - name: write version to ssm - run: | - aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_TAG_VERSION - - name: trigger lamber layer publish pipeline - run: | - aws codepipeline start-pipeline-execution --name ${{ secret.CODEPIPELINE_NAME }} + - name: Set release notes tag + run: | + export RELEASE_TAG_VERSION=${{ github.event.release.tag_name }} + echo ::set-env name=RELEASE_TAG_VERSION::${RELEASE_TAG_VERSION:1} + - name: write version to ssm + run: | + aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_TAG_VERSION + - name: trigger lamber layer publish pipeline + run: | + aws codepipeline start-pipeline-execution --name ${{ secret.CODEPIPELINE_NAME }} From 194959392570ccbec873518afa10184b520b8fc9 Mon Sep 17 00:00:00 2001 From: Alex Melnyk Date: Sun, 23 Aug 2020 12:00:46 +0200 Subject: [PATCH 03/12] fix typo in branch trigger --- .github/workflows/publish_layer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_layer.yml b/.github/workflows/publish_layer.yml index 94fc3da984e..f3c501d72b4 100644 --- a/.github/workflows/publish_layer.yml +++ b/.github/workflows/publish_layer.yml @@ -3,7 +3,7 @@ name: Publish lambda layer to SAR on: push: branches: - - feat/lambda-layer + - feat/lambda-layers env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} From 6ddd736a85cbf030a128fdcc9a48a16ca7617daf Mon Sep 17 00:00:00 2001 From: Alex Melnyk Date: Sun, 23 Aug 2020 12:01:19 +0200 Subject: [PATCH 04/12] more typos --- .github/workflows/publish_layer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_layer.yml b/.github/workflows/publish_layer.yml index f3c501d72b4..b98f966463c 100644 --- a/.github/workflows/publish_layer.yml +++ b/.github/workflows/publish_layer.yml @@ -23,4 +23,4 @@ jobs: aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_TAG_VERSION - name: trigger lamber layer publish pipeline run: | - aws codepipeline start-pipeline-execution --name ${{ secret.CODEPIPELINE_NAME }} + aws codepipeline start-pipeline-execution --name ${{ secrets.CODEPIPELINE_NAME }} From e6e5c1277013b46525b7398d7934d198384e6860 Mon Sep 17 00:00:00 2001 From: Alex Melnyk Date: Sun, 23 Aug 2020 12:03:48 +0200 Subject: [PATCH 05/12] add relase tag simulation --- .github/workflows/publish_layer.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish_layer.yml b/.github/workflows/publish_layer.yml index b98f966463c..463a46f3e78 100644 --- a/.github/workflows/publish_layer.yml +++ b/.github/workflows/publish_layer.yml @@ -20,6 +20,7 @@ jobs: echo ::set-env name=RELEASE_TAG_VERSION::${RELEASE_TAG_VERSION:1} - name: write version to ssm run: | + RELEASE_TAG_VERSION=1.3.0 # simulate release here, will be removed later aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_TAG_VERSION - name: trigger lamber layer publish pipeline run: | From dac548cde622e7474880459bc0c958cef0a75406 Mon Sep 17 00:00:00 2001 From: Alex Melnyk Date: Sun, 23 Aug 2020 14:55:01 +0200 Subject: [PATCH 06/12] add overwrite flag for ssm --- .github/workflows/publish_layer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_layer.yml b/.github/workflows/publish_layer.yml index 463a46f3e78..91633d62ee9 100644 --- a/.github/workflows/publish_layer.yml +++ b/.github/workflows/publish_layer.yml @@ -21,7 +21,7 @@ jobs: - name: write version to ssm run: | RELEASE_TAG_VERSION=1.3.0 # simulate release here, will be removed later - aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_TAG_VERSION + aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_TAG_VERSION --overwrite - name: trigger lamber layer publish pipeline run: | aws codepipeline start-pipeline-execution --name ${{ secrets.CODEPIPELINE_NAME }} From 7e0b8727f42c7a114eb2bbba00617033b9f80f7a Mon Sep 17 00:00:00 2001 From: Alex Melnyk Date: Sun, 23 Aug 2020 15:00:48 +0200 Subject: [PATCH 07/12] remove tmp release flag and set trigger to release published --- .github/workflows/publish_layer.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish_layer.yml b/.github/workflows/publish_layer.yml index 91633d62ee9..27a5de64287 100644 --- a/.github/workflows/publish_layer.yml +++ b/.github/workflows/publish_layer.yml @@ -1,9 +1,8 @@ name: Publish lambda layer to SAR on: - push: - branches: - - feat/lambda-layers + release: + types: [published] env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} @@ -20,7 +19,6 @@ jobs: echo ::set-env name=RELEASE_TAG_VERSION::${RELEASE_TAG_VERSION:1} - name: write version to ssm run: | - RELEASE_TAG_VERSION=1.3.0 # simulate release here, will be removed later aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_TAG_VERSION --overwrite - name: trigger lamber layer publish pipeline run: | From e8d77b7b001c9623f18dac80695e27215915077f Mon Sep 17 00:00:00 2001 From: Alex Melnyk Date: Sun, 23 Aug 2020 15:07:53 +0200 Subject: [PATCH 08/12] change to eu-west-1 default region --- .github/workflows/publish_layer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_layer.yml b/.github/workflows/publish_layer.yml index 27a5de64287..84f17151a31 100644 --- a/.github/workflows/publish_layer.yml +++ b/.github/workflows/publish_layer.yml @@ -6,7 +6,7 @@ on: env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: eu-central-1 + AWS_DEFAULT_REGION: eu-west-1 AWS_DEFAULT_OUTPUT: json jobs: From 2455001e11371f3f139e24912e5e1fa2711ae4c6 Mon Sep 17 00:00:00 2001 From: Alex Melnyk Date: Mon, 24 Aug 2020 13:18:31 +0200 Subject: [PATCH 09/12] moved publish step to publish workflow after pypi push --- .github/workflows/publish.yml | 11 +++++++++++ .github/workflows/publish_layer.yml | 25 ------------------------- 2 files changed, 11 insertions(+), 25 deletions(-) delete mode 100644 .github/workflows/publish_layer.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4a2bed27deb..058c8490934 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -56,6 +56,17 @@ jobs: env: PYPI_USERNAME: __token__ PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + - name: publish lambda layer in SAR by triggering the internal codepipeline + run: | + aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_TAG_VERSION --overwrite + aws codepipeline start-pipeline-execution --name ${{ secrets.CODEPIPELINE_NAME }} + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: eu-west-1 + AWS_DEFAULT_OUTPUT: json + + sync_master: needs: upload diff --git a/.github/workflows/publish_layer.yml b/.github/workflows/publish_layer.yml deleted file mode 100644 index 84f17151a31..00000000000 --- a/.github/workflows/publish_layer.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Publish lambda layer to SAR - -on: - release: - types: [published] -env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: eu-west-1 - AWS_DEFAULT_OUTPUT: json - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: Set release notes tag - run: | - export RELEASE_TAG_VERSION=${{ github.event.release.tag_name }} - echo ::set-env name=RELEASE_TAG_VERSION::${RELEASE_TAG_VERSION:1} - - name: write version to ssm - run: | - aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_TAG_VERSION --overwrite - - name: trigger lamber layer publish pipeline - run: | - aws codepipeline start-pipeline-execution --name ${{ secrets.CODEPIPELINE_NAME }} From ac10b4f8c7cec8184e0fc0ca57caa0a75d20fe17 Mon Sep 17 00:00:00 2001 From: Alex Melnyk Date: Mon, 24 Aug 2020 17:26:44 +0200 Subject: [PATCH 10/12] add layer to docs and how to use it from SAR --- docs/content/index.mdx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/content/index.mdx b/docs/content/index.mdx index e5c2688ecc7..ca1f8e6b5be 100644 --- a/docs/content/index.mdx +++ b/docs/content/index.mdx @@ -54,3 +54,18 @@ from aws_lambda_powertools.logging.logger import set_package_logger set_package_logger() ``` +## Lambda Layer + +Powertools is also available as a layer and is distributed via the [Serverless Application Repository](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html). +Create the layer via API with: + +``` +aws serverlessrepo create-cloud-formation-change-set --application-id arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer --stack-name YOUR_STACK_NAME --capabilities CAPABILITY_NAMED_IAM +CHANGE_SET_ID=$(aws cloudformation list-change-sets --stack-name YOUR_STACK_NAME --query 'Summaries[*].ChangeSetId' --output text) +aws cloudformation wait change-set-create-complete --change-set-name $CHANGE_SET_ID +aws cloudformation execute-change-set --change-set-name $CHANGE_SET_ID +``` + +this will create a CloudFormation stack with the powertools layer in a specific region where you run this commands. +Keep in mind that layers are regional resources and you need to create the layer in every region where you need it. +Alternatively, you can deploy the layer from the AWS Console by navigating to Serverless Application Repository and search for `aws-lambda-powertools-python-layer` and follow the deploy steps from there. From 679b22faecb31d490b94a70494e67dbec6bdc7d0 Mon Sep 17 00:00:00 2001 From: Alex Melnyk Date: Mon, 24 Aug 2020 17:36:37 +0200 Subject: [PATCH 11/12] formatting for bash script --- docs/content/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/index.mdx b/docs/content/index.mdx index ca1f8e6b5be..ecd29a461d8 100644 --- a/docs/content/index.mdx +++ b/docs/content/index.mdx @@ -59,7 +59,7 @@ set_package_logger() Powertools is also available as a layer and is distributed via the [Serverless Application Repository](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html). Create the layer via API with: -``` +```bash:title=bash-script aws serverlessrepo create-cloud-formation-change-set --application-id arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer --stack-name YOUR_STACK_NAME --capabilities CAPABILITY_NAMED_IAM CHANGE_SET_ID=$(aws cloudformation list-change-sets --stack-name YOUR_STACK_NAME --query 'Summaries[*].ChangeSetId' --output text) aws cloudformation wait change-set-create-complete --change-set-name $CHANGE_SET_ID From 607904c1e574e6176c5e4d69445e9c10f1b141a6 Mon Sep 17 00:00:00 2001 From: Alex Melnyk Date: Tue, 25 Aug 2020 13:46:31 +0200 Subject: [PATCH 12/12] fix heading error due to merge --- docs/content/index.mdx | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/content/index.mdx b/docs/content/index.mdx index f47b25125bb..aff7949bf93 100644 --- a/docs/content/index.mdx +++ b/docs/content/index.mdx @@ -73,7 +73,6 @@ aws cloudformation execute-change-set --change-set-name $CHANGE_SET_ID this will create a CloudFormation stack with the powertools layer in a specific region where you run this commands. Keep in mind that layers are regional resources and you need to create the layer in every region where you need it. Alternatively, you can deploy the layer from the AWS Console by navigating to Serverless Application Repository and search for `aws-lambda-powertools-python-layer` and follow the deploy steps from there. -======= ## Tenets @@ -85,4 +84,3 @@ Alternatively, you can deploy the layer from the AWS Console by navigating to Se * **Idiomatic** – Utilities follow programming language idioms and language-specific best practices. _`*` Core utilities are Tracer, Logger and Metrics. Optional utilities may vary across languages._ -