Support !Ref of template parameters - #657
Conversation
- Provide values for template parameters - Automatically picks up default values - Assigns sane defaults for CFN pseudo-parameters like AWS::Region
| Additional arguments passed to the debugger | ||
| debugger_path str | ||
| Path to the directory of the debugger to mount on Docker | ||
| aws_profile |
There was a problem hiding this comment.
Can you add the type to aws_profile and aws_region.
| AWS Credential profile to use | ||
| aws_region | ||
| AWS region to use | ||
| parameter_overrides : dict |
There was a problem hiding this comment.
Nit: remove the : to remain consistent with the other docstrings.
|
|
||
| click.option("--parameter-overrides", | ||
| type=CfnParameterOverridesType(), | ||
| help="Optional. A string that contains CloudFormation parameter overrides encoded as key-value " |
There was a problem hiding this comment.
Should this be key=value instead of key-value? You have an example but keeping this consistent will help communicate what we are expecting.
| error_output = process_stderr.decode('utf-8') | ||
| self.assertIn("no_event and event cannot be used together. Please provide only one.", error_output) | ||
|
|
||
| def test_invoke_with_timeout_set_by_parameters(self): |
There was a problem hiding this comment.
This is almost identical to the 'test_invoke_with_timeout_set' test. Can we parameterize them into one test? This will be help as we build out the tests more to cover different cases.
There was a problem hiding this comment.
good idea. will do
| ) | ||
|
|
||
| ]) | ||
| def test_successful_parsing(self, input, expected): |
| ]) | ||
| def test_successful_parsing(self, input, expected): | ||
| result = self.param_type.convert(input, None, None) | ||
| print(input) |
| "AWS::AccountId": "123456789012", | ||
| "AWS::Partition": "aws", | ||
|
|
||
| # There is not much value in inferring actual AWS region here. These values are just placeholders to help |
There was a problem hiding this comment.
Can you update this comment, to reflect the AWS::Region override change.
|
|
||
| default_values = {} | ||
|
|
||
| parameter_definition = sam_template.get("Parameters", None) |
| Removes wrapping double quotes and any '\ ' characters. They are usually added to preserve spaces when passing | ||
| value thru shell. | ||
|
|
||
| Ex: |
There was a problem hiding this comment.
just a nit:
Making it look like in the docstring, looks nice in the editor, because it interprets it as a python prompt. https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard
Examples
----------
>>> _unquote('val\ ue')
value
There was a problem hiding this comment.
Good idea! I will add it..
| self._debug_port = debug_port | ||
| self._debug_args = debug_args | ||
| self._debugger_path = debugger_path | ||
| self._parameter_overrides = parameter_overrides or {} |
There was a problem hiding this comment.
We set this to be None by default everywhere else, should we do that here too?
There was a problem hiding this comment.
Yes it is set as None everywhere else, but as a good practice I set to empty dictionary if customers don't specify any value.
|
Yay for this one. Just started using SAM, and this is a blocker. Thanks for adding it! |
|
I have the following issue with !Ref: When executing via only the first Function receives the value in the .env file (process.env.CLIENT_ID=="ABCD"). Am I using this wrong? |
Issue #, if available:
#573, #572, #528, #490
Description of changes:
Still very much a work in progress. This PR supports resolving !Ref of template parameters anywhere within a SAM template. It does not yet support other intrinsic functions like !Sub or !FindInMap.
--parameter-overridesCLI option--parameter-overridesCLI optionRemaining:
Thanks to @jfuss for providing the initial version of implementation. This PR is a cleaned up version of Jacob's implementation.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.