id: gcloud-sql-ha-not-enabled info: name: High Availability Not Enabled for Cloud SQL Database Instances author: princechaddha severity: high description: | Ensure that all your production and mission-critical Google Cloud SQL database instances are configured for High Availability (HA) and automatic failover support. Configuring HA ensures database reliability and minimizes downtime in the event of an outage. impact: | Cloud SQL database instances not configured with High Availability (HA) lack automatic failover support, which can lead to extended downtime and potential data accessibility issues during outages. remediation: | Update the configuration of your Google Cloud SQL database instances to use High Availability (REGIONAL) instead of the default ZONAL configuration to enable automatic failover and ensure minimal downtime. reference: - https://cloud.google.com/sql/docs/mysql/high-availability tags: cloud,devops,gcp,gcloud,google-cloud-sql,gcp-cloud-config flow: | code(1) for(let projectId of iterate(template.projectIds)){ set("projectId", projectId) code(2) for(let sqlInstance of iterate(template.sqlInstances)){ set("sqlInstance", sqlInstance) code(3) } } self-contained: true code: - engine: - sh - bash source: | gcloud projects list --format="json(projectId)" extractors: - type: json name: projectIds internal: true json: - '.[].projectId' - engine: - sh - bash source: | gcloud sql instances list --project $projectId --format="json(name)" extractors: - type: json name: sqlInstances internal: true json: - '.[].name' - engine: - sh - bash source: | gcloud sql instances describe $sqlInstance --format="value(settings.availabilityType)" matchers: - type: word words: - 'ZONAL' extractors: - type: dsl dsl: - '"High Availability is not enabled for Cloud SQL instance: " + sqlInstance + " in project: " + projectId' # digest: 4a0a00473045022100cef6d0de6fe5a9d8475847fc945466fecf4021c503b8d374ad298135c0bd475c022016568c2cc9e9f13c2d901abb4df36868da9e92523506bbb81cb1a025366d1b62:922c64590222798bb761d5b6d8e72950