cloudflare / cf-terraforming

A command line utility to facilitate terraforming your existing Cloudflare resources.
Mozilla Public License 2.0
989 stars 139 forks source link

Fix generation of cloudflare_access_application #736

Open hur opened 3 months ago

hur commented 3 months ago

Fixes https://github.com/cloudflare/cf-terraforming/issues/734

The Cloudflare API response for ListAccessApplications seems to contain much more policy-related data than is necessary to generate the Terraform manifests, which only require the policy IDs. writeAttrLine panics on this data as it is of unexpected format.

This PR remaps the policy data to only keep the IDs of the policies associated with each application.

I have tested this locally, but have not added any unit tests as they seem to require API key access for specific zones/accounts for the regeneration part. Happy to add some if there's any guidelines on the process.