4 Patterns for infrastructure dependencies
This chapter covers
- Writing loosely coupled infrastructure modules using dependency patterns
- Identifying ways to decouple infrastructure dependencies
- Recognizing infrastructure use cases for dependency patterns
An infrastructure system involves a set of resources that depend on each other. For example, a server depends on the existence of a network. How do you know the network exists before creating a server? You can express this with an infrastructure dependency. An infrastructure dependency happens when another resource requires another one to exist before creating or modifying it.
Definition
An infrastructure dependency expresses a relationship where an infrastructure resource depends on the existence and attributes of another resource.
Usually, you identify the server’s dependency on the network by hard-coding the network identifier. However, hard-coding more tightly binds the dependency between server and network. Any time you change the network, you must update the hard-coded dependency.
In Chapter 2, you learned how to avoid hard-coding values with variables to promote reproducibility and evolvability. Passing the network identifier as a variable better decouples the server and network. However, a variable only works between resources in the same module. How can you express dependencies between modules?