Bug: How to use --use-container for sam sync (because local python is not same as runtime)
See original GitHub issueI was able to build using --use-container so i dont have to bother about the local python version.
But while syncing it creates problem
$ sam sync --debug --stack-name santhosh-testing
2022-06-30 12:35:13,556 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2022-06-30 12:35:13,563 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2022-06-30 12:35:13,564 | Sending Telemetry: {'metrics': [{'templateWarning': {'requestId': '5b6c9cb7-e4a9-4c00-84c5-952ce7f5f5ab', 'installationId': 'a87120b0-ef01-4fa9-a2b4-d881501b50fc', 'sessionId': 'fb48edde-cf6e-46ea-8ac2-31688d6f3178', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.7.10', 'samcliVersion': '1.40.0', 'awsProfileProvided': True, 'debugFlagProvided': True, 'region': '', 'warningName': 'CodeDeployWarning', 'warningCount': 0}}]}
2022-06-30 12:35:14,839 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
2022-06-30 12:35:14,839 | Sending Telemetry: {'metrics': [{'templateWarning': {'requestId': '984e898d-8839-4b3d-8b0e-db500562c47c', 'installationId': 'a87120b0-ef01-4fa9-a2b4-d881501b50fc', 'sessionId': 'fb48edde-cf6e-46ea-8ac2-31688d6f3178', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.7.10', 'samcliVersion': '1.40.0', 'awsProfileProvided': True, 'debugFlagProvided': True, 'region': '', 'warningName': 'CodeDeployConditionWarning', 'warningCount': 0}}]}
2022-06-30 12:35:16,040 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
2022-06-30 12:35:16,040 | Using config file: samconfig.toml, config environment: default
2022-06-30 12:35:16,040 | Expand command line arguments to:
2022-06-30 12:35:16,041 | --template_file=/home/simha_personal_data/programming_arch_firefox/extra/Unsorted/vid/web_dev/hss_iqgateway/aws_sam/sam-app/template.yaml --stack_name=santhosh-testing --dependency_layer --capabilities=('CAPABILITY_NAMED_IAM', 'CAPABILITY_AUTO_EXPAND')
Managed S3 bucket: aws-sam-cli-managed-default-samclisourcebucket-1cqyp2bwbvv8u
Default capabilities applied: ('CAPABILITY_NAMED_IAM', 'CAPABILITY_AUTO_EXPAND')
To override with customized capabilities, use --capabilities flag or set it in samconfig.toml
2022-06-30 12:35:17,944 | Using build directory as .aws-sam/auto-dependency-layer
2022-06-30 12:35:17,945 | Using build directory as .aws-sam/auto-dependency-layer
This feature is currently in beta. Visit the docs page to learn more about the AWS Beta terms https://aws.amazon.com/service-terms/.
The SAM CLI will use the AWS Lambda, Amazon API Gateway, and AWS StepFunctions APIs to upload your code without
performing a CloudFormation deployment. This will cause drift in your CloudFormation stack.
**The sync command should only be used against a development stack**.
Confirm that you are synchronizing a development stack and want to turn on beta features.
Enter Y to proceed with the command, or enter N to cancel:
[y/N]: Y
2022-06-30 12:35:22,217 |
Experimental features are enabled for this session.
Visit the docs page to learn more about the AWS Beta terms https://aws.amazon.com/service-terms/.
2022-06-30 12:35:22,225 | No Parameters detected in the template
2022-06-30 12:35:22,249 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2022-06-30 12:35:22,249 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2022-06-30 12:35:22,251 | 2 stacks found in the template
2022-06-30 12:35:22,251 | No Parameters detected in the template
2022-06-30 12:35:22,268 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2022-06-30 12:35:22,268 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2022-06-30 12:35:22,269 | 2 resources found in the stack
2022-06-30 12:35:22,269 | No Parameters detected in the template
2022-06-30 12:35:22,289 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2022-06-30 12:35:22,290 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2022-06-30 12:35:22,290 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/'
2022-06-30 12:35:22,290 | --base-dir is not presented, adjusting uri hello_world/ relative to /home/simha_personal_data/programming_arch_firefox/extra/Unsorted/vid/web_dev/hss_iqgateway/aws_sam/sam-app/template.yaml
2022-06-30 12:35:22,290 | No Parameters detected in the template
2022-06-30 12:35:22,307 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2022-06-30 12:35:22,307 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2022-06-30 12:35:22,309 | Executing the build using build context.
2022-06-30 12:35:22,319 | No Parameters detected in the template
2022-06-30 12:35:22,344 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2022-06-30 12:35:22,344 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2022-06-30 12:35:22,345 | Your template contains a resource with logical ID "ServerlessRestApi", which is a reserved logical ID in AWS SAM. It could result in unexpected behaviors and is not recommended.
2022-06-30 12:35:22,346 | Instantiating build definitions
2022-06-30 12:35:22,351 | Same function build definition found, adding function (Previous: BuildDefinition(python3.7, /home/simha_personal_data/programming_arch_firefox/extra/Unsorted/vid/web_dev/hss_iqgateway/aws_sam/sam-app/hello_world, Zip, , fb2df3d3-6088-413d-a68d-fef68238b0c7, {}, {}, x86_64, []), Current: BuildDefinition(python3.7, /home/simha_personal_data/programming_arch_firefox/extra/Unsorted/vid/web_dev/hss_iqgateway/aws_sam/sam-app/hello_world, Zip, , 8dd59822-1269-438b-9689-5ab100c44500, {}, {}, x86_64, []), Function: Function(function_id='HelloWorldFunction', name='HelloWorldFunction', functionname='HelloWorldFunction', runtime='python3.7', memory=None, timeout=500, handler='app.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='/home/simha_personal_data/programming_arch_firefox/extra/Unsorted/vid/web_dev/hss_iqgateway/aws_sam/sam-app/hello_world', environment=None, rolearn=None, layers=[], events={'HelloWorld': {'Type': 'Api', 'Properties': {'Path': '/copy_files', 'Method': 'post', 'RestApiId': 'ServerlessRestApi'}}}, metadata={'SamResourceId': 'HelloWorldFunction'}, inlinecode=None, codesign_config_arn=None, architectures=['x86_64'], stack_path=''))
2022-06-30 12:35:22,353 | Async execution started
2022-06-30 12:35:22,353 | Invoking function functools.partial(<bound method CachedOrIncrementalBuildStrategyWrapper.build_single_function_definition of <samcli.lib.build.build_strategy.CachedOrIncrementalBuildStrategyWrapper object at 0x7fd85f7e9210>>, <samcli.lib.build.build_graph.FunctionBuildDefinition object at 0x7fd85f7fab10>)
2022-06-30 12:35:22,353 | Running incremental build for runtime python3.7 for build definition fb2df3d3-6088-413d-a68d-fef68238b0c7
2022-06-30 12:35:22,353 | Waiting for async results
2022-06-30 12:35:22,354 | Manifest file is changed (new hash: 523939fbec58410a5ca9b187c33945d0) or dependency folder (.aws-sam/deps/fb2df3d3-6088-413d-a68d-fef68238b0c7) is missing for fb2df3d3-6088-413d-a68d-fef68238b0c7, downloading dependencies and copying/building source
2022-06-30 12:35:22,354 | Building codeuri: /home/simha_personal_data/programming_arch_firefox/extra/Unsorted/vid/web_dev/hss_iqgateway/aws_sam/sam-app/hello_world runtime: python3.7 metadata: {} architecture: x86_64 functions: ['HelloWorldFunction']
2022-06-30 12:35:22,354 | Building to following folder /home/simha_personal_data/programming_arch_firefox/extra/Unsorted/vid/web_dev/hss_iqgateway/aws_sam/sam-app/.aws-sam/auto-dependency-layer/HelloWorldFunction
2022-06-30 12:35:22,355 | Loading workflow module 'aws_lambda_builders.workflows'
2022-06-30 12:35:22,358 | Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2022-06-30 12:35:22,359 | Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
2022-06-30 12:35:22,362 | Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
2022-06-30 12:35:22,363 | Registering workflow 'GoDepBuilder' with capability 'Capability(language='go', dependency_manager='dep', application_framework=None)'
2022-06-30 12:35:22,365 | Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
2022-06-30 12:35:22,367 | Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2022-06-30 12:35:22,369 | Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
2022-06-30 12:35:22,370 | Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
2022-06-30 12:35:22,371 | Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'
2022-06-30 12:35:22,374 | Registering workflow 'NodejsNpmEsbuildBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm-esbuild', application_framework=None)'
2022-06-30 12:35:22,375 | Found workflow 'PythonPipBuilder' to support capabilities 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2022-06-30 12:35:22,439 | Invalid executable for python at /usr/bin/python
Traceback (most recent call last):
File "aws_lambda_builders/workflow.py", line 66, in wrapper
File "aws_lambda_builders/workflows/python_pip/validator.py", line 51, in validate
aws_lambda_builders.exceptions.MisMatchRuntimeError: python executable found in your path does not match runtime.
Expected version: python3.7, Found version: /usr/bin/python.
Possibly related: https://github.com/awslabs/aws-lambda-builders/issues/30
2022-06-30 12:35:22,490 | Invalid executable for python at /bin/python
Traceback (most recent call last):
File "aws_lambda_builders/workflow.py", line 66, in wrapper
File "aws_lambda_builders/workflows/python_pip/validator.py", line 51, in validate
aws_lambda_builders.exceptions.MisMatchRuntimeError: python executable found in your path does not match runtime.
Expected version: python3.7, Found version: /bin/python.
Possibly related: https://github.com/awslabs/aws-lambda-builders/issues/30
2022-06-30 12:35:22,491 | Exception raised during the execution
Build Failed
2022-06-30 12:35:22,494 | Sending Telemetry: {'metrics': [{'commandRunExperimental': {'requestId': 'fde47179-0655-4f96-89a7-ebf26da76734', 'installationId': 'a87120b0-ef01-4fa9-a2b4-d881501b50fc', 'sessionId': 'fb48edde-cf6e-46ea-8ac2-31688d6f3178', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.7.10', 'samcliVersion': '1.40.0', 'awsProfileProvided': True, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam sync', 'metricSpecificAttributes': {'experimentalAccelerate': True, 'experimentalAll': False, 'experimentalEsbuild': False, 'experimentalMavenScopeAndLayer': False, 'projectType': 'CFN'}, 'duration': 8937, 'exitReason': 'WorkflowFailedError', 'exitCode': 1}}]}
2022-06-30 12:35:23,703 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: PythonPipBuilder:Validation - Binary validation failed for python, searched for python in following locations : ['/usr/bin/python', '/bin/python'] which did not satisfy constraints for runtime: python3.7. Do you have python for runtime: python3.7 on your PATH?
Additional environment details (Ex: Windows, Mac, Amazon Linux etc) OS: Linux sam --version: $ sam --version SAM CLI, version 1.40.0 AWS region:
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
sam build - AWS Serverless Application Model
Build an AWS SAM application using the sam build command from the AWS SAM CLI. ... the --use-container option is specified, otherwise an...
Read more >aws sam build: runtime python version not same as ...
The solution is to use --use-container sam build --debug --use-container.
Read more >AWS SAM build: how it provides artifacts for deployment ...
In this session I cover using the AWS CLI to build artifacts for testing and deploying AWS Lambda functions. I demonstrate how sam...
Read more >AWS Lambda Applications and NodeJS
I noticed that NodeJS is the only runtime option when creating an ... C:\Users\bensi\IdeaProjects\team-up\.aws-sam\build --use-container Starting Build ...
Read more >Docker - Could not find python3 image locally and failed to ...
python3 --version Python 3.8.10 $ sam build --template ${SAM_TEMPLATE} --use-container ... HTTPError: 404 Client Error: Not Found for url: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the suggestions! I believe as this looks like a widely asked feature, we will definitely discuss about this and see if we can include this in recent releases!
I’d like to second this, not because I’m using a different runtime version locally, but because I develop on a Mac and (obviously) deploy to Linux. I’m going to try running
sam sync
inside a container mounted to my$PWD
, but a--use-container
flag would be really useful.