How To Solve: Error when reading or editing Project Service Foo/container.googleapis.com: googleapi: Error 403

In order to enable service APIs in GCP, your user or service account which is being used to run Terraform needs to have the following role:

roles/serviceusage.serviceUsageAdmin

So, you will either have to grant the user or SA the role above from the console or if you have a Terraform resource to bind roles to users/SA that can be used as well.

From Terraform authentication perspective, if you are using a user account make sure you are properly authenticating from the terminal to GCP using the following command:

gcloud auth application-default login

If you are using a service account, you will need to specify the environment variable GOOGLE_APPLICATION_CREDENTIALS passing the json key file.

For Terraform authentication reference: https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference