Courseiva

CCNA Configuring Access and Security Questions

75 of 83 questions · Page 1/2 · Configuring Access and Security · Answers revealed

1
MCQmedium

An engineer needs to allow HTTP traffic from the internet to a set of Compute Engine instances that have the network tag 'web-server'. The instances are in a VPC with a default firewall rule that denies all ingress. Which command creates the required firewall rule?

A.gcloud compute firewall-rules create allow-http --allow tcp:80 --source-tags web-server
B.gcloud compute firewall-rules create allow-http --allow tcp:80 --source-ranges web-server
C.gcloud compute firewall-rules create allow-http --allow http --target-tags web-server
D.gcloud compute firewall-rules create allow-http --allow tcp:80 --source-ranges 0.0.0.0/0 --target-tags web-server
AnswerD

This command correctly opens inbound TCP port 80 to traffic from any IPv4 address (0.0.0.0/0) and applies the rule only to VM instances tagged with 'web-server', matching the requirement precisely. The combination of --source-ranges 0.0.0.0/0 for internet sources and --target-tags web-server to scope the rule to the intended backend VMs is the standard way to allow HTTP in GCP. No other flags are needed, and the protocol:port syntax 'tcp:80' is accurately specified.

Why this answer

The rule must allow TCP port 80 from source 0.0.0.0/0 to instances with target tag 'web-server'. The correct command uses '--allow tcp:80', '--source-ranges 0.0.0.0/0', and '--target-tags web-server'. Priority can be default (1000).

2
Multi-Selectmedium

An engineer wants to create a VPC with a custom subnet mode and then create a subnet with Private Google Access enabled. Which two commands should they use? (Choose TWO.)

Select 2 answers
A.gcloud compute networks subnets create my-subnet --network my-vpc --region us-central1 --range 10.0.0.0/24 --enable-private-ip-google-access
B.gcloud compute networks create my-vpc --subnet-mode custom
C.gcloud compute networks subnets create my-subnet --network my-vpc --region us-central1 --range 10.0.0.0/24
D.gcloud compute firewall-rules create allow-http --allow tcp:80
E.gcloud compute networks create my-vpc --subnet-mode auto
AnswersA, B

This command explicitly creates a subnet in a custom mode VPC (assuming the VPC already exists) and enables Private Google Access, allowing instances in that subnet to reach Google APIs and services through their internal IP addresses without needing a NAT or external IP. In a custom mode VPC, you must create each subnet manually, and this command defines the region and IP range, making it a required step after the VPC is created. Without this flag, the subnet would lack the Private Google Access capability, which is often a prerequisite for workloads that should reach Google services without public IPs.

Why this answer

To create a custom mode VPC, use 'gcloud compute networks create' with '--subnet-mode custom'. Then add a subnet with 'gcloud compute networks subnets create' including '--enable-private-ip-google-access'. The other commands are incorrect: one creates an auto mode VPC, another is for firewall rules.

3
MCQmedium

To meet compliance requirements, a company must encrypt all data at rest in Cloud SQL using customer-managed encryption keys (CMEK). What is required to enable CMEK on a Cloud SQL instance?

A.Specify the key during instance creation using --disk-encryption-key, and ensure the Cloud SQL service account has encryption/decryption permissions on the key
B.Create the instance without encryption, then use gcloud sql instances patch to add CMEK later
C.Enable CMEK by setting an organization policy that requires CMEK for all Cloud SQL instances
D.Use the default encryption; CMEK is not supported for Cloud SQL
AnswerA

For Cloud SQL, customer-managed encryption keys (CMEK) must be supplied at the moment you create the instance. You specify the key with the --disk-encryption-key flag in the gcloud sql instances create command, and the Cloud SQL service account must be granted Cloud KMS CryptoKey Encrypter/Decrypter permissions so it can use the key to encrypt data at rest. If these permissions are missing, instance creation fails; the key cannot be retroactively attached to an existing instance because the encryption setting is immutable.

Why this answer

When creating the Cloud SQL instance, you must specify a Cloud KMS key using the --disk-encryption-key flag. The Cloud SQL service account must be granted the Cloud KMS CryptoKey Encrypter/Decrypter role. The key must be in the same region as the Cloud SQL instance.

4
Multi-Selectmedium

An organization wants to enforce that all Compute Engine instances in a project use customer-managed encryption keys (CMEK) for their boot disks. Which TWO steps should the security team take?

Select 2 answers
A.Set an organization policy constraint that requires CMEK for Compute Engine disks
B.Specify the CMEK key in each instance template used for managed instance groups
C.Grant the Cloud KMS Admin role to the project's compute service account
D.Create a Cloud Audit Logs sink to monitor instances without CMEK
E.Grant the Cloud KMS CryptoKey Encrypter/Decrypter role to the Compute Engine service account
AnswersA, E

Setting an organization policy constraint (iam.disableServiceAccountKeyCreation is not relevant; here it's a custom constraint or the predefined compute.disableNestedVirtualization? Actually for CMEK, the relevant org policy is a custom constraint or the new `constraints/compute.requireCmek` that enforces CMEK on new Compute Engine disks at creation time. This is the only preventive control among the options because it blocks the disk-creation API call unless a valid CMEK key is supplied, making noncompliant instances impossible to create. It operates at the organization or folder level and is enforced by the resource manager before the Compute Engine API accepts the request.

Why this answer

To enforce CMEK, you can set an organization policy constraint (e.g., constraints/compute.requireCmek) to prevent creation of instances without CMEK. Additionally, you must grant the compute engine service account permission to use the KMS key so it can encrypt disks. Simply specifying the key in the instance template does not enforce the policy, and the Cloud KMS Admin role is too broad.

5
MCQeasy

Which IAM role should be granted to a user to allow them to create and manage secrets in Secret Manager?

A.roles/secretmanager.admin
B.roles/secretmanager.secretAccessor
C.roles/editor
D.roles/secretmanager.viewer
AnswerA

roles/secretmanager.admin is the correct choice because it grants the full set of Secret Manager permissions needed to create, update, and delete secrets, versions, and their IAM policies. It includes actions such as secretmanager.secrets.create, secretmanager.secrets.update, secretmanager.secrets.delete, and secretmanager.versions.add, allowing complete lifecycle management without granting unrelated service permissions.

Why this answer

roles/secretmanager.admin provides full control over secrets, including creation, deletion, and granting access. roles/secretmanager.secretAccessor only allows reading secret payloads. roles/editor is too broad and not specific. roles/viewer is read-only.

6
MCQeasy

You need to allow inbound HTTP traffic to a set of Compute Engine instances that have the tag 'web-server'. All other inbound traffic should be denied. Which firewall rule configuration should you create?

A.Create an allow rule for tcp:80 with target tags 'web-server' and source range 0.0.0.0/0, and a deny rule for all other traffic.
B.Create an allow rule for tcp:80 with source range 0.0.0.0/0 and apply to all instances.
C.Create a deny rule for all ports except tcp:80 with target tags 'web-server'.
D.Create an allow rule for tcp:80 with source range 0.0.0.0/0 and target tags 'web-server'. No deny rule is needed.
AnswerD

This is correct because VPC networks include an implicit deny-all rule for inbound traffic, so the only rule needed is an explicit allow for HTTP traffic (TCP port 80) from all source IP addresses (0.0.0.0/0) to instances tagged with 'web-server'. Target tags let you apply the rule selectively, ensuring only web server VMs accept inbound HTTP while all other instances remain blocked by the implicit deny. No additional deny rule is required or advisable.

Why this answer

Firewall rules are stateful; you should create an allow rule for HTTP (tcp:80) with source range 0.0.0.0/0 and target tag 'web-server'. Implicit deny all inbound traffic is the default, so no explicit deny is needed.

7
MCQmedium

A developer wants to allow a Compute Engine instance to access Cloud Storage without using a service account key file. What is the recommended approach?

A.Use Application Default Credentials with a user account.
B.Download a service account key and store it on the instance.
C.Create a service account, grant it the required roles, and attach it to the instance using the --service-account flag.
D.Set up a VPN connection to Cloud Storage.
AnswerC

Create a service account, grant it the required IAM roles (for example, roles/storage.objectViewer for Cloud Storage read access), and attach it to the instance using the --service-account flag at instance creation time. The instance then automatically authenticates to Google Cloud APIs through the instance's metadata server, which provides OAuth 2.0 access tokens on behalf of the service account without storing any secret material on the disk. This is the standard, secure pattern for granting a Compute Engine instance access to other GCP resources, as it leverages the cloud-native identity and avoids managing static credentials.

Why this answer

The recommended approach is to create a service account, grant it the necessary roles, and attach it to the instance. The instance can then use the service account via the metadata server without needing keys.

8
MCQhard

An organization has a hierarchy: Organization -> Folder A -> Project 1. An IAM policy at the organization level grants roles/editor to user@example.com. A policy at Folder A denies roles/editor to the same user. What is the effective role for the user in Project 1?

A.The user has the editor role only in resources directly under the organization, not under Folder A.
B.The user does not have the editor role in Project 1 because the deny policy at the folder level blocks it.
C.The user has the editor role because organization-level grants override folder-level denials.
D.The user has the editor role in Project 1 unless there is a specific project-level deny.
AnswerB

IAM deny policies are evaluated with higher precedence than allow policies, so a deny rule on Folder A explicitly blocks any inherited editor grant from reaching resources below that folder. Project 1, being a child of Folder A, inherits both the organization-level editor role and the folder-level deny, but deny rules win. As a result, even though the user was granted editor at the organization, the user's effective permissions in Project 1 do not include editor; the deny policy specifically prevents that role from being granted.

Why this answer

IAM policies are additive, but deny policies can override allow policies. If a deny policy is set at a higher level and applies to the user, it denies the permission even if granted at a lower level. However, if the deny policy is at the folder level, it denies the role in all resources under that folder, including Project 1.

9
MCQmedium

An engineer needs to grant an external auditor read-only access to a subset of Cloud Storage buckets in a project. The auditor's identity is a Google account. Which IAM approach should the engineer use?

A.Add the auditor's email as a member with the Storage Admin role on the project.
B.Use a signed URL for each object the auditor needs to see.
C.Add the auditor's email as a member with the Storage Object Viewer role on each individual bucket.
D.Add the auditor's email as a member with the Storage Object Viewer role on the project, and use IAM Conditions to restrict access to specific bucket resources.
AnswerD

Assigning Storage Object Viewer at the project level grants read-only access to all objects in all buckets by default, but binding that grant with an IAM Condition that checks the resource name (e.g., resource.name.startsWith("projects/_/buckets/audit-")) restricts the access to exactly the intended buckets at access time. The auditor can then list and read objects only within those matches, while the project-level policy remains a single, centrally managed binding that can be audited and adjusted without touching each bucket. This delivers the least-privilege read-only guarantee the auditor needs while keeping operations scalable and governance clean.

Why this answer

The best practice is to grant the Storage Object Viewer role at the project level and then use IAM Conditions to restrict access to specific bucket resources. This avoids managing multiple bindings per bucket while ensuring the auditor only sees the intended buckets. Granting at the bucket level is possible but less scalable; granting Storage Admin is too permissive; using ACLs is legacy and more complex to audit.

10
MCQmedium

A company has a Cloud SQL instance with CMEK enabled. The Cloud KMS key used for encryption is accidentally disabled. What is the impact on the Cloud SQL instance?

A.The instance will be automatically deleted after 30 days.
B.The instance becomes unavailable and cannot be started until the key is re-enabled.
C.A read replica can be promoted to replace the primary.
D.The instance continues to operate normally, but new data cannot be encrypted.
AnswerB

Cloud SQL with CMEK uses the customer-managed key for every data-plane operation, including reads and writes to the database, logs, and system tables. When the key is disabled, the instance loses access to the key material, causing the database engine to fail all I/O requests immediately. Consequently, the instance becomes unavailable and cannot be started or used until the key is re-enabled in Cloud KMS; re-enabling the key automatically restores normal operation without manual intervention.

Why this answer

When a CMEK key is disabled, the Cloud SQL instance becomes unavailable because the database cannot encrypt or decrypt data. The instance cannot be started or used until the key is re-enabled.

11
MCQeasy

You need to view the current IAM policy for a project named 'my-project' in JSON format. Which command should you use?

A.gcloud projects add-iam-policy-binding my-project --format json
B.gcloud projects get-iam-policy my-project --format json
C.gcloud iam service-accounts list --project my-project
D.gcloud projects set-iam-policy my-project policy.json
AnswerB

`gcloud projects get-iam-policy my-project --format json` is the correct command for viewing the current IAM policy of a project. It retrieves the full policy, including all role bindings, conditions, and the etag, and returns it in a structured JSON format. The `--format json` flag ensures the output is machine-readable, which is useful for auditing, scripting, or feeding into other tools like `jq`. This command performs no mutation and is the standard way to inspect IAM policy state.

Why this answer

The correct command is 'gcloud projects get-iam-policy my-project --format json'. The 'add-iam-policy-binding' command is for adding bindings, 'set-iam-policy' is for setting from a file, and 'list' is not a valid subcommand for IAM policies.

12
MCQhard

A security team wants to enable audit logging for all Data Access (ADMIN_READ, DATA_READ, DATA_WRITE) on a specific Google Cloud project. They plan to use gcloud commands to configure this. What is the correct approach?

A.Use gcloud compute firewall-rules update to enable logging on firewall rules.
B.Use gcloud logging sinks to export data access logs to a BigQuery dataset.
C.Use gcloud projects set-iam-policy to set the auditConfig on the project.
D.Use gcloud services enable to enable the Cloud Audit Logs API.
AnswerC

This is correct because Data Access audit logs are controlled by the auditConfig field of the project's IAM policy. You retrieve the policy, add an auditConfig specifying the services and log types (ADMIN_READ, DATA_READ, DATA_WRITE), then set it back with gcloud projects set-iam-policy. After that, Cloud Audit Logs will start recording data access operations for the enabled services.

Why this answer

Audit log configuration is set at the organization, folder, or project level using the 'gcloud projects get-iam-policy' and 'gcloud projects set-iam-policy' commands with audit configs. The correct method is to modify the IAM policy to include auditConfigs. The other options either use wrong commands or wrong scopes.

13
MCQhard

An engineer is configuring a Cloud NAT to allow private Compute Engine instances to access the internet. After creating the Cloud Router and NAT gateway, the instances still cannot connect to the internet. What is the most likely missing configuration?

A.The VPC does not have a default route (0.0.0.0/0) to the default internet gateway.
B.The firewall rules do not allow egress traffic.
C.The Cloud Router is in a different region.
D.The instances are not assigned a network tag used by the NAT.
AnswerA

For Cloud NAT to work, the VPC network must contain a default route (0.0.0.0/0) whose next hop is the default internet gateway. This route is what causes outbound packets from instances to be sent to the gateway, where Cloud NAT performs the source IP translation. Without this route, packets destined for the internet have no valid next hop and are dropped, so the instances cannot reach the internet at all—Cloud NAT alone does not create routing logic.

Why this answer

Cloud NAT requires that the subnet has Private Google Access enabled for certain Google APIs, but for general internet access, the instances must have a default route to the internet gateway (0.0.0.0/0 next hop to default internet gateway). If this route is missing, traffic won't be sent to NAT. The other options are possible but less common.

14
MCQmedium

A DevOps engineer needs to grant a service account the ability to pull images from a specific Container Registry repository in project 'my-project'. The service account is in project 'other-project'. Which command should the engineer use?

A.gcloud projects add-iam-policy-binding my-project --member user:admin@other-project.com --role roles/storage.objectViewer
B.gcloud iam service-accounts add-iam-policy-binding sa@other-project.iam.gserviceaccount.com --member serviceAccount:sa@other-project.iam.gserviceaccount.com --role roles/storage.objectViewer
C.gcloud projects add-iam-policy-binding other-project --member serviceAccount:sa@other-project.iam.gserviceaccount.com --role roles/storage.objectViewer
D.gcloud projects add-iam-policy-binding my-project --member serviceAccount:sa@other-project.iam.gserviceaccount.com --role roles/storage.objectViewer
AnswerD

This correctly adds an IAM policy binding on my-project, which owns the Container Registry artifacts, and defines the member as the service account from other-project using the `serviceAccount:` prefix. Since `roles/storage.objectViewer` grants read access to Cloud Storage objects that back GCR, this allows sa@other-project.iam.gserviceaccount.com to pull images and list repositories in my-project without needing a key or user account. The binding is cross-project: the member belongs to other-project, but the resource is in my-project, which is exactly the required configuration.

Why this answer

Cross-project IAM bindings require the resource owner project (my-project) to grant access to the service account principal. The correct command is 'gcloud projects add-iam-policy-binding' on the resource project.

15
Multi-Selectmedium

A security engineer wants to audit all attempts to access a specific Cloud Storage bucket, including successful and failed read requests. Which THREE steps should they take? (Choose THREE)

Select 3 answers
A.Create a log sink to BigQuery for the bucket's admin activity logs.
B.Enable Data Access audit logs for the Cloud Storage service.
C.Use Log Explorer to filter for the bucket's data access logs.
D.Grant the auditor the roles/logging.viewer role on the project.
E.Enable Admin Activity audit logs for the bucket.
AnswersB, C, D

Enabling Data Access audit logs for the Cloud Storage service is correct because these logs specifically record every successful and failed read, write, and metadata operation on objects and buckets. By default, Data Access audit logs are disabled, so they must be explicitly turned on for Cloud Storage for the auditor to capture access attempts. Once enabled, each entry includes the principal, source IP, operation (e.g. storage.objects.get), and timestamp—providing the detailed evidence needed for an audit trail.

Why this answer

To audit data access, Data Access audit logs must be enabled for the bucket. Admin Activity logs only record configuration changes. Using Log Explorer allows filtering and analyzing logs.

Granting the logging viewer role is necessary to view the logs. Creating a sink is for exporting logs, not necessary for auditing.

16
MCQmedium

A developer wants to create a service account for an application running on Compute Engine. The application needs to access Cloud Storage. What is the best practice for granting this access?

A.Use Workload Identity Federation to grant access.
B.Create a service account, grant it the Cloud Storage roles, and attach it to the instance using the --service-account flag.
C.Use the default Compute Engine service account and grant it Cloud Storage roles.
D.Create a service account, download its key, and store it on the instance.
AnswerB

Creating a dedicated service account, granting it only the required Cloud Storage IAM roles such as roles/storage.objectViewer, and attaching it to the instance with the --service-account flag at creation time follows the principle of least privilege. The VM's metadata server then provides short-lived access tokens to the application, avoiding the need to manage or download any service account keys. This is the recommended, secure pattern for a GCE workload to access Cloud Storage with minimal permissions.

Why this answer

The best practice is to create a service account, grant it the necessary roles, and attach it to the Compute Engine instance using the '--service-account' flag. Downloading keys is discouraged. Workload Identity is for on-premises or non-GCP workloads.

17
MCQeasy

An engineer needs to view the current IAM policy for a project in JSON format. Which gcloud command should they use?

A.gcloud iam projects describe-iam-policy PROJECT_ID --format json
B.gcloud projects add-iam-policy-binding PROJECT_ID --format json
C.gcloud projects set-iam-policy PROJECT_ID --format json
D.gcloud projects get-iam-policy PROJECT_ID --format json
AnswerD

This is the correct read-only command for retrieving a project's IAM policy. It outputs the complete policy document, including bindings, version, etag, and audit configs, and '--format json' formats that document as JSON for easy parsing. It is the standard tool for viewing current IAM state and is the basis for making offline changes with set-iam-policy.

Why this answer

The gcloud projects get-iam-policy command retrieves the IAM policy for a project. The --format flag allows you to specify the output format, such as JSON. The other commands are for different purposes: set-iam-policy sets the policy, add-iam-policy-binding adds a binding, and describe-iam-policy does not exist.

18
MCQmedium

You are configuring a Cloud NAT to allow private Compute Engine instances to access the internet for updates. What other resource is required to set up Cloud NAT?

A.A Cloud VPN tunnel
B.An interconnect attachment
C.A Cloud Router
D.A VPC peering connection
AnswerC

A Cloud Router is the correct component because Cloud NAT requires a Cloud Router in the same region and VPC network to function. The Cloud Router holds the NAT gateway's configuration, manages the NAT IP addresses, and dynamically exchanges routes with the VPC network. Without a Cloud Router, Cloud NAT cannot be created or operate, making it the essential resource for allowing private Compute Engine instances to access the internet or other destinations while remaining private.

Why this answer

Cloud NAT requires a Cloud Router to manage dynamic routing and NAT configurations. The Cloud Router is created in the same region and VPC network as the NAT gateway.

19
Multi-Selectmedium

A security team wants to restrict access to a Cloud Storage bucket so that only objects encrypted with a specific CMEK key can be uploaded. Which three actions are needed? (Choose 3)

Select 3 answers
A.Grant authorized users the roles/cloudkms.cryptoKeyEncrypterDecrypter role.
B.Grant all users the roles/cloudkms.cryptoKeyEncrypterDecrypter role.
C.Create a bucket IAM policy that denies storage.objects.create without the encryption header matching the CMEK key.
D.Enable Uniform Bucket-Level Access.
E.Create a Cloud KMS key and set it as the default key on the bucket using --kms-key.
AnswersA, C, E

Granting authorized users the roles/cloudkms.cryptoKeyEncrypterDecrypter role on the Cloud KMS key is correct because this IAM role grants permission to call the Cloud KMS Encrypt and Decrypt operations, which are required for objects to be uploaded with and read from a CMEK-encrypted bucket. Even if a user has bucket-level permissions, they cannot create or read objects encrypted with that key unless they have this role on the key itself. This ensures only the intended authorized principals can use the customer-managed key for cryptographic operations.

Why this answer

Setting the CMEK key on the bucket, creating a bucket-level policy denying uploads without the key, and granting the encrypt/decrypt role to users are required.

20
MCQeasy

Which Google Cloud service provides a managed, scalable, and secure way to store API keys, passwords, and certificates?

A.Cloud Key Management Service (Cloud KMS)
B.Cloud IAM
C.Secret Manager
D.Cloud Storage
AnswerC

Secret Manager is the dedicated Google Cloud service for storing, managing, and accessing secrets such as API keys, passwords, and certificates. It provides built-in secret versioning with immutable payloads, IAM-based access control at the secret-version level, automatic replication for high availability, and full audit logging via Cloud Audit Logs. This makes it the managed and scalable solution that directly matches the requirement.

Why this answer

Secret Manager is the correct service for storing secrets such as API keys, passwords, and certificates. It provides encryption, access control, and versioning. Cloud KMS is for managing encryption keys, Cloud IAM is for access management, and Cloud Storage is for object storage.

21
MCQmedium

A security team wants to ensure that all Compute Engine instances in a project automatically use a custom service account with minimal permissions. What must the engineer do when creating new instances?

A.Create a custom role and assign it to the instance's service account through the instance metadata.
B.Use gcloud compute instances create with the --service-account flag pointing to the custom service account.
C.Set the project-wide default service account to the custom service account in the project settings.
D.Create a startup script that configures the instance to use the custom service account after boot.
AnswerB

When creating an instance, you must specify the service account with `gcloud compute instances create --service-account <SA_EMAIL>`, which attaches that identity to the instance for its entire lifetime. Once attached, the instance metadata server returns OAuth credentials for that service account, so all API calls from the instance are made as that identity. This is the correct way to ensure the instance uses a custom, least-privileged service account, provided the account has been granted the necessary IAM roles.

Why this answer

When creating a Compute Engine instance, you can specify a custom service account using the --service-account flag. This attaches the service account to the instance and grants the associated IAM roles. The instance will use the custom service account instead of the default compute engine service account.

22
MCQmedium

A developer needs to store a database password in Secret Manager and then allow a Compute Engine instance to access it. The instance uses the default compute engine service account. Which role should be granted to the service account?

A.roles/cloudsql.client
B.roles/secretmanager.admin
C.roles/viewer
D.roles/secretmanager.secretAccessor
AnswerD

roles/secretmanager.secretAccessor is the correct predefined role for accessing a secret payload because it includes the secretmanager.versions.access permission, which is the exact IAM permission required to retrieve the stored database password. This role is narrowly scoped; it grants no management capabilities like secret creation, deletion, or IAM policy changes. For a developer whose sole need is to fetch the secret value at runtime, this role provides the minimum access needed while supporting least privilege best practices.

Why this answer

To access the secret version's payload, the service account needs the 'secretmanager.secretAccessor' role on the secret (or project). That role allows accessing secret versions. roles/secretmanager.admin is too broad. roles/cloudsql.client is for Cloud SQL, not Secret Manager. roles/viewer does not allow access to secret payloads.

23
MCQmedium

A company wants to use Customer-Managed Encryption Keys (CMEK) for a Cloud SQL instance. What must be done first?

A.Create a bucket and upload a key file.
B.Create a Cloud KMS key ring and key, and grant the Cloud SQL service account the cloudkms.cryptoKeyEncrypterDecrypter role.
C.Enable Cloud KMS API and use default encryption.
D.Set the --disk-encryption-key flag to an existing key in Cloud KMS.
AnswerB

This is the correct prerequisite for enabling CMEK on a Cloud SQL instance. You must create a key ring and a crypto key in Cloud KMS, then grant the Cloud SQL service account (e.g., service-<project>@gcp-sa-cloudsql.iam.gserviceaccount.com) the cloudkms.cryptoKeyEncrypterDecrypter role. That IAM binding lets Cloud SQL call Cloud KMS to encrypt and decrypt the data encryption keys used to protect the instance.

Why this answer

CMEK requires a Cloud KMS key ring and key to be created, and the Cloud SQL service account must be granted the Encrypter/Decrypter role on that key.

24
MCQmedium

An organization requires that all Compute Engine instances be created with a specific service account. Which organization policy can enforce this?

A.constraints/compute.setServiceAccount
B.constraints/compute.vmExternalIpAccess
C.constraints/iam.allowedPolicyMemberDomains
D.constraints/compute.restrictCreateOnFirewall
AnswerA

This Organization Policy constraint on Compute Engine restricts the service accounts that can be attached to newly created VM instances. It is the correct control because the requirement is to ensure all instances run under a specific identity: when you configure constraints/compute.setServiceAccount with an allowlist of permitted service account IDs, any attempt to create an instance with a different service account is rejected. This prevents a developer from accidentally or intentionally launching a workload as a privileged service account.

Why this answer

The 'constraints/compute.setServiceAccount' constraint can be used to restrict which service accounts can be used when creating instances. It can be set at the organization or project level. The other constraints are not related to service accounts.

25
MCQhard

A company has a VPC with two subnets: subnet-a (10.0.1.0/24) and subnet-b (10.0.2.0/24). They want to allow traffic from instances in subnet-a to reach a specific instance in subnet-b only on TCP port 443. What is the most specific firewall rule to achieve this?

A.Create a rule with source tag 'subnet-a-instances', allow tcp:443, and target tag 'https-server'.
B.Create a rule with source range 0.0.0.0/0, allow tcp:443, and target the specific instance.
C.Create a rule with source range 10.0.1.0/24, allow tcp:443, and apply to all instances in subnet-b.
D.Create a rule with source range 10.0.1.0/24, allow tcp:443, and target tag 'https-server' applied to the specific instance.
AnswerD

This rule is correct because it pairs a source range of 10.0.1.0/24—exactly matching subnet-a—with a target tag, such as 'https-server', that is applied only to the specific instance in subnet-b. The VPC firewall rule then evaluates the source IP of the incoming packet against the allowed CIDR and the destination instance's effective firewall tags to determine whether to permit TCP 443. Since both conditions are tightly scoped, the rule enforces the intended access: only instances in subnet-a can reach that one HTTPS server, and all other traffic is implicitly denied.

Why this answer

Firewall rules can specify source ranges (IP addresses or CIDR blocks) and target tags or service accounts. The most specific rule would use the subnet-a CIDR block (10.0.1.0/24) as the source, allow TCP port 443, and target the specific instance using a target tag. Using a tag makes the rule apply only to instances with that tag, avoiding impact on other instances in subnet-b.

26
MCQmedium

A company has a VPC with a subnet that has Private Google Access enabled. They want their Compute Engine instances to access Google APIs and services through internal IP addresses. Which additional configuration is required?

A.No additional configuration is required.
B.Configure Cloud NAT to enable access to Google APIs.
C.Set up Cloud VPN tunnels to Google APIs.
D.Create a VPC peering connection with the Google APIs VPC.
AnswerA

Private Google Access is a subnet-level setting that already routes traffic from VM instances with only internal IP addresses to Google APIs and services over Google's internal network. When this is enabled on the subnet, DNS resolution for googleapis.com automatically maps to Google's internal IP ranges, so the existing VPC routing handles API calls without any extra networking components. Therefore, no additional configuration is required.

Why this answer

Private Google Access on a subnet allows instances in that subnet to reach Google APIs and services using internal IP addresses. No additional configuration is needed if the instances are in that subnet. Cloud NAT is for outbound internet access, not for Google API access.

Cloud VPN and Cloud Interconnect are for hybrid connectivity.

27
Multi-Selecthard

An engineer needs to audit all Data Access logs for a project to detect unauthorized access to sensitive data. The engineer must ensure that logs are retained for 5 years and are immutable. Which THREE steps should the engineer take?

Select 3 answers
A.Configure the Cloud Storage bucket with a retention policy and enable object versioning
B.Enable Data Access audit logs for the relevant services in the project's IAM audit config
C.Use the default Logging retention of 30 days
D.Set up a Cloud Monitoring alert for any Data Access log entries
E.Create a log sink to export logs to a Cloud Storage bucket
AnswersA, B, E

The retention policy on the Cloud Storage bucket prevents objects from being deleted or overwritten for a specified duration, and object versioning preserves every version of each object, so even if an object is deleted or replaced, an immutable prior version remains. This is critical for compliance because audit logs must be tamper-proof and available for a multi-year period. However, this step alone does not capture logs; it secures the destination bucket where the log sink delivers exported log entries.

Why this answer

To achieve this, the engineer must: 1. Enable Data Access audit logs for the required services (e.g., Cloud Storage, BigQuery) in the project's IAM audit config. 2. Create a log sink that exports the logs to a Cloud Storage bucket (which provides cost-effective long-term retention). 3.

Configure the bucket with retention policy and object versioning to make logs immutable and protect against deletion. Using Logging's default retention is only 30 days, not 5 years. Cloud Monitoring does not store logs.

BigQuery is not ideal for immutable storage.

28
MCQeasy

You want to view the current IAM policy for a project in JSON format using the gcloud command-line tool. Which command should you run?

A.gcloud projects get-iam-policy <project-id> --format json
B.gcloud iam service-accounts get-iam-policy <service-account> --format json
C.gcloud iam policies get <project-id> --format json
D.gcloud projects describe <project-id> --format json
AnswerA

This is the correct command. `gcloud projects get-iam-policy` invokes the Cloud Resource Manager `getIamPolicy` API for the specified project, and the `--format json` flag requests the output as a structured JSON object containing the policy's `etag`, `version`, and `bindings`. It is the standard way to view all project-level IAM bindings.

Why this answer

The correct command is `gcloud projects get-iam-policy <project-id> --format json`. This retrieves the IAM policy and formats it as JSON.

29
MCQmedium

An engineer needs to view the current IAM policy for a project in JSON format to analyze bindings. Which command should be used?

A.gcloud resource-manager folders get-iam-policy my-project --format json
B.gcloud projects get-iam-policy my-project --format yaml
C.gcloud projects get-iam-policy my-project --format json
D.gcloud iam policies get my-project --format json
AnswerC

This is the correct command. It uses the 'gcloud projects get-iam-policy' subcommand to retrieve the IAM policy for the specified project ID ('my-project') and sets the output format to JSON via '--format json'. The command returns the Policy object containing bindings, roles, members, etag, and version, all serialized in the requested JSON structure.

Why this answer

The command gcloud projects get-iam-policy PROJECT_ID --format json retrieves the IAM policy for the project in JSON format. Other commands either get policies for different resources or use a different format.

30
MCQmedium

An organization has multiple projects under a folder. They want to grant a network admin the ability to create firewall rules in all projects in the folder. Which IAM policy binding achieves this with least privilege?

A.Grant roles/owner at the folder level
B.Grant roles/compute.admin at the project level for each project
C.Grant roles/compute.networkAdmin at the folder level
D.Grant roles/compute.securityAdmin at the folder level
AnswerD

Granting roles/compute.securityAdmin at the folder level is the most precise solution because this role includes the compute.firewalls.create, compute.firewalls.update, and compute.firewalls.delete permissions needed to manage firewall rules, but does not include broader permissions to manage instances, networks, or IAM. IAM policies at the folder level are inherited by all projects and resources within that folder, so this single binding covers every descendant project, including newly created ones. This follows least privilege by granting exactly the permissions needed for firewall rule management and nothing extra.

Why this answer

Grant the roles/compute.securityAdmin role at the folder level. This allows managing firewall rules across all projects under that folder. Granting at project level would require adding the role to each project individually.

The compute.networkAdmin role does not include firewall rule management.

31
MCQeasy

You need to store a database password securely in Google Cloud. The password will be used by a Compute Engine instance. Which service should you use?

A.Secret Manager
B.Cloud Storage
C.Cloud KMS
D.Cloud Firestore
AnswerA

Secret Manager is the dedicated GCP service for securely storing secrets such as database passwords, API keys, and TLS certificates. It provides automatic encryption at rest and in transit, granular IAM-permission binding, versioning, and audit logging, enabling applications to retrieve secrets on demand via API without embedding them in code. As a fully managed and centralized secret store, it is purpose-built to safeguard database credentials in compliance with security best practices.

Why this answer

Secret Manager is the correct service for storing secrets like database passwords. It provides encryption, access control, and versioning.

32
MCQhard

A company has an organization with multiple folders and projects. They want to audit all IAM policy changes across the entire organization. Which approach meets the requirement with minimal effort?

A.View Admin Activity audit logs in Logs Explorer, which are enabled by default.
B.Use Organization Policy to deny IAM policy changes and monitor violations.
C.Enable Data Access audit logs for all services in the organization.
D.Enable audit logging on each project individually using gcloud logging sinks.
AnswerA

Admin Activity audit logs are enabled by default for every Google Cloud project and record all IAM policy changes, including modifications to roles, bindings, and service account keys. To see who changed permissions, you can go directly to the Logs Explorer and query protoPayload.methodName=SetIamPolicy without creating any sinks or enabling additional features. This is the only option that directly answers the question with zero configuration effort.

Why this answer

Admin Activity audit logs capture all IAM policy changes by default and are enabled for all projects. Data Access audit logs do not capture IAM changes. Organization policies don't capture changes.

Enabling logs per project would be more effort.

33
MCQmedium

An engineer wants to create a Google-managed SSL certificate for an HTTPS load balancer. Which command should they use?

A.gcloud compute ssl-policies create my-policy --profile MODERN
B.gcloud compute ssl-certificates create my-cert --domains example.com
C.gcloud compute ssl-certificates create my-cert --certificate cert.pem --private-key key.pem
D.gcloud compute target-https-proxies create my-proxy --ssl-certificates my-cert
AnswerB

This is the correct command because it explicitly instructs Compute Engine to provision a Google-managed certificate for the specified domains. The --domains flag triggers Google's automatic certificate management lifecycle: Google Cloud obtains the certificate and handles renewals approximately 30 days before expiration, though you must verify domain ownership first. After creation, the certificate resource still needs to be attached to a target HTTPS proxy and associated with a forwarding rule before it can serve traffic.

Why this answer

To create a Google-managed SSL certificate, use 'gcloud compute ssl-certificates create' with the '--domains' flag. The other commands are for other purposes or require manual certificate provisioning.

34
MCQmedium

An engineer needs to grant a service account the ability to impersonate another service account when making API calls. Which IAM role should be assigned to the impersonating service account?

A.roles/iam.serviceAccountAdmin
B.roles/serviceusage.serviceUsageConsumer
C.roles/iam.serviceAccountUser
D.roles/iam.serviceAccountTokenCreator
AnswerC

roles/iam.serviceAccountUser is the correct role because it includes the permissions iam.serviceAccounts.actAs and iam.serviceAccounts.implicitDelegation. The actAs permission allows a principal to use the service account to access resources and create resources that are owned by or signed with the service account's identity. ImplicitDelegation also permits the principal to impersonate service accounts that are arranged in a delegated chain, making this the minimal standard role for granting a service account the ability to act on behalf of another entity.

Why this answer

The roles/iam.serviceAccountUser role allows a principal to impersonate a service account (by getting an access token for that account). roles/iam.serviceAccountTokenCreator allows creating tokens but not full impersonation. roles/serviceusage.serviceUsageConsumer is for service usage, not impersonation. roles/iam.serviceAccountAdmin allows administrative actions but not impersonation.

35
MCQmedium

A team needs to create a new service account and grant it the roles/storage.objectViewer role on a project. Which two gcloud commands are required?

A.gcloud iam service-accounts create and gcloud iam service-accounts add-iam-policy-binding
B.gcloud projects add-iam-policy-binding only
C.gcloud iam service-accounts create and gcloud projects add-iam-policy-binding
D.gcloud iam service-accounts create and gcloud iam roles create
AnswerC

This is the correct sequence: first, `gcloud iam service-accounts create` provisions the service account and generates its unique email address, which becomes the IAM member identity. Then, `gcloud projects add-iam-policy-binding` adds that service account email as a member in the project's IAM policy and grants the specified role (e.g., roles/storage.objectAdmin) for the whole project. This binds the service account as an identity to the project-level resource, which is exactly what is needed.

Why this answer

First, create the service account with gcloud iam service-accounts create. Then grant the role on the project using gcloud projects add-iam-policy-binding with the service account as member. The commands in other options are either missing steps or incorrect.

36
Multi-Selectmedium

An engineer needs to allow a set of Compute Engine instances (with tag 'web-server') to receive traffic on port 443 from the internet. The VPC has a default network with default firewall rules. Which TWO actions should the engineer take? (Choose TWO)

Select 2 answers
A.Create a firewall rule allowing ingress from 0.0.0.0/0 on port 443 with target tag 'https-server' and priority 1000.
B.Modify the default-allow-https rule to change the target tag to 'web-server'.
C.Delete the default-allow-https rule to avoid conflicts.
D.Create a firewall rule allowing ingress from 0.0.0.0/0 on port 443 with target tag 'web-server' and priority 1000.
E.Ensure that instances have the 'web-server' network tag applied.
AnswersD, E

Correct: This rule allows the desired traffic.

Why this answer

To allow ingress on port 443 to instances with tag 'web-server', the engineer must create a firewall rule allowing that traffic. The default rules are already there but may not include port 443; the default-allow-https rule exists but only for instances with tag 'https-server', not 'web-server'. So a new rule is needed.

The engineer should not modify the default rule (cannot be modified) or delete it. Creating a rule with priority 1000 is appropriate.

37
MCQmedium

An engineer needs to grant a service account the ability to start and stop Compute Engine instances in a specific project. The service account should not have permissions to delete instances or modify other resources. Which IAM role should be assigned?

A.roles/compute.viewer
B.roles/compute.admin
C.roles/compute.osAdminLogin
D.roles/compute.instanceAdmin.v1
AnswerD

roles/compute.instanceAdmin.v1 is a predefined IAM role specifically designed for managing Compute Engine instances without granting broader administrative power. It includes permissions to start, stop, and reset instances, as well as modify metadata and change instance settings, but it does not allow deleting instances or creating new ones. This role exactly matches the requirement of enabling a service account to start and stop instances while maintaining least privilege.

Why this answer

The Compute Instance Admin (roles/compute.instanceAdmin.v1) role provides permissions to create, start, stop, and reset instances, but does not include delete permissions. The Compute Admin role is too broad, and Compute Viewer is read-only. Compute OS Admin Login is for OS login, not instance lifecycle.

38
MCQmedium

An engineer needs to create a firewall rule that allows incoming HTTPS traffic only from a specific IP range to instances tagged 'web-server'. Which command should they use?

A.gcloud compute firewall-rules create allow-https --allow tcp:443 --source-ranges 192.168.0.0/16 --target-tags web-server
B.gcloud compute firewall-rules create allow-https --allow tcp:443 --source-tags web-server
C.gcloud compute firewall-rules create allow-https --allow udp:443 --source-ranges 192.168.0.0/16 --target-tags web-server
D.gcloud compute firewall-rules create allow-https --allow tcp:443 --source-ranges 0.0.0.0/0 --target-tags web-server
AnswerA

This rule is correct because it explicitly restricts inbound HTTPS (TCP port 443) to source IPs within the RFC 1918 private range 192.168.0.0/16 and applies only to VM instances bearing the network tag 'web-server'. The combination of --source-ranges with a CIDR and --target-tags ensures the rule targets exactly the intended web servers and only allows traffic from the specified internal subnet, satisfying the requirement.

Why this answer

The correct command creates a firewall rule allowing TCP port 443 from the specified source range to instances with the target tag 'web-server'.

39
MCQeasy

An engineer wants to create a Google-managed SSL certificate for a domain and attach it to an HTTPS load balancer. Which gcloud command should they use to create the certificate?

A.gcloud compute target-https-proxies create --ssl-certificates
B.gcloud compute ssl-certificates create --domains example.com
C.gcloud compute ssl-policies create
D.gcloud compute ssl-certificates create --certificate example.crt --private-key example.key
AnswerB

The `gcloud compute ssl-certificates create` command with the `--domains` flag provisions a Google-managed SSL certificate, which satisfies the stem’s requirement for a Google-managed certificate rather than a self-managed one. This command triggers Google’s Certificate Authority to automatically handle domain validation and renewal for `example.com`, eliminating the need for manual certificate uploads. It directly attaches to the HTTPS load balancer’s target proxy, meeting the load-balancer constraint.

Why this answer

The gcloud compute ssl-certificates create command with the --domains flag creates a Google-managed SSL certificate. The other commands are for creating SSL policies, self-managed certificates, or target HTTPS proxies.

40
MCQmedium

An engineer wants to view the current IAM policy for a project in JSON format. Which command should they use?

A.gcloud resource-manager folders get-iam-policy my-project --format json
B.gcloud projects describe my-project --format json
C.gcloud projects get-iam-policy my-project --format json
D.gcloud iam policies get my-project --format json
AnswerC

This is the exact, valid CLI command for retrieving a project's IAM policy. The subcommand get-iam-policy reads the IAM policy bound to the specified project resource, and --format json renders it as a JSON array of bindings, including roles, members, and conditions. It is the correct tool for this task.

Why this answer

The gcloud projects get-iam-policy command with --format json outputs the IAM policy in JSON format.

41
MCQmedium

An engineer needs to grant an external auditor read-only access to view IAM policies on a GCP project. The auditor should not have access to any other resources. Which IAM role should be assigned?

A.roles/iam.roleAdmin
B.roles/iam.serviceAccountAdmin
C.roles/viewer
D.roles/iam.securityReviewer
AnswerD

roles/iam.securityReviewer is the correct choice because it grants permission to view IAM policies (for example, 'getIamPolicy') across all resources without allowing any modifications. It also includes permissions to list and get roles, which is exactly what an external auditor needs to review access configuration. This role aligns with least privilege for a read-only audit.

Why this answer

The `roles/iam.securityReviewer` role grants permission to view IAM policies without granting access to other resources. It is specifically designed for security auditors.

42
MCQmedium

A company wants to use Cloud NAT to allow private instances in a VPC to send outbound traffic to the internet and to receive inbound responses. Which two resources must be configured to set up Cloud NAT?

A.Cloud Router and NAT gateway
B.Cloud Router only
C.Cloud VPN and Cloud NAT
D.Cloud Interconnect and Cloud NAT
AnswerA

Cloud NAT is implemented as a NAT gateway configured on a Cloud Router, and this pair is the required core of the service. The Cloud Router holds the NAT IP addresses and manages the dynamic routes (via BGP) that allow private instances to use them, while the NAT gateway performs source address translation for outbound connections. Without a NAT gateway, a Cloud Router alone cannot translate addresses, which is why both components are mandatory for a functioning Cloud NAT.

Why this answer

Cloud NAT requires a Cloud Router (to manage dynamic routing and NAT IP allocation) and a NAT gateway (the actual NAT service). The Cloud Router is a separate resource that must be created in the same region as the NAT gateway. The NAT gateway configuration includes the Cloud Router name.

43
MCQhard

An organization has a folder hierarchy with multiple projects. They want to grant a support team the ability to view all IAM policies across the entire folder. What is the most efficient way?

A.Grant roles/iam.securityReviewer at the folder level.
B.Grant roles/iam.securityReviewer on each project individually.
C.Grant roles/owner at the folder level.
D.Grant roles/viewer at the folder level.
AnswerA

Granting roles/iam.securityReviewer at the folder level is correct because IAM permissions propagate through the resource hierarchy. This predefined role includes resourcemanager.folders.getIamPolicy and resourcemanager.projects.getIamPolicy, allowing the user to read IAM policies on the folder and every project, folder, and resource beneath it. Because the audit scope is the entire folder hierarchy, one grant at the folder root covers all child projects without per-project assignments, satisfying the requirement efficiently and with least privilege.

Why this answer

Granting the role at the folder level applies to all projects under it, which is efficient and follows best practices for hierarchical IAM.

44
MCQmedium

A company has multiple VPC networks in their project. They want Compute Engine instances in one VPC to communicate with instances in another VPC using internal IP addresses. Which feature should they use?

A.Cloud NAT
B.VPC Network Peering
C.Cloud VPN
D.Firewall rules
AnswerB

VPC Network Peering directly connects two VPC networks over Google's private backbone, allowing instances in each network to communicate using internal RFC 1918 addresses without needing public IPs or a VPN. It is the recommended method for inter-VPC connectivity because it offers low latency, no bandwidth restrictions, and no single point of failure. Peering works across projects and organizations, and it automatically exchanges routes for all subnets in the peered networks, so it fully satisfies the requirement to connect multiple VPC networks.

Why this answer

VPC Peering allows connectivity between two VPC networks using internal IPs. VPN is for on-premises connectivity. Cloud NAT is for outbound internet access.

Firewall rules control traffic but do not enable routing between VPCs.

45
MCQhard

A company has a Google Cloud organization with multiple folders and projects. The security team wants to audit all actions that create or modify IAM policies across the entire organization. Which type of audit log should they examine?

A.System Event audit logs
B.Data Access audit logs
C.VPC Flow Logs
D.Admin Activity audit logs
AnswerD

Admin Activity audit logs are enabled by default and capture all API calls that modify the configuration or metadata of resources, including IAM policy updates. For an organization with multiple folders, these logs at the org level record IAM binding changes on any resource in the hierarchy, such as 'setIamPolicy' from projects or folders. They provide an audit trail of who changed what, when, from where, and for which resource, making them the correct log type for investigating IAM policy modifications.

Why this answer

Admin Activity audit logs record all API calls that modify the configuration or metadata of resources, including IAM policy changes. These logs are enabled by default and cannot be disabled. Data Access logs record read operations and are not enabled by default.

System Event logs cover GCP infrastructure events, not IAM changes.

46
MCQeasy

You need to add an IAM binding for a user to a project using the gcloud command. Which command should you use?

A.gcloud projects add-iam-policy-binding
B.gcloud iam service-accounts add-iam-policy-binding
C.gcloud projects set-iam-policy
D.gcloud iam roles update
AnswerA

gcloud projects add-iam-policy-binding PROJECT_ID --member=user:email@example.com --role=roles/viewer is the correct command because it performs an additive update to the project's IAM policy. It reads the current policy, appends the new binding (role + member) to the existing set, and writes the merged policy back atomically, leaving all other bindings untouched. This is the standard CLI operation for granting a specific role to a user at the project scope.

Why this answer

The command `gcloud projects add-iam-policy-binding <project-id> --member user:<email> --role <role>` adds an IAM policy binding to a project.

47
Multi-Selecteasy

Which TWO of the following are valid ways to grant IAM roles to a service account for accessing a Cloud Storage bucket? (Select 2 correct answers)

Select 2 answers
A.Use gcloud projects set-iam-policy with a policy file that includes the binding.
B.Use gcloud storage buckets add-iam-policy-binding to grant the role directly on the bucket.
C.Use gcloud iam roles create to assign the role to the service account.
D.Use gcloud projects add-iam-policy-binding to grant the role at the project level.
E.Use gcloud iam service-accounts add-iam-policy-binding.
AnswersB, D

`gcloud storage buckets add-iam-policy-binding` is the dedicated command to add a single IAM binding on a specific Cloud Storage bucket. You specify the bucket name with `--member` and `--role` to grant that role directly to a user, group, or service account at the bucket level. This is a valid, surgical way to grant permissions to exactly that bucket and no other resource.

Why this answer

IAM roles can be granted at the bucket level using gcloud storage buckets add-iam-policy-binding (or gsutil iam ch) or at the project level which applies to all buckets in the project. The other options are incorrect: gcloud iam roles create creates a custom role definition, not a grant; gcloud iam service-accounts add-iam-policy-binding grants roles on the service account itself; and gcloud projects set-iam-policy replaces the entire policy, not a granular add.

48
Multi-Selecteasy

An engineer wants to view the current IAM policy for a project. Which TWO commands will accomplish this?

Select 2 answers
A.gcloud projects get-iam-policy my-project --format json
B.gcloud resource-manager folders get-iam-policy my-folder
C.gcloud iam service-accounts get-iam-policy my-sa@my-project.iam.gserviceaccount.com
D.gcloud projects get-iam-policy my-project
E.gcloud projects get-ancestors-iam-policy my-project
AnswersA, D

This is the correct command to retrieve the IAM policy for a specific project, and using `--format json` explicitly instructs the CLI to output the policy as a JSON object. The `--format` flag does not change the underlying policy data, but it provides a structured, machine-readable representation that is ideal for scripting with tools like `jq` or for programmatic inspection. Without this flag, the same data would be rendered in YAML by default, so this flag only ensures the output format is standard and predictable.

Why this answer

The gcloud projects get-iam-policy command retrieves the IAM policy for a project. The gcloud projects get-ancestors-iam-policy retrieves policies from ancestors, not the project itself. The other commands are for different purposes.

49
Multi-Selectmedium

A company needs to audit all actions that modify a Cloud Storage bucket. Which TWO steps should they take to enable this? (Choose 2 answers.)

Select 2 answers
A.Use Log Explorer to filter logs by the Cloud Storage service and the 'data_access' log type.
B.Create a VPC Service Controls perimeter.
C.Enable Admin Activity audit logs for the Cloud Storage service.
D.Assign the roles/logging.viewer role to the security team.
E.Enable Data Access audit logs for the Cloud Storage service in the project's IAM audit config.
AnswersA, E

Using Log Explorer in the Google Cloud console lets you query and filter audit logs once they are enabled. By applying a filter for the Cloud Storage service and the 'data_access' log type, you can view object-level operations such as writes, deletes, and overwrites. This is the final step that makes the audit trail visible and actionable for compliance, but it requires Data Access logging to already be enabled in the IAM audit config.

Why this answer

To audit data access modifications, you need to enable Data Access audit logs for the storage service and then view those logs in Log Explorer. Admin Activity logs record configuration changes (like creating a bucket), but data modifications (like uploading objects) require Data Access logs.

50
MCQmedium

An organization needs to audit all data access (read/write) to a Cloud Storage bucket for compliance. Which type of audit log should they enable?

A.System Event audit logs
B.Access Transparency logs
C.Admin Activity audit logs
D.Data Access audit logs
AnswerD

Data Access audit logs are the correct Cloud Audit Logs category for recording data-plane read/write operations, including Cloud Storage object GETs, BigQuery query reads, and Pub/Sub message publishes/pulls. They are typically disabled by default for most services and must be explicitly enabled for each service in the Audit Logs configuration, after which they deliver the who/what/when trail needed to audit data access across the organization.

Why this answer

Data Access audit logs record who accessed what data, including read and write operations. Admin Activity logs record changes to configurations, not data access. To enable Data Access logs, they need to configure the audit policy at the organization, folder, or project level for the specific service (storage.googleapis.com).

51
MCQhard

A developer created a service account for an application running on a Compute Engine instance. The instance was started without specifying the service account. What must the developer do to make the application use the service account?

A.Use gcloud iam service-accounts add-iam-policy-binding to grant the instance access.
B.Stop the instance, update it with the --service-account flag using gcloud compute instances set-service-account, then start it.
C.Use gcloud compute instances add-iam-policy-binding to assign the service account to the instance.
D.Create a new instance with the service account and migrate the application.
AnswerB

Compute Engine requires an instance to be in the TERMINATED state before its service account can be changed, so you must stop the instance first. The gcloud compute instances set-service-account command updates the attached service account (and optionally the access scopes), and then you start the instance to apply the change. This approach preserves the existing VM, avoids resource recreation or workload migration, and is the documented way to attach a service account to an existing instance.

Why this answer

If an instance is created without a service account, it uses the default compute engine service account. To use a custom service account, the instance must be created with '--service-account' flag. If already running, the instance must be stopped and the service account can be changed (attached) by updating the instance.

The correct approach is to stop the instance, attach the service account, and restart.

52
MCQeasy

A company wants to automate the rotation of encryption keys for Cloud Storage buckets every 30 days. Which key type should be used?

A.Customer-Managed Encryption Keys (CMEK)
B.Google-managed encryption keys
C.Key Access Justification
D.Customer-Supplied Encryption Keys (CSEK)
AnswerA

Customer-Managed Encryption Keys (CMEK) is correct because it lets you control and automate key rotation through Cloud KMS. You define a rotation period (e.g., 30 days) on a key, and Cloud KMS automatically generates a new key version on that schedule while continuing to decrypt data with older versions. This provides both automated rotation and full auditability of when each version is used, which aligns with a company's requirement to rotate encryption keys without manual intervention.

Why this answer

Customer-Managed Encryption Keys (CMEK) allow you to control the key lifecycle, including rotation. Google-Managed keys rotate automatically but you cannot schedule or force rotation. CSEK requires manual rotation.

Key Access Justification is a feature of CMEK for access transparency.

53
MCQmedium

You need to create a service account for a Compute Engine instance to allow it to access Cloud Storage objects. The service account should have minimal permissions. What is the recommended approach?

A.Create a service account and assign it to the instance using gcloud compute instances set-service-account after creation
B.Use the default compute engine service account and grant it roles/storage.objectAdmin
C.Create a service account, download a JSON key, and store it on the instance's local disk
D.Create a service account, grant it the required roles, and specify it when creating the instance using the --service-account flag
AnswerD

Creating a dedicated service account, granting it only the IAM roles the application needs, and passing it via the --service-account flag at instance creation time is the Google-recommended pattern. This attaches the identity to the instance without ever downloading a key, so the instance authenticates through the metadata server's short-lived OAuth tokens. It ensures least privilege and avoids the security risk of storing long-lived credentials on the VM.

Why this answer

Create a service account with only the necessary roles (e.g., roles/storage.objectViewer) and attach it to the instance at creation time. Avoid downloading service account keys; use instance metadata-based credentials instead.

54
MCQeasy

You need to create a Google-managed SSL certificate for an external HTTPS load balancer. The domain is 'www.example.com'. Which command creates the certificate?

A.gcloud compute ssl-certificates create my-cert --certificate example.crt --private-key example.key
B.gcloud compute ssl-certificates create my-cert --certificate example.crt
C.gcloud compute ssl-certificates create my-cert --domains www.example.com
D.gcloud compute ssl-certificates create my-cert --domains www.example.com --managed
AnswerC

The --domains flag is the correct mechanism to request a Google-managed certificate: gcloud will create an SslCertificate resource in MANAGED state, and Google's Certificate Authority will issue a certificate for the specified domain, handling the entire lifecycle including automatic renewal. No additional flags are required, because the presence of --domains unambiguously selects the managed provisioning mode. This command is the exact answer for creating a managed certificate via the gcloud CLI.

Why this answer

The correct command is gcloud compute ssl-certificates create with the --domains flag. This creates a Google-managed certificate that will be provisioned and renewed automatically.

55
MCQhard

An organization wants to enforce encryption at rest for all data in Cloud Storage using Customer-Managed Encryption Keys (CMEK). They have created a Cloud KMS key ring and key. What additional step is required when creating a new bucket to use CMEK?

A.Use the `--encryption-key` flag in the `gsutil mb` command.
B.Use the `--default-encryption-key` flag with the KMS key resource ID in the `gsutil mb` command.
C.Assign the Cloud KMS CryptoKey Encrypter/Decrypter role to the Cloud Storage service account.
D.Enable CMEK in the Cloud Console under the bucket's encryption settings after creation.
AnswerB

The `--default-encryption-key` flag, when used with `gsutil mb`, sets the bucket's default customer-managed encryption key at creation time. The value must be the full resource ID in the format `projects/PROJECT_ID/locations/REGION/keyRings/KEY_RING/cryptoKeys/KEY`. This ensures every object uploaded to the bucket is automatically encrypted with that KMS key, enforcing encryption at rest for all data without requiring per-object flags.

Why this answer

When creating a bucket with CMEK, you must specify the `--default-encryption-key` flag with the KMS key resource ID. This sets the default encryption key for objects stored in the bucket.

56
MCQeasy

Which of the following is required to enable Private Google Access on a subnet?

A.Configuring the subnet with --enable-private-ip-google-access
B.A Cloud Router in the same region
C.A Cloud NAT gateway
D.VPC peering with a Google-managed network
AnswerA

The subnet-level flag --enable-private-ip-google-access is the required element because it configures the VPC subnet to route traffic from instances without external IPs directly to Google's public API endpoints over the Google network. Without this flag, VMs that lack an external IP address cannot reach Google APIs and services, even if the subnet has a default route with an internet gateway. This flag is set per subnet, and enabling it on the relevant subnet is the fundamental prerequisite for Private Google Access.

Why this answer

Private Google Access is enabled at the subnet level using the '--enable-private-ip-google-access' flag. A Cloud NAT is not required for Private Google Access, though it is commonly used together. Cloud Router and VPC peering are not prerequisites.

57
Multi-Selecthard

A company wants to implement a least-privilege security model for a service account that needs to read secrets from Secret Manager and publish messages to Pub/Sub. Which TWO IAM roles should be granted? (Choose TWO)

Select 2 answers
A.roles/pubsub.publisher
B.roles/secretmanager.viewer
C.roles/secretmanager.secretAccessor
D.roles/pubsub.admin
E.roles/secretmanager.admin
AnswersA, C

roles/pubsub.publisher is the correct least-privilege choice because it contains only the pubsub.topics.publish permission, which is exactly what a producer needs to send messages to a Pub/Sub topic. It does not grant permission to create, delete, or modify topics, subscribe, or manage IAM, so a compromised token from this service account could not reconfigure messaging infrastructure.

Why this answer

The minimum roles needed are: roles/secretmanager.secretAccessor for reading secret versions, and roles/pubsub.publisher for publishing messages. roles/secretmanager.admin is too broad, roles/pubsub.admin is too broad, and roles/secretmanager.viewer only allows viewing metadata, not accessing secret values.

58
MCQmedium

An engineer needs to enable Private Google Access for a subnet to allow instances without external IPs to access Google APIs and services. Which flag should be used when creating or updating the subnet?

A.--enable-google-access
B.--private-google-access
C.--enable-private-ip-google-access
D.--enable-private-ip
AnswerC

This is the correct flag. According to the gcloud compute networks subnets update documentation, "--enable-private-ip-google-access" modifies the subnet's privateIpGoogleAccess field, allowing VM instances without external IP addresses to reach Google APIs using the subnet's default route. This is the only flag listed that maps directly to the REST API parameter.

Why this answer

Private Google Access is enabled on a subnet using the `--enable-private-ip-google-access` flag. This allows instances in the subnet to reach Google APIs via the default route.

59
Multi-Selecthard

A company wants to allow developers to create and manage secrets in Secret Manager, but prevent them from viewing secret values. Which TWO predefined roles should be combined to achieve this?

Select 2 answers
A.roles/secretmanager.admin
B.roles/secretmanager.secretAccessor
C.roles/secretmanager.secretManager
D.roles/secretmanager.secretVersionManager
E.roles/secretmanager.viewer
AnswersC, D

roles/secretmanager.secretManager grants permissions to create, get, list, update, and delete secret resources, plus view metadata, but deliberately omits secretmanager.versions.access. This lets developers fully manage the secret lifecycle without ever being able to view the sensitive payload, making it the correct least-privilege choice for the stated requirement to create and manage secrets while preventing access to values.

Why this answer

The roles/secretmanager.admin role includes permissions to create and manage secrets but not to access secret versions (i.e., view values). However, it includes the permission to access versions. Actually, the admin role includes secretmanager.versions.access, so it can view values.

To separate manage from view, you need roles/secretmanager.secretVersionManager (manage versions without access) and roles/secretmanager.secretManager (manage secrets). Wait, the correct combination is roles/secretmanager.secretVersionManager (create/disable/destroy versions) and roles/secretmanager.secretManager (create/update/delete secrets). Neither includes secretmanager.versions.access.

The roles/secretmanager.viewer allows viewing metadata but not values. The roles/secretmanager.secretAccessor allows accessing versions. To manage without viewing, combine roles that exclude access.

Check accurate roles: roles/secretmanager.admin includes all permissions including access. roles/secretmanager.secretManager includes manage secrets but not access versions? Let's verify: roles/secretmanager.secretManager has permissions: secretmanager.secrets.create, secretmanager.secrets.delete, secretmanager.secrets.get, secretmanager.secrets.update, secretmanager.secrets.list. It does NOT include secretmanager.versions.access. roles/secretmanager.secretVersionManager has permissions: secretmanager.versions.create, secretmanager.versions.disable, secretmanager.versions.destroy, secretmanager.versions.enable, secretmanager.versions.get, secretmanager.versions.list. It does NOT include secretmanager.versions.access.

So combining these two roles allows managing secrets and versions but not accessing the payload. roles/secretmanager.viewer allows viewing metadata but not accessing payload. roles/secretmanager.secretAccessor allows accessing payload. So the correct two are secretManager and secretVersionManager.

60
MCQeasy

You need to grant a user the ability to view audit logs for a project but not modify any resources. Which predefined IAM role should you assign?

A.roles/iam.securityReviewer
B.roles/owner
C.roles/viewer
D.roles/logging.viewer
AnswerD

roles/logging.viewer is the predefined role for read-only access to Cloud Logging data. It includes permissions such as logging.logEntries.list, logging.logEntries.get, and logging.logs.list, which are required to view audit logs in the Logs Explorer. This role cannot modify log sinks or delete logs, providing the least-privileged access to view audit logs.

Why this answer

The roles/logging.viewer role provides read-only access to logs, including audit logs. roles/iam.securityReviewer provides read access to IAM policies but not logs. roles/viewer is too broad. roles/owner is administrative.

61
MCQmedium

A security team wants to audit all Data Access attempts in a project for a specific Cloud Storage bucket, including who accessed which object and when. Which configuration is required?

A.Configure VPC Flow Logs on the VPC network
B.Set up Cloud Monitoring alerts on the bucket
C.Enable Admin Activity audit logs for Cloud Storage in the project
D.Enable Data Access audit logs for Cloud Storage in the project's IAM audit config
AnswerD

Data Access audit logs for Cloud Storage capture object-level read (e.g., object.get) and write (e.g., object.create) API calls, including the principal, source IP, timestamp, and the specific resource accessed. Because Data Access audit logs are disabled by default, they must be explicitly enabled in the project's IAM audit config to satisfy security auditing requirements.

Why this answer

Data Access audit logs must be enabled for Cloud Storage at the project level via IAM audit config. Admin Activity logs are always enabled but only record configuration changes, not data access. VPC Flow Logs record network metadata, not object-level access.

Cloud Monitoring does not provide audit logs.

62
MCQhard

An organization uses Organization Policies to restrict the use of certain IAM roles. The security team wants to audit all modifications to IAM policies across the organization, including at the project level. Which log type should be enabled and analyzed?

A.Admin Activity audit logs
B.System Event audit logs
C.Data Access audit logs (READ)
D.Data Access audit logs (WRITE)
AnswerA

Admin Activity audit logs record all API calls that modify configuration or metadata of resources, including IAM policy changes. In Cloud Logging, they are enabled by default and retained for 400 days. Since setting an IAM policy (e.g., projects.setIamPolicy) is a configuration-modifying operation, it's captured here. That's why this is the correct choice.

Why this answer

Admin Activity audit logs record all modifications to IAM policies. Data Access logs record reads of data, not policy changes. To audit IAM policy changes, Admin Activity logs must be enabled and analyzed.

63
MCQhard

An organization wants to use Cloud NAT to allow private Compute Engine instances to access the internet for updates. They have a VPC with a custom subnet and a Cloud Router configured. However, instances cannot reach the internet. What is the most likely cause?

A.The Cloud NAT gateway has not been created on the Cloud Router.
B.The instances do not have external IP addresses.
C.The firewall rules block egress traffic.
D.The subnet does not have Private Google Access enabled.
AnswerA

A Cloud Router alone is only a BGP session manager; it does not perform address translation by itself. To enable NAT on a VPC, you must explicitly create a Cloud NAT gateway and attach it to the Cloud Router for a given region and subnetwork, which then maps private IPs to a pool of external IPs. Without that gateway, outbound packets from private instances are dropped when they try to reach the internet, regardless of routing.

Why this answer

Cloud NAT requires a Cloud Router and a NAT gateway configuration on the router. If the NAT gateway is not created, instances cannot use NAT. Other issues like missing routes or firewall rules are possible but less likely when Cloud NAT is set up correctly.

64
MCQhard

A company is using Cloud NAT to allow private Compute Engine instances to access the internet. They notice that traffic from some instances is not being NATed. What is the most likely cause?

A.The instances have external IP addresses assigned.
B.The Cloud Router is not configured correctly.
C.The firewall rules block egress traffic.
D.The instances are in a different region than the Cloud NAT gateway.
AnswerA

Cloud NAT is designed to provide source network address translation for private instances that do not have external IP addresses. If an instance is assigned an external IP, even an ephemeral one, its outbound traffic will use that IP as the source address, completely bypassing Cloud NAT. Therefore, the observation that traffic is 'not being NATed' is exactly what would happen when instances have external IPs, not a sign of NAT misconfiguration.

Why this answer

Cloud NAT only applies to instances that do not have external IP addresses. If an instance has an external IP, it will use that IP for outbound traffic and bypass Cloud NAT.

65
MCQmedium

A security engineer needs to ensure that Compute Engine instances in a VPC can only communicate with each other on port 443 and cannot receive traffic from the internet. The VPC has a default network with default firewall rules. What should the engineer do?

A.Create a firewall rule with priority 2000 denying ingress from 0.0.0.0/0 and a rule allowing ingress from 10.0.0.0/16 on port 443 with priority 1000.
B.Create a firewall rule with priority 1000 allowing ingress from 0.0.0.0/0 on port 443 and deny all other traffic.
C.Delete all default firewall rules and create a rule allowing ingress from the VPC's subnet range (e.g., 10.0.0.0/16) on port 443.
D.Modify the default-allow-internal rule to only allow port 443.
AnswerC

Correct: Deleting default rules removes internet ingress and the default allow-all-internal rule. New rule restricts internal communication to port 443.

Why this answer

The default VPC includes default firewall rules that allow ingress from the internet and allow all internal traffic. To restrict communication, the engineer must first delete the default ingress rule that allows all traffic from the internet (allow-ssh, allow-icmp, allow-rdp, and allow-http/https can be deleted), then create a new rule that allows ingress only from the VPC's IP range on port 443. The default internal rule allows all traffic within the network; to restrict to port 443, a new rule with higher priority can override it, or the default rule can be deleted and a new one created.

66
MCQeasy

What is the primary benefit of using a Google-managed SSL certificate for an HTTPS Load Balancer?

A.It is free of charge.
B.It automatically renews the certificate before expiration.
C.It can be used with any type of load balancer.
D.It provides stronger encryption than self-managed certificates.
AnswerB

Google-managed certificates automatically handle both provisioning and renewal, so you never have to manually track expiration dates or replace certificates. After you configure the certificate on an HTTPS target proxy, Google Cloud's certificate manager regularly checks the certificate's validity and renews it approximately 30 days before expiration, provided the domain's DNS record still points to the load balancer. This automation is the key advantage because it prevents outages caused by expired certificates.

Why this answer

Google-managed certificates automatically provision and renew SSL/TLS certificates, reducing manual effort and preventing expiration issues.

67
Multi-Selectmedium

A developer wants to automate the creation of a service account and assign it a role using the gcloud command-line tool. Which TWO commands are needed? (Choose 2 answers.)

Select 2 answers
A.gcloud projects add-iam-policy-binding
B.gcloud iam service-accounts keys create
C.gcloud projects set-iam-policy
D.gcloud iam service-accounts create
E.gcloud iam roles create
AnswersA, D

gcloud projects add-iam-policy-binding is the precise command to grant an existing service account an IAM role on a project. It performs an additive update to the project's IAM policy, leaving all other bindings intact, which is exactly what is needed when automating service account creation and subsequent access provisioning. The command requires the service account's email as the member and the role name (e.g., roles/storage.objectViewer), and it applies the binding only at the project level, matching the scenario.

Why this answer

First, you create the service account with `gcloud iam service-accounts create`. Then, you grant a role to the service account by adding an IAM policy binding to the project.

68
MCQeasy

Which IAM role should be granted to a service account to allow it to access a secret stored in Secret Manager?

A.roles/secretmanager.secretAccessor
B.roles/secretmanager.admin
C.roles/iam.serviceAccountUser
D.roles/secretmanager.viewer
AnswerA

roles/secretmanager.secretAccessor is the correct and minimal predefined role for service accounts that need to retrieve secret payloads. It includes the `secretmanager.versions.access` permission, which allows the caller to access the encryption-decrypted secret value from a specified version, and `secretmanager.versions.get` for metadata of that version. It does not permit creating, deleting, or modifying secrets, nor changing IAM policies, making it the exact role for a workload that reads a secret at runtime without administrative side effects.

Why this answer

The role 'secretmanager.secretAccessor' grants access to read secret versions.

69
MCQeasy

A developer wants to store a database password securely and make it accessible to a Compute Engine instance. Which Google Cloud service should be used?

A.Secret Manager
B.Cloud Storage
C.Cloud Filestore
D.Cloud KMS
AnswerA

Secret Manager is the correct choice because it is Google Cloud's purpose-built service for storing sensitive data such as database passwords, API keys, and certificates. It provides fine-grained IAM policies, automatic versioning, audit logging of secret access, and integration with services like Cloud Functions and GKE. Additionally, it supports secret rotation and allows you to enforce retention policies, making it the secure and native solution for managing a database password.

Why this answer

Secret Manager is designed for storing secrets like passwords, API keys, and certificates. Cloud KMS is for encryption key management. Cloud Storage is not secure for secrets.

Cloud Filestore is for file storage.

70
MCQmedium

An engineer creates a firewall rule allowing ingress on port 8080 from source range 10.0.0.0/8 with priority 1000. Another rule denies ingress on port 8080 from source range 10.0.0.0/24 with priority 500. What is the effective behavior for traffic from 10.0.0.1?

A.Traffic is denied only if the source is exactly 10.0.0.1; otherwise allowed.
B.Traffic is denied because the deny rule has a higher priority (lower number).
C.Traffic is allowed because the allow rule covers a larger range.
D.Traffic is allowed because both rules match and the default is to allow.
AnswerB

In Google Cloud VPC firewall rules, priority values determine evaluation order; lower numbers are evaluated first. The deny rule has a priority of 500, whereas the allow rule has 1000, so the deny rule is matched first. Because GCP applies the first matching rule and then stops, the traffic is denied before the allow rule is ever considered.

Why this answer

Firewall rules are evaluated in order of priority; lower numbers have higher priority. The deny rule (priority 500) has higher priority than the allow rule (priority 1000), so traffic from 10.0.0.1 (within 10.0.0.0/24) will be denied.

71
MCQhard

An organization wants to enable Data Access audit logs for all Cloud Storage buckets in a project. Which step is necessary?

A.Use gcloud logging to create a log sink for Cloud Storage.
B.Enable Data Access logs in each bucket's settings.
C.Configure an organization policy or IAM audit config to enable Data Access logs for Cloud Storage.
D.Add an IAM binding with the roles/logging.admin role to a user.
AnswerC

This is the correct approach: Data Access audit logs for Cloud Storage are enabled by adding a Cloud Storage audit config at the project, folder, or organization level using the IAM 'Audit Logs' tab or by setting an auditConfig in the IAM policy. You can specify the service storage.googleapis.com and include the desired permission types—ADMIN_READ, DATA_READ, DATA_WRITE—or use ALL. After the audit config is applied, Cloud Logging begins recording data access events on the matching buckets automatically, with no further per-bucket steps needed.

Why this answer

Data Access audit logs must be enabled at the organization or project level using IAM audit config, and can be scoped to specific services like Cloud Storage.

72
Multi-Selecthard

Which THREE configurations are required to enable Private Google Access for Compute Engine instances in a custom VPC subnet? (Select 3 correct answers)

Select 3 answers
A.Create a Cloud Router to advertise routes to Google.
B.Create a subnet with the --enable-private-ip-google-access flag.
C.Create a VPC network.
D.Launch Compute Engine instances in the subnet.
E.Configure Cloud NAT to route traffic to Google APIs.
AnswersB, C, D

Enabling the --enable-private-ip-google-access flag on the subnet is the core requirement because it tells Google Cloud to allow instances in that subnet to reach Google APIs using only their internal IP addresses. After this flag is set, the VPC's routing table automatically includes a route for Google's API ranges that sends traffic over the internal Google network instead of the public internet. This flag must be present on every subnet where you want Private Google Access to work; enabling it on the VPC or a single instance is not possible.

Why this answer

Private Google Access is enabled on a subnet. Instances in that subnet can reach Google APIs using internal IPs. It does not require Cloud NAT, Cloud VPN, or internet access.

The three required elements are: a VPC network, a subnet with Private Google Access enabled, and instances in that subnet.

73
MCQeasy

Which command is used to view the current IAM policy for a Google Cloud project in JSON format?

A.gcloud compute instances get-iam-policy [INSTANCE]
B.gcloud organizations get-iam-policy [ORG_ID]
C.gcloud projects get-iam-policy [PROJECT_ID] --format json
D.gcloud iam service-accounts get-iam-policy [SERVICE_ACCOUNT]
AnswerC

This command correctly retrieves the IAM policy for the specified GCP project, including all role bindings for members at the project level. The --format json flag ensures the output is machine-readable JSON, which is useful for automation or programmatic inspection. It is the standard gcloud command for viewing project-level IAM policies.

Why this answer

The 'gcloud projects get-iam-policy' command retrieves the IAM policy for a project. The '--format json' flag outputs it in JSON. The other options are for other resources or wrong scope.

74
MCQhard

A company uses Cloud SQL with Customer-Managed Encryption Keys (CMEK). The security team wants to rotate the encryption key. What is the impact on the Cloud SQL instance?

A.The instance becomes unavailable until the key rotation is complete.
B.All data in the instance is re-encrypted immediately.
C.The instance must be stopped and restarted after the key rotation.
D.There is no impact; the instance automatically uses the new key version.
AnswerC

This is the correct operational behavior. After rotating the key version in Cloud KMS, you must restart the Cloud SQL instance using the console, gcloud command, or API so that it recognizes the new key version as the encryption key for upcoming writes. The restart is required because the instance caches the old key version in memory, and the new version is only picked up during instance startup. This allows existing data to still be decrypted with the prior version while new encrypted data uses the updated version.

Why this answer

When rotating a CMEK for Cloud SQL, the instance must be restarted to use the new key version. Data remains encrypted at all times.

75
MCQmedium

A DevOps team needs to grant a CI/CD service account the ability to create secrets in Secret Manager. Which role should be assigned?

A.roles/secretmanager.admin
B.roles/secretmanager.secretCreator
C.roles/secretmanager.secretAccessor
D.roles/secretmanager.viewer
AnswerA

The `roles/secretmanager.admin` role includes the `secretmanager.secrets.create` permission required for adding a new secret via the Cloud Console, gcloud CLI, or Secret Manager API. It also grants full management of versions, IAM policies, and deletion, so it is the predefined role that reliably supports all CI/CD operations that need to provision and rotate secrets.

Why this answer

The roles/secretmanager.admin role grants full control, including creating secrets. roles/secretmanager.secretCreator does not exist; the admin role includes create permission.

Page 1 of 2 · 83 questions totalNext →

Ready to test yourself?

Try a timed practice session using only Configuring Access and Security questions.