Skip to main content

database

This Terraform script provisions Google Cloud SQL instances for two databases, one for Care and another Metabase analytics.

  1. Random Password Generation:

    • Two random passwords are generated, one for the PostgreSQL database (random_password.postgres) and another for the Metabase database (random_password.metabase).
  2. Google Cloud SQL Instances:

    • care-db: An instance for the "care" application database.
      • Configured with specified settings such as database version, deletion protection, region, tier, disk autoresize, edition, disk size, availability type, IP configuration, backup configuration, and maintenance window.
    • metabase-db: An instance for the "metabase" analytics database.
      • Configured similarly to the "care-db" instance.
  3. Databases Creation:

    • Two databases are created within their respective instances: "care" (google_sql_database.care-db-database) and "metabase" (google_sql_database.metabase-db-database). Both databases use the specified charset and collation.
  4. Database Users:

    • Two database users are created, one for the "care" application (google_sql_user.postgres) and another for "metabase" (google_sql_user.metabase). These users are associated with their respective instances and use the randomly generated passwords.

The script sets up Google Cloud SQL instances for Care and Metabase, creates databases within these instances, and establishes database users with randomly generated passwords.