Ensure that Cloud IAM Database Authentication feature is enabled for your Google Cloud SQL for PostgreSQL and MySQL database instances, in order to eliminate static, password-based database authentication and instead use short-lived IAM tokens for database access. To enable this feature, turn on the "cloudsql.iam_authentication" database configuration flag for PostgreSQL instances, or the "cloudsql_iam_authentication" database configuration flag for MySQL instances. This feature is not currently supported for Cloud SQL for SQL Server instances.
IAM database authentication removes the operational burden of managing static database passwords by providing automatic credential rotation, centralized access control through Cloud IAM, and immediate revocation of database access without having to distribute or rotate passwords across your applications. In addition, because database connections are correlated with Cloud IAM principals in Cloud Logging, you can maintain better audit trails and attribute database queries to the exact user or service account that generated them.
Note 1: Enabling the IAM database authentication flag does not prevent existing, non-IAM users from using their standard usernames and passwords to log in.
Note 2: Some database flag settings can affect instance availability and/or stability, and eventually remove the Cloud SQL instance from the Google Cloud SQL Service Level Agreement (SLA).
Audit
To determine if IAM database authentication is enabled for your Cloud SQL for PostgreSQL and MySQL database instances, perform the following operations:
Remediation / Resolution
To enable IAM database authentication for your existing Cloud SQL for PostgreSQL and MySQL database instances, and configure database users that authenticate via IAM credentials, perform the following operations:
References
- Google Cloud Platform (GCP) Documentation
- IAM authentication
- Configure new and existing instances for IAM database authentication
- IAM authentication
- Manage users with IAM database authentication
- CIS Security Documentation
- CIS Google Cloud Computing Platform Benchmarks
- GCP Command Line Interface (CLI) Documentation
- gcloud projects list
- gcloud sql instances list
- gcloud sql instances describe
- gcloud sql instances patch
- gcloud sql users create
- gcloud projects add-iam-policy-binding
- gcloud beta sql connect