Create a local reservation
Stay organized with collections
Save and categorize content based on your preferences.
Create a single-project reservation for N2 machine types
Explore further
For detailed documentation that includes this code sample, see the following:
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"]],[],[[["\u003cp\u003eThis content demonstrates how to create a single-project reservation for Google Compute Engine using Terraform.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eshare_type\u003c/code\u003e is set to \u003ccode\u003eLOCAL\u003c/code\u003e within the \u003ccode\u003eshare_settings\u003c/code\u003e block to configure the reservation for a single project.\u003c/p\u003e\n"],["\u003cp\u003eThe reservation is configured to accommodate one instance with the \u003ccode\u003en2-standard-2\u003c/code\u003e machine type.\u003c/p\u003e\n"],["\u003cp\u003eThe configuration does not require affinity to use the reservation via \u003ccode\u003especific_reservation_required\u003c/code\u003e, which defaults to false.\u003c/p\u003e\n"]]],[],null,["# Create a local reservation\n\nCreate a single-project reservation for N2 machine types\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Create a reservation for a single project](/compute/docs/instances/reservations-single-project)\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\n resource \"google_compute_reservation\" \"default\" {\n name = \"gce-reservation-local\"\n zone = \"us-central1-a\"\n\n /**\n * To specify a single-project reservation, omit the share_settings block\n * (default) or set the share_type field to LOCAL.\n */\n share_settings {\n share_type = \"LOCAL\"\n }\n\n specific_reservation {\n count = 1\n instance_properties {\n machine_type = \"n2-standard-2\"\n }\n }\n\n /**\n * To let VMs with affinity for any reservation consume this reservation, omit\n * the specific_reservation_required field (default) or set it to false.\n */\n specific_reservation_required = false\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=compute)."]]