Open fluffy-cakes opened 4 years ago
In addition to that, I've now added an option on the NSG creation in the subnets
field of .tfvars
. The biggest issue around CAF is when a requirement changes, such as the client wanting/not-wanting an NSG/route; it usually involves destruction, which doesn't work out when you have things knocking about in your subnets.
Here's a screenshot of my fix for an option adding an NSG in the subnet `.tfvars.
I understand the original idea around creating special subnets, but we have found that sometimes you do actually need a custom route, but no NSG, or vice versa. Our internal client needed to have a route table but no NSG on one of their special subnets, and thus I wen about creating the option for this. Whilst working this out I realised that I don't really need a special subnet to split up the functions of what a deployed subnet needs/consumes; however given that the subnet already being used and would require some down time to rebuild it all, I've had to continue with the split sections.
Essentially I enabled a 'switch' on the .tfvars for special subnets; whether or no they want to associate with a route table. The same method used for this could be the same method for attaching an NSG, or not.
My
.tfvars
file, take note of subnet objects with the key ofroute
and how they link in with theroute_tables
object;Now I run a
for_each
on creating routes (bear in mind I use a naming convention module that I reference):And then finally I attach the route to the subnet via
for_each
using the object which comes from the CAF module;Now if I hadn't already had stuff deployed in
Special Subnets
, I would have done away with that completely and then I wouldn't have needed the two route table associations. I would have needed to create a solution for the NSGs which required more work, but it still would have been better in the long run; subnets/routes/nsg would have been far more customisable.Note; if you don't want a subnet to have a route associated with it, the key/vaule for that subnet must be;
route = null