3

I am using AWS SAM.
I have created a samconfig.toml file with the following entry:

[default.build.parameters]
container_env_var_file = "envDefault.json"

When I do sam build I see in .aws-sam/build.toml The env values from envDefault.json
But when I check the template .aws-sam/build/template.yaml I see the original values, not the overwrites I have in envDefault.json

What is the best way to sam deploy with overwrites of the env variables for each environment I am deploying to?
I am trying to avoid entering parameters manually during the deploy process.

Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278

1 Answers1

1

It seems you are trying to set build parameters not deploy parameters.

All the build parameters section in AWS SAM toml file starts with, [default.build.parameters]

And for the overriding deployment parameters, you have to use [default.deploy.parameters] section (default denotes the default profile).

So in your case, it will be like this.

[default.deploy.parameters]
parameter_overrides = "ParamKey=\"ParamValue\""

or you can use command line,

sam deploy --parameter-overrides

But if you are trying to get some values for your lambda functions based on environment, I strongly suggest the usage of parameter store.

Sam
  • 4,046
  • 8
  • 31
  • 47
  • I am trying to specify what environment variables values go with each deployment profile to overwrite the environment values in the template.yaml - not parameters. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html – Itay Moav -Malimovka Nov 26 '21 at 05:00
  • @ItayMoav-Malimovka You can use these parameters to pass your environment so that it would override values in your template.yaml and if you have many variables say, same variables for different env, make use of cloudformation 'mappings'. so you can specify your environment in the parameter and it will select correct mappings https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html – Sam Nov 26 '21 at 07:42
  • tnx - that looks like what I am looking for – Itay Moav -Malimovka Nov 27 '21 at 00:01
  • will be once I make it work for me (Wait for the work week to start :-) ) I always accept answers, I am of the founding generation in SO – Itay Moav -Malimovka Nov 27 '21 at 18:57