Comments (3)
Hi @devmuch, thanks for opening the issue. The modules
folder needs to be copied to the image as well. Here is a simple project that I have created based on the details you provided:
template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
python3.9
Sample SAM Template for sam-app-6592
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
MemorySize: 128
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
PackageType: Image
Architectures:
- x86_64
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /hello
Method: get
Metadata:
Dockerfile: ./hello_world/Dockerfile
DockerContext: .
DockerTag: python3.9-v1
app.py
from modules.my_module import create_message
def lambda_handler(event, context):
return {
"statusCode": 200,
"body": create_message()
}
Dockerfile
FROM public.ecr.aws/lambda/python:3.9
COPY ./hello_world/requirements.txt ./
RUN python3.9 -m pip install -r requirements.txt -t .
COPY ./hello_world/app.py ./
ADD ./modules ./modules
# Command can be overwritten by providing a different command in the template directly.
CMD ["app.lambda_handler"]
directory structure
.
├── README.md
├── __init__.py
├── events
│ └── event.json
├── hello_world
│ ├── Dockerfile
│ ├── __init__.py
│ ├── app.py
│ └── requirements.txt
├── modules
│ └── my_module.py
├── samconfig.toml
├── template.yaml
Let us know if you still have questions.
from aws-sam-cli.
Thanks for this. I naively assumed it copy the folder contents, but RTFM proves me wrong. :-)
from aws-sam-cli.
⚠️ COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
from aws-sam-cli.
Related Issues (20)
- Token Authorizer doesn't get linked if FunctionPayloadType missing in template.yml HOT 1
- Feature Request: Set ECR Lifecycle when deploying a lambda with a docker image HOT 9
- Unable to Retrieve Bot Response: ERR_NAME_NOT_RESOLVED and 403 Forbidden Error in Flask Application HOT 6
- Bug: sam cli build stuck on mounting.... HOT 3
- Permission denied: '/tmp/samcli/source/gradlew' when building aws-sam-cli-build-image-java11 HOT 3
- Bug: option --base-dir does not work HOT 1
- Bug: sam build - OSError HOT 1
- CDK followSymlinks not supported HOT 2
- Unclear how to use different build-image values for sam build call HOT 3
- SAM CLI Build Not Recognizing requirements.txt File HOT 3
- Bug: sam local invoke - FileNotFoundError HOT 3
- Bug: sam build - PermissionError HOT 2
- Unable to solve mapping for Timeout property HOT 3
- Bug: sam build - InvalidSamDocumentException HOT 3
- Bug: ValueError when executing `sam init` HOT 3
- Unable to debug AWS Quick Start application - Hello World Example with Powertools for AWS Lambda HOT 4
- Bug: CDK typescript project fails with "Runtime.ImportModuleError" when running sam local HOT 7
- SAM Does not build the application, returns "PythonPipBuilder:ResolveDependencies failed HOT 4
- Bug: Missing DockerContext doesn't fail validation HOT 2
- `sam init` fails to deploy a standard sample on Windows platform HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-sam-cli.