Advise on choosing an approach to generate multiple VPCs in AWS

Problem: Generate multiple VPCs connected to a central transit gateway. VPCs to belong in one account while transit gateway to belong to another (control plane) AWS account.

Approach1:

  1. Specify the desired VPC as JSON.
  2. A python filter to use step1 JSON as input, generate a corresponding CDKTF stack
  3. Synthesize cdk.tf.json
  4. Run terraform plan|apply on the output of step3

Approach2:
Create a custom terraform provider wrapped-aws implementing the above logic.

Anybody considered writing a custom terraform provider implementing best practices, say for established by a specific department?

Thanks

I see a custom terraform provider as being more for when there is a service that you are using that doesn’t already have an existing provider.

What you described seems perfectly doable with CDKTF. You’ll want to have different stacks for the transit gateway and each account. If you have multiple VPCs within a single account you could either do 1 stack or multiple stacks depending on your needs.
You certainly could generate the stack, but you might not need to go that far. If there is a JSON file that defines the specifics, you could either add a line of code to add the new vpc stack or even load from a directory and to dynamically define all the stacks.

1 Like