-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Multiple Functions in Stack Assume DockerContext is Unique #2514
Comments
For my initial documentation I can work around this by having the "web" function handle both events. Events:
HttpApiProxy:
Type: HttpApi
Properties:
ApiId: !Ref RailsHttpApi
SQSJobs:
Type: SQS
Properties:
Queue: !GetAtt JobsQueue.Arn
BatchSize: 1 But this is not going to scale for our production usage. We need the same image for both functions like we had in the Zip format. |
CORRECT. I fell back to I'm gonna try that as well as a symlink later tonight to see if that helps and report back. But still hoping this is a simple bug that can be fixed with SAM. Thanks y'all. |
Duplicate of #2466? It's hard to understand the problem you are hitting @metaskills but from my understanding it sounds like #2466 is what you are after (which already has a pr). |
OK, so testing the Resources:
WebLambda:
Type: AWS::Serverless::Function
Metadata:
Dockerfile: Dockerfile
DockerContext: .
Properties:
ImageUri: 012345678901.dkr.ecr.us-east-1.amazonaws.com/helloworldfunction:weblambda-6b6f5d9b54ab-latest
JobLambda:
Type: AWS::Serverless::Function
Metadata:
Dockerfile: Dockerfile
DockerContext: .
Properties:
ImageUri: helloworldfunction:latest So my next attempt was to use a simple symlink like so. lrwxr-xr-x 1 kencollins staff 1B Jan 5 16:17 jobs -> . And then point my jobs resource to: JobLambda:
Type: AWS::Serverless::Function
Metadata:
Dockerfile: Dockerfile
DockerContext: ./jobs This actually works but I'm still testing now. |
Closing in favor of #2466 |
For Ruby on Rails with AWS Lambda using the Zip deployment package, we promoted using the same code with different function handlers. For example, one for Web and another for Jobs. This was easy to do with the and we even leveraged the Makefile build method to avoid building the same code twice. Tho this was not necessary. See here for details. https://lamby.custominktech.com/docs/activejob_and_lambda#3-new-jobslambda
Now that we have switched to containers I just realized a major bug with SAM that has stopped my work. Basically you can not do what SAM and the Zip package format did using Image. You can reproduce this issue by following this guide (https://aws.amazon.com/blogs/compute/using-container-image-support-for-aws-lambda-with-aws-sam/) and simply changing the
DockerContext
of theHolaWorldFunction
to be the same./hello-world
used in theHelloWorldFunction
. When you do this, you end up with one of a few errors depending on you method, guided, not, etc.For Rails we will end up using the PWD so
DockerContext: .
vs a directory, but the error is still the same. We need to have the same image for multiple functions in the stack so we can allocate memory and timeouts differently for our "web" function or "job" functions. Hope that makes sense.The text was updated successfully, but these errors were encountered: