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

feat(build): publish lib as a Lambda Layer #884

Merged
merged 35 commits into from
Aug 9, 2022
Merged

Conversation

flochaz
Copy link
Contributor

@flochaz flochaz commented May 19, 2022

Description of your changes

This PR aims to add the capability to publish safely AWS Lambda PowerTools for TypeScript.

TODO list:

How to verify this change

Test layer publisher

Build layer manually in your account:

cd layer-publisher
npm ci
npm run cdk deploy

Then you can use the layer shown as cfn output.

Or you can use the e2e tests that will:

  1. Create a public layer in your account called e2e-tests-layer-nodejs
  2. Create a Lambda function consuming the previously created layer
  3. Check the outputs logs of the function checking no error is thrown

Test in github action

check https://github.com/flochaz/aws-lambda-powertools-typescript/actions/runs/2718610199

Diff with Powertools for Python version

The only difference with Python version for publishing layer is the way we do e2e tests:

  • Python is launching a Canary stack launching a Lambda Function (as a CustomResource) which consume the published layer in the same CDK App. This canary function deployed in their beta and prod account will use the layer and throw exception if any issue found making the stack deployment fail.
  • TypeScript version is doing E2E testing the same way we were doing for npm: layer-publisher cdk app contains a Jest test that will
    1. Create a public layer in the test account called e2e-tests-layer-nodejs
    2. Create a Lambda function consuming the previously created layer
    3. Check the outputs logs of the function checking no error is thrown

Related issues, RFCs

Issue number: #826

PR status

Is this ready for review?: YES
Is it a breaking change?: NO

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding changes to the examples
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • New and existing unit tests pass locally and in Github Actions
  • Any dependent changes have been merged and published in downstream module
  • The PR title follows the conventional commit semantics

Breaking change checklist

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

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

@flochaz flochaz force-pushed the feat/layerPublisher branch 4 times, most recently from 275f79f to e3fd639 Compare May 20, 2022 07:44
@dreamorosi dreamorosi added the internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) label May 20, 2022
@dreamorosi dreamorosi added this to the production-ready-release milestone May 20, 2022
@saragerion saragerion removed this from the production-ready-release milestone May 27, 2022
@saragerion saragerion added this to the Lambda layer milestone Jul 19, 2022
docs/index.md Outdated Show resolved Hide resolved
docs/index.md Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Jul 22, 2022

📊 Package size report   -50.7%↓

File Before After
commons-bundle.zip 6.8 kB
logger-bundle.zip 24.8 kB
metrics-bundle.zip 18.2 kB
tracer-bundle.zip 22.1 kB
Total (Includes all files) 142.0 kB -50.7%↓70.0 kB
Tarball size 140.8 kB -50.2%↓70.2 kB
Unchanged files
File Size
aws-lambda-powertools-commons-1.0.2.tgz 6.3 kB
aws-lambda-powertools-logger-1.0.2.tgz 24.3 kB
aws-lambda-powertools-metrics-1.0.2.tgz 17.7 kB
aws-lambda-powertools-tracer-1.0.2.tgz 21.6 kB

🤖 This report was automatically generated by pkg-size-action
(options hash: e17332db0705db7a856b60c057b7d255)

@flochaz flochaz marked this pull request as ready for review July 22, 2022 16:33
@github-actions
Copy link
Contributor

github-actions bot commented Jul 22, 2022

📊 Package size report   -50.7%↓

File Before After
commons-bundle.zip 6.8 kB
logger-bundle.zip 24.8 kB
metrics-bundle.zip 18.2 kB
tracer-bundle.zip 22.1 kB
Total (Includes all files) 142.0 kB -50.7%↓70.0 kB
Tarball size 140.7 kB -50.2%↓70.2 kB
Unchanged files
File Size
aws-lambda-powertools-commons-1.0.2.tgz 6.3 kB
aws-lambda-powertools-logger-1.0.2.tgz 24.3 kB
aws-lambda-powertools-metrics-1.0.2.tgz 17.7 kB
aws-lambda-powertools-tracer-1.0.2.tgz 21.6 kB

🤖 This report was automatically generated by pkg-size-action
(options hash: f15ee5cc09f53757f6faed42cd6f802b)


const runtime = lambda.Runtime.ALL.find((r) => r.name === process.env.RUNTIME) ?? lambda.Runtime.NODEJS_14_X;

const powerToolsPackageVersion = '1.0.1';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this synced to the actual version published on NPM? If yes, how do we increment it when we release?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no it's only to test and therefore on purpose set as a lower version than latest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect, thanks for the explanation.

Leaving the thread open so others can see the answer in case they have the same question

@github-actions
Copy link
Contributor

github-actions bot commented Jul 22, 2022

📊 Package size report   -50.7%↓

File Before After
commons-bundle.zip 6.8 kB
logger-bundle.zip 24.8 kB
metrics-bundle.zip 18.2 kB
tracer-bundle.zip 22.1 kB
Total (Includes all files) 142.0 kB -50.7%↓70.0 kB
Tarball size 140.7 kB -50.2%↓70.2 kB
Unchanged files
File Size
aws-lambda-powertools-commons-1.0.2.tgz 6.3 kB
aws-lambda-powertools-logger-1.0.2.tgz 24.3 kB
aws-lambda-powertools-metrics-1.0.2.tgz 17.7 kB
aws-lambda-powertools-tracer-1.0.2.tgz 21.6 kB

🤖 This report was automatically generated by pkg-size-action
(options hash: a51bc9e9f4f835e32a61e7b391cf15a9)

docs/index.md Outdated Show resolved Hide resolved
@@ -0,0 +1,32 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Putting this comment here because the file above called is a binary and doesn't allow comments:

Do we need this layer-publisher/[email protected]???

Copy link
Contributor

Choose a reason for hiding this comment

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

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for now yes since my PR there is not merged yet : aws-samples/cdk-lambda-powertools-python-layer#52

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, thanks for the explanation

@github-actions
Copy link
Contributor

github-actions bot commented Jul 22, 2022

📊 Package size report   -50.7%↓

File Before After
commons-bundle.zip 6.8 kB
logger-bundle.zip 24.8 kB
metrics-bundle.zip 18.2 kB
tracer-bundle.zip 22.1 kB
Total (Includes all files) 142.0 kB -50.7%↓70.0 kB
Tarball size 140.8 kB -50.2%↓70.2 kB
Unchanged files
File Size
aws-lambda-powertools-commons-1.0.2.tgz 6.3 kB
aws-lambda-powertools-logger-1.0.2.tgz 24.3 kB
aws-lambda-powertools-metrics-1.0.2.tgz 17.7 kB
aws-lambda-powertools-tracer-1.0.2.tgz 21.6 kB

🤖 This report was automatically generated by pkg-size-action
(options hash: 31921c0fee6bce29e62a7b9f4747f9cc)

@github-actions
Copy link
Contributor

github-actions bot commented Jul 22, 2022

📊 Package size report   -50.7%↓

File Before After
commons-bundle.zip 6.8 kB
logger-bundle.zip 24.8 kB
metrics-bundle.zip 18.2 kB
tracer-bundle.zip 22.1 kB
Total (Includes all files) 142.0 kB -50.7%↓70.0 kB
Tarball size 140.7 kB -50.1%↓70.2 kB
Unchanged files
File Size
aws-lambda-powertools-commons-1.0.2.tgz 6.3 kB
aws-lambda-powertools-logger-1.0.2.tgz 24.3 kB
aws-lambda-powertools-metrics-1.0.2.tgz 17.7 kB
aws-lambda-powertools-tracer-1.0.2.tgz 21.6 kB

🤖 This report was automatically generated by pkg-size-action
(options hash: 015a1eeebe540ca3ec0dc6305e69f386)

@flochaz flochaz force-pushed the feat/layerPublisher branch from 1714919 to 810e0dc Compare August 4, 2022 10:05
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2022

📊 Package size report   -50.7%↓

File Before After
commons-bundle.zip 6.8 kB
logger-bundle.zip 24.8 kB
metrics-bundle.zip 18.2 kB
tracer-bundle.zip 22.1 kB
Total (Includes all files) 142.0 kB -50.7%↓70.0 kB
Tarball size 140.8 kB -50.2%↓70.2 kB
Unchanged files
File Size
aws-lambda-powertools-commons-1.0.2.tgz 6.3 kB
aws-lambda-powertools-logger-1.0.2.tgz 24.3 kB
aws-lambda-powertools-metrics-1.0.2.tgz 17.7 kB
aws-lambda-powertools-tracer-1.0.2.tgz 21.6 kB

🤖 This report was automatically generated by pkg-size-action
(options hash: b7ccdb16df8d9a213af05756706f4dac)

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2022

📊 Package size report   -50.7%↓

File Before After
commons-bundle.zip 6.8 kB
logger-bundle.zip 24.8 kB
metrics-bundle.zip 18.2 kB
tracer-bundle.zip 22.1 kB
Total (Includes all files) 142.0 kB -50.7%↓70.0 kB
Tarball size 140.8 kB -50.2%↓70.2 kB
Unchanged files
File Size
aws-lambda-powertools-commons-1.0.2.tgz 6.3 kB
aws-lambda-powertools-logger-1.0.2.tgz 24.3 kB
aws-lambda-powertools-metrics-1.0.2.tgz 17.7 kB
aws-lambda-powertools-tracer-1.0.2.tgz 21.6 kB

🤖 This report was automatically generated by pkg-size-action
(options hash: 731be7d63b86b6ad43259050be54a2bb)

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2022

📊 Package size report   -50.7%↓

File Before After
commons-bundle.zip 6.8 kB
logger-bundle.zip 24.8 kB
metrics-bundle.zip 18.2 kB
tracer-bundle.zip 22.1 kB
Total (Includes all files) 142.0 kB -50.7%↓70.0 kB
Tarball size 140.8 kB -50.2%↓70.2 kB
Unchanged files
File Size
aws-lambda-powertools-commons-1.0.2.tgz 6.3 kB
aws-lambda-powertools-logger-1.0.2.tgz 24.3 kB
aws-lambda-powertools-metrics-1.0.2.tgz 17.7 kB
aws-lambda-powertools-tracer-1.0.2.tgz 21.6 kB

🤖 This report was automatically generated by pkg-size-action
(options hash: 80ee68abe74bf056022dfdd9bf901dbd)

@dreamorosi dreamorosi requested review from ijemmy and dreamorosi August 8, 2022 14:43
dreamorosi
dreamorosi previously approved these changes Aug 8, 2022
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

LGTM

* chore: broke up pr workflow & measure package size

* chore: explicitly set packages where to run cmds

* fix: added missing dependency to examples/sam

* added cache in workflow

* chore: updated workflow + removed env var from command

* chore: updated action version

* fix: removed redundant env variable
ijemmy
ijemmy previously approved these changes Aug 9, 2022
@dreamorosi dreamorosi dismissed stale reviews from ijemmy and themself via fa2f59b August 9, 2022 12:51
@dreamorosi dreamorosi requested review from dreamorosi and ijemmy August 9, 2022 12:54
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

Fixed merge conflicts

@dreamorosi dreamorosi merged commit c3a20c6 into main Aug 9, 2022
@dreamorosi dreamorosi deleted the feat/layerPublisher branch August 9, 2022 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants