What package type would you like to use? 1 - Zip 2 - Image Package type: 2
Based on your selections, the only dependency manager available is pip. We will proceed copying the template using pip.
Would you like to enable X-Ray tracing on the function(s) in your application? [y/N]: n
Would you like to enable monitoring using CloudWatch Application Insights? For more info, please view https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-application-insights.html [y/N]: n
Project name [sam-app]: scanocr-sam
Cloning from https://github.com/aws/aws-sam-cli-app-templates (process may take a moment)
Next steps can be found in the README file at scanocr-sam/README.md
Commands you can use next ========================= [*] Create pipeline: cd scanocr-sam && sam pipeline init --bootstrap [*] Validate SAM template: cd scanocr-sam && sam validate [*] Test Function in the Cloud: cd scanocr-sam && sam sync --stack-name {stack-name} --watch
RUN python3.9 -m pip install -r requirements.txt -t .
# Command can be overwritten by providing a different command in the template directly. CMD ["app.lambda_handler"]
試しにローカル実行してみます。
1 2 3 4
$ cd scanocr-sam/ $ sam build $ sam local invoke {"statusCode": 200, "body": "{\"message\": \"hello world\"}"}END RequestId: 770d2ec0-6d05-4ee2-a2b6-df18fdefc43c
ローカルAPI実行も試してみます。
1 2 3 4 5 6 7
$ sam local start-api Initializing the lambda functions containers. Building image................. Using local image: helloworldfunction:rapid-x86_64.
Containers Initialization is done. Mounting HelloWorldFunction at http://127.0.0.1:3000/hello [GET]