Professional Cloud Developer · Domain 1: Designing highly scalable, secure, and reliable cloud-native applications · 32% of the exam
Task 1.2: Designing secure applications.
Cloud Storage lifecycle and retention policies, IAP and Web Security Scanner, fixing what Artifact Analysis and Security Command Center find, secrets and keys in Secret Manager and Cloud KMS, Application Default Credentials, tokens and auth proxies, service account roles and least privilege, secure service-to-service traffic, and Binary Authorization.
Study it
Data retention and protection: Cloud Storage lifecycle and retention, IAP, Web Security Scanner, Artifact Analysis and Security Command Center
Try each one before opening the answer. Every option is explained, with the Google Cloud documentation page that proves it.
Question 1 · choose 1
The bucket logs-raw had this lifecycle configuration:
{"rule": [{"action": {"type": "Delete"}, "condition": {"age": 30}}]}
On Tuesday at 09:00 an engineer changed the age to 60 so that logs stay
longer. On Wednesday morning, objects 31 to 35 days old that were present on
Tuesday are gone. What explains this?
AThe Delete action takes precedence over the edited rule until the old rule is removed
BThe bucket's soft delete policy removed the objects once they passed 30 days
CThe age condition counts from each object's last read, so idle objects expired
DLifecycle changes can take up to 24 hours to take effect, and the old 30-day rule can still act meanwhile
Show the answer and why
AThe Delete action takes precedence over the edited rule until the old rule is removed
Incorrect
Precedence decides between Delete and SetStorageClass actions; the bucket has one rule only.
BThe bucket's soft delete policy removed the objects once they passed 30 days
Incorrect
Soft delete keeps deleted objects restorable for a while; it doesn't delete live objects.
CThe age condition counts from each object's last read, so idle objects expired
Incorrect
Age counts from the object's creation time, not from its last access.
DLifecycle changes can take up to 24 hours to take effect, and the old 30-day rule can still act meanwhile
Correct
Cloud Storage documents this delay and gives the same example of an object deleted under the old age condition.
Changes to a bucket's lifecycle configuration can take up to 24 hours to go into effect, and Object Lifecycle Management might still perform actions based on the old configuration during this time. Objects that met the old 30-day age condition could therefore still be deleted on the night after the edit. An object deleted by a Delete action becomes soft-deleted and can be restored within the soft delete retention duration.
A Cloud Run service gets its database password from Secret Manager:
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: db-password
key: "3"
The team added version 4 with a new password, made the database accept both
passwords, and then disabled version 3 in Secret Manager, without deploying
the service. The service scales between 2 and 20 instances during the day.
What happens next?
AAll running instances lose the password at their next request
BRunning instances keep working, but instances started afterwards, for example during a scale-out, fail to start
CNew instances start with version 4, because a disabled version gives way to the latest enabled one
DNothing changes until the next deployment, because each revision keeps the secret value it read when it was first deployed
Show the answer and why
AAll running instances lose the password at their next request
Incorrect
Each running instance read the value when it started, and it keeps that value.
BRunning instances keep working, but instances started afterwards, for example during a scale-out, fail to start
Correct
A new instance retrieves version 3 before it starts, and a disabled version can't be accessed, so that instance doesn't start.
CNew instances start with version 4, because a disabled version gives way to the latest enabled one
Incorrect
The revision names version 3, and a disabled version can't be accessed; no other version is used in its place.
DNothing changes until the next deployment, because each revision keeps the secret value it read when it was first deployed
Incorrect
The value is retrieved at each instance's startup, not once per revision.
Cloud Run resolves a secret exposed as an environment variable at instance startup: it retrieves the value before starting the instance, and if the retrieval fails, the instance doesn't start. A disabled secret version can't be accessed until it is re-enabled. Instances that were already running keep the password they read, while every instance started after the disable, such as those added during a scale-out, fails to start until the service points at version 4 or version 3 is enabled again.
A Cloud Run service runs as the user-managed service account orders-run,
which has the Firestore role it needs. Every Firestore call fails with a
permission error. The Dockerfile, copied from a developer's local setup,
contains:
COPY dev-key.json /app/dev-key.json
ENV GOOGLE_APPLICATION_CREDENTIALS=/app/dev-key.json
What should the team do?
AGrant the Firestore role to orders-run again, this time at the project level
BAdd gcloud auth application-default login to the Dockerfile so that ADC finds user credentials
CRemove the key file and the variable from the image, so that ADC uses the service's own account
DRedeploy with --service-account=orders-run to attach the account again
Show the answer and why
AGrant the Firestore role to orders-run again, this time at the project level
Incorrect
orders-run already has the role, and the calls aren't being made as orders-run.
BAdd gcloud auth application-default login to the Dockerfile so that ADC finds user credentials
Incorrect
ADC still reads the variable first, and user credentials don't belong on a Google Cloud compute resource.
CRemove the key file and the variable from the image, so that ADC uses the service's own account
Correct
ADC uses the file named by GOOGLE_APPLICATION_CREDENTIALS before the attached service account from the metadata server.
DRedeploy with --service-account=orders-run to attach the account again
Incorrect
The service already runs as orders-run; ADC keeps using the key file first.
Application Default Credentials search in order: the GOOGLE_APPLICATION_CREDENTIALS environment variable, then the credential file created by gcloud auth application-default login, then the attached service account from the metadata server. With the variable set in the image, the client libraries authenticate as the key's account. The Cloud Run page warns never to set GOOGLE_APPLICATION_CREDENTIALS on a service that uses its service identity.
Services on GKE use Cloud Service Mesh with its default settings, and sidecar proxies are injected in the payments and shop namespaces. A review found that a batch Job in the reports namespace, which has no sidecar, calls the payments service in plain text and gets answers. Payments must accept only mutually authenticated, encrypted traffic. What should the team do?
AConfigure the payments workloads to accept only mTLS traffic
BNothing, because auto mTLS already encrypts every call to payments
CTurn on auto mTLS for the mesh so that every client uses certificates
DRely on the mesh's access logging to record the Job's identity
Show the answer and why
AConfigure the payments workloads to accept only mTLS traffic
Correct
By default services accept both plain text and mTLS, so only an mTLS-only setting rejects the Job's plain-text calls.
BNothing, because auto mTLS already encrypts every call to payments
Incorrect
Auto mTLS sends plain text to workloads without sidecars, and services still accept plain text.
CTurn on auto mTLS for the mesh so that every client uses certificates
Incorrect
Auto mTLS is on by default and still leaves services accepting plain text.
DRely on the mesh's access logging to record the Job's identity
Incorrect
Access logs capture the identity of mTLS clients; they don't block plain text.
In Cloud Service Mesh, auto mTLS is enabled by default: a client sidecar sends mTLS to workloads with sidecars and plain text to workloads without them, and services accept both plain-text and mTLS traffic. To secure the mesh, Google recommends migrating services to accept only mTLS traffic, which rejects callers such as a Job without a sidecar.
Binary Authorization was enabled today on the Cloud Run service api with --binary-authorization=default, and the project's policy accepts only images attested by the current release pipeline. Revision api-00087, which is attested, serves all traffic. Revision api-00080, built months ago before any attestations existed, still exists. During an incident, the on-call engineer updates the service's traffic settings to send all of its traffic back to api-00080. What happens?
AThe traffic moves, because Binary Authorization checks only new deployments of container images
BThe traffic moves, because api-00080 was created before enforcement was enabled
CThe traffic moves, and the policy is applied at the next deployment instead
DThe update is rejected, because enforcement covers every revision that would receive traffic
Show the answer and why
AThe traffic moves, because Binary Authorization checks only new deployments of container images
Incorrect
Once enabled, Binary Authorization enforces any update to the service, including changes that affect traffic.
BThe traffic moves, because api-00080 was created before enforcement was enabled
Incorrect
A traffic change is enforced on every revision that receives traffic, whenever it was created.
CThe traffic moves, and the policy is applied at the next deployment instead
Incorrect
The traffic change itself is an update that Binary Authorization enforces.
DThe update is rejected, because enforcement covers every revision that would receive traffic
Correct
api-00080 would receive traffic and has no attestation, so the policy blocks the change.
After Binary Authorization is enabled on a Cloud Run service, it enforces any update to the service. When a change affects traffic, Binary Authorization enforces deployment on any revision receiving traffic. Moving traffic to an old revision whose image lacks the required attestation is therefore rejected.
A team creates a Web Security Scanner custom scan for a public web app on GKE. The app's domain points to an ephemeral external IP address of its load balancer, and the scan configuration fails because the target isn't allowed. What should the team do?
AUse the app's IPv6 address as the starting URL instead
BPut a firewall in front of the app that admits only the scanner's traffic
CCreate the scan in another project that still has scans available
DReserve a static external IP address in the same project for the app
Show the answer and why
AUse the app's IPv6 address as the starting URL instead
Incorrect
Web Security Scanner only supports websites that use IPv4; IPv6 sites aren't scanned.
BPut a firewall in front of the app that admits only the scanner's traffic
Incorrect
The scanner supports only public URLs and IPs that aren't behind a firewall.
CCreate the scan in another project that still has scans available
Incorrect
GKE scan targets must belong to the scan's own project, so another project can't scan this address.
DReserve a static external IP address in the same project for the app
Correct
Scans for GKE are restricted to domains that map to static external IP addresses reserved for the same project.
Web Security Scanner restricts scans of Compute Engine and GKE apps to domains that map to static external IP addresses reserved for the same project, and to static external IP addresses of that project. Reserving a static address for the load balancer and pointing the domain at it makes the target valid.
A deployment service account gets a permission error when it deploys to Cloud Run. A developer finds the role Cloud Run Service Agent in the IAM role list and proposes granting it to the deployment account, since it seems to cover everything Cloud Run does. What does Google's guidance say?
AGrant it, because service agent roles are meant for automation accounts
BGrant it only on the service, so that the scope stays small
CDon't grant it; service agent roles must go only to service agents
DGrant it, then remove it from the Cloud Run service agent itself
Show the answer and why
AGrant it, because service agent roles are meant for automation accounts
Incorrect
Service agent roles are for Google-managed service agents only, not for a project's own accounts.
BGrant it only on the service, so that the scope stays small
Incorrect
A smaller scope doesn't change the rule about who may hold service agent roles.
CDon't grant it; service agent roles must go only to service agents
Correct
Google says not to grant service agent roles to any principals except service agents.
DGrant it, then remove it from the Cloud Run service agent itself
Incorrect
The role belongs to the service agent, which uses it to act for the product.
Service agents are Google-managed service accounts that let a service act on your resources, and Google Cloud grants each one its service agent role when it is created. Google's guidance is not to grant service agent roles to any principals except service agents; a deployment account should get the predefined roles it needs instead.
A notification service publishes to one Pub/Sub topic, orders-events, and does nothing else in the project. It currently runs as a service account with the Editor role on the project. Which grant follows least privilege?
AThe Pub/Sub Editor role on the project
BThe Viewer role on the project plus Pub/Sub Publisher on the project
CThe Owner role on the topic orders-events
DThe Pub/Sub Publisher role on the topic orders-events
Show the answer and why
AThe Pub/Sub Editor role on the project
Incorrect
It covers every topic and subscription in the project, far beyond publishing to one topic.
BThe Viewer role on the project plus Pub/Sub Publisher on the project
Incorrect
Viewer adds read access the service doesn't need, and the grant covers every topic.
CThe Owner role on the topic orders-events
Incorrect
Owner is a basic role with far more permissions than publishing.
DThe Pub/Sub Publisher role on the topic orders-events
Correct
It is a limited predefined role granted at the smallest scope the service needs.
Google's IAM guidance is to avoid basic roles in production, to grant the most limited predefined roles instead, and to grant roles at the smallest scope needed. A service that only publishes to one topic needs the Pub/Sub Publisher role on that topic.