Open davidjb opened 10 months ago
Thanks again @davidjb. My personal view on this is that it's not feasible to do every validation that CFN does, so we should do the validations that correspond to our local emulation. From your examples, it seems there are some valid use cases for early validation. I will discuss it with the team for prioritization.
Thanks @mildaniel for the consideration, I really appreciate it.
From my experience, using parameters without validating means unexpected results and a range of impacts. The impact may be minor/negligible if a parameter was used in, say, a description or comment, but when used for operational values (architectures, paths, env variables etc - as is in my production config), mistakes or missed parameters can subtly creep in and be hard to detect.
As Parameters are (can be) used by SAM in builds or locally (and passed as a CLI flag or in config), I was expecting they’d be validated as SAM’s other options/flags are.
Description:
As described in https://github.com/aws/aws-sam-cli/issues/6110, SAM doesn't attempt to validate values for Parameters according to their
AllowedValues
.CloudFormation will validate values, but only during the deploy process (e.g. once a changeset is running). This means a lot can occur before this point with invalid values: with an invalid value, you could still end up with broken, successful builds, attempts to download invalid containers or files, or failures anywhere else in the process, since a
Parameter
can be used anywhere.Steps to reproduce:
template.yml
:Run
sam build --parameter-overrides MyParam="fake" NumParam=11
and observe results, as per next section below. SAM attempts to findhello_world/fake-11
, despite the value of"fake"
not being in theAllowedValues
list and outside of the length bounds, andNumParm
being outside of the allowed range.Likewise, running with
NumParam="fake"
is permitted, despite this value being a different type (a string and not a number). Validation also doesn't occur for any other parameter Type, such as specifyinga,b,c
for the value of aList<Number>
.Observed result:
sam build --parameter-overrides MyParam="fake"
errors, trying to find the CodeUri ofhelloworld/fake
, as it has templated in the unverifiedMyParam
value:Expected result:
Validation errors would be shown when the SAM config is loaded for parameters that are outside the conditions, before the values are used for building. Builds would not succeed when invalid values are used and deploys would not begin.
As per https://github.com/aws/aws-sam-cli/issues/3244, these values will be validated but only during deployment by CloudFormation, assuming you're able to create a configuration that is able to be built successfully (e.g. suitable parameter values chosen depending on their use in
template.yaml
).Additional environment details (Ex: Windows, Mac, Amazon Linux etc)