简体   繁体   中英

Dis-AllowedPattern for Cloudformation parameter value constraint?

I am trying to exclude certain characters from being entered as a parameter string in a YAML CloudFormation template. Specifically, I'm trying to not allow ampersands to be included. The documentation says that I can use AllowedPattern as a parameter property with regex such as

AllowedPattern: "[^&]"

However Cloudformation gives me an error saying this is malformed. I even tried the opposite to allow every character I can think of like "[a-zA-Z0-9 +-=._:/@."$?%'()*>.[]`{|}~\^#]" but that gives me an error about malformed YAML.

All the docs say is that you can use regex without any exceptions or caveats. Does anyone know what I'm missing here? Every place I test this regex, it works exactly as I'd like it to except in CloudFormation.

I've tried double and single quotes as well as escaping characters out the wazoo. With "[^&]", I'm able to be properly scolded when I use a string with an ampersand, but removing the ampersand doesn't resolve the error. Also, using a string without an ampersand also throws the same constraints error.

Does this achieve your aim?

AllowedPattern: "[^&]+"

If you want to allow characters other than '&', this will fit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM