Conversation
|
Hi @sigJoe thanks for contributing, would like to hear more opinion on the change of behavior here
|
Prior to this PR, specifying In this PR, SAM will merge both sources of overrides and build/deploy/etc with the resulting set. I consider the new behaviour to be objectively better. It was also the basis for #2380. However, I admit it is conceivable that somebody might rely on the way it is currently working, even though I personally don't have any use cases for it. Edit: I didn't really think about it when I started, but I suppose it could be a good idea to make it retain the current default behaviour and only merge samconfig when someone specifies |
|
After thinking about it further, I removed the merging of samconfig with CLI parameter overrides as probably deserves further discussion |
|
To recap: I changed the syntax that failed the Python3.9 tests and removed the merging of parameters that caused that integration test to fail (can re-add if necessary but should probably be its own thing). and here's some documentation: Parameter Overrides Syntaxsamconfig.tomlThree supported parameter_overrides formats: version = 0.1
[default.deploy.parameters]
stack_name = "sam-app"
region = "us-east-1"
parameter_overrides = [
"file://params.toml", # NEW! Amazing file syntax
"ParameterKey=foo,ParameterValue=bar", # Long form key/value pair. Unnecessarily verbose
"a=1" # Short form key/value pair
]You can now also use parameter_overrides as a TOML table/section version = 0.1
[default.deploy.parameters]
stack_name = "sam-app"
region = "us-east-1"
[default.deploy.parameters.parameter_overrides]
a = "1"Multiple parameters per string are not best practice: version = 0.1
[default.deploy.parameters]
stack_name = "sam-app"
region = "us-east-1"
parameter_overrides = [
"a=1 b=2", # Valid to bundle multiple parameters, although not as clean as putting them on separate lines
"c=3 ParameterKey=d,ParameterValue=4", # Invalid: Cannot mix syntax
"d=4 file://params.toml", # Invalid: Still not allowed to mix syntax
"file://params.toml file://otherparams.toml", # Invalid: Despite being the same syntax, it didn't feel necessary to support this
]samconfig.yamlOld formatversion: 0.1
default:
deploy:
parameters:
stack_name: sam-app
region: us-east-1
parameter_overrides:
- A=1
- B=2
- Spaces='String with spaces'
- ListParam='a,b,c'NEW! Dictionary format supportLooks cleaner and supports IDE syntax highlighting version: 0.1
default:
deploy:
parameters:
stack_name: sam-app
region: us-east-1
parameter_overrides:
- A: 1
- B: 2
- Spaces: String with spaces
- ListParam: # Converts to "a,b,c"
- a
- b
- c
- file://params.yamlNEW! Anchors and aliases format supportSee https://www.educative.io/blog/advanced-yaml-syntax-cheatsheet#YAML-Anchors-and-Alias for more info. version: 0.1
prod-a:
deploy:
parameters:
stack_name: sam-app
region: us-east-1
parameter_overrides: &prod_a_overrides
- Name: prod-a
- ParamA: 1
- ParamB: 2
prod-b:
deploy:
parameters:
stack_name: sam-app-2
region: us-east-1
parameter_overrides:
- *prod_a_overrides # Pulls in above params (Name, ParamA, and ParamB)
- Name: prod-b # But we want this one named differentlyExternal TOML params filesWhen specifying a StringParam = "Pam Param"
NumberParam = 42
ListParam = "a,b,c"
ListParam2 = ["a", "b", "c"] # Converts to "a,b,c"Note there are limitations to the format such that you cannot specify nested TOML files StringParam = "Pam Param"
NumberParam = 42
file://another_toml_file.toml # This will fail because it is not valid TOMLExternal YAML params filesWhen specifying a - A=1 # OK if you really must
- ParameterKey=B,ParameterValue=2 # It works, but now you're just being silly
- StringParam: String with Spaces
- NumberParam: 42
- ListParam: a,b,c
- ListParam2: # Converts to "a,b,c"
- a
- b
- c
- file://other_yaml_params.yaml
- file://toml_params_because_I_can.tomlIdeal ScenarioThese features unlock a lot of different use cases, but personally I would be using it something like this: version: 0.1
prod-a:
deploy:
parameters:
stack_name: sam-app
region: us-east-1
parameter_overrides: file://prod-a.yaml # includes prod.yaml, which includes common.yaml
prod-b:
deploy:
parameters:
stack_name: sam-app
region: us-west-2
parameter_overrides: file://prod-b.yaml # includes prod.yaml, which includes common.yaml
dev:
deploy:
parameters:
stack_name: sam-app
region: us-east-1
parameter_overrides: file://dev.yaml # includes common.yaml |
|
Thank you for your update. Pending review from team. |
|
Sorry about that - I'm not sure how I missed those other failing tests. |
Co-authored-by: Roger Zhang <roger.zhang.cs@gmail.com>
|
Hi @roger-zhangg. With apologies, I accidentally reset your approval when I clicked the |
841de33
|
Resolve the conflict which trigger the approval to reset. Pending workflow result and approval from maintainers. |
| self.fail(f"{value} uses an unsupported extension", param, ctx) | ||
|
|
||
| # Recursively process the file's contents and update parameters | ||
| if file_path in seen_files: |
There was a problem hiding this comment.
Thank you for this protection for endless recursive loop.
Which issue(s) does this change fix?
Issues:
#2380#2253 #2054Discussions: #4591 #6377
Why is this change necessary?
It's a roundup of quality of life improvements for users of SAM CLI that need to manage multiple environments with different parameters.
How does it address the issue?
file://MyParams.yamlorfile://MyParams.toml), which can be used both in samconfig and via CLIFILE_MANAGER_MAPPERadds it as a supported option. I could have bypassed that to directly use theJsonFileManager, but I figured there's probably a reason JSON is explicitly disabled.What side effects does this change have?
n/a
Mandatory Checklist
PRs will only be reviewed after checklist is complete
make prpassesmake update-reproducible-reqsif dependencies were changedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
I don't know where I'm expected to write documentation