Thank you for your feedback.
Form temporarily unavailable. Please try again or contact docfeedback@servicenow.com to submit your comments.
Versions
  • London
  • Kingston
  • Jakarta
  • Istanbul
  • Helsinki
  • Geneva
  • Store
Close

Validate parameter value with the AllowedPattern property

Validate parameter value with the AllowedPattern property

You can specify the AllowedPattern property in an Azure Resource Manager (ARM) and CloudFormation (CF) template to make an input validation before sending the provisioning request to the cloud.

Before you begin

Role required: sn.cmp.cloud_service_designer

About this task

You can provide rules to validate a parameter value before sending the provisioning request to the cloud. To be notified with an error message if the validation fails, specify the ConstraintDescription property in the template. You can customize the error message in the ConstraintDescription property to make the message clear and explicit. Usually, the CF templates already have the AllowedPattern and ConstraintDescription properties. If these properties are not present, you can add them as mentioned in the following procedure:

Procedure

  1. Navigate to Cloud Management > Cloud Admin Portal > Design > Cloud Templates.
  2. Click New to create a new cloud template or select an existing template. If you select an existing template, rename that template.
  3. In the Body area, make the following changes in an ARM and a CF template.
    1. In an ARM template, make these changes:
      • Inside the parameters metadata section, enter SNC::Parameter::Metadata.
      • Enter the key as AllowedPattern and a valid value range.
      • Enter the key as ConstraintDescription and enter an error message.
      "parameters": {
               "newStorageAccountName": {
                   "type": "string",
                    "metadata": {
                        "description": "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed.",
                         "SNC::Parameter::Metadata": {
                             "allowedPattern": "[0-9a-z]{1,11}",
                              "ConstraintDescription": "must be an alphanumeric "
                                                    
                                 }}} 
             
          
      
    2. In a CF template, make these changes:
      • Enter the key as AllowedPattern an a valid value range.
      • Enter the key as ConstraintDescription and enter an error message.
      "Parameters" : {
                      "SSHLocation" : {
                      "Description" : "The IP address range that can be used to SSH to the EC2 instances",
                      "Type": "String",
                      "MinLength": "9",
                      "MaxLength": "18",
                      "Default": "0.0.0.0/0",
                       "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
                       "ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
      
          } 
        }
  4. Click Submit.