Google Cloud に Compute Engine インスタンスのフリートをデプロイしました。インスタンスのモニタリング指標とログが、会社の運用チームとサイバー セキュリティ チームによって Cloud Logging と Cloud Monitoring に表示されるようにする必要があります。最小権限の原則に従いながら、Identity and Access Management(IAM)を使用して、Compute Engine サービス アカウントに必要なロールを付与する必要があります。あなたは何をするべきか?
正解:D
Explanation
The correct answer is D. Grant the logging.logWriter and monitoring.metricWriter roles to the Compute Engine service accounts.
According to the Google Cloud documentation, the Compute Engine service account is a Google-managed service account that is automatically created when you enable the Compute Engine API1. This service account is used by default to run your Compute Engine instances and access other Google Cloud services on your behalf1. To ensure that monitoring metrics and logs for the instances are visible in Cloud Logging and Cloud Monitoring, you need to grant the following IAM roles to the Compute Engine service account23:
The logging.logWriter role allows the service account to write log entries to Cloud Logging4.
The monitoring.metricWriter role allows the service account to write custom metrics to Cloud Monitoring5.
These roles grant the minimum permissions that are needed for logging and monitoring, following the principle of least privilege. The other roles are either unnecessary or too broad for this purpose. For example, the logging.editor role grants permissions to create and update logs, log sinks, and log exclusions, which are not required for writing log entries6. The logging.admin role grants permissions to delete logs, log sinks, and log exclusions, which are not required for writing log entries and may pose a security risk if misused. The monitoring.editor role grants permissions to create and update alerting policies, uptime checks, notification channels, dashboards, and groups, which are not required for writing custom metrics.