All Products
Search
Document Center

Resource Orchestration Service:Fn::Add

Last Updated:Jun 17, 2026

Fn::Add calculates the sum of numbers, combines lists, or merges dictionaries.

Declaration

  • JSON

    {
      "Fn::Add": [
        {k1: v1},
        {k2: v2}
      ]
    }
  • YAML

    • Syntax for the full function name:

      Fn::Add:
        - k1: v1
        - k2: v2
    • Syntax for the short form:

      !Add [{k1: v1}, {k2: v2}, ...]

Parameters

  • Parameters must be provided as a list.

  • All parameters in a list must be of the same type: Number, List, or Dictionary. A list must contain at least two parameters.

Return value

  • Number: returns the sum of all values.

  • List: returns a single combined list.

  • Dictionary: returns a merged dictionary. If dictionaries share the same key, the latter value overwrites the former.

Examples

  • Dictionary parameters

    !Add
      - key1: value1
      - key2: value2

    Returns {"key1": "value1", "key2": "value2"}.

  • List parameters

    !Add
    	- - list_1_value_1
      	- list_1_value_2
      - - list_2_value_1
      	- list_2_value_2

    Returns ["list_1_value_1","list_1_value_2","list_2_value_1","list_2_value_2"].

  • Number parameters

    !Add
     - 1
     - 2
     - 3

    Returns 6.