Skip to content

envvar not picked up in AWS Lambda context #414

Description

@zopyx

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Typer documentation, with the integrated search.
  • I already searched in Google "How to X in Typer" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to Typer but to Click.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

database: str = typer.Option(
        ...,
        help="URL for Postgres sync database (e.g. postgresqlext://user:pw@localhost/mydb)",
        envvar="SYNC_DATABASE",
    )

Description

I havr a main() method with a parameter database as documented above. It will pick up its configuration from the given environment variable SYNC_DATABASE. This works perfectly from the commandline.

Now, I want to use the same application code with main() as entry point from within an AWS Lambda function.
The related environment variable is correctly set through the AWS Lambda environment (checked by using logger messages).
So SYNC_DATABASE is correctly available for the Python process.

The Lambda handler invokes typer.run(main).

However, the database parameter is always set to OptionInfo rather than the value of the configured environment variable.

Expected behavior: database should have the value of the env var SYNC_DATABASE.

Operating System

Linux

Operating System Details

AWS Lambda

Typer Version

0.4.2

Python Version

3.9

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion or problem

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions