Skip to content

feat: publish lib as Lambda Layer #1095

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

Merged
merged 7 commits into from
Oct 10, 2022
Merged

feat: publish lib as Lambda Layer #1095

merged 7 commits into from
Oct 10, 2022

Conversation

flochaz
Copy link
Contributor

@flochaz flochaz commented Sep 29, 2022

Description of your changes

  • Integrate layer publication in CI/CD release process
  • Publish doc on layer usage
  • Add example on how to use it with CDK

How to verify this change

Release process: https://github.com/awslabs/aws-lambda-powertools-typescript/actions/runs/2826141922

A public version is already available under this ARN: arn:aws:lambda:{REGION}:094274105915:layer:AWSLambdaPowertoolsTypeScript:1 that was published during 1.0.2 release. So can be used in any deployment. An example of its usage is available in our CDK examples and be deploy simply:

cd examples/cdk
npm ci
npm run cdk deploy

Get to your AWS Console lambda , select the Lambda called MyLayeredFunction and check it's code and execution.

E2E tests has been added in the layer publisher as well.

Related issues, RFCs

#826

PR status

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

Checklist

  • Check tracking is in place for our layer
  • Add doc in SAM README on how to set the layer
  • Add doc on release process with manual update doc for version bump
  • 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

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 marked this pull request as ready for review October 3, 2022 05:21
@flochaz flochaz requested review from dreamorosi, ijemmy and saragerion and removed request for dreamorosi and ijemmy October 3, 2022 05:21
dreamorosi
dreamorosi previously approved these changes Oct 3, 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.

Great work Florian, thank you fro this PR.

I've left only a couple of minor comments but it's already looking good.

docs/index.md Outdated
BuildMethod: esbuild
BuildProperties:
Minify: true
External:s
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 s in External:s (<- this) on purpose? If yes please resolve this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oups , well catched

@dreamorosi dreamorosi added this to the Lambda layer milestone Oct 3, 2022
dreamorosi
dreamorosi previously approved these changes Oct 3, 2022
@flochaz
Copy link
Contributor Author

flochaz commented Oct 4, 2022

Docker dependency might be an overkill, thinking about moving to a simple zip bundling:

mkdir nodejs && cd $_
npm init -y
npm install @aws-lambda-powertools/commons @aws-lambda-powertools/logger @aws-lambda-powertools/metrics @aws-lambda-powertools/tracer
rm package.json package-lock.json
cd ..
zip -r layer.zip nodejs

@@ -150,6 +150,41 @@ sam logs -n getAllItemsFunction --stack-name powertools-example --tail

You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html).

## Switch to Lambda Layer

This example bundle all your dependencies in a single JS file thanks to esbuild but you can switch the AWSLambdaPowertoolsTypeScript Layer by:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This example bundle all your dependencies in a single JS file thanks to esbuild but you can switch the AWSLambdaPowertoolsTypeScript Layer by:
This example bundles all your dependencies in a single JS file with `esbuild`. You can switch the `AWSLambdaPowertoolsTypeScript` Layer by:

@flochaz flochaz merged commit 83f6efb into main Oct 10, 2022
@flochaz flochaz deleted the layerPublic branch October 10, 2022 08:11
@github-actions
Copy link
Contributor

@awslabs/aws-lambda-powertools-typescript No related issues found. Please ensure 'pending-release' label is applied before releasing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants