ExitInfrastructure as code (IaC): reusable infrastructure components1 / 9
Explanation

Separate supported variation from security invariants

How to design and validate versioned infrastructure modules whose parameter contracts preserve secure architectural defaults while supporting different GenAI deployment scenarios. · advanced

A reusable infrastructure module is a versioned architectural contract, not just a template with variables. Its contract includes accepted inputs, promised outputs, security properties, and update behavior. Start with workload reviews using the AWS Well-Architected Framework and its Generative AI Lens, then translate applicable decisions into explicit requirements. For this lesson's module library, those requirements include encrypted data stores, blocked public data access, scoped workload permissions, and operational audit records without prompt bodies.

Separate supported variation from invariants. Capacity, approved model identifiers, and bounded retention periods can vary. Callers must not be able to disable required encryption or replace scoped permissions with arbitrary policies. A secure default alone is insufficient: a parameter that defaults to private access but accepts public access does not preserve the private-access invariant. An exception needs a separately reviewed contract, not an undocumented escape hatch.

Use composition rather than one module with many interacting switches. A managed-inference module can support generation-only deployments; a retrieval module can add a private index for retrieval-augmented generation. Self-hosted inference can use a separate adapter with its own compute and scaling inputs. Share baseline controls across these components, but do not force incompatible deployment models into one parameter set.

Contract concernSupported variationEnforced baseline
Model accessApproved model identifierScoped invocation permissions
RetrievalOptional retrieval componentNo public data access
OperationsBounded retention periodRequired audit records
StorageApproved encryption keyEncryption required