database
This Terraform script provisions Google Cloud SQL instances for two databases, one for Care and another Metabase analytics.
-
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
).
- Two random passwords are generated, one for the PostgreSQL database (
-
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.
- care-db: An instance for the "care" application database.
-
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.
- Two databases are created within their respective instances: "care" (
-
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.
- Two database users are created, one for the "care" application (
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.