Terraform can be used to provision firewall rules from any source (Load balancers, Routes, Services, VMs, etc) to any destination. A terraform module for this would make use of the cloud provider of the platform on which the infra needs to come up. After the infra is provisioned using terraform, it can generate an inventory for ansible to work on it. To generate the ansible inventory, it would use 'templates'. Then Ansible would use this inventory to configure the provisioned infra.