aws-sam-cli
aws-sam-cli copied to clipboard
Bug: sam build --use-container fails for Hello world sample application in Cloud9
Description:
sam build --use-container fails for Hello world sample application in Cloud9
Steps to reproduce:
- Start new default Cloud9 with AL2.
- Run
sudo yum update. - Install latest SAM CLI: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html#install-sam-cli-instructions
- Run sam init and create sample Hello world app with default settings (Python): https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html
- Run
sam build --use-container.
Observed result:
Admin:~/environment/sam-app $ sam build --use-container --debug
2023-11-28 14:55:22,515 | Config file location: /home/ec2-user/environment/sam-app/samconfig.toml
2023-11-28 14:55:22,519 | Loading configuration values from [default.['build'].parameters] (env.command_name.section) in config file
at '/home/ec2-user/environment/sam-app/samconfig.toml'...
2023-11-28 14:55:22,521 | Configuration values successfully loaded.
2023-11-28 14:55:22,522 | Configuration values are: {'stack_name': 'sam-app', 'cached': True, 'parallel': True}
2023-11-28 14:55:22,529 | Using SAM Template at /home/ec2-user/environment/sam-app/template.yaml
2023-11-28 14:55:22,578 | Using config file: samconfig.toml, config environment: default
2023-11-28 14:55:22,580 | Expand command line arguments to:
2023-11-28 14:55:22,581 | --template_file=/home/ec2-user/environment/sam-app/template.yaml --use_container --parallel
--mount_with=READ --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache --cached
2023-11-28 14:55:22,711 | 'build' command is called
2023-11-28 14:55:22,713 | Starting Build use cache
2023-11-28 14:55:22,714 | Starting Build inside a container
2023-11-28 14:55:22,719 | No Parameters detected in the template
2023-11-28 14:55:22,747 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the
resource logical id as the resource id
2023-11-28 14:55:22,748 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the
resource logical id as the resource id
2023-11-28 14:55:22,750 | 0 stacks found in the template
2023-11-28 14:55:22,751 | No Parameters detected in the template
2023-11-28 14:55:22,774 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the
resource logical id as the resource id
2023-11-28 14:55:22,775 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the
resource logical id as the resource id
2023-11-28 14:55:22,777 | 2 resources found in the stack
2023-11-28 14:55:22,778 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/'
2023-11-28 14:55:22,780 | --base-dir is not presented, adjusting uri hello_world/ relative to
/home/ec2-user/environment/sam-app/template.yaml
2023-11-28 14:55:22,788 | 2 resources found in the stack
2023-11-28 14:55:22,790 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/'
2023-11-28 14:55:22,793 | Instantiating build definitions
2023-11-28 14:55:22,794 | No previous build graph found, generating new one
2023-11-28 14:55:22,796 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(python3.9,
/home/ec2-user/environment/sam-app/hello_world, Zip, , 9a97982b-4cf7-4621-b94b-8ec43afd29c4, {}, {}, x86_64, []), Function:
Function(function_id='HelloWorldFunction', name='HelloWorldFunction', functionname='HelloWorldFunction', runtime='python3.9',
memory=128, timeout=3, handler='app.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None,
codeuri='/home/ec2-user/environment/sam-app/hello_world', environment=None, rolearn=None, layers=[], events={'HelloWorld': {'Type':
'Api', 'Properties': {'Path': '/hello', 'Method': 'get', 'RestApiId': 'ServerlessRestApi'}}}, metadata={'SamResourceId':
'HelloWorldFunction'}, inlinecode=None, codesign_config_arn=None, architectures=['x86_64'], function_url_config=None,
function_build_info=<FunctionBuildInfo.BuildableZip: ('BuildableZip', 'Regular ZIP function which can be build with SAM CLI')>,
stack_path='', runtime_management_config=None, logging_config=None))
2023-11-28 14:55:22,808 | Async execution started
2023-11-28 14:55:22,809 | Invoking function functools.partial(<bound method ParallelBuildStrategy.build_single_function_definition of
<samcli.lib.build.build_strategy.ParallelBuildStrategy object at 0x7f14aa46ab10>>,
<samcli.lib.build.build_graph.FunctionBuildDefinition object at 0x7f14a8f03e90>)
2023-11-28 14:55:22,812 | Running incremental build for runtime python3.9 for following resources (HelloWorldFunction)
2023-11-28 14:55:22,813 | Waiting for async results
2023-11-28 14:55:22,815 | Cache is invalid, running build and copying resources for following functions (HelloWorldFunction)
2023-11-28 14:55:22,816 | Building codeuri: /home/ec2-user/environment/sam-app/hello_world runtime: python3.9 metadata: {}
architecture: x86_64 functions: HelloWorldFunction
2023-11-28 14:55:22,817 | Building to following folder /home/ec2-user/environment/sam-app/.aws-sam/build/HelloWorldFunction
Fetching public.ecr.aws/sam/build-python3.9:latest-x86_64 Docker container image.............................................................................................................................................................................................................................................................................................................................................................................................................................
2023-11-28 14:56:01,424 | Mounting /home/ec2-user/environment/sam-app/hello_world as /tmp/samcli/source:ro,delegated, inside runtime
container
Using the request object from command line argument
Loading workflow module 'aws_lambda_builders.workflows'
Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'
Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framewor =None)'
Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
Registering workflow 'NodejsNpmEsbuildBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm-esbuild', application_framework=None)'
Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
Registering workflow 'RustCargoLambdaBuilder' with capability 'Capability(language='rust', dependency_manager='cargo', application_framework=None)'
Found workflow 'PythonPipBuilder' to support capabilities 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Running workflow 'PythonPipBuilder'
Running PythonPipBuilder:ResolveDependencies
calling pip download -r /tmp/samcli/source/requirements.txt --dest /tmp/samcli/scratch --exists-action i
Full dependency closure: {requests==2.31.0(wheel), charset-normalizer==3.3.2(wheel), idna==3.6(wheel), certifi==2023.11.17(wheel), urllib3==2.1.0(wheel)}
initial compatible: {requests==2.31.0(wheel), charset-normalizer==3.3.2(wheel), idna==3.6(wheel), certifi==2023.11.17(wheel), urllib3==2.1.0(wheel)}
initial incompatible: set()
Downloading missing wheels: set()
compatible wheels after second download pass: {requests==2.31.0(wheel), charset-normalizer==3.3.2(wheel), idna==3.6(wheel), certifi==2023.11.17(wheel), urllib3==2.1.0(wheel)}
Build missing wheels from sdists (C compiling True): set()
compatible after building wheels (no C compiling): {requests==2.31.0(wheel), charset-normalizer==3.3.2(wheel), idna==3.6(wheel), certifi==2023.11.17(wheel), urllib3==2.1.0(wheel)}
Build missing wheels from sdists (C compiling False): set()
compatible after building wheels (C compiling): {requests==2.31.0(wheel), charset-normalizer==3.3.2(wheel), idna==3.6(wheel), certifi==2023.11.17(wheel), urllib3==2.1.0(wheel)}
Final compatible: {requests==2.31.0(wheel), charset-normalizer==3.3.2(wheel), idna==3.6(wheel), certifi==2023.11.17(wheel), urllib3==2.1.0(wheel)}
Final incompatible: set()
Final missing wheels: set()
PythonPipBuilder:ResolveDependencies succeeded
Running PythonPipBuilder:CopySource
Copying source file (/tmp/samcli/source/__init__.py) to destination (/tmp/samcli/artifacts/__init__.py)
Copying source file (/tmp/samcli/source/app.py) to destination (/tmp/samcli/artifacts/app.py)
Copying source file (/tmp/samcli/source/requirements.txt) to destination (/tmp/samcli/artifacts/requirements.txt)
PythonPipBuilder:CopySource succeeded
2023-11-28 14:56:05,382 | Build inside container returned response {"jsonrpc": "2.0", "id": 1, "result": {"artifacts_dir":
"/tmp/samcli/artifacts"}}
2023-11-28 14:56:05,385 | Build inside container was successful. Copying artifacts from container to host
2023-11-28 14:56:05,521 | Copying from container: /tmp/samcli/artifacts/. ->
/home/ec2-user/environment/sam-app/.aws-sam/build/HelloWorldFunction
2023-11-28 14:56:05,639 | Build inside container succeeded
2023-11-28 14:56:05,656 | Async execution completed
2023-11-28 14:56:05,663 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the
resource logical id as the resource id
2023-11-28 14:56:05,666 | 2 resources found in the stack
2023-11-28 14:56:05,668 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/'
Build Succeeded
Built Artifacts : .aws-sam/build
Built Template : .aws-sam/build/template.yaml
Commands you can use next
=========================
[*] Validate SAM template: sam validate
[*] Invoke Function: sam local invoke
[*] Test Function in the Cloud: sam sync --stack-name {{stack-name}} --watch
[*] Deploy: sam deploy --guided
2023-11-28 14:56:05,674 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-11-28 14:56:05,712 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-11-28 14:56:05,714 | Unable to find Click Context for getting session_id.
2023-11-28 14:56:05,714 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': 'e5aa1313-8979-40fa-9f2d-e7e0f0cf6689',
'installationId': 'e41d02ab-ef17-4ff0-b021-7c58fb6b881a', 'sessionId': '2eef3681-b69f-4de9-b3f1-0c9fdc7cc44b', 'executionEnvironment':
'CLI', 'ci': False, 'pyversion': '3.11.3', 'samcliVersion': '1.103.0', 'awsProfileProvided': False, 'debugFlagProvided': True,
'region': '', 'commandName': 'sam build', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName':
'593ab2ca51e925b9f6c2f258bc55ed5926cf6d2c78239a685d65907e4ec7edd3', 'initialCommit': None}, 'duration': 43095, 'exitReason':
'success', 'exitCode': 0}}]}
2023-11-28 14:56:05,716 | Sending Telemetry: {'metrics': [{'events': {'requestId': '975f8ecf-1045-46a3-9d31-e07c5a23f34e',
'installationId': 'e41d02ab-ef17-4ff0-b021-7c58fb6b881a', 'sessionId': '2eef3681-b69f-4de9-b3f1-0c9fdc7cc44b', 'executionEnvironment':
'CLI', 'ci': False, 'pyversion': '3.11.3', 'samcliVersion': '1.103.0', 'commandName': 'sam build', 'metricSpecificAttributes':
{'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': 'd7abf6112ff04daa856d9823b284754c',
'time_stamp': '2023-11-28 14:55:22.515', 'exception_name': None}, {'event_name': 'SamConfigFileExtension', 'event_value': '.toml',
'thread_id': '2ebe3c43b8b34d1fa5c585ade9e175b5', 'time_stamp': '2023-11-28 14:55:22.578', 'exception_name': None}, {'event_name':
'BuildWorkflowUsed', 'event_value': 'python-pip', 'thread_id': '16301a4ef6e947ee834f1fdf620ddc08', 'time_stamp': '2023-11-28
14:55:22.792', 'exception_name': None}, {'event_name': 'BuildFunctionRuntime', 'event_value': 'python3.9', 'thread_id':
'4bd3d38ea9394855a0f69e6c64867704', 'time_stamp': '2023-11-28 14:55:22.792', 'exception_name': None}, {'event_name':
'BuildWorkflowUsed', 'event_value': 'python-pip', 'thread_id': '311a8df80c45468ea4a2e8204230f8aa', 'time_stamp': '2023-11-28
14:55:22.819', 'exception_name': None}]}}}]}
2023-11-28 14:56:06,087 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed
out. (read timeout=0.1)
2023-11-28 14:56:06,089 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed
out. (read timeout=0.1)
Expected result:
SAM build container.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Amazon Linux 2
sam --version: 1.103.0- AWS region: us-west-1
{
"version": "1.103.0",
"system": {
"python": "3.11.3",
"os": "Linux-5.10.198-187.748.amzn2.x86_64-x86_64-with-glibc2.26"
},
"additional_dependencies": {
"docker_engine": "20.10.25",
"aws_cdk": "2.108.1 (build 2320255)",
"terraform": "1.6.4"
},
"available_beta_feature_env_vars": [
"SAM_CLI_BETA_FEATURES",
"SAM_CLI_BETA_BUILD_PERFORMANCE",
"SAM_CLI_BETA_TERRAFORM_SUPPORT",
"SAM_CLI_BETA_RUST_CARGO_LAMBDA"
]
}
Add --debug flag to command you are running
⚠️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.