Index services by name instead of number
The google_project_service.project
resource is created using count
so that an integer-indexed instance is created for each project service. This means that when the list of services is changed slightly (e.g. removing a service), it's possible for many resources to be re-created as the indices change, sometimes causing cycles when attempting to terraform apply
.
Switching to for_each
and indexing by the name of each service would avoid such issues and improve robustness.