-
Notifications
You must be signed in to change notification settings - Fork 597
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
"when 'Ref' is resolved" to a parameter #3378
Comments
Thank you for being proactive about this. After the 1.0 update we have a large number of lint errors we're working through and this represents a decent portion of them, especially with our code modules. For those errors, I think removing the default for the parameters (which are blank) we expect from a user will be a great solution. I have not tested the module deployment or usage yet but the linting errors are gone after removing the blank defaults and I plan to add the proper validation to the schema so we can lint things like the ImageId and SecurityGroupIds list. The documentation for figuring out how to use custom schemas, override specs, and custom rules could be better but I don't have any specific advice other than it could be more cohesive with, perhaps, a few more examples of using .cfnlintrc in conjuction with other external files. |
@randybasrs If you are wrapping those Heard on the documentation let me see what we can do to improve that documentation. I'll start tackling that next week. |
To confirm, using Default: "" with some of our non required parameters did function properly as long as there was a condition for that particular property. Works like a champ! Ex:
Both of these EC2 properties have a defulat of '' which expectedly allows a user to specify the static IP or userdata or not. |
I have an error related to this but it is really a mis-match between cfn-lint and easiest example is when you are deploying a multi-regioned resource using the same template. example:
without paramDynamoStreamArn having a default when we try to deploy in the DbOwner region |
@animaxcg What is the logic for |
@kddejong |
@animaxcg to summarize... If the Default is added to the parameter the template will work in us-east-1 and fail in any other region unless a valid parameter value is provided. cfn-lint will fail relating to the fact that this template will fail in a region other than us-east-1. If The current resolution that cfn-lint would stir you towards is updating the Condition to be something like whats below. This would allow you to keep the Default and then would require the resource to have a non-default value during provisioning time. conditionIsDbOwningRegion: !And [!Equals [!Ref AWS::Region, us-east-1], !Not [!Equals [!Ref paramDynamoStreamArn, ""]]] |
@kddejong Also adding that to the conditional now means I have 2 places where the same logic exists in different languages (in the template and in the code that deploys the cfn) which means modifying that logic in the future means double the work which also not desirable and will likely lead to an unclear headache for people in the future |
What is the proposed solution for cases when the Default value is a valid string representation of the object, but that validation fails?
The above set up fails with |
cfn-lint Version
cfn-lint will validate your template parameters against the resource provider schemas. To do this we use any values that are provided in the template including
Default
andAllowedValues
.AllowedValues
will be used if provided and if not we use theDefault
value.The result can be confusing so I want to discuss how some of the expectations are and to use this issue to track this issue to see if it needs to be changed.
Basic example
To represent the issue we will use this basic template
returns the below error because when we resolve the
Default
value we do not end up with a valid AMI IDResolutions
Conditions
Sometimes we use the default parameter to represent an optional parameter and we wrap it in a condition. The following template will be error free as
cfn-lint
can now determine the value will not be""
whenImageId
is validated.No Default
If we require the template implementer to provide a valid value remove the
Default
property. If we removeDefault
we can use other parameter properties (AllowedPattern
) to better validate the parameter value. We do this because we are expecting the template user to provide a value when they are deploying the template."Valid" Default
For this we will provide a "valid" value as the
Default
value.You can also use
Metadata
to provide hints to the user that are using the console to deploy the template.The text was updated successfully, but these errors were encountered: