Using Validations

Edit your Oracle Cloud Stack template file and configure advanced validation criteria.
When a stack is created from a template, any validations defined in the template are executed prior to the provisioning of the resources in the template. If the validations succeed, Oracle Cloud Stack attempts to create the resources. Any failed validations are reported to the user and the stack is not created.

Basic Syntax

Define template validations within the validations node of your template file. For each validation, specify a validationType and add a parameters node.

validations:
  myFirstValidation:
    validationType: DB_CONNECT
    parameters:
      ...
  mySecondValidation:
    validationType: STORAGE_CONNECT
    parameters:
      ...

The available parameters depend on the type of validation. You can assign static values to these validation parameters, or assign the value of a template parameter by using the GetParam function.

You can optionally assign the name of an existing condition. The validation will not execute unless the specified condition evaluates to true:

validations:
  myValidation:
    condition: connectToDB
    validationType: DB_CONNECT
    parameters:
      ...

Database Connectivity

Check the connectivity to an existing Oracle Database Cloud Service deployment prior to creating a stack. Provide the connection details for the database deployment in the validation definition. For example:

dbConnectivityValidation:
  validationType: DB_CONNECT
  parameters:
    serviceName: MyDBInstance
    userName: SYS
    password: password
    requiredSize: 10GB
    constraintDescription: Failed to connect to the MyDBInstance database
Parameter Description

serviceName (Optional)

Enter the name of an existing Oracle Database Cloud Service deployment.

You must specify either serviceName or connectString.

connectString (Optional)

Enter a Java Database Connectivity (JDBC) URL for an existing Oracle Database Cloud Service deployment. For example: jdbc:oracle:thin:@203.0.113.100:1521:orcl.

You must specify either serviceName or connectString.

userName

The database user with which to make a connection

password

The database user’s password

requiredSize (Optional)

The validation fails if the database’s available capacity is less than this size.

pdbName (Optional)

The validation fails if the specified pluggable database (PDB) does not exist in the database.

schemaName (Optional)

The validation fails if the specified schema already exists in the database.

constraintDescription (Optional)

The error message to display to the user if this validation fails

Storage Connectivity

Not Oracle Cloud at Customer This topic does not apply to Oracle Cloud at Customer.

Check the connectivity to Oracle Cloud Infrastructure Container Service Classic prior to creating a stack. Provide the storage connection details in the validation definition.

You can connect to cloud storage with a username and password, as shown in the example below:

storageConnectivityValidation:
  validationType: STORAGE_CONNECT
  parameters:
    cloudStorageContainer: https://foo.storage.oraclecloud.com/v1/MyService-bar/MyContainer
    cloudStorageUser: john@example.com
    cloudStoragePassword: your_password
    checkIfContainerExists: false
    constraintDescription: Failed to connect to cloud storage as john

If you do not provide storage credentials, Oracle Cloud Stack will attempt to connect to cloud storage by using the OAuth protocol. You can optionally specify the name of an Oracle Cloud service that has been previously configured for OAuth authentication to cloud storage. For example:

storageConnectivityValidation:
  validationType: STORAGE_CONNECT
  parameters:
    cloudStorageContainer: https://foo.storage.oraclecloud.com/v1/MyService-bar/MyContainer
    serviceType: jaas
    checkIfContainerExists: false
    constraintDescription: Failed to connect to cloud storage using jaas OAuth configuration 

Alternatively, you can specify an Oracle Cloud entitlement ID that has been previously configured for authentication to cloud storage by using the OAuth protocol. For example:

storageConnectivityValidation:
  validationType: STORAGE_CONNECT
  parameters:
    cloudStorageContainer: https://foo.storage.oraclecloud.com/v1/MyService-bar/MyContainer
    serviceEntitlementId: 123456
    checkIfContainerExists: false
    constraintDescription: Failed to connect to cloud storage using entitlement 123456
Parameter Description

cloudStorageContainer

The URL for a cloud storage container

If checkIfContainerExists is true, then this container must already exist for this validation to succeed.

cloudStorageUser (Optional)

The Oracle Cloud user with which to make a connection

If you do not provide a value for this parameter, Oracle Cloud Stack attempts to connect to cloud storage by using the OAuth protocol.

cloudStoragePassword (Optional)

The password for the specified cloud user

If you do not provide a value for this parameter, Oracle Cloud Stack will attempt to connect to cloud storage by using the OAuth protocol.

checkIfContainerExists (Optional)

If set to true, then the validation will succeed only if the specified storage container exists.

If set to false, then the validation simply checks for connectivity to the storage cloud service.

serviceType (Optional)

The name of an Oracle Cloud service that has been previously configured for authentication to cloud storage by using the OAuth protocol. Oracle Cloud Stack uses this service’s OAuth configuration to validate connectivity to cloud storage. See List of Resource Types.

If not specified, Oracle Cloud Stack automatically selects a service that is configured for OAuth.

serviceEntitlementId (Optional)

An Oracle Cloud entitlement ID that has been previously configured for authentication to cloud storage by using the OAuth protocol. Oracle Cloud Stack uses this account’s OAuth configuration to validate connectivity to cloud storage.

If not specified, Oracle Cloud Stack automatically selects an account that is configured for OAuth.

If both serviceType and serviceEntitlementId are specified, serviceEntitlementId takes precedence.

constraintDescription (Optional)

The error message to display to the user if this validation fails

Generic Constraint

Not Oracle Cloud at Customer This topic does not apply to Oracle Cloud at Customer.

Evaluate a conditional expression that uses standard template functions. Validation fails if the expression evaluates to false. For example:

passwordValidation:
  validationType: CONSTRAINT
  parameters:
    constraint: {"Fn::Equals": [{"Fn::GetParam": "password"}, "oracle"]}
    constraintDescription: The password oracle is not permitted. Enter a different password.

To learn more about conditional expressions, see Using Conditions and List of Functions.

Parameter Description

constraint

A YAML expression that evaluates to either true or false. Validation fails if the expression evaluates to false.

constraintDescription (Optional)

The error message to display to the user if this validation fails