Skip to content
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

Bug: sam build --use-container times out on Amazon Linux 2 #6361

Closed
pbv0 opened this issue Nov 29, 2023 · 10 comments
Closed

Bug: sam build --use-container times out on Amazon Linux 2 #6361

pbv0 opened this issue Nov 29, 2023 · 10 comments
Labels
blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days

Comments

@pbv0
Copy link

pbv0 commented Nov 29, 2023

Description:

sam build --use-container times out for my project.

Steps to reproduce:

Start new Cloud9 instance with default configuration (Amazon Linux 2):

git clone https://github.com/aws-samples/serverless-pdf-chat.git
cd serverless-pdf-chat/backend
sam deploy --use-container

Observed result:

The command just keeps running and even after 30 minutes shows no reaction:

Admin:~/environment/serverless-pdf-chat/backend (main) $ sam build --use-container
Starting Build inside a container                                                                                                     
Building codeuri: /home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_presigned_url runtime: python3.11 metadata: {}  
architecture: arm64 functions: GeneratePresignedUrlFunction                                                                           

Fetching public.ecr.aws/sam/build-python3.11:latest-arm64 Docker container image.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Mounting /home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_presigned_url as /tmp/samcli/source:ro,delegated, inside 
runtime container                                                                                                                     
^Cexec /usr/local/opt/sam-cli/bin/lambda-builders: exec format error

Aborted!
^CAdmin:~/environment/serverless-pdf-chat/backend (main) $ ^C
Admin:~/environment/serverless-pdf-chat/backend (main) $ sam build --use-container --debug
2023-11-29 17:40:50,140 | No config file found in this directory.                                                                     
2023-11-29 17:40:50,145 | OSError occurred while reading TOML file: [Errno 2] No such file or directory:                              
'/home/ec2-user/environment/serverless-pdf-chat/backend/samconfig.toml'                                                               
2023-11-29 17:40:50,148 | Config file location: /home/ec2-user/environment/serverless-pdf-chat/backend/samconfig.toml                 
2023-11-29 17:40:50,149 | Config file '/home/ec2-user/environment/serverless-pdf-chat/backend/samconfig.toml' does not exist          
2023-11-29 17:40:50,189 | Using SAM Template at /home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                  
2023-11-29 17:40:50,220 | OSError occurred while reading TOML file: [Errno 2] No such file or directory:                              
'/home/ec2-user/environment/serverless-pdf-chat/backend/samconfig.toml'                                                               
2023-11-29 17:40:50,222 | Using config file: samconfig.toml, config environment: default                                              
2023-11-29 17:40:50,223 | Expand command line arguments to:                                                                           
2023-11-29 17:40:50,225 | --template_file=/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml --use_container        
--mount_with=READ --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache                                                               
2023-11-29 17:40:50,365 | 'build' command is called                                                                                   
2023-11-29 17:40:50,367 | Starting Build inside a container                                                                           
2023-11-29 17:40:50,404 | Collected default values for parameters: {'Frontend': 'local'}                                              
2023-11-29 17:40:50,457 | There is no customer defined id or cdk path defined for resource DocumentBucket, so we will use the resource
logical id as the resource id                                                                                                         
2023-11-29 17:40:50,459 | There is no customer defined id or cdk path defined for resource DocumentBucketPolicy, so we will use the   
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,461 | There is no customer defined id or cdk path defined for resource EmbeddingQueue, so we will use the resource
logical id as the resource id                                                                                                         
2023-11-29 17:40:50,463 | There is no customer defined id or cdk path defined for resource EmbeddingQueuePolicy, so we will use the   
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,465 | There is no customer defined id or cdk path defined for resource DocumentTable, so we will use the resource 
logical id as the resource id                                                                                                         
2023-11-29 17:40:50,467 | There is no customer defined id or cdk path defined for resource MemoryTable, so we will use the resource   
logical id as the resource id                                                                                                         
2023-11-29 17:40:50,469 | There is no customer defined id or cdk path defined for resource CognitoUserPool, so we will use the        
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,471 | There is no customer defined id or cdk path defined for resource CognitoUserPoolClient, so we will use the  
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,473 | There is no customer defined id or cdk path defined for resource Api, so we will use the resource logical id
as the resource id                                                                                                                    
2023-11-29 17:40:50,475 | There is no customer defined id or cdk path defined for resource GeneratePresignedUrlFunction, so we will   
use the resource logical id as the resource id                                                                                        
2023-11-29 17:40:50,477 | There is no customer defined id or cdk path defined for resource UploadTriggerFunction, so we will use the  
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,479 | There is no customer defined id or cdk path defined for resource GetDocumentFunction, so we will use the    
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,481 | There is no customer defined id or cdk path defined for resource GetAllDocuments, so we will use the        
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,483 | There is no customer defined id or cdk path defined for resource AddConversationFunction, so we will use the
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,485 | There is no customer defined id or cdk path defined for resource GenerateEmbeddingsFunction, so we will use 
the resource logical id as the resource id                                                                                            
2023-11-29 17:40:50,487 | There is no customer defined id or cdk path defined for resource GenerateResponseFunction, so we will use   
the resource logical id as the resource id                                                                                            
2023-11-29 17:40:50,489 | There is no customer defined id or cdk path defined for resource AmplifyApp, so we will use the resource    
logical id as the resource id                                                                                                         
2023-11-29 17:40:50,491 | There is no customer defined id or cdk path defined for resource AmplifyBranch, so we will use the resource 
logical id as the resource id                                                                                                         
2023-11-29 17:40:50,497 | Unable to resolve property QUEUE: {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}. Leaving as is.           
2023-11-29 17:40:50,499 | Unable to resolve property queueName: {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}. Leaving as is.       
2023-11-29 17:40:50,501 | Unable to resolve property Resource: {'Fn::Sub':                                                            
['arn:${AWS::Partition}:sqs:${AWS::Region}:${AWS::AccountId}:${queueName}', {'queueName': {'Fn::GetAtt': ['EmbeddingQueue',           
'QueueName']}}]}. Leaving as is.                                                                                                      
2023-11-29 17:40:50,504 | Unable to resolve property queueName: {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}. Leaving as is.       
2023-11-29 17:40:50,505 | Unable to resolve property Resource: {'Fn::Sub':                                                            
['arn:${AWS::Partition}:sqs:${AWS::Region}:${AWS::AccountId}:${queueName}', {'queueName': {'Fn::GetAtt': ['EmbeddingQueue',           
'QueueName']}}]}. Leaving as is.                                                                                                      
2023-11-29 17:40:50,509 | Unable to resolve property AppId: {'Fn::GetAtt': ['AmplifyApp', 'AppId']}. Leaving as is.                   
2023-11-29 17:40:50,511 | 0 stacks found in the template                                                                              
2023-11-29 17:40:50,513 | Collected default values for parameters: {'Frontend': 'local'}                                              
2023-11-29 17:40:50,556 | There is no customer defined id or cdk path defined for resource DocumentBucket, so we will use the resource
logical id as the resource id                                                                                                         
2023-11-29 17:40:50,558 | There is no customer defined id or cdk path defined for resource DocumentBucketPolicy, so we will use the   
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,559 | There is no customer defined id or cdk path defined for resource EmbeddingQueue, so we will use the resource
logical id as the resource id                                                                                                         
2023-11-29 17:40:50,561 | There is no customer defined id or cdk path defined for resource EmbeddingQueuePolicy, so we will use the   
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,563 | There is no customer defined id or cdk path defined for resource DocumentTable, so we will use the resource 
logical id as the resource id                                                                                                         
2023-11-29 17:40:50,565 | There is no customer defined id or cdk path defined for resource MemoryTable, so we will use the resource   
logical id as the resource id                                                                                                         
2023-11-29 17:40:50,567 | There is no customer defined id or cdk path defined for resource CognitoUserPool, so we will use the        
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,569 | There is no customer defined id or cdk path defined for resource CognitoUserPoolClient, so we will use the  
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,571 | There is no customer defined id or cdk path defined for resource Api, so we will use the resource logical id
as the resource id                                                                                                                    
2023-11-29 17:40:50,573 | There is no customer defined id or cdk path defined for resource GeneratePresignedUrlFunction, so we will   
use the resource logical id as the resource id                                                                                        
2023-11-29 17:40:50,575 | There is no customer defined id or cdk path defined for resource UploadTriggerFunction, so we will use the  
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,577 | There is no customer defined id or cdk path defined for resource GetDocumentFunction, so we will use the    
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,579 | There is no customer defined id or cdk path defined for resource GetAllDocuments, so we will use the        
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,581 | There is no customer defined id or cdk path defined for resource AddConversationFunction, so we will use the
resource logical id as the resource id                                                                                                
2023-11-29 17:40:50,583 | There is no customer defined id or cdk path defined for resource GenerateEmbeddingsFunction, so we will use 
the resource logical id as the resource id                                                                                            
2023-11-29 17:40:50,585 | There is no customer defined id or cdk path defined for resource GenerateResponseFunction, so we will use   
the resource logical id as the resource id                                                                                            
2023-11-29 17:40:50,588 | There is no customer defined id or cdk path defined for resource AmplifyApp, so we will use the resource    
logical id as the resource id                                                                                                         
2023-11-29 17:40:50,590 | There is no customer defined id or cdk path defined for resource AmplifyBranch, so we will use the resource 
logical id as the resource id                                                                                                         
2023-11-29 17:40:50,595 | Unable to resolve property QUEUE: {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}. Leaving as is.           
2023-11-29 17:40:50,597 | Unable to resolve property queueName: {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}. Leaving as is.       
2023-11-29 17:40:50,598 | Unable to resolve property Resource: {'Fn::Sub':                                                            
['arn:${AWS::Partition}:sqs:${AWS::Region}:${AWS::AccountId}:${queueName}', {'queueName': {'Fn::GetAtt': ['EmbeddingQueue',           
'QueueName']}}]}. Leaving as is.                                                                                                      
2023-11-29 17:40:50,601 | Unable to resolve property queueName: {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}. Leaving as is.       
2023-11-29 17:40:50,602 | Unable to resolve property Resource: {'Fn::Sub':                                                            
['arn:${AWS::Partition}:sqs:${AWS::Region}:${AWS::AccountId}:${queueName}', {'queueName': {'Fn::GetAtt': ['EmbeddingQueue',           
'QueueName']}}]}. Leaving as is.                                                                                                      
2023-11-29 17:40:50,605 | Unable to resolve property AppId: {'Fn::GetAtt': ['AmplifyApp', 'AppId']}. Leaving as is.                   
2023-11-29 17:40:50,606 | 18 resources found in the stack                                                                             
2023-11-29 17:40:50,607 | Found Serverless function with name='GeneratePresignedUrlFunction' and CodeUri='src/generate_presigned_url/'
2023-11-29 17:40:50,608 | --base-dir is not presented, adjusting uri src/generate_presigned_url/ relative to                          
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-11-29 17:40:50,610 | Found Serverless function with name='UploadTriggerFunction' and CodeUri='src/upload_trigger/'               
2023-11-29 17:40:50,611 | --base-dir is not presented, adjusting uri src/upload_trigger/ relative to                                  
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-11-29 17:40:50,613 | Found Serverless function with name='GetDocumentFunction' and CodeUri='src/get_document/'                   
2023-11-29 17:40:50,614 | --base-dir is not presented, adjusting uri src/get_document/ relative to                                    
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-11-29 17:40:50,615 | Found Serverless function with name='GetAllDocuments' and CodeUri='src/get_all_documents/'                  
2023-11-29 17:40:50,616 | --base-dir is not presented, adjusting uri src/get_all_documents/ relative to                               
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-11-29 17:40:50,618 | Found Serverless function with name='AddConversationFunction' and CodeUri='src/add_conversation/'           
2023-11-29 17:40:50,619 | --base-dir is not presented, adjusting uri src/add_conversation/ relative to                                
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-11-29 17:40:50,620 | Found Serverless function with name='GenerateEmbeddingsFunction' and CodeUri='src/generate_embeddings/'     
2023-11-29 17:40:50,622 | --base-dir is not presented, adjusting uri src/generate_embeddings/ relative to                             
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-11-29 17:40:50,623 | Found Serverless function with name='GenerateResponseFunction' and CodeUri='src/generate_response/'         
2023-11-29 17:40:50,624 | --base-dir is not presented, adjusting uri src/generate_response/ relative to                               
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-11-29 17:40:50,661 | 18 resources found in the stack                                                                             
2023-11-29 17:40:50,662 | Found Serverless function with name='GeneratePresignedUrlFunction' and CodeUri='src/generate_presigned_url/'
2023-11-29 17:40:50,663 | Found Serverless function with name='UploadTriggerFunction' and CodeUri='src/upload_trigger/'               
2023-11-29 17:40:50,664 | Found Serverless function with name='GetDocumentFunction' and CodeUri='src/get_document/'                   
2023-11-29 17:40:50,666 | Found Serverless function with name='GetAllDocuments' and CodeUri='src/get_all_documents/'                  
2023-11-29 17:40:50,667 | Found Serverless function with name='AddConversationFunction' and CodeUri='src/add_conversation/'           
2023-11-29 17:40:50,669 | Found Serverless function with name='GenerateEmbeddingsFunction' and CodeUri='src/generate_embeddings/'     
2023-11-29 17:40:50,670 | Found Serverless function with name='GenerateResponseFunction' and CodeUri='src/generate_response/'         
2023-11-29 17:40:50,673 | Instantiating build definitions                                                                             
2023-11-29 17:40:50,693 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_presigned_url, Zip, , 88a6afa2-b978-44de-9a35-880eb4d2d422, {},   
{}, arm64, []), Current: BuildDefinition(python3.11,                                                                                  
/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_presigned_url, Zip, , cbe183d8-16a1-4a18-82da-ede783b9b502, {},   
{}, arm64, []), Function: Function(function_id='GeneratePresignedUrlFunction', name='GeneratePresignedUrlFunction',                   
functionname='GeneratePresignedUrlFunction', runtime='python3.11', memory=None, timeout=None, handler='main.lambda_handler',          
imageuri=None, packagetype='Zip', imageconfig=None,                                                                                   
codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_presigned_url', environment={'Variables': {'LOG_LEVEL':  
'INFO', 'BUCKET': 'DocumentBucket', 'REGION': 'us-east-1'}}, rolearn=None, layers=[<samcli.lib.providers.provider.LayerVersion object 
at 0x7f40a174ecd0>], events={'Root': {'Type': 'Api', 'Properties': {'RestApiId': 'Api', 'Path': '/generate_presigned_url', 'Method':  
'GET'}}}, metadata={'SamResourceId': 'GeneratePresignedUrlFunction'}, inlinecode=None, codesign_config_arn=None,                      
architectures=['arm64'], 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-29 17:40:50,701 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/upload_trigger, Zip, , 3f5cbbb5-3aa5-468a-bf80-771bf2def7ab, {}, {}, arm64,
[]), Current: BuildDefinition(python3.11, /home/ec2-user/environment/serverless-pdf-chat/backend/src/upload_trigger, Zip, ,           
d3400ad4-b01d-49c2-9c39-cd20bfc988a2, {}, {}, arm64, []), Function: Function(function_id='UploadTriggerFunction',                     
name='UploadTriggerFunction', functionname='UploadTriggerFunction', runtime='python3.11', memory=None, timeout=None,                  
handler='main.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None,                                                    
codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/upload_trigger', environment={'Variables': {'LOG_LEVEL': 'INFO',  
'DOCUMENT_TABLE': 'DocumentTable', 'MEMORY_TABLE': 'MemoryTable', 'QUEUE': {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}, 'BUCKET': 
'local-us-east-1-123456789012'}}, rolearn=None, layers=[<samcli.lib.providers.provider.LayerVersion object at 0x7f40a128d4d0>],       
events={'S3Event': {'Type': 'S3', 'Properties': {'Bucket': 'DocumentBucket', 'Events': ['s3:ObjectCreated:*'], 'Filter': {'S3Key':    
{'Rules': [{'Name': 'suffix', 'Value': '.pdf'}]}}}}}, metadata={'SamResourceId': 'UploadTriggerFunction'}, inlinecode=None,           
codesign_config_arn=None, architectures=['arm64'], 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-29 17:40:50,708 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/get_document, Zip, , aa6a49cb-1f5e-48c4-89b5-2a45255c213f, {}, {}, arm64,  
[]), Current: BuildDefinition(python3.11, /home/ec2-user/environment/serverless-pdf-chat/backend/src/get_document, Zip, ,             
910afdd7-25eb-4cb1-a93e-4bc84c1dcd6d, {}, {}, arm64, []), Function: Function(function_id='GetDocumentFunction',                       
name='GetDocumentFunction', functionname='GetDocumentFunction', runtime='python3.11', memory=None, timeout=None,                      
handler='main.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None,                                                    
codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/get_document', environment={'Variables': {'LOG_LEVEL': 'INFO',    
'DOCUMENT_TABLE': 'DocumentTable', 'MEMORY_TABLE': 'MemoryTable'}}, rolearn=None, layers=[<samcli.lib.providers.provider.LayerVersion 
object at 0x7f40a137a210>], events={'Root': {'Type': 'Api', 'Properties': {'RestApiId': 'Api', 'Path':                                
'/doc/{documentid}/{conversationid}', 'Method': 'GET'}}}, metadata={'SamResourceId': 'GetDocumentFunction'}, inlinecode=None,         
codesign_config_arn=None, architectures=['arm64'], 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-29 17:40:50,715 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/get_all_documents, Zip, , ac631865-731c-4c66-85f1-c532c86a39f9, {}, {},    
arm64, []), Current: BuildDefinition(python3.11, /home/ec2-user/environment/serverless-pdf-chat/backend/src/get_all_documents, Zip, , 
e61b66eb-3d61-435e-aab8-ece2099caa2e, {}, {}, arm64, []), Function: Function(function_id='GetAllDocuments', name='GetAllDocuments',   
functionname='GetAllDocuments', runtime='python3.11', memory=None, timeout=None, handler='main.lambda_handler', imageuri=None,        
packagetype='Zip', imageconfig=None, codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/get_all_documents',          
environment={'Variables': {'LOG_LEVEL': 'INFO', 'DOCUMENT_TABLE': 'DocumentTable'}}, rolearn=None,                                    
layers=[<samcli.lib.providers.provider.LayerVersion object at 0x7f40a11a4b90>], events={'Root': {'Type': 'Api', 'Properties':         
{'RestApiId': 'Api', 'Path': '/doc', 'Method': 'GET'}}}, metadata={'SamResourceId': 'GetAllDocuments'}, inlinecode=None,              
codesign_config_arn=None, architectures=['arm64'], 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-29 17:40:50,721 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/add_conversation, Zip, , c4e79296-6b90-443f-b14a-d4b896e8b922, {}, {},     
arm64, []), Current: BuildDefinition(python3.11, /home/ec2-user/environment/serverless-pdf-chat/backend/src/add_conversation, Zip, ,  
8b92a961-8964-42b9-8dcc-cdf4a480b280, {}, {}, arm64, []), Function: Function(function_id='AddConversationFunction',                   
name='AddConversationFunction', functionname='AddConversationFunction', runtime='python3.11', memory=None, timeout=None,              
handler='main.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None,                                                    
codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/add_conversation', environment={'Variables': {'LOG_LEVEL': 'INFO',
'DOCUMENT_TABLE': 'DocumentTable', 'MEMORY_TABLE': 'MemoryTable'}}, rolearn=None, layers=[<samcli.lib.providers.provider.LayerVersion 
object at 0x7f40a13797d0>], events={'Root': {'Type': 'Api', 'Properties': {'RestApiId': 'Api', 'Path': '/doc/{documentid}', 'Method': 
'POST'}}}, metadata={'SamResourceId': 'AddConversationFunction'}, inlinecode=None, codesign_config_arn=None, architectures=['arm64'], 
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-29 17:40:50,727 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_embeddings, Zip, , 27bb95b9-2f6c-4055-944a-4502b78a6ff7, {}, {},  
arm64, []), Current: BuildDefinition(python3.11, /home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_embeddings, Zip, 
, cd6c5047-d27f-4ac5-bd70-27c24aa3cf8d, {}, {}, arm64, []), Function: Function(function_id='GenerateEmbeddingsFunction',              
name='GenerateEmbeddingsFunction', functionname='GenerateEmbeddingsFunction', runtime='python3.11', memory=2048, timeout=180,         
handler='main.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None,                                                    
codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_embeddings', environment={'Variables': {'LOG_LEVEL':     
'INFO', 'DOCUMENT_TABLE': 'DocumentTable', 'BUCKET': 'DocumentBucket'}}, rolearn=None,                                                
layers=[<samcli.lib.providers.provider.LayerVersion object at 0x7f40a137a950>], events={'EmbeddingQueueEvent': {'Type': 'SQS',        
'Properties': {'Queue': 'arn:aws:lambda:us-east-1:123456789012:function:EmbeddingQueue', 'BatchSize': 1}}}, metadata={'SamResourceId':
'GenerateEmbeddingsFunction'}, inlinecode=None, codesign_config_arn=None, architectures=['arm64'], 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-29 17:40:50,740 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_response, Zip, , 1a07a7f7-4251-4cc0-a962-16ff41d835f6, {}, {},    
arm64, []), Current: BuildDefinition(python3.11, /home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_response, Zip, , 
2890408c-7d88-4cfe-b723-019c057e9d5e, {}, {}, arm64, []), Function: Function(function_id='GenerateResponseFunction',                  
name='GenerateResponseFunction', functionname='GenerateResponseFunction', runtime='python3.11', memory=2048, timeout=30,              
handler='main.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None,                                                    
codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_response', environment={'Variables': {'LOG_LEVEL':       
'INFO', 'MEMORY_TABLE': 'MemoryTable', 'BUCKET': 'DocumentBucket'}}, rolearn=None, layers=[<samcli.lib.providers.provider.LayerVersion
object at 0x7f40a136c390>], events={'Root': {'Type': 'Api', 'Properties': {'RestApiId': 'Api', 'Path':                                
'/{documentid}/{conversationid}', 'Method': 'POST'}}}, metadata={'SamResourceId': 'GenerateResponseFunction'}, inlinecode=None,       
codesign_config_arn=None, architectures=['arm64'], 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-29 17:40:50,753 | Building codeuri: /home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_presigned_url runtime:
python3.11 metadata: {} architecture: arm64 functions: GeneratePresignedUrlFunction                                                   
2023-11-29 17:40:50,757 | Building to following folder                                                                                
/home/ec2-user/environment/serverless-pdf-chat/backend/.aws-sam/build/GeneratePresignedUrlFunction                                    

Fetching public.ecr.aws/sam/build-python3.11:latest-arm64 Docker container image......
2023-11-29 17:40:51,724 | Mounting /home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_presigned_url as               
/tmp/samcli/source:ro,delegated, inside runtime container       

Expected result:

On my local machine (Macbook Air M1, macOS Ventura), I can successfully build and deploy.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

{
  "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"
  ]
}
@pbv0 pbv0 added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Nov 29, 2023
@lucashuy
Copy link
Contributor

Thanks for opening this issue! I can reproduce your issue where it appears that the build command is stuck. It looks like the Docker container that is created as part of the --use-container build process failed to exit gracefully and the build command ends up waiting for something to happen.

Taking a look at the template, the functions are defined as arm64 functions, while the Cloud9 machine is an x86_64 machine. You can build inside of an arm64 based image by utilizing qemu emulators to emulate the arm64 instructions on Cloud9. There are community provided Docker images that can help setup qemu emulators on your machine.

Alternatively, changing the architecture over to x86_64 will result in a successful build.

@lucashuy lucashuy added blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Nov 30, 2023
@pbv0
Copy link
Author

pbv0 commented Dec 1, 2023

Thank you, I tried switching to:

Architectures:
      - x86_64

However, this results in a different error:

Admin:~/environment/serverless-pdf-chat/backend (main) $ sam build --use-container --debug
2023-12-01 05:32:54,110 | No config file found in this directory.                                                                     
2023-12-01 05:32:54,116 | OSError occurred while reading TOML file: [Errno 2] No such file or directory:                              
'/home/ec2-user/environment/serverless-pdf-chat/backend/samconfig.toml'                                                               
2023-12-01 05:32:54,118 | Config file location: /home/ec2-user/environment/serverless-pdf-chat/backend/samconfig.toml                 
2023-12-01 05:32:54,120 | Config file '/home/ec2-user/environment/serverless-pdf-chat/backend/samconfig.toml' does not exist          
2023-12-01 05:32:54,157 | Using SAM Template at /home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                  
2023-12-01 05:32:54,188 | OSError occurred while reading TOML file: [Errno 2] No such file or directory:                              
'/home/ec2-user/environment/serverless-pdf-chat/backend/samconfig.toml'                                                               
2023-12-01 05:32:54,196 | Using config file: samconfig.toml, config environment: default                                              
2023-12-01 05:32:54,197 | Expand command line arguments to:                                                                           
2023-12-01 05:32:54,200 | --template_file=/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml --use_container        
--mount_with=READ --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache                                                               
2023-12-01 05:32:54,310 | 'build' command is called                                                                                   
2023-12-01 05:32:54,311 | Starting Build inside a container                                                                           
2023-12-01 05:32:54,348 | Collected default values for parameters: {'Frontend': 'local'}                                              
2023-12-01 05:32:54,389 | There is no customer defined id or cdk path defined for resource DocumentBucket, so we will use the resource
logical id as the resource id                                                                                                         
2023-12-01 05:32:54,392 | There is no customer defined id or cdk path defined for resource DocumentBucketPolicy, so we will use the   
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,393 | There is no customer defined id or cdk path defined for resource EmbeddingQueue, so we will use the resource
logical id as the resource id                                                                                                         
2023-12-01 05:32:54,395 | There is no customer defined id or cdk path defined for resource EmbeddingQueuePolicy, so we will use the   
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,397 | There is no customer defined id or cdk path defined for resource DocumentTable, so we will use the resource 
logical id as the resource id                                                                                                         
2023-12-01 05:32:54,399 | There is no customer defined id or cdk path defined for resource MemoryTable, so we will use the resource   
logical id as the resource id                                                                                                         
2023-12-01 05:32:54,401 | There is no customer defined id or cdk path defined for resource CognitoUserPool, so we will use the        
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,403 | There is no customer defined id or cdk path defined for resource CognitoUserPoolClient, so we will use the  
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,405 | There is no customer defined id or cdk path defined for resource Api, so we will use the resource logical id
as the resource id                                                                                                                    
2023-12-01 05:32:54,407 | There is no customer defined id or cdk path defined for resource GeneratePresignedUrlFunction, so we will   
use the resource logical id as the resource id                                                                                        
2023-12-01 05:32:54,409 | There is no customer defined id or cdk path defined for resource UploadTriggerFunction, so we will use the  
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,411 | There is no customer defined id or cdk path defined for resource GetDocumentFunction, so we will use the    
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,413 | There is no customer defined id or cdk path defined for resource GetAllDocuments, so we will use the        
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,415 | There is no customer defined id or cdk path defined for resource AddConversationFunction, so we will use the
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,417 | There is no customer defined id or cdk path defined for resource GenerateEmbeddingsFunction, so we will use 
the resource logical id as the resource id                                                                                            
2023-12-01 05:32:54,419 | There is no customer defined id or cdk path defined for resource GenerateResponseFunction, so we will use   
the resource logical id as the resource id                                                                                            
2023-12-01 05:32:54,421 | There is no customer defined id or cdk path defined for resource AmplifyApp, so we will use the resource    
logical id as the resource id                                                                                                         
2023-12-01 05:32:54,423 | There is no customer defined id or cdk path defined for resource AmplifyBranch, so we will use the resource 
logical id as the resource id                                                                                                         
2023-12-01 05:32:54,428 | Unable to resolve property QUEUE: {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}. Leaving as is.           
2023-12-01 05:32:54,430 | Unable to resolve property queueName: {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}. Leaving as is.       
2023-12-01 05:32:54,432 | Unable to resolve property Resource: {'Fn::Sub':                                                            
['arn:${AWS::Partition}:sqs:${AWS::Region}:${AWS::AccountId}:${queueName}', {'queueName': {'Fn::GetAtt': ['EmbeddingQueue',           
'QueueName']}}]}. Leaving as is.                                                                                                      
2023-12-01 05:32:54,435 | Unable to resolve property queueName: {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}. Leaving as is.       
2023-12-01 05:32:54,437 | Unable to resolve property Resource: {'Fn::Sub':                                                            
['arn:${AWS::Partition}:sqs:${AWS::Region}:${AWS::AccountId}:${queueName}', {'queueName': {'Fn::GetAtt': ['EmbeddingQueue',           
'QueueName']}}]}. Leaving as is.                                                                                                      
2023-12-01 05:32:54,440 | Unable to resolve property AppId: {'Fn::GetAtt': ['AmplifyApp', 'AppId']}. Leaving as is.                   
2023-12-01 05:32:54,442 | 0 stacks found in the template                                                                              
2023-12-01 05:32:54,443 | Collected default values for parameters: {'Frontend': 'local'}                                              
2023-12-01 05:32:54,479 | There is no customer defined id or cdk path defined for resource DocumentBucket, so we will use the resource
logical id as the resource id                                                                                                         
2023-12-01 05:32:54,481 | There is no customer defined id or cdk path defined for resource DocumentBucketPolicy, so we will use the   
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,483 | There is no customer defined id or cdk path defined for resource EmbeddingQueue, so we will use the resource
logical id as the resource id                                                                                                         
2023-12-01 05:32:54,484 | There is no customer defined id or cdk path defined for resource EmbeddingQueuePolicy, so we will use the   
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,487 | There is no customer defined id or cdk path defined for resource DocumentTable, so we will use the resource 
logical id as the resource id                                                                                                         
2023-12-01 05:32:54,489 | There is no customer defined id or cdk path defined for resource MemoryTable, so we will use the resource   
logical id as the resource id                                                                                                         
2023-12-01 05:32:54,491 | There is no customer defined id or cdk path defined for resource CognitoUserPool, so we will use the        
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,492 | There is no customer defined id or cdk path defined for resource CognitoUserPoolClient, so we will use the  
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,495 | There is no customer defined id or cdk path defined for resource Api, so we will use the resource logical id
as the resource id                                                                                                                    
2023-12-01 05:32:54,496 | There is no customer defined id or cdk path defined for resource GeneratePresignedUrlFunction, so we will   
use the resource logical id as the resource id                                                                                        
2023-12-01 05:32:54,499 | There is no customer defined id or cdk path defined for resource UploadTriggerFunction, so we will use the  
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,501 | There is no customer defined id or cdk path defined for resource GetDocumentFunction, so we will use the    
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,503 | There is no customer defined id or cdk path defined for resource GetAllDocuments, so we will use the        
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,505 | There is no customer defined id or cdk path defined for resource AddConversationFunction, so we will use the
resource logical id as the resource id                                                                                                
2023-12-01 05:32:54,507 | There is no customer defined id or cdk path defined for resource GenerateEmbeddingsFunction, so we will use 
the resource logical id as the resource id                                                                                            
2023-12-01 05:32:54,509 | There is no customer defined id or cdk path defined for resource GenerateResponseFunction, so we will use   
the resource logical id as the resource id                                                                                            
2023-12-01 05:32:54,511 | There is no customer defined id or cdk path defined for resource AmplifyApp, so we will use the resource    
logical id as the resource id                                                                                                         
2023-12-01 05:32:54,513 | There is no customer defined id or cdk path defined for resource AmplifyBranch, so we will use the resource 
logical id as the resource id                                                                                                         
2023-12-01 05:32:54,518 | Unable to resolve property QUEUE: {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}. Leaving as is.           
2023-12-01 05:32:54,520 | Unable to resolve property queueName: {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}. Leaving as is.       
2023-12-01 05:32:54,521 | Unable to resolve property Resource: {'Fn::Sub':                                                            
['arn:${AWS::Partition}:sqs:${AWS::Region}:${AWS::AccountId}:${queueName}', {'queueName': {'Fn::GetAtt': ['EmbeddingQueue',           
'QueueName']}}]}. Leaving as is.                                                                                                      
2023-12-01 05:32:54,524 | Unable to resolve property queueName: {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}. Leaving as is.       
2023-12-01 05:32:54,525 | Unable to resolve property Resource: {'Fn::Sub':                                                            
['arn:${AWS::Partition}:sqs:${AWS::Region}:${AWS::AccountId}:${queueName}', {'queueName': {'Fn::GetAtt': ['EmbeddingQueue',           
'QueueName']}}]}. Leaving as is.                                                                                                      
2023-12-01 05:32:54,527 | Unable to resolve property AppId: {'Fn::GetAtt': ['AmplifyApp', 'AppId']}. Leaving as is.                   
2023-12-01 05:32:54,529 | 18 resources found in the stack                                                                             
2023-12-01 05:32:54,531 | Found Serverless function with name='GeneratePresignedUrlFunction' and CodeUri='src/generate_presigned_url/'
2023-12-01 05:32:54,532 | --base-dir is not presented, adjusting uri src/generate_presigned_url/ relative to                          
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-12-01 05:32:54,534 | Found Serverless function with name='UploadTriggerFunction' and CodeUri='src/upload_trigger/'               
2023-12-01 05:32:54,535 | --base-dir is not presented, adjusting uri src/upload_trigger/ relative to                                  
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-12-01 05:32:54,536 | Found Serverless function with name='GetDocumentFunction' and CodeUri='src/get_document/'                   
2023-12-01 05:32:54,537 | --base-dir is not presented, adjusting uri src/get_document/ relative to                                    
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-12-01 05:32:54,539 | Found Serverless function with name='GetAllDocuments' and CodeUri='src/get_all_documents/'                  
2023-12-01 05:32:54,540 | --base-dir is not presented, adjusting uri src/get_all_documents/ relative to                               
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-12-01 05:32:54,542 | Found Serverless function with name='AddConversationFunction' and CodeUri='src/add_conversation/'           
2023-12-01 05:32:54,543 | --base-dir is not presented, adjusting uri src/add_conversation/ relative to                                
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-12-01 05:32:54,544 | Found Serverless function with name='GenerateEmbeddingsFunction' and CodeUri='src/generate_embeddings/'     
2023-12-01 05:32:54,545 | --base-dir is not presented, adjusting uri src/generate_embeddings/ relative to                             
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-12-01 05:32:54,547 | Found Serverless function with name='GenerateResponseFunction' and CodeUri='src/generate_response/'         
2023-12-01 05:32:54,548 | --base-dir is not presented, adjusting uri src/generate_response/ relative to                               
/home/ec2-user/environment/serverless-pdf-chat/backend/template.yaml                                                                  
2023-12-01 05:32:54,584 | 18 resources found in the stack                                                                             
2023-12-01 05:32:54,586 | Found Serverless function with name='GeneratePresignedUrlFunction' and CodeUri='src/generate_presigned_url/'
2023-12-01 05:32:54,587 | Found Serverless function with name='UploadTriggerFunction' and CodeUri='src/upload_trigger/'               
2023-12-01 05:32:54,588 | Found Serverless function with name='GetDocumentFunction' and CodeUri='src/get_document/'                   
2023-12-01 05:32:54,589 | Found Serverless function with name='GetAllDocuments' and CodeUri='src/get_all_documents/'                  
2023-12-01 05:32:54,591 | Found Serverless function with name='AddConversationFunction' and CodeUri='src/add_conversation/'           
2023-12-01 05:32:54,592 | Found Serverless function with name='GenerateEmbeddingsFunction' and CodeUri='src/generate_embeddings/'     
2023-12-01 05:32:54,593 | Found Serverless function with name='GenerateResponseFunction' and CodeUri='src/generate_response/'         
2023-12-01 05:32:54,596 | Instantiating build definitions                                                                             
2023-12-01 05:32:54,614 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_presigned_url, Zip, , 526748f7-9905-4208-9f95-11eb76731f1e, {},   
{}, x86_64, []), Current: BuildDefinition(python3.11,                                                                                 
/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_presigned_url, Zip, , 5742cdf5-6585-4a29-8986-5680d736e8ca, {},   
{}, x86_64, []), Function: Function(function_id='GeneratePresignedUrlFunction', name='GeneratePresignedUrlFunction',                  
functionname='GeneratePresignedUrlFunction', runtime='python3.11', memory=None, timeout=None, handler='main.lambda_handler',          
imageuri=None, packagetype='Zip', imageconfig=None,                                                                                   
codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_presigned_url', environment={'Variables': {'LOG_LEVEL':  
'INFO', 'BUCKET': 'DocumentBucket', 'REGION': 'us-east-1'}}, rolearn=None, layers=[<samcli.lib.providers.provider.LayerVersion object 
at 0x7f76a900af50>], events={'Root': {'Type': 'Api', 'Properties': {'RestApiId': 'Api', 'Path': '/generate_presigned_url', 'Method':  
'GET'}}}, metadata={'SamResourceId': 'GeneratePresignedUrlFunction'}, 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-12-01 05:32:54,622 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/upload_trigger, Zip, , b94366d2-1831-4f69-8b6f-65db0c98218d, {}, {},       
x86_64, []), Current: BuildDefinition(python3.11, /home/ec2-user/environment/serverless-pdf-chat/backend/src/upload_trigger, Zip, ,   
b2654db5-5d2d-4cc8-b127-8f32ab8b0314, {}, {}, x86_64, []), Function: Function(function_id='UploadTriggerFunction',                    
name='UploadTriggerFunction', functionname='UploadTriggerFunction', runtime='python3.11', memory=None, timeout=None,                  
handler='main.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None,                                                    
codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/upload_trigger', environment={'Variables': {'LOG_LEVEL': 'INFO',  
'DOCUMENT_TABLE': 'DocumentTable', 'MEMORY_TABLE': 'MemoryTable', 'QUEUE': {'Fn::GetAtt': ['EmbeddingQueue', 'QueueName']}, 'BUCKET': 
'local-us-east-1-123456789012'}}, rolearn=None, layers=[<samcli.lib.providers.provider.LayerVersion object at 0x7f76a8ff6f10>],       
events={'S3Event': {'Type': 'S3', 'Properties': {'Bucket': 'DocumentBucket', 'Events': ['s3:ObjectCreated:*'], 'Filter': {'S3Key':    
{'Rules': [{'Name': 'suffix', 'Value': '.pdf'}]}}}}}, metadata={'SamResourceId': 'UploadTriggerFunction'}, 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-12-01 05:32:54,629 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/get_document, Zip, , 885991f3-b99b-441c-9180-901421d602a3, {}, {}, x86_64, 
[]), Current: BuildDefinition(python3.11, /home/ec2-user/environment/serverless-pdf-chat/backend/src/get_document, Zip, ,             
5fc132c0-6ae2-41d3-ace6-51b979e3e7de, {}, {}, x86_64, []), Function: Function(function_id='GetDocumentFunction',                      
name='GetDocumentFunction', functionname='GetDocumentFunction', runtime='python3.11', memory=None, timeout=None,                      
handler='main.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None,                                                    
codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/get_document', environment={'Variables': {'LOG_LEVEL': 'INFO',    
'DOCUMENT_TABLE': 'DocumentTable', 'MEMORY_TABLE': 'MemoryTable'}}, rolearn=None, layers=[<samcli.lib.providers.provider.LayerVersion 
object at 0x7f76a8ff71d0>], events={'Root': {'Type': 'Api', 'Properties': {'RestApiId': 'Api', 'Path':                                
'/doc/{documentid}/{conversationid}', 'Method': 'GET'}}}, metadata={'SamResourceId': 'GetDocumentFunction'}, 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-12-01 05:32:54,636 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/get_all_documents, Zip, , d8a85378-4245-47fb-a10a-c3da84865519, {}, {},    
x86_64, []), Current: BuildDefinition(python3.11, /home/ec2-user/environment/serverless-pdf-chat/backend/src/get_all_documents, Zip, ,
f3be56ab-f8a4-4ac7-8662-87e38bf3ed66, {}, {}, x86_64, []), Function: Function(function_id='GetAllDocuments', name='GetAllDocuments',  
functionname='GetAllDocuments', runtime='python3.11', memory=None, timeout=None, handler='main.lambda_handler', imageuri=None,        
packagetype='Zip', imageconfig=None, codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/get_all_documents',          
environment={'Variables': {'LOG_LEVEL': 'INFO', 'DOCUMENT_TABLE': 'DocumentTable'}}, rolearn=None,                                    
layers=[<samcli.lib.providers.provider.LayerVersion object at 0x7f76a9000e90>], events={'Root': {'Type': 'Api', 'Properties':         
{'RestApiId': 'Api', 'Path': '/doc', 'Method': 'GET'}}}, metadata={'SamResourceId': 'GetAllDocuments'}, 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-12-01 05:32:54,642 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/add_conversation, Zip, , cc2a171f-776c-4bba-92d3-a5a3e22668b8, {}, {},     
x86_64, []), Current: BuildDefinition(python3.11, /home/ec2-user/environment/serverless-pdf-chat/backend/src/add_conversation, Zip, , 
d9d7809c-d788-4197-88db-69319f55192b, {}, {}, x86_64, []), Function: Function(function_id='AddConversationFunction',                  
name='AddConversationFunction', functionname='AddConversationFunction', runtime='python3.11', memory=None, timeout=None,              
handler='main.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None,                                                    
codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/add_conversation', environment={'Variables': {'LOG_LEVEL': 'INFO',
'DOCUMENT_TABLE': 'DocumentTable', 'MEMORY_TABLE': 'MemoryTable'}}, rolearn=None, layers=[<samcli.lib.providers.provider.LayerVersion 
object at 0x7f76a8c5e910>], events={'Root': {'Type': 'Api', 'Properties': {'RestApiId': 'Api', 'Path': '/doc/{documentid}', 'Method': 
'POST'}}}, metadata={'SamResourceId': 'AddConversationFunction'}, 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-12-01 05:32:54,648 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_embeddings, Zip, , 243f7dcc-598f-4a95-b076-cedd19dc9723, {}, {},  
x86_64, []), Current: BuildDefinition(python3.11, /home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_embeddings, Zip,
, c9c4f1bb-f22e-47c4-83ca-07cdfc2109c0, {}, {}, x86_64, []), Function: Function(function_id='GenerateEmbeddingsFunction',             
name='GenerateEmbeddingsFunction', functionname='GenerateEmbeddingsFunction', runtime='python3.11', memory=2048, timeout=180,         
handler='main.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None,                                                    
codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_embeddings', environment={'Variables': {'LOG_LEVEL':     
'INFO', 'DOCUMENT_TABLE': 'DocumentTable', 'BUCKET': 'DocumentBucket'}}, rolearn=None,                                                
layers=[<samcli.lib.providers.provider.LayerVersion object at 0x7f76a8c2a7d0>], events={'EmbeddingQueueEvent': {'Type': 'SQS',        
'Properties': {'Queue': 'arn:aws:lambda:us-east-1:123456789012:function:EmbeddingQueue', 'BatchSize': 1}}}, metadata={'SamResourceId':
'GenerateEmbeddingsFunction'}, 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-12-01 05:32:54,655 | Same function build definition found, adding function (Previous: BuildDefinition(python3.11,                
/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_response, Zip, , 291b6ee4-e11a-4b5d-a661-6d470f41d6a5, {}, {},    
x86_64, []), Current: BuildDefinition(python3.11, /home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_response, Zip, ,
9cd1f32c-7a1e-40b2-b46d-bfc44083f572, {}, {}, x86_64, []), Function: Function(function_id='GenerateResponseFunction',                 
name='GenerateResponseFunction', functionname='GenerateResponseFunction', runtime='python3.11', memory=2048, timeout=30,              
handler='main.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None,                                                    
codeuri='/home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_response', environment={'Variables': {'LOG_LEVEL':       
'INFO', 'MEMORY_TABLE': 'MemoryTable', 'BUCKET': 'DocumentBucket'}}, rolearn=None, layers=[<samcli.lib.providers.provider.LayerVersion
object at 0x7f76a8c2b010>], events={'Root': {'Type': 'Api', 'Properties': {'RestApiId': 'Api', 'Path':                                
'/{documentid}/{conversationid}', 'Method': 'POST'}}}, metadata={'SamResourceId': 'GenerateResponseFunction'}, 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-12-01 05:32:54,669 | Building codeuri: /home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_presigned_url runtime:
python3.11 metadata: {} architecture: x86_64 functions: GeneratePresignedUrlFunction                                                  
2023-12-01 05:32:54,671 | Building to following folder                                                                                
/home/ec2-user/environment/serverless-pdf-chat/backend/.aws-sam/build/GeneratePresignedUrlFunction                                    

Fetching public.ecr.aws/sam/build-python3.11:latest-x86_64 Docker container image..............................................................................................................................................................................................................
2023-12-01 05:33:08,126 | Mounting /home/ec2-user/environment/serverless-pdf-chat/backend/src/generate_presigned_url as               
/tmp/samcli/source:ro,delegated, inside runtime container                                                                             
2023-12-01 05:33:08,133 | Container was not created. Skipping deletion                                                                
2023-12-01 05:33:08,135 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics  

Error: Container does not exist. Cannot get logs for this container
Traceback:
  File "click/core.py", line 1078, in main
  File "click/core.py", line 1688, in invoke
  File "click/core.py", line 1434, in invoke
  File "click/core.py", line 783, in invoke
  File "samcli/cli/cli_config_file.py", line 347, in wrapper
  File "click/decorators.py", line 92, in new_func
  File "click/core.py", line 783, in invoke
  File "samcli/lib/telemetry/metric.py", line 184, in wrapped
  File "samcli/lib/telemetry/metric.py", line 149, in wrapped
  File "samcli/lib/utils/version_checker.py", line 42, in wrapped
  File "samcli/cli/main.py", line 95, in wrapper
  File "samcli/commands/build/command.py", line 171, in cli
  File "samcli/commands/build/command.py", line 260, in do_cli
  File "samcli/commands/build/build_context.py", line 281, in run
  File "samcli/lib/build/app_builder.py", line 219, in build
  File "samcli/lib/build/build_strategy.py", line 81, in build
  File "samcli/lib/build/build_strategy.py", line 91, in _build_functions
  File "samcli/lib/build/build_strategy.py", line 164, in build_single_function_definition
  File "samcli/lib/build/app_builder.py", line 699, in _build_function
  File "samcli/lib/build/app_builder.py", line 952, in _build_function_on_container
  File "samcli/local/docker/container.py", line 383, in wait_for_logs

An unexpected error was encountered while executing "sam build".
Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20build%20-%20RuntimeError
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20build%20-%20RuntimeError
2023-12-01 05:33:08,140 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics  
2023-12-01 05:33:08,144 | Unable to find Click Context for getting session_id.                                                        
Admin:~/environment/serverless-pdf-chat/backend (main) $ 

@lucashuy
Copy link
Contributor

lucashuy commented Dec 1, 2023

Thanks for getting back to me, can you try removing the build images that are currently present in the instance? You can find which images are in the instance with docker images, and then remove the build images with docker image rm <image ID here>

@ninmonkey
Copy link

ninmonkey commented Dec 4, 2023

I've been having similar issues.

All my sam builds hangs, and I cannot recover the console. ctrl+c even after waiting a long time never gives control back. I have to kill the tab.

  • I'm running on windows.
  • I have wsl installed.
  • I tested that make is installed on the default distro, by reading the man page
wsl -- man make

I'm trying to build this template: examples/demo-runtime-layer-function/template.yml
which uses this template powershell-runtime/template.yml

Here's my log file from before deleting my docker images. I'll test again afterward.

Running on windows
Pwsh 7.4.0> 🐒
    sam --version

SAM CLI, version 1.103.0

Pwsh 7.4.0> 🐒
    sam build --use-container --debug

2023-12-04 11:51:48,317 | Config file location:
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\samconfig.toml
2023-12-04 11:51:48,320 | Loading configuration values from
[default.['build'].parameters] (env.command_name.section) in config file at
'H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\samconfig.toml'...
2023-12-04 11:51:48,322 | Configuration values successfully loaded.
2023-12-04 11:51:48,323 | Configuration values are: {}
2023-12-04 11:51:48,336 | Using SAM Template at
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\template.yml
2023-12-04 11:51:48,382 | Using config file: samconfig.toml, config environment:
default
2023-12-04 11:51:48,384 | Expand command line arguments to:
2023-12-04 11:51:48,385 |
--template_file=H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\template.yml --use_container --mount_with=READ
--build_dir=.aws-sam\build --cache_dir=.aws-sam\cache
2023-12-04 11:51:49,920 | 'build' command is called
2023-12-04 11:51:49,921 | Starting Build inside a container
2023-12-04 11:51:49,928 | No Parameters detected in the template
2023-12-04 11:51:50,034 | There is no customer defined id or cdk path defined for
    # ...

2023-12-04 11:51:50,075 | --base-dir is not presented, adjusting uri
../../powershell-runtime/source relative to
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\template.yml
2023-12-04 11:51:50,077 | --base-dir is not presented, adjusting uri
../../powershell-modules/AWSToolsforPowerShell/Demo-AWS.Tools/buildlayer relative to
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\template.yml
2023-12-04 11:51:50,079 | Found Serverless function with name='DemoPowerShellFunction'
and CodeUri='function/'
2023-12-04 11:51:50,080 | --base-dir is not presented, adjusting uri function/ relativeto
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\template.yml
2023-12-04 11:51:50,082 | --base-dir is not presented, adjusting uri
../../powershell-runtime/source relative to
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\template.yml
2023-12-04 11:51:50,084 | --base-dir is not presented, adjusting uri
../../powershell-modules/AWSToolsforPowerShell/Demo-AWS.Tools/buildlayer relative to
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\template.yml
2023-12-04 11:51:51,632 | 5 resources found in the stack
2023-12-04 11:51:51,633 | Found Serverless function with name='DemoPowerShellFunction'
and CodeUri='function/'
2023-12-04 11:51:51,638 | Instantiating build definitions
2023-12-04 11:51:51,671 | Unique function build definition found, adding as new
(Function Build Definition: BuildDefinition(provided.al2023,
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\functnction, Zip, , ec329683-acdb-42d9-ba98-c4665909de7a, {'BuildMethod':
'makefile'}, {}, x86_64, []), Function: Function(function_id='DemoPowerShellFunction',
name='DemoPowerShellFunction', functionname='DemoPowerShellFunction',
runtime='provided.al2023', memory=1024, timeout=100,
handler='examplehandler.ps1::handler', imageuri=None, packagetype='Zip',
imageconfig=None,
codeuri='H:\\temp_clone\\aws-lambda-pwsh\\aws-lambda-powershell-runtime\\examples\\demo-runtime-layer-er-function\\function', environment={'Variables':
{'DOTNET_SYSTEM_GLOBALIZATION_INVARIANT': '1'}}, rolearn=None,
layers=[<samcli.lib.providers.provider.LayerVersion object at 0x0000021B2C65B590>,
<samcli.lib.providers.provider.LayerVersion object at 0x0000021B2C65B310>],
events=None, metadata={'BuildMethod': 'makefile', 'SamResourceId':
'DemoPowerShellFunction'}, 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-12-04 11:51:51,680 | Same Layer build definition found, adding layer (Previous:
LayerBuildDefinition(PwshRuntimeLayer,
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\powershell-runtime\source,
dd08f09795014528c602cb5f4084293fad4144e6492ea2bfdcc5d2f3cba10c0c,
a166b1e6-8404-4595-a5a3-24d8a2917238, makefile, ['provided.al2', 'provided.al2023'],
x86_64, {}), Current: LayerBuildDefinition(PwshRuntimeLayer,
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\powershell-runtime\source,
, 6f426eed-d46a-4a2e-9591-e857f52242d9, makefile, ['provided.al2', 'provided.al2023'],
x86_64, {}), Layer: <samcli.lib.providers.provider.LayerVersion object at
0x0000021B2C7A4C50>)
2023-12-04 11:51:51,684 | Same Layer build definition found, adding layer (Previous:
LayerBuildDefinition(DemoAWSToolsLayer,
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\powershell-modules\AWSToolsforPowerShell\Dl\Demo-AWS.Tools\buildlayer,
20fbd72647d053f196a25709f39e0ca88d194b16958347a062a3b9fecd64a2cd,
d3ff3721-1233-4562-afc3-0ba8f6fca1ce, makefile, ['provided.al2', 'provided.al2023'],
x86_64, {}), Current: LayerBuildDefinition(DemoAWSToolsLayer,
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\powershell-modules\AWSToolsforPowerShell\Dl\Demo-AWS.Tools\buildlayer, , 541214a8-7787-4cce-b60b-0e732f7d74e2,
makefile, ['provided.al2', 'provided.al2023'], x86_64, {}), Layer:
<samcli.lib.providers.provider.LayerVersion object at 0x0000021B2C7A4B90>)
2023-12-04 11:51:51,690 | Building layer 'PwshRuntimeLayer'
2023-12-04 11:51:51,694 | For container layer build, first compatible runtime is chosenas build targetget for container.

Fetching public.ecr.aws/sam/build-provided.al2:latest-x86_64 Docker container image......
2023-12-04 11:51:54,039 | Mounting
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\powershell-runtime\source 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_framework=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 'CustomMakeBuilder' to support capabilities 'Capability(language='provided', dependency_manager=None, application_framework=None)'
Running workflow 'CustomMakeBuilder'
PwshRuntimeLayer: Running CustomMakeBuilder:CopySource
Copying source file (/tmp/samcli/source/bootstrap) to destination (/tmp/samcli/scratch/bootstrap)
Copying source file (/tmp/samcli/source/Makefile) to destination (/tmp/samcli/scratch/Makefile)
Creating target folders at /tmp/samcli/scratch/modules
Copying directory metadata from source (/tmp/samcli/source/modules) to destination (/tmp/samcli/scratch/modules)
Creating target folders at /tmp/samcli/scratch/modules/Private
Copying directory metadata from source (/tmp/samcli/source/modules/Private) to destination (/tmp/samcli/scratch/modules/Private)
Copying source file (/tmp/samcli/source/modules/Private/Get-Handler.ps1) to destination (/tmp/samcli/scratch/modules/Private/Get-Handler.ps1)
Copying source file (/tmp/samcli/source/modules/Private/Get-LambdaNextInvocation.ps1) to destination (/tmp/samcli/scratch/modules/Private/Get-LambdaNextInvocation.ps1)
Copying source file (/tmp/samcli/source/modules/Private/Invoke-FunctionHandler.ps1) to destination
(/tmp/samcli/scratch/modules/Private/Invoke-FunctionHandler.ps1)
Copying source file (/tmp/samcli/source/modules/Private/Send-FunctionHandlerError.ps1) to destination (/tmp/samcli/scratch/modules/Private/Send-FunctionHandlerError.ps1)
Copying source file (/tmp/samcli/source/modules/Private/Send-FunctionHandlerResponse.ps1) to destination (/tmp/samcli/scratch/modules/Private/Send-FunctionHandlerResponse.ps1)
Copying source file (/tmp/samcli/source/modules/Private/Set-HandlerEnvironmentVariables.ps1) to destination (/tmp/samcli/scratch/modules/Private/Set-HandlerEnvironmentVariables.ps1)
Copying source file (/tmp/samcli/source/modules/Private/Set-LambdaContext.ps1) to destination (/tmp/samcli/scratch/modules/Private/Set-LambdaContext.ps1)
Copying source file (/tmp/samcli/source/modules/Private/Set-PSModulePath.ps1) to destination (/tmp/samcli/scratch/modules/Private/Set-PSModulePath.ps1)
Copying source file (/tmp/samcli/source/modules/pwsh-runtime.psd1) to destination (/tmp/samcli/scratch/modules/pwsh-runtime.psd1)
Copying source file (/tmp/samcli/source/modules/pwsh-runtime.psm1) to destination (/tmp/samcli/scratch/modules/pwsh-runtime.psm1)
Copying source file (/tmp/samcli/source/PowerShellLambdaContext.cs) to destination (/tmp/samcli/scratch/PowerShellLambdaContext.cs)
CustomMakeBuilder:CopySource succeeded
PwshRuntimeLayer: Running CustomMakeBuilder:MakeBuild
PwshRuntimeLayer: Current Artifacts Directory : /tmp/samcli/artifacts
executing Make: ['make', '--makefile', '/tmp/samcli/source/Makefile', 'build-PwshRuntimeLayer']
curl -L -o /tmp/samcli/artifacts/powershell-7.4.0-x64.tar.gz https://github.com/PowerShell/PowerShell/releases/download/v7.4.0/powershell-7.4.0-linux-x64.tar.gz
mkdir -p /tmp/samcli/artifacts/powershell
tar zxf /tmp/samcli/artifacts/powershell-7.4.0-x64.tar.gz -C /tmp/samcli/artifacts/powershell/
rm /tmp/samcli/artifacts/powershell-7.4.0-x64.tar.gz
chmod +x /tmp/samcli/artifacts/powershell/pwsh
cp bootstrap /tmp/samcli/artifacts
cp PowerShellLambdaContext.cs /tmp/samcli/artifacts
mkdir /tmp/samcli/artifacts/modules
cp -R ./modules/* /tmp/samcli/artifacts/modules/
cd /tmp/samcli/artifacts/modules/Private
tail -n +3 -q /tmp/samcli/artifacts/modules/Private/*.ps1 >> /tmp/samcli/artifacts/modules/pwsh-runtime.psm1
rm -Rf /tmp/samcli/artifacts/modules/Private
chmod +x /tmp/samcli/artifacts/bootstrap
CustomMakeBuilder:MakeBuild succeeded
2023-12-04 11:52:19,669 | Build inside container returned response {"jsonrpc": "2.0", "id": 1,
"result": {"artifacts_dir": "/tmp/samcli/artifacts"}}
2023-12-04 11:52:19,681 | Build inside container was successful. Copying artifacts from container
to host
2023-12-04 11:52:29,734 | Copying from container: /tmp/samcli/artifacts/. ->
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\.aws-sam\build\PwshRuntimeLayer
2023-12-04 11:52:33,390 | Build inside container succeeded
2023-12-04 11:52:33,392 | Building layer 'DemoAWSToolsLayer'
2023-12-04 11:52:33,396 | For container layer build, first compatible runtime is chosen as build
target for container.


Fetching public.ecr.aws/sam/build-provided.al2:latest-x86_64 Docker container image......
2023-12-04 11:52:34,588 | Mounting
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\powershell-modules\AWSToolsforPowerShell\Demo-AWS.Tools\buildlayer as /tmp/samcli/source:ro,delegated, inside runtime container
mkdir -p /tmp/samcli/artifacts/modules
unzip /tmp/samcli/artifacts/AWS.Tools.zip 'AWS.Tools.Common/**/*' -d /tmp/samcli/artifacts/modules/Archive:  /tmp/samcli/artifacts/AWS.Tools.zip
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/aws-crt-auth.dll
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/aws-crt-checksums.dll
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/aws-crt-http.dll
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/aws-crt.dll
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/AWS.Tools.Common.Aliases.psm1
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/AWS.Tools.Common.Completers.psm1
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/AWS.Tools.Common.dll
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/AWS.Tools.Common.dll-Help.xml
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/AWS.Tools.Common.Format.ps1xml
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/AWS.Tools.Common.psd1
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/AWS.Tools.Common.XML
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/AWSSDK.Core.dll
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/AWSSDK.Extensions.CrtIntegration.dll
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/AWSSDK.SecurityToken.dll
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/ImportGuard.ps1
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/LICENSE
  inflating: /tmp/samcli/artifacts/modules/AWS.Tools.Common/4.1.467/NOTICE
rm /tmp/samcli/artifacts/AWS.Tools.zip
CustomMakeBuilder:MakeBuild succeeded
2023-12-04 11:52:46,467 | Build inside container returned response {"jsonrpc": "2.0", "id": 1,
"result": {"artifacts_dir": "/tmp/samcli/artifacts"}}
2023-12-04 11:52:46,474 | Build inside container was successful. Copying artifacts from container
to host
2023-12-04 11:52:49,932 | Copying from container: /tmp/samcli/artifacts/. ->
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\.aws-sam\build\DemoAWSToolsLayer
2023-12-04 11:52:50,673 | Build inside container succeeded
2023-12-04 11:52:50,677 | Building codeuri:
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\function runtime: provided.al2023 metadata: {'BuildMethod': 'makefile'} architecture: x86_64

functions: DemoPowerShellFunction
2023-12-04 11:52:50,679 | Building to following folder
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\.aws-sam\build\DemoPowerShellFunction

Fetching public.ecr.aws/sam/build-provided.al2023:latest-x86_64 Docker container image......
2023-12-04 11:52:52,042 | Mounting
H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\function as /tmp/samcli/source:ro,delegated, inside runtime container

In docker desktop, if I choose container -> last ran -> log file, I think it completed successfully?

CustomMakeBuilder:MakeBuild succeeded

2023-12-04 11:53:00 Using the request object from command line argument
2023-12-04 11:53:00 Loading workflow module 'aws_lambda_builders.workflows'
2023-12-04 11:53:00 Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'
2023-12-04 11:53:00 Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
2023-12-04 11:53:00 Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
2023-12-04 11:53:00 Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2023-12-04 11:53:00 Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
2023-12-04 11:53:00 Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
2023-12-04 11:53:00 Registering workflow 'NodejsNpmEsbuildBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm-esbuild', application_framework=None)'
2023-12-04 11:53:00 Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2023-12-04 11:53:00 Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
2023-12-04 11:53:00 Registering workflow 'RustCargoLambdaBuilder' with capability 'Capability(language='rust', dependency_manager='cargo', application_framework=None)'
2023-12-04 11:53:00 Found workflow 'CustomMakeBuilder' to support capabilities 'Capability(language='provided', dependency_manager=None, application_framework=None)'
2023-12-04 11:53:00 Running workflow 'CustomMakeBuilder'
2023-12-04 11:53:00 DemoPowerShellFunction: Running CustomMakeBuilder:CopySource
2023-12-04 11:53:00 Copying source file (/tmp/samcli/source/examplehandler.ps1) to destination (/tmp/samcli/scratch/examplehandler.ps1)
2023-12-04 11:53:00 Creating target folders at /tmp/samcli/scratch/examplemodule
2023-12-04 11:53:00 Copying directory metadata from source (/tmp/samcli/source/examplemodule) to destination (/tmp/samcli/scratch/examplemodule)
2023-12-04 11:53:00 Copying source file (/tmp/samcli/source/examplemodule/examplemodule.psd1) to destination (/tmp/samcli/scratch/examplemodule/examplemodule.psd1)
2023-12-04 11:53:00 Copying source file (/tmp/samcli/source/examplemodule/examplemodule.psm1) to destination (/tmp/samcli/scratch/examplemodule/examplemodule.psm1)
2023-12-04 11:53:00 Copying source file (/tmp/samcli/source/examplescript.ps1) to destination (/tmp/samcli/scratch/examplescript.ps1)
2023-12-04 11:53:00 Copying source file (/tmp/samcli/source/Makefile) to destination (/tmp/samcli/scratch/Makefile)
2023-12-04 11:53:00 CustomMakeBuilder:CopySource succeeded
2023-12-04 11:53:00 DemoPowerShellFunction: Running CustomMakeBuilder:MakeBuild
2023-12-04 11:53:00 DemoPowerShellFunction: Current Artifacts Directory : /tmp/samcli/artifacts
2023-12-04 11:53:00 executing Make: ['make', '--makefile', '/tmp/samcli/source/Makefile', 'build-DemoPowerShellFunction']
2023-12-04 11:53:00 cp -R . /tmp/samcli/artifacts
2023-12-04 11:53:00 rm /tmp/samcli/artifacts/Makefile
2023-12-04 11:53:00 CustomMakeBuilder:MakeBuild succeeded
2023-12-04T17:53:00.519749208Z {"jsonrpc": "2.0", "id": 1, "result": {"artifacts_dir": "/tmp/samcli/artifacts"}}

image

@pbv0
Copy link
Author

pbv0 commented Dec 6, 2023

I tried again with a clean Cloud9 setup and changing arm64 to x86_64 and I can successfully build now. Thanks for the support.

@ninmonkey
Copy link

ninmonkey commented Dec 6, 2023

I tried again with a clean Cloud9 setup and changing arm64 to x86_64 and I can successfully build now. Thanks for the support.

This might sound weird, but what if you run it twice? I was about to say it fixed mine too, but

# [1] Deleted images. rebooted. 
# [2] build runs, and returns self to the console
# works!
> sam build --use-container --cached --debug
# [3] build runs, and returns self to the console
# lockup
> sam build --use-container --cached --debug

# stalled at the same line
# Fetching public.ecr.aws/sam/build-provided.al2023:latest-x86_64 Docker container image......
2023-12-06 05:43:38,068 | Mounting H:\temp_clone\aws-lambda-pwsh\aws-lambda-powershell-runtime\examples\demo-runtime-layer-function\function as /tmp/samcli/source:ro,delegated, inside runtime
container

the logs in docker-desktop says CustomMakeBuilder:MakeBuild succeeded so I think the container executes fine
but control isn't being released back to the console by sam?

@ninmonkey
Copy link

ninmonkey commented Dec 6, 2023

I forgot I've had a similar error before #4595 (comment)

Merged issues summary

  • previous issue appeared to be caused by sam trying to read a file, timing out with the delay of 0.1
  • current issue sometimes hits a read timeout at the same location.

That would make sense why running sam build with the exact same inputs would fail on one run, but not the other. That's what happened above.

Potential fix?

Is there a timeout setting that I can turn up, because that should be an easy way for me to confirm if that works or not?
Or would I need to build a custom version of this repository?


The current build sometimes, but not always will end with this message:

2023-12-04 11:53:00 CustomMakeBuilder:MakeBuild succeeded
2023-12-06 10:31:22,082 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com',
port=443): Read timed out. (read timeout=0.1)

Back in July, it would give a stack trace at the same location.

```log
executing Make: ['make', '--makefile', '/tmp/samcli/source/Makefile', 'build-AbcDemoPowerShellFunction']
cp -R . /tmp/samcli/artifacts
rm /tmp/samcli/artifacts/Makefile
CustomMakeBuilder:MakeBuild succeeded
2023-07-19 11:27:03,526 | Failed to get the logs from the container
Traceback (most recent call last):
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\container.py", line 433, in _write_container_output
    for stdout_data, stderr_data in output_itr:
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\types\daemon.py", line 32, in __next__
    return next(self._stream)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\api\client.py", line 406, in <genexpr>
    gen = (demux_adaptor(*frame) for frame in gen)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\utils\socket.py", line 94, in frames_iter_no_tty
    (stream, n) = next_frame_header(socket)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\utils\socket.py", line 66, in next_frame_header
    data = read_exactly(socket, 8)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\utils\socket.py", line 51, in read_exactly
    next_data = read(socket, n - len(data))
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\utils\socket.py", line 35, in read
    return socket.recv(n)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\transport\npipesocket.py", line 23, in wrapped
    return f(self, *args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\transport\npipesocket.py", line 117, in recv
    err, data = win32file.ReadFile(self._handle, bufsize)
pywintypes.error: (109, 'ReadFile', 'The pipe has been ended.')
2023-07-19 11:27:03,542 | Build inside container returned response {"jsonrpc": "2.0", "id": 1, "result": {"artifacts_dir": "/tmp/samcli/artifacts"}}
2023-07-19 11:27:03,542 | Build inside container was successful. Copying artifacts from container to host
2023-07-19 11:27:03,874 | Copying from container: /tmp/samcli/artifacts/. -> G:\user\demo-runtime-layer-function\.aws-sam\build\AbcDemoPowerShellFunction
2023-07-19 11:27:04,443 | Build inside container succeeded
2023-07-19 11:27:07,956 | Async execution completed
2023-07-19 11:27:08,123 | There is no customer defined id or cdk path defined for resource AbcDemoPowerShellFunction, so we will use the resource logical id as the resource id
    ...
2023-07-19 11:27:08,127 | 5 resources found in the stack
2023-07-19 11:27:08,127 | Found Serverless function with name='AbcDemoPowerShellFunction' and CodeUri='function/'

@lucashuy
Copy link
Contributor

lucashuy commented Dec 8, 2023

I tried again with a clean Cloud9 setup and changing arm64 to x86_64 and I can successfully build now. Thanks for the support.

Thanks for getting back, glad this worked out in the end.

@ninmonkey, while the container not responding correctly might be the same between the OP and the issue you're facing, this might have a different root cause. I see that the layer that is in that template is using al2023, and you're using WSL/Windows, can you make sure that the Docker you have installed is up to date? We also recently released a new version of SAM CLI, can you try reproducing this issue on the latest versions of both tools?

If you are still unable to build successfully (ie. it doesn't hang), can you create a new issue with the steps to reproduce, partial/full debug logs, and the output of sam --info and docker version?

@hnnasit
Copy link
Contributor

hnnasit commented Jan 17, 2024

Closing this issue as the OP's issue has been fixed. @ninmonkey, as @lucashuy mentioned above, feel free to create a new issue with more details if you are still facing problems or have questions.

@hnnasit hnnasit closed this as completed Jan 17, 2024
Copy link
Contributor

⚠️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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days
Projects
None yet
Development

No branches or pull requests

4 participants