How to Enable Cloud Pub/Sub API for App Engine
You want to send and consume Cloud Pub/Sub messages from your App Engine application. The Cloud Pub/Sub API is currently disabled. You will use a service account to authenticate your application to the API. You want to make sure your application can use Cloud Pub/Sub. What should you do?
Community Insight
The question tests whether a disabled GCP API can be turned on implicitly; the trap is assuming service-account access or Deployment Manager deployment will auto-enable the Cloud Pub/Sub API.
Cloud Pub/Sub must be explicitly enabled per project before an App Engine application can publish or consume messages with its service account. This page confirms that enabling the Cloud Pub/Sub API in the Console API Library is the required first step, and explains why automatic enablement options fail.
Option B is the most common wrong pick, because learners assume that a service account's first authenticated call automatically enables the API — Google Cloud has no such automatic enablement for disabled APIs.
Community Discussion (34 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
The Cloud Pub/Sub API is explicitly stated as disabled, and in Google Cloud an API must be enabled for the project before any client, including an App Engine app using the App Engine Default service account, can call it. Enabling it in the API Library of the GCP Console (option A) is the documented, least-privileged way to make the API usable. Once enabled, the service account can simply authenticate to the API with whatever Pub/Sub roles it has been granted, with no extra permissions needed for setup. As ESP_SAP's quoted quickstart notes, the flow is "Set up a Cloud Console project... Enable the Pub/Sub API for that project."Why the Other Options Are Wrong
Option B is wrong because there is no automatic API enablement triggered when a service account first accesses a disabled API — the call would simply fail with a permission/enabled-API error. Option C is wrong for the same reason: Deployment Manager does not magically enable every API a deployed application touches; APIs used by a deployment must be enabled beforehand. Option D is wrong because enabling an API from inside the application requires serviceusage.services.enable and would hand the app the excessive Cloud Pub/Sub Admin role, which contradicts least privilege — Schladde noted that "D could be possible, but to much permissions are given to the app."Community Comment Notes
The community overwhelmingly converges on A, with Buruguduystunstugudunstu explaining that "Since the Cloud Pub/Sub API is currently disabled, the first step is to enable it" via the API Library. Schladde adds nuance that APIs can also be enabled programmatically with gcloud or the Service Usage API, but still concludes A for this question, observing that "rely on..." is never a good option. obeythefist frames the underlying doctrine correctly: "there's no automatic enablement of the API," which eliminates both B and C.Official Reference
Exam Strategy
Treat any "API is currently disabled" stem as an enablement question first and an IAM question second — the correct answer is almost always an explicit enable step in the API Library. Reject any option that says the platform will enable the API automatically, and reject options that grant broad admin roles to the application just to perform setup.
Frequently Asked Questions
Why can't the service account auto-enable the Cloud Pub/Sub API on first access?
Google Cloud has no automatic enablement for disabled APIs; a first call to a disabled API simply fails until an admin enables it for the project.
Why is granting Cloud Pub/Sub Admin to enable the API a bad answer?
It forces the app to hold serviceusage.services.enable plus a broad admin role at runtime, violating least privilege when a one-time Console enable step suffices.
Related Analysis
Practice All ACE Questions
Access 84 questions with complete answers and detailed explanations.
View Full ACE Practice Test →