Skip to content

Fn

Resource Orchestration Service intrinsic functions.

https://help.aliyun.com/zh/ros/user-guide/functions

Static Functions

Name Description
add No description.
any Returns whether a value in the specified array is true or false.
avg No description.
base64Decode No description.
base64Encode The intrinsic function Fn::Base64 returns the Base64 representation of the input string.
calculate No description.
cidr Returns a list of CIDR addresses.
conditionAnd Returns true if all the specified conditions evaluate to true, or returns false if any one of the conditions evaluates to false.
conditionEquals Compares if two values are equal.
conditionIf Returns one value if the specified condition evaluates to true and another value if the specified condition evaluates to false.
conditionNot Returns true for a condition that evaluates to false or returns false for a condition that evaluates to true.
conditionOr Returns true if any one of the specified conditions evaluate to true, or returns false if all of the conditions evaluates to false.
contains Returns true if at least one member of the list matches the specified value and false otherwise.
eachMemberIn Returns true if every member of the first list is equal to at least one value in the second list, and false otherwise.
findInMap The intrinsic function Fn::FindInMap returns the value corresponding to keys in a two-level map that is declared in the Mappings section.
formatTime Returns the formatted time of the object.
getAtt The Fn::GetAtt intrinsic function returns the value of an attribute from a resource in the template.
getAzs The intrinsic function Fn::GetAZs returns an array that lists Availability Zones for a specified region.
getJsonValue No description.
getStackOutput The intrinsic function Fn::GetStackOutput returns the value of an output exported by another stack.
indent The intrinsic function Fn::Indent adjust the indentation of the string.
index Returns the index of the item in the list.
join The intrinsic function Fn::Join appends a set of values into a single value, separated by the specified delimiter.
jq No description.
lengthOf Returns the length of the object.
listMerge No description.
marketplaceImage The intrinsic function Fn::MarketplaceImage returns the default image ID of the specified cloud marketplace image product Code.
matchPattern Returns true if a specified string matches a specified pattern.
max No description.
mergeMapToList No description.
min No description.
ref The Ref intrinsic function returns the value of the specified parameter or resource.
replace No description.
select The intrinsic function Fn::Select returns a single object from a list of objects by index.
selectMapList No description.
split To split a string into a list of string values so that you can select an element from the resulting string list, use the Fn::Split intrinsic function.
str No description.
sub The intrinsic function Fn::Sub substitutes variables in an input string with values that you specify.

add

import { Fn } from '@alicloud/ros-cdk-core'
Fn.add(values: number | any[] | {[ key: string ]: any})

valuesRequired

  • Type: number | any[] | {[ key: string ]: any}

any

import { Fn } from '@alicloud/ros-cdk-core'
Fn.any(values: any[] | IResolvable)

Returns whether a value in the specified array is true or false.

Returns true if any item in the array is true, and false otherwise.

valuesRequired

An array of values.


avg

import { Fn } from '@alicloud/ros-cdk-core'
Fn.avg(ndigits: number, values: number[])

ndigitsRequired

  • Type: number

valuesRequired

  • Type: number[]

base64Decode

import { Fn } from '@alicloud/ros-cdk-core'
Fn.base64Decode(data: string)

dataRequired

  • Type: string

base64Encode

import { Fn } from '@alicloud/ros-cdk-core'
Fn.base64Encode(data: string)

The intrinsic function Fn::Base64 returns the Base64 representation of the input string.

dataRequired

  • Type: string

The string value you want to convert to Base64.


calculate

import { Fn } from '@alicloud/ros-cdk-core'
Fn.calculate(values: string, ndigits: number, para: number[])

valuesRequired

  • Type: string

ndigitsRequired

  • Type: number

paraRequired

  • Type: number[]

cidr

import { Fn } from '@alicloud/ros-cdk-core'
Fn.cidr(ipBlock: string | IResolvable, count: number | IResolvable, cidrBits: number | IResolvable)

Returns a list of CIDR addresses.

ipBlockRequired

The IP address block from which you want to allocate the CIDR.

The block must be expressed in CIDR notation.


countRequired

The number of IPv4 CIDRs to generate.

Valid input values range from 1 to 256 and are used to decide the total number of final subnets.


cidrBitsRequired

The number of subnet bits of the new CIDR.

For example, if the value "8" is specified for this parameter, a CIDR with a "/24" mask will be created.


conditionAnd

import { Fn } from '@alicloud/ros-cdk-core'
Fn.conditionAnd(conditions: string | IRosConditionExpression)

Returns true if all the specified conditions evaluate to true, or returns false if any one of the conditions evaluates to false.

Fn::And acts as an AND operator. The minimum number of conditions that you can include is 2, and the maximum is 10.

conditionsRequired

conditions to AND.


conditionEquals

import { Fn } from '@alicloud/ros-cdk-core'
Fn.conditionEquals(lhs: any, rhs: any)

Compares if two values are equal.

Returns true if the two values are equal or false if they aren't.

lhsRequired

  • Type: any

A value of any type that you want to compare.


rhsRequired

  • Type: any

A value of any type that you want to compare.


conditionIf

import { Fn } from '@alicloud/ros-cdk-core'
Fn.conditionIf(conditionId: string | IRosConditionExpression, valueIfTrue: any, valueIfFalse: any)

Returns one value if the specified condition evaluates to true and another value if the specified condition evaluates to false.

conditionIdRequired

A reference to a condition in the Conditions section.

Use the condition's name to reference it.


valueIfTrueRequired

  • Type: any

A value to be returned if the specified condition evaluates to true.


valueIfFalseRequired

  • Type: any

A value to be returned if the specified condition evaluates to false.


conditionNot

import { Fn } from '@alicloud/ros-cdk-core'
Fn.conditionNot(condition: string | IRosConditionExpression)

Returns true for a condition that evaluates to false or returns false for a condition that evaluates to true.

Fn::Not acts as a NOT operator.

conditionRequired

A condition such as Fn::Equals that evaluates to true or false.


conditionOr

import { Fn } from '@alicloud/ros-cdk-core'
Fn.conditionOr(conditions: string | IRosConditionExpression)

Returns true if any one of the specified conditions evaluate to true, or returns false if all of the conditions evaluates to false.

Fn::Or acts as an OR operator. The minimum number of conditions that you can include is 2, and the maximum is 10.

conditionsRequired

conditions that evaluates to true or false.


contains

import { Fn } from '@alicloud/ros-cdk-core'
Fn.contains(values: any[] | IResolvable, value: any)

Returns true if at least one member of the list matches the specified value and false otherwise.

valuesRequired

An array of values.


valueRequired

  • Type: any

A value.


eachMemberIn

import { Fn } from '@alicloud/ros-cdk-core'
Fn.eachMemberIn(values1: any[] | IResolvable, values2: any[] | IResolvable)

Returns true if every member of the first list is equal to at least one value in the second list, and false otherwise.

values1Required

An array of values.


values2Required

An array of values.


findInMap

import { Fn } from '@alicloud/ros-cdk-core'
Fn.findInMap(mapName: string, topLevelKey: string, secondLevelKey: string)

The intrinsic function Fn::FindInMap returns the value corresponding to keys in a two-level map that is declared in the Mappings section.

mapNameRequired

  • Type: string

topLevelKeyRequired

  • Type: string

secondLevelKeyRequired

  • Type: string

formatTime

import { Fn } from '@alicloud/ros-cdk-core'
Fn.formatTime(format: string | IResolvable, timeZone: string | IResolvable)

Returns the formatted time of the object.

formatRequired

The format of the time.


timeZoneRequired

The time zone.


getAtt

import { Fn } from '@alicloud/ros-cdk-core'
Fn.getAtt(logicalNameOfResource: string, attributeName: string)

The Fn::GetAtt intrinsic function returns the value of an attribute from a resource in the template.

logicalNameOfResourceRequired

  • Type: string

The logical name (also called logical ID) of the resource that contains the attribute that you want.


attributeNameRequired

  • Type: string

The name of the resource-specific attribute whose value you want.

See the resource's reference page for details about the attributes available for that resource type.


getAzs

import { Fn } from '@alicloud/ros-cdk-core'
Fn.getAzs(region: string)

The intrinsic function Fn::GetAZs returns an array that lists Availability Zones for a specified region.

Because customers have access to different Availability Zones, the intrinsic function Fn::GetAZs enables template authors to write templates that adapt to the calling user's access. That way you don't have to hard-code a full list of Availability Zones for a specified region.

regionRequired

  • Type: string

The name of the region for which you want to get the Availability Zones.

You can use the ROS::Region pseudo parameter to specify the region in which the stack is created. Specifying an empty string is equivalent to specifying ROS::Region.


getJsonValue

import { Fn } from '@alicloud/ros-cdk-core'
Fn.getJsonValue(key: string, jsonData: any)

keyRequired

  • Type: string

jsonDataRequired

  • Type: any

getStackOutput

import { Fn } from '@alicloud/ros-cdk-core'
Fn.getStackOutput(stackID: string, outputKey: string, stackRegion?: string)

The intrinsic function Fn::GetStackOutput returns the value of an output exported by another stack.

stackIDRequired

  • Type: string

outputKeyRequired

  • Type: string

stackRegionOptional

  • Type: string

indent

import { Fn } from '@alicloud/ros-cdk-core'
Fn.indent(str: string | IResolvable, level: number | IResolvable, indent?: number | IResolvable)

The intrinsic function Fn::Indent adjust the indentation of the string.

strRequired

Strings that need to be indented.


levelRequired

Indentation level.

The range is [0,20].


indentOptional

Optional, defaults to 2 for two Spaces per level, in the range [0,4].


index

import { Fn } from '@alicloud/ros-cdk-core'
Fn.index(itemToFindIndex: any, itemList: any[] | IResolvable)

Returns the index of the item in the list.

itemToFindIndexRequired

  • Type: any

The item to find in the list.


itemListRequired

The list to find the item in.


join

import { Fn } from '@alicloud/ros-cdk-core'
Fn.join(delimiter: string, listOfValues: string | IResolvable[])

The intrinsic function Fn::Join appends a set of values into a single value, separated by the specified delimiter.

If a delimiter is the empty string, the set of values are concatenated with no delimiter.

delimiterRequired

  • Type: string

The value you want to occur between fragments.

The delimiter will occur between fragments only. It will not terminate the final value.


listOfValuesRequired

The list of values you want combined.


jq

import { Fn } from '@alicloud/ros-cdk-core'
Fn.jq(method: string, script: string, inputString: string | {[ key: string ]: any})

methodRequired

  • Type: string

scriptRequired

  • Type: string

inputStringRequired

  • Type: string | {[ key: string ]: any}

lengthOf

import { Fn } from '@alicloud/ros-cdk-core'
Fn.lengthOf(obj: any)

Returns the length of the object.

objRequired

  • Type: any

An object whose length needs to be computed.

Three types are supported: strings, lists, and dictionaries.


listMerge

import { Fn } from '@alicloud/ros-cdk-core'
Fn.listMerge(valueList: any[] | IResolvable[])

valueListRequired


marketplaceImage

import { Fn } from '@alicloud/ros-cdk-core'
Fn.marketplaceImage(imageProductCode: string | IResolvable)

The intrinsic function Fn::MarketplaceImage returns the default image ID of the specified cloud marketplace image product Code.

imageProductCodeRequired

The product code of the cloud marketplace image.


matchPattern

import { Fn } from '@alicloud/ros-cdk-core'
Fn.matchPattern(pattern: string | IResolvable, value: string | IResolvable)

Returns true if a specified string matches a specified pattern.

patternRequired

A regular expression in string form.


valueRequired

The string to match.


max

import { Fn } from '@alicloud/ros-cdk-core'
Fn.max(values: number[])

valuesRequired

  • Type: number[]

mergeMapToList

import { Fn } from '@alicloud/ros-cdk-core'
Fn.mergeMapToList(mapList: {[ key: string ]: any[]}[])

mapListRequired

  • Type: {[ key: string ]: any[]}[]

min

import { Fn } from '@alicloud/ros-cdk-core'
Fn.min(values: number[])

valuesRequired

  • Type: number[]

ref

import { Fn } from '@alicloud/ros-cdk-core'
Fn.ref(logicalName: string)

The Ref intrinsic function returns the value of the specified parameter or resource.

Note that it doesn't validate the logicalName, it mainly serves paremeter/resource reference defined in a RosInclude template.

logicalNameRequired

  • Type: string

The logical name of a parameter/resource for which you want to retrieve its value.


replace

import { Fn } from '@alicloud/ros-cdk-core'
Fn.replace(replaceData: {[ key: string ]: any}, content: string)

replaceDataRequired

  • Type: {[ key: string ]: any}

contentRequired

  • Type: string

select

import { Fn } from '@alicloud/ros-cdk-core'
Fn.select(index: string | number, array: any)

The intrinsic function Fn::Select returns a single object from a list of objects by index.

indexRequired

  • Type: string | number

The index of the object to retrieve.

This must be a value from zero to N-1, where N represents the number of elements in the array.


arrayRequired

  • Type: any

The list of objects to select from.

This list must not be null, nor can it have null entries.


selectMapList

import { Fn } from '@alicloud/ros-cdk-core'
Fn.selectMapList(key: string, mapList: {[ key: string ]: any}[])

keyRequired

  • Type: string

mapListRequired

  • Type: {[ key: string ]: any}[]

split

import { Fn } from '@alicloud/ros-cdk-core'
Fn.split(delimiter: string, source: string)

To split a string into a list of string values so that you can select an element from the resulting string list, use the Fn::Split intrinsic function.

Specify the location of splits with a delimiter, such as , (a comma). After you split a string, use the Fn::Select function to pick a specific element.

delimiterRequired

  • Type: string

A string value that determines where the source string is divided.


sourceRequired

  • Type: string

The string value that you want to split.


str

import { Fn } from '@alicloud/ros-cdk-core'
Fn.str(value: any)

valueRequired

  • Type: any

sub

import { Fn } from '@alicloud/ros-cdk-core'
Fn.sub(body: string, variables?: {[ key: string ]: any})

The intrinsic function Fn::Sub substitutes variables in an input string with values that you specify.

In your templates, you can use this function to construct commands or outputs that include values that aren't available until you create or update a stack.

bodyRequired

  • Type: string

A string with variables that Ros Template substitutes with their associated values at runtime.

Write variables as ${MyVarName}. Variables can be template parameter names, resource logical IDs, resource attributes, or a variable in a key-value map. If you specify only template parameter names, resource logical IDs, and resource attributes, don't specify a key-value map.


variablesOptional

  • Type: {[ key: string ]: any}

The name of a variable that you included in the String parameter.

The value that Ros Template substitutes for the associated variable name at runtime.