The other day (one day in September 2020), I tried to output sam (Serverless Application Model) hello world template (runtime is python3.8) in the newly created AWS Cloud9 development environment (platform = AmazonLinux) and try build and deploy. When I tried to build with the "sam build --use-container" command, I encountered the following error. I got an error (Runtime Error: Container does not exist) in the environment I just created, so I got "What ??".
(↓ is for reference, until the hello_world template is output)
ec2-user:~/environment $ sam init --runtime python3.8 -n sam-py38
SAM CLI now collects telemetry to better understand customer needs.
You can OPT OUT and disable telemetry collection by setting the
environment variable SAM_CLI_TELEMETRY=0 in your shell.
Thanks for your help!
Learn More: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-telemetry.html
Which template source would you like to use?
1 - AWS Quick Start Templates
2 - Custom Template Location
Choice: 1
Allow SAM CLI to download AWS-provided quick start templates from Github [Y/n]: Y
AWS quick start application templates:
1 - Hello World Example
2 - EventBridge Hello World
3 - EventBridge App from scratch (100+ Event Schemas)
4 - Step Functions Sample App (Stock Trader)
5 - Elastic File System Sample App
Template selection: 1
-----------------------
Generating application:
-----------------------
Name: sam-py38
Runtime: python3.8
Dependency Manager: pip
Application Template: hello-world
Output Directory: .
Next steps can be found in the README file at ./sam-py38/README.md
ec2-user:~/environment $ cd sam-py38/
(The place where the sam build command of hello_world output by ↓ becomes RuntimeError)
ec2-user:~/environment/sam-py38 $ sam build --use-container
Starting Build inside a container
Building resource 'HelloWorldFunction'
Fetching lambci/lambda:build-python3.8 Docker container image.....................................................................................................................................................................................................................................................
Mounting /home/ec2-user/environment/sam-py38/hello_world as /tmp/samcli/source:ro,delegated inside runtime container
Traceback (most recent call last):
File "/usr/local/bin/sam", line 11, in <module>
sys.exit(cli())
File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 764, in __call__
~ (Omitted) ~
File "/usr/local/lib/python3.6/site-packages/samcli/local/docker/container.py", line 197, in wait_for_logs
raise RuntimeError("Container does not exist. Cannot get logs for this container")
RuntimeError: Container does not exist. Cannot get logs for this container
I did not know the cause intuitively from the error message, so when I contacted AWS support,
Due to insufficient capacity of the EBS volume associated with the EC2 instance in the Cloud9 environment
I received the answer.
I solved it by expanding the capacity of the EBS volume to 20G by referring to the following document.
Resize an Amazon EBS volume used by an environment https://docs.aws.amazon.com/cloud9/latest/user-guide/move-environment.html#move-environment-resize
The size expansion by this method is also introduced in the article below, and it can be expanded very easily. Increase the disk size of AWS Cloud9 https://qiita.com/Keisuke69/items/af87eb8629ad4249bd22
The initial volume size will quickly run out, especially if you're doing docker-related work on Cloud9, so remember how to easily expand the volume as needed using resize.sh. I think it's convenient.
It's easy, but that's it. I hope that fewer people will have trouble with the same problem.
Recommended Posts