Expressions
Maeztro supports all the following as expressions in *.mz files:
- Most Terraform references
var.Vto refer to any variableVdefined in avariablesblocklocal.Lto refer to any localLdefined in alocalsblockresource_type.resource_idto refer to a resource (as an AMP entity)resource_type.resource_id.attributeon this to access Terraform attributes as well as AMP sensorsself.attributeto refer to attrigbutes on the resource where an expression is being used
- Common Terraform functions and operations, including:
- String functions:
join,upper,lower,trimspace,regex - Grouping, all logic operations, and the ternary operator:
false || true && (false ? false : true) min,max,absand all arithmetic operations and comparions:1+1 > 1/1fileto read from a file in the folder of the module where usedtemplatefileto read as perfileand 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
tostringandtonumbertype coerciondecodeyamlanddecodejsonto process JSON or YAML stringscanandtryto be able to ignore expressions which might not resolve and have fallback behavior (as with Terraform,can(expression)returns true or false whether theexpressionis resolvable, andtry(expr1,expr2,expr3)returns the value of the first expression which is resolvable, or fails
- String functions:
- A few custom functions:
brooklyn_external(provider, key)to access externalized configuration such as credentials and other secretstypecoerce(obj, [type])to attempt standard AMP type coercion to the specified type or based on metadata in the object (such as atypekey)
-
Standard AMP expressions in workflow
- Some extensions to AMP expressions that align with Terraform expressions, including:
namerefers to the display name, either set explicitly or inferred from the addressidandaddressrefer to the local resource address (the only difference is thataddressfor the application root is empty, whereasidis the Maeztro application ID (e.g.app-oANjaM37y6p8)entity_idrefers to the internal unique random identifierparent,module_root, andapplication_rootcan be used to refer to the corresponding entity, either as a variable on its own, or as a field on another entitynicknamerefers to the nickname set on the application root- a field
keyon 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 bymz_to have them searched first, so for example ifselfhas a TF attribute callednameand an AMP config calledname,self.namewill return the value of the TF attribute, andself.mz_namewill return the display name (name set in Maeztro), andself.config.namewill return the config value