full image - Repost: Question About Module Design? (from Reddit.com, Question About Module Design?)
Mining:
Exchanges:
Donations:
Hi I fairly new at terraform and would like to check if my module design is considered best practice.What I am trying to achieve is automated provision of new subscriptions within Azure. I therefor have create a module to handle creation of virtual networks, a module to setup/manage permissions, module to handle billing alerts, etc. Basically “smallish” module to handle a certain area that are reusable and easy to maintain.Calling each of these modules I can provision a new subscription how I want. However, for each subscription there a lot of code repeated. I basically have a file inside per subscription my infrastructure subscription provision project that mostly a copy and past of each other. The only differences been subscriptions is mostly the network setup. This mostly works fine except for these files are large and making change means I need to generally make a change accross all files (ie updating to new module version). One other issue is some people (somehow) keep forgetting to call all modules so setups are incomplete. So what I currently thinking is to create a wrapper/passthrough module (not sure what your call it). The idea here is you can just call this module and then its job is to call all modules that are required to setup a subscription (virtual network, permissions, billing etc) by passing variables to them. This is so that it not possible to forget to include something and be able to more easily update things in a single place. I did consider just creating one big module to do everything but I prefer ideally having the smaller modules dedicated to one role or creating infrastructure or configuration, so they could be used for other use cases if required. Is what I doing consider best practise or would people suggest something else?Any advice would be great thanks.
Social Media Icons