Aws-sam-cli: Specify globals in --env-vars file

Created on 8 Mar 2019  路  3Comments  路  Source: aws/aws-sam-cli

Describe your idea/feature/enhancement

I wish SAM CLI JSON file provided by --env-vars had support for globals. In our template.yaml we specify certain environment variables via Globals: Function: Environment: Variables. It would be nice if such shared variables could be added in one place inside the JSON file you can provide to --env-vars. Currently as far as I understand it you can only specify env vars per function in this file.

Proposal

Add something like Globals, Function or similar to the JSON file. What do you think? Any other workarounds? Now I frequently get caught in missing specifying this thing when adding a new function as I rely on the globals for that in the regular template.

arelambda-invoke typfeature

Most helpful comment

@terlar I tested this and it worked:

{
    "Parameters": {
        "BAR": "helloworld"
    }
}

That seems to define the BAR environment variable for all functions.

All 3 comments

@terlar I tested this and it worked:

{
    "Parameters": {
        "BAR": "helloworld"
    }
}

That seems to define the BAR environment variable for all functions.

@terlar Thanks for the issue. You can achieve this though the option @mnapoli has shown. We currently support two formats but you cannot intermix them. So if two functions have the same Env Var but you wanted different values, you would need to specify with the LogicalIds instead of Parameters. Marking this as a feature request as I can see some use-cases where it could be beneficial to have some kind of mixed format.

Here is the spot in the code where we parse the env vars file contents.

Can this be issue be modified to be a documentation change? Specifically, this section of documentation needs to document the Parameters option.

Was this page helpful?
0 / 5 - 0 ratings