Skip to main content

Overlay & Anchor

Definition

An overlay enriches models by adding additional capabilities. Think of overlays as standard functionalities that can be easily added to or removed from models. This flexibility enables model implementations to remain clean and free of unnecessary clutter.

Suppose your server requires access to AWS S3 in order to read and write to a specific bucket. You can define a generic overlay that adds this capability to a server, allowing specific servers to opt-in to that overlay.

HTTPS is another suitable candidate for overlays, enabling backend servers to securely serve APIs.

info

An overlay can only be added to Models.

Overlays operate on Anchors — a set of logical hooks to which overlays attach. For example, an AWS IAM Role can serve as an anchor, defined on a server.

Overlays utilize these anchors to add or remove capabilities.

overlay-and-anchor-diagram
info

An overlay is not fundamentally different from a Model or a Resource. Like them, it also has actions and can be serialized and deserialized.

Summary

Here, we've delved into Overlays and Actions. These add-on classes aid in maintaining Infrastructure as Code (IaC) by ensuring it remains simplified and self-contained.