Make parameter input required in CloudFormation template
Asked Answered
B

1

6

I have a template for AWS Cloud Formation. In this template I have set several parameters. Now, what I would like to do is to leave a parameter field empty but allow the user to select a specific parameter for example a security group. Now what I would like to do is that if a user does not select anything (field stays empty) I want it to give an error message saying field required when you want to proceed and prevent the user from proceeding, as it happens when you do not enter a stack name (see screenshot below).

enter image description here

How do I do this for any parameter in a cloud formation template??? I have searched around but do not find anything regarding validation of user input …

I know I could set a default for everything, but I do not want to set a default and specifically force a user to make a selection in this case …

Broeker answered 7/6, 2020 at 11:21 Comment(2)
Could you clarify. You wish to create a parameter which will result in a drop-down list, but without any value selected by default?Lathrope
No, I wish for field validation, for example, if the field is empty and you hit next, it should result in an error saying "SecurityGroup parameter required" for example, I want to force users to fill in the fields. I do not want to add a default. I have several parameters with a dropdown list, but without any default, so the field is empty. The user should choose a value him/herself and if he/she does not do it it should not be possible to proceed with the template resulting in an empty value …Broeker
C
11

Please see this thread:

https://forums.aws.amazon.com/thread.jspa?threadID=230829

Suggested solution: simply use regular expressions in AllowedPattern.

For e.g. to have a non blank value:

  "AllowedPattern" : ".+"

If you want the parameter to be alpha numeric:

  "AllowedPattern" : "[a-zA-Z0-9]+"

To match an exact word:

  "AllowedPattern" : "^my_matched_word$"
Catamite answered 7/6, 2020 at 17:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.