List of Functions

Oracle Cloud Stack offers several intrinsic functions that you can use when creating a template. These functions are executed at runtime by Oracle Cloud Stack when a stack is being created.

Function Description and Syntax Examples
And

Return true if the sequence of expressions all evaluate to true; otherwise return false.

Fn::And: [exp1, exp2, expN]
"Fn::And": [{"Fn::Equals": [{"Fn::GetParam": stage}, "dev"]}, {"Fn::Equals": [{"Fn::GetParam": container}, ""]}] 
Base64

Convert the given string to base64 encoding.

Fn::Base64: string
publicKeyText: { "Fn::Base64": {"Fn::GetParam": "key"} }
Contains

Return true if the first string is found in the second string, or if the specified value is found in a sequence of values; otherwise return false.

Fn::Contains: [valueToSearchFor, stringOrSequence]
"Fn::Contains": ["us", {"Fn::GetParam": region}]
Empty

Return true if the provided string is empty; otherwise return false.

Fn::Empty: string
"Fn::Empty": {"Fn::GetParam": region}
Equals

Compare a sequence containing two expressions and return true if the expressions evaluate to the same value; otherwise return false.

Fn::Equals: [exp1, exp2]
"Fn::Equals": [{"Fn::GetParam": appType}, "Java"]
FindInMap

Retrieve the value for the specified key from a map that’s defined in this template.

Fn::FindInMap: [mapName, submapName, keyName]
usableStorage: "Fn::FindInMap": ["dbMap", "size", {"Fn::GetParam": projectType}]
GetAtt

Retrieve the value of the runtime attribute from a specific resource. The attribute name supports a dot notation to access nested attributes within a JSON payload.

Fn::GetAtt: [resourceName, attributeName]
dbServiceName: { "Fn::GetAtt": [HRDatabase, serviceName] }
shape: { "Fn::GetAtt": [HRWeb, options.clusters.shape] }
GetParam

Retrieve the value of a template parameter.

Fn::GetParam: parameterName
network: { "Fn::GetParam": networkName }
description: { "Fn::GetParam": serviceName }
container: { "Fn::GetParam": backupStorage.cloudStorageContainer }
GetRandom

Generate a string of random characters.

Fn::GetRandom: [size, characterSet]

Use characterSet to limit the characters that are allowed in the generated string:

  • ALPHANUMERIC - The characters A-Z,a-z,0-9

  • ALPHABET - The characters A-Z,a-z

  • NUMERIC - The characters 0–9

  • A custom sequence of characters. For example: [$,!,#,&]

password: { "Fn::GetRandom": [10, "ALPHANUMERIC"] }
dbServiceName: { "Fn::Join": ["", ["DB",{"Fn::GetRandom" : [8, "ALPHABET"] }]] }
GetResource

Retrieve a resource’s definition.

Fn::GetResource: resourceName
configs:
  - name: DB1-dbScripts
    config: { "Fn::GetResource": dbScripts }
GetTimestamp

Return the current time in the specified format.

Fn::GetTimestamp: format

See SimpleDateFormat for the available date and time options in the format string.

serviceName: { "Fn::GetTimestamp": "'DB'yyMMdd" }

For example: DB180521

description: { "Fn::GetTimestamp": "'Created on' EEE, MMM dd" }

For example: Created on Wed, May 21

GreaterThan

Compare a sequence containing two expressions and return true if the first expression evaluates to a value that is greater than the value of the second expression; otherwise return false.

Fn::GreaterThan: [exp1, exp2]
"Fn::GreaterThan": [{"Fn::GetParam": clusterSize}, 1]
If

Evaluate a global condition defined in this template. If the specified condition evaluates to true, return the second item in the sequence; otherwise return the third item in the sequence.

Fn::If: [conditionName, trueValue, falseValue]
shape: { "Fn::If": ["prodEnv","oc4","oc3"] }
Join

Combine a sequence of values into a single string, and using the specified delimiter character between the values.

The function takes a sequence (delimiter, values) as its argument, and the values themselves are a sequence. To simply join the values without a delimiter specify an empty string for the first argument.

Fn::Join: [delimiterChar, [value1, value2, valueN]]
serviceName: { "Fn::Join": ["_", [HRApp, "Fn::GetParam": userName]] }

If the userName parameter’s value is bill5, the serviceName parameter would be HRApp_bill5.

LessThan

Compare a sequence containing two expressions and return true if the first expression evaluates to a value that is less than the value of the second expression; otherwise return false.

Fn::LessThan: [exp1, exp2]
"Fn::LessThan": [{"Fn::GetParam": clusterSize}, 2]
Match

Return true if a string matches a regular expression; otherwise return false.

Fn::Match: [regularExpression, string]

This expression returns true if the region parameter begins with the text us:

"Fn::Match": ["^us", {"Fn::GetParam": region}]

This expression returns true if the schemaName parameter contains only letters and the numbers 0-3:

"Fn::Match": ["^(?=.*?[A-Z])(?=.*?[a-z])(?=.*[0-3])[a-zA-Z]([a-zA-Z0-3_#])+$", {"Fn::GetParam": schemaName}]
Not

Negate the boolean value of an expression. If the expression evaluates to true, return false.

Fn::Not: booleanExpression
"Fn::Not": {"Fn::Equals": [{"Fn::GetParam":"userName"}, ""]}}
Or

Return true if at least one expression in the sequence evaluates to true; otherwise return false.

Fn::Or: [exp1, exp2, expN]
"Fn::Or": [{"Fn::Equals": [{"Fn::GetParam": shape}, "oc3"]}, {"Fn::Equals": [{"Fn::GetParam": shape}, "oc4"]}] 
Replace

Dynamically find and replace one or more values in a string (body).

The replacements (substitutions) object can contain one or more name/value attributes and their values can be static or dynamic.

Fn::Replace: {"body" : string, "substitutions" : {find:replace, find:replace, ...}
appURL: { "Fn::Replace": {"body" : "host:port/myapp", "substitutions" : {"host" : "Fn:GetParam": publicIP, "port" : "7002"}} }

If the publicIP parameter’s value is 192.0.2.10, the appURL parameter would be 192.0.2.10:7002/myapp.

Select

Select an object from a list of indexed objects, by passing in the index of the desired object.

Fn::Select: [indexToFetch, objectList]
serverHost: { "Fn::Select": [0, "Fn::Split": [":", "host123:9001"]] }

The serverHost parameter is assigned the value host123.

Size

Return the number of characters in the specified string, or the number of elements in the specified sequence.

Fn::Size: stringOrSequence
"Fn::Size": {"Fn::GetParam": dbName}

If the dbName parameter is the string “mydb”, the value returned is 4. If the parameter is a sequence ["db1","db2"], the value returned is 2.

Split

Split a single string into a sequence of strings by using the specified delimiter character.

The function takes a sequence (delimiter, string) as its argument, and returns a sequence.

You can also use the Select function on the result of Split to retrieve a specific item in the sequence.

Fn::Split: [delimiterChar, string]
databases: { "Fn::Split": ["_", "mydb1_mydb2"] }

The databases parameter is assigned the sequence [mydb1, mydb2].