How do I create a Google Cloud SQL Database?
To create a Google Cloud SQL database using Pulumi, you need to define the necessary resources like the SQL instance and the database. Below is a TypeScript program that accomplishes this:
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
// Create a Google Cloud SQL instance
const sqlInstance = new gcp.sql.DatabaseInstance("sqlInstance", {
name: "my-sql-instance",
databaseVersion: "MYSQL_5_7",
region: "us-central1",
settings: {
tier: "db-f1-micro",
backupConfiguration: {
enabled: true,
},
},
});
// Create a database within the SQL instance
const database = new gcp.sql.Database("database", {
name: "myDatabase",
instance: sqlInstance.name,
});
// Export the connection name of the SQL instance
export const connectionName = sqlInstance.connectionName;
In this program, we first import the necessary Pulumi and GCP packages. Then, we create a Google Cloud SQL instance with the specified properties like name, database version, region, and settings. After that, we create a database within the SQL instance. Finally, we export the connection name of the SQL instance for reference.
This program sets up a Google Cloud SQL instance and a database within it, allowing you to manage and use the database in your applications.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.