Aspects are a powerful tool for applying operations to all constructs within a given scope. They follow the Visitor pattern and are commonly used for cross-cutting concerns such as tagging, compliance checks, and validation.Documentation Index
Fetch the complete documentation index at: https://tfts.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
The IAspect Interface
An Aspect is a class that implements theIAspect interface. This interface requires a single method: visit.
visit method is called for every construct in the scope where the Aspect is applied, including the scope itself and all its children.
Applying Aspects
You apply an Aspect to a scope (such as anApp or a Stack) using the Aspects class.
Use Cases
Tagging
One of the most common use cases for Aspects is applying a consistent set of tags to all resources in a stack.Compliance and Validation
Aspects can be used to enforce security policies or organizational standards.Execution Flow
Aspects are invoked during the synthesis process. Whenapp.synth() is called, the framework triggers invokeAspects(). This method performs a depth-first traversal of the construct tree, applying all registered Aspects to each node.
Because Aspects run during synthesis, they can modify the properties of resources before the final Terraform HCL is generated. This allows for dynamic adjustments based on the state of the entire construct tree.