How to Deploy a Windows Server with SQL Server VM Instance in GCP using Terraform

Guillermo Musumeci
9 min readFeb 28, 2022


In this story, we will learn how to deploy a Windows Server with SQL Server VM Instance (VM) in GCP (Google Cloud Platform) using Terraform.

GCP Compute Engine provides images with Microsoft SQL Server preinstalled on Windows Server. In addition, Compute Engine manages the license for both Windows Server and SQL Server for these SQL Server images and includes the cost in your monthly bill.

SQL Server Express

SQL Server Express is a free edition of SQL Server, ideal for development and production for desktop, web, and small server applications. Unfortunately, it is not available for all versions of SQL Server in GCP.

SQL Server Web

SQL Server Web edition is a low total cost-of-ownership option for Web hosting and Web VAPs to provide scalability, affordability, and manageability capabilities for small to large-scale Web properties.

SQL Server Standard

We can run SQL Server Standard on VMs with any machine type, but shared-core machine types will not run optimally. Therefore, Google recommends using VMs with at least one vCPU to run SQL Server Standard.

SQL Server Enterprise

VMs that run SQL Server Enterprise must have at least four vCPUs. For optimal performance, Google recommends running SQL Server Enterprise on VMs with larger memory capacities. We should use high-memory machine types with eight vCPUs or more, depending on our workload. These machine types maximize the ratio of memory to each vCPU available on Compute Engine, which is optimal for SQL Server Enterprise VMs.

Prerequisite: GCP Credentials

Before creating our GCP VM Instances, we need GCP Credentials to execute our Terraform code.

Please refer to the “How to Create a Service Account for Terraform in GCP (Google Cloud Platform)” story if you need help to create the credentials.

Note: Using private key .JSON files are great for learning and testing however they are not recommended in production environments. Never push private keys files to code repositories.



Guillermo Musumeci

Certified AWS, Azure & GCP Architect | HashiCorp Ambassador | Terraform SME | KopiCloud Founder | ex-AWS | Entrepreneur | Book Author | Husband & Dad of ✌