Create a Compute Engine instance with SQL Server
Stay organized with collections
Save and categorize content based on your preferences.
Use Terraform to create an SQL Server instance on Compute Engine
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[],[],null,["# Create a Compute Engine instance with SQL Server\n\nUse Terraform to create an SQL Server instance on Compute Engine\n\nCode sample\n-----------\n\n### Terraform\n\n\nTo learn how to apply or remove a Terraform configuration, see\n[Basic Terraform commands](/docs/terraform/basic-commands).\n\n\nFor more information, see the\n[Terraform provider reference documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs).\n\n # VPC network\n resource \"google_compute_network\" \"default\" {\n provider = google-beta\n name = \"vpc-network\"\n auto_create_subnetworks = false\n }\n\n # Subnet\n resource \"google_compute_subnetwork\" \"default\" {\n provider = google-beta\n name = \"vpc-subnet\"\n ip_cidr_range = \"10.0.1.0/24\"\n region = \"europe-west1\"\n network = google_compute_network.default.id\n }\n\n resource \"google_compute_instance\" \"sqlserver_vm\" {\n provider = google-beta\n name = \"sqlserver-vm\"\n boot_disk {\n auto_delete = true\n device_name = \"persistent-disk-0\"\n initialize_params {\n image = \"windows-sql-cloud/sql-std-2019-win-2022\"\n size = 50\n type = \"pd-balanced\"\n }\n mode = \"READ_WRITE\"\n }\n machine_type = \"n1-standard-4\"\n zone = \"europe-west1-b\"\n network_interface {\n access_config {\n network_tier = \"PREMIUM\"\n }\n network = google_compute_network.default.id\n stack_type = \"IPV4_ONLY\"\n subnetwork = google_compute_subnetwork.default.id\n }\n }\n\n resource \"google_compute_firewall\" \"sql_server_1433\" {\n provider = google-beta\n name = \"sql-server-1433-3\"\n allow {\n ports = [\"1433\"]\n protocol = \"tcp\"\n }\n description = \"Allow SQL Server access from all sources on port 1433.\"\n direction = \"INGRESS\"\n network = google_compute_network.default.id\n priority = 1000\n source_ranges = [\"0.0.0.0/0\"]\n }\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=cloud_sql_sqlserver)."]]