-
-
Notifications
You must be signed in to change notification settings - Fork 15
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(aws-lambda): AWS Lambda layer target #160
Conversation
Check and get environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`, before publishing to AWS Lambda.
If `AWS_LAYER_NAME` is set as an environment variable, it's used as the layer name. If not, the default layer name is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly minor comments.
Separate 👍 👍 for adding tests for the target!
Please also add the documentation for this new target to README.
- Delete `aws-lambda` target from `.craft.yml`. - Include start of line anchor (`^`) in the AWS Lambda regex. - Return promise instead of awaiting it inside the aws publish and add layer permissions methods. - Delete `TestArtifactProvider` and use `NoneArtifactProvider` instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff @iker-barriocanal
Dropped some comments to help move this to completion. Let's chat if I can help.
High level notes:
- Need to split clearly what is part of project config and what is part of the Craft implementation.
- Missing some documentation on how to use this new target in a craft-powered project (like sentry-javascript and sentry-python), essentially documenting what is the required config.
- Rename to `awsLambdaLayer`. - Extract hardcoded attributes to project settings in `.craft.yml` files: - Dist regex. - Compatible runtimes. - Layer name.
Extract layer permission variables to `.craft.yml` files.
- AWS SDK upgrade from v2 to v3. - AWS regions are now fetched using the EC2 client. - A license is now required in the project config. - Update tests to support SDKv3 and region fetch.
// returned. Thus, both alternatives have been considered. | ||
expect(publishedLayerVersion).toBe(undefined); | ||
} catch (error) { | ||
expect(error instanceof Error).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To confirm: wouldn't this always be true?
If you want to confirm that a function throws an error, please consider using https://jestjs.io/docs/en/expect.html#tothrowerror
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code inside catch
, yes. publish
will only throw if it's not running in dry-run mode; if it is, it doesn't throw anything and returns undefined
. So, the approach is to run publish
and expect to get undefined
; if it throws an error before that, catch it. The method toThrow
, afaik, requires to make the function call inside the expect
, passing the test when the dry-run mode is off but failing when it's on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I think we can go ahead and update sentry-python and sentry-javascript to use this and make any adjustments later if need be. Good job @iker-barriocanal!
targets: | ||
- name: aws-lambda-layer | ||
includeNames: /^sentry-node-serverless-\d+(\.\d+)*\.zip$/ | ||
layerName: SentryNodeServerlessSDK | ||
compatibleRuntimes: | ||
- nodejs10.x | ||
- nodejs12.x | ||
license: MIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Re-requesting Anton if he still has any concerns from the points raised earlier. |
@rhcarvalho Let's give Iker a break 😅 I've already left one a few minutes ago. |
Oh sorry, I did not see it before I posted. |
Add a target to publish a layer and sets its permissions in each region for the JS SDK.