`local start-api --container-env-vars` option does not work
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Description:
It is not clear (to me) what `--container-env-vars` does when used with `sam local start-api`.
My understanding is that it should set environment variable to underlying docker container which runs lambda (of PackageType::Zip) in `sam local` environment without having that environment variable defined in `template.yaml`
when I run:
```
sam local start-api --container-env-vars sam_local_envs.json --warm-containers EAGER
```
`sam` does not set environment variables to container it starts.
Also, it is not clear what kind the format that file should have, is it same format like `--env-vars` ?
### Steps to reproduce:
```
sam local start-api --container-env-vars sam_local_envs.json --warm-containers EAGER
```
where `sam_local_envs.json` is defined like (hoping that at least one key will work) :
```json
{
"P1": "V1",
"Parameters": {
"P2": "V2",
}
}
```
function part of `template.yaml` is something like:
```yaml
LambdaFunction:
Type: AWS::Serverless::Function
Properties:
Handler: bootstrap
Runtime: provided.al2
CodeUri: .
Events:
HelloApi:
Type: Api
Properties:
Path: /{path_param}
Method: get
RestApiId:
Ref: ApiGatewayApi
Metadata:
BuildMethod: makefile
```
### Observed result:
`docker inspect` of container which `sam` started returns:
```json
"Env": [
"AWS_SAM_LOCAL=true",
"AWS_LAMBDA_FUNCTION_MEMORY_SIZE=128",
"AWS_LAMBDA_FUNCTION_TIMEOUT=10",
"AWS_LAMBDA_FUNCTION_HANDLER=bootstrap",
"AWS_LAMBDA_FUNCTION_NAME=[REDACTED]",
"AWS_LAMBDA_FUNCTION_VERSION=$LATEST",
"AWS_LAMBDA_LOG_GROUP_NAME=aws/lambda/[REDACTED]",
"AWS_LAMBDA_LOG_STREAM_NAME=$LATEST",
"AWS_REGION=us-east-1",
"AWS_DEFAULT_REGION=us-east-1",
"AWS_ACCESS_KEY_ID=[REDACTED]",
"AWS_SECRET_ACCESS_KEY=[REDACTED]",
"AWS_ACCOUNT_ID=[REDACTED]",
"RUST_BACKTRACE=1",
"RUST_LOG=trace",
"LANG=en_US.UTF-8",
"TZ=:/etc/localtime",
"PATH=/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin",
"LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib",
"LAMBDA_TASK_ROOT=/var/task",
"LAMBDA_RUNTIME_DIR=/var/runtime"
],
```
### Expected result:
environment variables which exists in `--container-env-vars` file should be set in container
### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
1. OS: MacOS
2. `sam --version`: SAM CLI, version 1.43.0
3. AWS region:
`Add --debug flag to command you are running`
Contributor guide
Assessment
This issue has not been assessed yet.