I am trying to get a Cloudformation script to enforce a valid url path which could contain version information. I am trying to match something like:
/mypath-1.2.1
I am using
"AllowedPattern": "/[/a-zA-Z0-9_\-\.]*",
"Default": "mypath-1.2.1"
I have checked the regex against an online checker and it is fine but I am getting a "Template validation error: Template format error: JSON not well-formed" on the backslashes.
It will validate ok without the backslashes but fails on the default value not matching the regex
AllowedPattern
is a JSON
string and must follow the JSON standard for strings.
Your AllowedPattern
contains escape sequences like \-
and \.
which are invalid in JSON
.
You need to escape the black slashes in the AllowedPattern
to make this valid JSON
;
"AllowedPattern": "/[/a-zA-Z0-9_\\-\\.]*"
The JSON
specification only allows escape sequences that follow these rules;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With