The parameter_overrides field in [default.deploy.parameters] consists of space-separated Key=Value pairs. While toml supports multiline strings, it causes an error because it does not process newlines as whitespace. Fixing that would be an improvement, but what I'd really prefer is that these key-value pairs get their own proper section. Say my samconfig.toml would look like:
version=0.1
[default.deploy.parameters]
stack_name = "my-app-stack"
s3_bucket = "my-source-bucket"
[default.deploy.parameters.template_parameters]
TemplateInput1 = "Value1"
TemplateInput2 = "Value2"
equivalent to
version=0.1
[default.deploy.parameters]
stack_name = "my-app-stack"
s3_bucket = "my-source-bucket"
parameter_overrides = "TemplateInput1=Value1 TemplateInput2=Value2"
One of the things this would make easier is updating the values in this file programmatically.
I like this idea.
It could also solve the current problem that we cannot have some default parameters to override in the toml file, and override some others from the command line. If you use "parameter-overrides" in the command line, it completely discards the ones in the toml file because the entire argument "paramter-overrides" gets replaced (that's what I saw).
This is useful when you have some common environment parameters in the toml file, but you left secrets and other critical values for the command line to pass on runtime.
That is an excellent point!
I Tried this in the samconfig.toml file and it seems to work for me is this relevant to the issue you raised @benkehoe ?
parameter_overrides=["TemplateInput1=Value1", TemplateInput2=Value2"]
@gannaramu This does appear to work, and allows the key-value pairs to placed on separate lines.
parameter_overrides=[
"TemplateInput1=Value1",
"TemplateInput2=Value2"
]
However, I'd like to keep this issue open, as I think a proper section would be a better user experience, and fits with @diegogurpegui's idea that there should be a command line option to keep the parameters defined in the config file but selectively override/add to them.
That is good idea. The parameter_overrides really hard to manage on IaC view
Even with three parameters it's too long.
version=0.1
[default.deploy.parameters]
parameter_overrides = "EvaluatorRuntime=ruby2.7 EvaluatorMemorySize=128 EvaluatorTimeout=10"
I like @benkehoe solution because as a developer its how I thought it would have worked
@benkehoe Do you think a separate section is still a better experience? regarding @diegogurpegui 's idea, I believe the current experience can be improved to handle it. right?
@elbayaaa I do think a separate section is a better experience, because it's clear and concise. Additionally, @diegogurpegui's idea can't be implemented for the existing configuration method, because it would break backwards compatibility, but this new separate section could have different semantics.
Most helpful comment
@gannaramu This does appear to work, and allows the key-value pairs to placed on separate lines.
However, I'd like to keep this issue open, as I think a proper section would be a better user experience, and fits with @diegogurpegui's idea that there should be a command line option to keep the parameters defined in the config file but selectively override/add to them.