-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand parameter overrides #7876
base: develop
Are you sure you want to change the base?
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.yaml NEW! 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 differently External 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 TOML External 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.toml Ideal 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. While fixing them, I realized that there was another issue of the JSON schema validation. I'm not entirely satisfied I addressed it in the best way (see |
Which issue(s) does this change fix?
Issues: #2380 #2253
Discussions: #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.yaml
orfile://MyParams.toml
), which can be used both in samconfig and via CLIFILE_MANAGER_MAPPER
adds 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 pr
passesmake update-reproducible-reqs
if 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