cloudsoft.io

Expressions

Maeztro supports all the following as expressions in *.mz files:

  • Most Terraform references
    • var.V to refer to any variable V defined in a variables block
    • local.L to refer to any local L defined in a locals block
    • resource_type.resource_id to refer to a resource (as an AMP entity)
    • resource_type.resource_id.attribute on this to access Terraform attributes as well as AMP sensors
    • self.attribute to refer to attrigbutes on the resource where an expression is being used
  • Common Terraform functions and operations, including:
    • String functions: join, upper, lower, trimspace
    • Grouping, all logic operations, and the ternary operator: false || true && (false ? false : true)
    • min, max, abs and all arithmetic operations and comparions: 1+1 > 1/1
    • file to read from a file in the folder of the module where used
    • templatefile to read as per file and then apply explicit variable substitutions per Terraform, or optionally if the variables are omitted and only the filename is supplied, Maeztro can resolve the template with regards to all valid references dynamically evaluated
    • Coercion and conversion: tostring and tonumber type coercion; decodeyaml and decodejson; can and try to be able to ignore expressions which might not resolve and have fallback behavior
  • Standard AMP expressions in workflow

  • Some extensions to AMP expressions that align with Terraform expressions, including:
    • name refers to the display name, either set explicitly or inferred from the address
    • id and address refer to the local resource address (the only difference is that address for the application root is empty, whereas id is the Maeztro application ID (e.g. app-oANjaM37y6p8)
    • entity_id refers to the internal unique random identifier
    • parent, module_root, and application_root can be used to refer to the corresponding entity, either as a variable on its own, or as a field on another entity
    • nickname refers to the nickname set on the application root
    • a field key on an entity, e.g. self.key, it is attempted as an attribute, a sensor (including module outputs), and as AMP entity config; those are preferred to the extension fields listed above; the extension fields listed above can be preceded by mz_ to have them searched first, so for example if self has a TF attribute called name and an AMP config called name, self.name will return the value of the TF attribute, and self.mz_name will return the display name (name set in Maeztro), and self.config.name will return the config value