Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(layers): add release pipeline in GitHub Actions #1278

Merged
merged 25 commits into from
Jul 7, 2022
Merged

chore(layers): add release pipeline in GitHub Actions #1278

merged 25 commits into from
Jul 7, 2022

Conversation

am29d
Copy link
Contributor

@am29d am29d commented Jul 4, 2022

Issue number: #1183

Summary

We have been using internal pipeline to release public layers for with powertools. Because of the initial design we could not ship public layers to all commercial regions. This PR introduces a CDK project and GitHub action workflow and we will integrate it into the release process in this repository. The goal is to deploy public layers after a release and update the documentation with the latest ARNs automatically.

Changes

The CDK project has two stacks LayerStack and CanaryStack. We use CDK customer resource capability to run a canary function after the layer deployment so we can verify that the layer works. We also need to track layer ARNs, powertools and the available region, so we can put this information into our documentation. To achieve that, there is dedicated version tracking application. After a successful deployment the canary functions sends an event with all the details. This application is maintained separately. The only information we need is the event bus ARN to send the data.

To deploy into an AWS account we assume a role by using GitHub OIDC configuration. We store the target account and the role name as secrets (though the target account will be public after the public layer is released). The OIDC configuration for target accounts will be provided, no additional work is required in this project.

Open tasks

  • add secrets
  • add python caching for workflow jobs

After merge

  • remove single deployment manually, to have consistent ARNs across all regions
  • uncomment to enable all region

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.


View rendered layer/README.md

@boring-cyborg boring-cyborg bot added the github-actions Pull requests that update Github_actions code label Jul 4, 2022
@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 4, 2022
@boring-cyborg boring-cyborg bot added the internal Maintenance changes label Jul 4, 2022
@am29d am29d requested a review from heitorlessa July 4, 2022 14:33
Alexander Melnyk added 2 commits July 4, 2022 16:39
@heitorlessa heitorlessa changed the title chore: add mechanism to release layers in github chore(layers): add release pipeline in GitHub Actions Jul 4, 2022
Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick initial review on the Workflow with some tips

.github/workflows/publish_layer.yml Outdated Show resolved Hide resolved
.github/workflows/publish_layer.yml Show resolved Hide resolved
.github/workflows/publish_layer.yml Outdated Show resolved Hide resolved
.github/workflows/publish_layer.yml Show resolved Hide resolved
Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick typos and branding

layer/README.md Outdated Show resolved Hide resolved
layer/README.md Outdated Show resolved Hide resolved
layer/README.md Show resolved Hide resolved
layer/README.md Show resolved Hide resolved
layer/README.md Outdated Show resolved Hide resolved
layer/README.md Outdated Show resolved Hide resolved
layer/README.md Outdated Show resolved Hide resolved
layer/README.md Outdated Show resolved Hide resolved
layer/README.md Show resolved Hide resolved
layer/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments and suggestions on the canary

layer/app.py Outdated Show resolved Hide resolved
layer/source.bat Outdated Show resolved Hide resolved
layer/layer/canary/app.py Show resolved Hide resolved
layer/layer/canary/app.py Show resolved Hide resolved
layer/layer/canary/app.py Outdated Show resolved Hide resolved
layer/layer/canary/app.py Outdated Show resolved Hide resolved
layer/layer/canary/app.py Show resolved Hide resolved
@heitorlessa
Copy link
Contributor

This is so so so exciting. I can't believe we're finally at the stage we will have Layers with Extras, ARM, all commercial regions, except the special ones (yet), and more importantly tightly integrated with the release process now.

Can't thank you enough!

@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 5, 2022
@am29d am29d requested a review from heitorlessa July 5, 2022 14:44
@am29d
Copy link
Contributor Author

am29d commented Jul 5, 2022

I have configured the GitHub OIDC connection to AWS accounts and added the secrets used in for layer deployments.

Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks awesome! loved how reusable workflow turned out, so clean! Made some questions as I think you accidentally left a workflow dependency which might fail in the first run.

The only thing missing is the ability to add custom builds for when we introduce additional layers like Extra deps, and when we optimize boto size after our E2E are done -- we can do that later as part of introducing them.

.github/workflows/delploy_cdk_stack.yml Outdated Show resolved Hide resolved
.github/workflows/delploy_cdk_stack.yml Outdated Show resolved Hide resolved
.github/workflows/delploy_cdk_stack.yml Outdated Show resolved Hide resolved
.github/workflows/delploy_cdk_stack.yml Outdated Show resolved Hide resolved
.github/workflows/publish_layer.yml Outdated Show resolved Hide resolved
layer/requirements.txt Outdated Show resolved Hide resolved
@heitorlessa heitorlessa marked this pull request as ready for review July 6, 2022 08:39
@pull-request-size pull-request-size bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 6, 2022
Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two final comments: workflow naming, and address a potential security vulnerability when downloading cdk.out

.github/workflows/publish_layer.yml Outdated Show resolved Hide resolved
.github/workflows/delploy_cdk_stack.yml Outdated Show resolved Hide resolved
@heitorlessa
Copy link
Contributor

I can't believe it's finally here for the next release ;) In a separate PR, we should include a new section in the MAINTAINERS playbook to explain a bit more on Lambda Layers - how to check it worked, areas in the docs to update (until we have automation), etc.

@heitorlessa heitorlessa merged commit 1f570a6 into aws-powertools:develop Jul 7, 2022
heitorlessa added a commit to heitorlessa/aws-lambda-powertools-python that referenced this pull request Jul 7, 2022
* develop:
  fix: unzip the right artifact name
  fix: path to artefact
  fix: add entire ARN role instead of account and role name
  fix: no need to cache npm since we only install cdk cli and don't have .lock files
  fix: typo in input for layer workflow
  chore(layers): add release pipeline in GitHub Actions (aws-powertools#1278)
heitorlessa added a commit that referenced this pull request Jul 13, 2022
* chore: add layer project

* reduce to 1 region for dev

* chore: shorter name for the workflow

* fix ignore markdown lint for now

* fix: more f strings

* ignore mdlint

* add reusable workflow for both beta and prod

* Update layer/layer/canary/app.py

Co-authored-by: Heitor Lessa <[email protected]>

* Update layer/layer/canary/app.py

Co-authored-by: Heitor Lessa <[email protected]>

* readme review

* rephrase canary stack ssm parameter usage

* add default RELEASE_TAG_VERSION assignment based on the input (release or manual trigger)

* add reference to layer docs

* wording

* move version trackign arn to canary stack

* remove outdated npm caching, add release tag resolution for manual workflow trigger

* review: fix layer name and remove dependencies from reusable workflow

* remove debug statement, add default working dir

* pin versions and hashes for requirements with pip-compile

* rename reusable workflow

* pass artefact name to the reusable workflow to prevent potential future conflicts

Co-authored-by: Heitor Lessa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github-actions Pull requests that update Github_actions code internal Maintenance changes size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants