Skip to content

sam build --use-container fails hello_world when behind proxy. #913

@DevOpsChris

Description

@DevOpsChris

Description:

The hello_world example bombs everytime when following the written instructions when behind a proxy. Need to create a proxy flag or introduce passing proxy envs with the build command. Better yet, honor the .docker/config.json and service settings in your container code.

Also, really need to make logging or stderr MUCH better in https://github.com/awslabs/aws-lambda-builders, because it just says

{"jsonrpc": "2.0", "id": 1, "error": {"code": 400, "message": "PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement: requests==2.20.0"}}

instead of

Collecting foo
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x10c04e780>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')': /simple/foo/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x10c04e588>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')': /simple/foo/
......
  Could not find a version that satisfies the requirement foo (from versions: )
No matching distribution found for foo

It really misleads people when debugging.

Dirtiest Fix, put in proxy envs in env dictionary https://github.com/DevOpsChris/aws-sam-cli/blob/develop/samcli/local/docker/lambda_build_container.py#L77-L81

Best fix: Honor the environment settings the docker service provides.

Steps to reproduce the issue:

  1. Follow the 0.10.0 hello world instructions
  2. sam build --use-container

Observed result:

aws_lambda_builders.exceptions.WorkflowFailedError: PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement: requests==2.20.0
2019-01-04 13:37:35 Build inside container returned response {"jsonrpc": "2.0", "id": 1, "error": {"code": 400, "message": "PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement: requests==2.20.0"}}
Build Failed
Error: PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement: requests==2.20.0

Expected result:

Build Succeeded

Built Artifacts  : .aws-sam/build
Built Template   : .aws-sam/build/template.yaml

Commands you can use next
=========================
[*] Invoke Function: sam local invoke
[*] Package: sam package --s3-bucket <yourbucket>

Running PythonPipBuilder:ResolveDependencies
Running PythonPipBuilder:CopySource

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

  • Mac OSX: 10.13.6
  • Docker: Version 2.0.0.0-mac81 (29211)

Output of sam --version: SAM CLI, version 0.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions