Hoping for some advice on how to create hierarchical resources in a loop in Terraform v12x.
The exact use case I have is trying to create
aws_api_gateway_resource in a parent child relationship.
I would like to model the hierarchy as a flat list [‘parent_path_step’, ‘child_path_step’], pass this list to a module and have the module use a looping construct in Terraform to build the path steps top down:
The hierarchy in the AWS provider is obtained via the
parent_id property of the
aws_api_gateway_resource. The first iteration of the loop has to refer to the root_id provided by the API Gatweway resource, the second iteration of the loop would have to refer to the id generated from the resource creation of ‘parent_path-step’. IE refer to the id returned by loop iteration [current - 1]
Any ideas on how I could achieve this please?