Is there a way to pass environment variables to the container doing the build in:
sam build --use-container
In the sam build documentation, in parameters related to Docker, there is only --docker-network
and --skip-pull-image
I am using private PyPI repository, and I need to pass credentials as environment variables.
A workaround is:
lambci/lambda:build-python3.7
sam build -u
with parameter --skip-pull-image
Created a feature request in SAM repo: https://github.com/aws/aws-sam-cli/issues/2144
New parameters were released: --container-env-var
and --container-env-var-file
in v1.20.0
Starting from release v1.20.0 (2021-03-04) you can pass environment variables to the container, either from the command line:
sam build --use-container \
--container-env-var Function1.GITHUB_TOKEN=<token1> \
--container-env-var GLOBAL_ENV_VAR=<global-token>
or from a file:
sam build --use-container --container-env-var-file <env-file.json>
Ref: sam build documentation