ArticCon 2022 (continued)
There are additional benefits
On top of making it easier to write your terraform code, having a clearly defined interface where you transform your configuration allows for an abstraction layer.
Say for example using the same configuration to deploy networks in multiple cloud providers. You have a generic config that you transform and hand of to different implementations.
We can just leverage the interface we had before
// we have subnet data with no requirements
export interface SubnetData {}
// that is used to compose a SubnetDefinition
export type SubnetDefinition<T extends SubnetData> = PartialRecord<
Subnets,
T
>;
// that is used to composed Network Data
export interface NetworkData<T> {
subnets: SubnetDefinition<T>;
}
// that is used to compose Network Config
export type NetworkConfig<T, N extends NetworkData<T>> = Record<
Vpcs,
Which seems pretty abstract; But we can use these as building blocks