updateMethod field hint controls this behavior.
Atomic Fields
UseupdateMethod = "Atomic" for fields that should be treated as opaque values rather than compared recursively. The entire field value is replaced as a single operation.
- The field is compared as a whole, with no sub-field diffing
- Any change produces a single
replaceoperation for the entire value - Nested structure is irrelevant to the comparison
Dynamic-typed property with provider-specific structure that formae shouldn’t decompose.
The Three Collection Types
Set (Default)
When noupdateMethod is specified, collections are treated as unordered sets. Elements are compared regardless of their position in the list.
- Order doesn’t matter:
["a", "b", "c"]equals["c", "a", "b"] - Duplicates are ignored
- Adding an element that already exists results in no change
- In reconcile mode, elements not in the desired state are removed
Array
UseupdateMethod = "Array" when the order of elements matters.
- Position-based comparison
["a", "b"]does NOT equal["b", "a"]- Elements at the same index are compared directly
EntitySet
UseupdateMethod = "EntitySet" with indexField for collections of objects identified by a key.
- Objects are matched by their key field (e.g.,
Keyfor tags) - If an object with the same key exists, only changed properties are updated
- New keys result in add operations
- Missing keys in reconcile mode result in remove operations
Example: AWS Tags
The most common use of EntitySet is for resource tags:How It Works
When formae compares current state with desired state, it uses theupdateMethod hint to determine the comparison strategy:
- No hint or Set: Compare collections as unordered sets
- Array: Compare collections position-by-position
- EntitySet: Match objects by
indexField, then compare matched objects property-by-property
Reconcile vs Patch Mode
The apply mode significantly affects how collections are handled: Reconcile mode (--mode reconcile, default): The desired state is the complete truth. Elements not in your forma file are removed from the actual resource.
Patch mode (--mode patch): Collections are append-only. Elements in your forma file are added if missing, but existing elements are never removed.
This append-only behavior in patch mode applies to all three collection types:
Example: If the actual resource has tags
[A, B, C] and your forma file specifies [B, D]:
- Reconcile: Result is
[B, D](A and C removed) - Patch: Result is
[A, B, C, D](D added, nothing removed)
Choosing the Right Semantics
When in doubt, start with the default (Set) semantics. Only specify
Array, EntitySet, or Atomic when you have a specific reason.
