liveBook · Manning

Adapter

As explained in Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform

An adapter pattern converts one interface into another interface expected by clients so incompatible components can work together.

An adapter transforms metadata from a low-level resource or module into the interface expected by higher-level resources. It lets incompatible infrastructure components work together without changing the low-level implementation. section 4.4 section 4.7

Mapping generic permissions to GCP roles

A reusable identity module can expose read, write, and admin permissions with generic usernames. A GCP adapter converts them to roles/viewer, roles/editor, and roles/owner so GCP can assign users, service accounts, and groups correctly. Equivalent mappings can target AWS or Azure. section 4.4

Choose the adapter when:

  • Many high-level modules depend on one low-level module or resource. section 4.6
  • Infrastructure must support multiple providers while isolating provider-specific changes. section 4.6 section 4.7
  • You can accept greater implementation and troubleshooting effort in exchange for scalability and evolvability. section 4.6
Figure 4.9 The adapter pattern transforms attributes to a different interface that high-level modules can consume.

Visualizes how an adapter changes attributes into an interface consumable by high-level modules. section 4.4

How Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform covers it

How deep it goes
Defines the transformation and demonstrates role mapping, while deferring complete troubleshooting and testing details.
Examples
Uses Python-oriented identity mappings that translate generic permissions into GCP, AWS, or Azure role terminology.
What it assumes
Assumes familiarity with infrastructure modules, resources, dependencies, and provider-specific permissions.
What you can do after
Apply it to isolate provider-specific changes while extending infrastructure modules across providers.
How it connects
Connects dependency injection with facade, mediator, inversion of control, and dependency inversion principle.

Also explained in

Compare how 9 books explain adapter →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform. The section links point to the parts of the book it draws on.