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

Add support for layers #1

Closed
S-Cardenas opened this issue May 12, 2020 · 4 comments
Closed

Add support for layers #1

S-Cardenas opened this issue May 12, 2020 · 4 comments

Comments

@S-Cardenas
Copy link
Contributor

S-Cardenas commented May 12, 2020

In response to this original issue and comment.

I'm not quite sure what you're doing behind the scenes, but I imagine if you're mounting a lambci container for each function in the SAM template, you could check for any local layers and mount a volume between the layer path and /opt on the lambci container.

@duartemendes
Copy link
Owner

Yes, that's what's happening behind the scenes and that's exactly what it's needed according to the lambci docs.

I just need to think a bit about the scenario where a SAM template is using several layers, and each function uses different layers. The CLI will probably need to accept a mapping of layers names to their paths. Does this makes sense?

@S-Cardenas
Copy link
Contributor Author

This makes sense, but why would we have to supply the mapping via the cli? Couldn't the CLI parse the SAM template and deduce which functions have layers and then read the path.

I think we also have to take into consideration the case where a layer is specified locally, and the case where the layer is already on AWS and defined by an ARN. When it's defined by an ARN we would need to pull that image down from AWS, store it somewhere, and then run it as a separate container or volume.

@duartemendes
Copy link
Owner

Okay, I haven't used layers for some time but here is my understanding, let me know what you think.

For any of the following cases, we would have to, at startup, create a folder for each function, in which it would have the necessary function layers code, extracted. This folder would then be used for the docker volume.

  1. Layer is ARN

We'll need to download layer from AWS and store the extracted content (cache needs to take in consideration the layer version).

  1. Layer is a reference to a local resource of type AWS::Serverless::LayerVersion
  • ContentUri is AWS S3 Uri or LayerContent - same as when layer is ARN but zip download is made from the given S3 bucket.

  • ContentUri is a local file path - No need to download anything, just copy the content and make sure the runtime folder is being respect as stated in here.

@duartemendes
Copy link
Owner

@S-Cardenas Thanks for your interest but supporting layers requires a really big effort and I don't think it's worth it, as the sam cli team has already announced that they will tackle the keep container warm issue.

Said this, if you still want layers support and don't mind getting your hands dirty, I'm more than happy to provide an hand 👍

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

No branches or pull requests

2 participants