Expressions
Maeztro supports all the following as expressions in *.mz
files:
- Most Terraform references
var.V
to refer to any variableV
defined in avariables
blocklocal.L
to refer to any localL
defined in alocals
blockresource_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 sensorsself.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
,regex
- 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 usedtemplatefile
to read as perfile
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
andtonumber
type coerciondecodeyaml
anddecodejson
to process JSON or YAML stringscan
andtry
to be able to ignore expressions which might not resolve and have fallback behavior (as with Terraform,can(expression)
returns true or false whether theexpression
is 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 atype
key)
-
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 addressid
andaddress
refer to the local resource address (the only difference is thataddress
for the application root is empty, whereasid
is the Maeztro application ID (e.g.app-oANjaM37y6p8
)entity_id
refers to the internal unique random identifierparent
,module_root
, andapplication_root
can be used to refer to the corresponding entity, either as a variable on its own, or as a field on another entitynickname
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 bymz_
to have them searched first, so for example ifself
has a TF attribute calledname
and an AMP config calledname
,self.name
will return the value of the TF attribute, andself.mz_name
will return the display name (name set in Maeztro), andself.config.name
will return the config value