forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(layers): add support for publishing v2 layer (aws-powertools#1558)
Co-authored-by: Heitor Lessa <[email protected]>
- Loading branch information
1 parent
034128c
commit 157eacc
Showing
15 changed files
with
550 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 [email protected] | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.