-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API Key configuration to google_firebase_project (beta) #15485
Comments
In general we prefer not to add fields like this that duplicate another resource. It also looks like the API doesn't provide any way to pass these values when setting up a firebase project, which means that we would need to manually do that in a separate API call. We could potentially add an output field that provides the full ID of the created API key, but that doesn't really solve your use case. Ideally the API resource would not implicitly create another resource. I'm not sure if there's a better workaround. Similar case: GoogleCloudPlatform/magic-modules#8301 deprecates google_firebase_project_location due to its implicit creation of resources. It looks like this is a valid request - being able to configure created API keys. It's just a matter of figuring out whether there's a way to do it that doesn't involve duplicating the fields. |
When you create certain a Firebase project, register an Android app, or register an Apple app, Firebase automatically creates API keys so they could function. Restricting these keys should not be your primary mechanism to protect your backend resources, (see documentation). Firebase recommended protection mechanisms such as Security Rules and App Check offer better protection than simply restriction API keys. However, there are still valid scenarios to add restriction to API keys, and you're right that the only way right now is to find the ID of the API key and import it. @intotecho How are you planning to use the API key? Do you plan to use one per web app, or shared among multiple web apps? What products are you using? |
Mostly ApiKeys used in Firebase are used through the App resources ex AndroidApp.api_key_id. This can mostly be seen as a request to add the api_key_id fields to the App resources in Terraform. If an api_key_id is provided, the API will use that instead of allocating a new one. The changing the key allocated in the background of provisioning the FirebaseProject resource is a bigger feature request, as it might be effectively a breaking change to the API to alter the behavior. I'm going to start the discussion with the appropriate folks. |
Hi @intotecho , we've added a capability to use your own API key for registering a Firebase app https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/firebase_web_app#example-usage---firebase-web-app-custom-api-key However, the team agrees with you that automatically provisioning an API key during Firebase project creation is awkward. We are in discussion about what to do there. |
Community Note
Description
google_firebase_project in google-beta v4.77 creates an unrestricted api_key.
Because it is not created by terraform directly as a resource, it is necessary to import it to create restrictions.
New or Affected Resource(s)
<!--- Please list the new or affected resources and data sources. Use google_* if all resources or data sources are affected. --->
google_firebase_project (beta)
Potential Terraform Configuration
References
b/296619021
The text was updated successfully, but these errors were encountered: