Giter Site home page Giter Site logo

gcp_terraform's Introduction

Terraform Configuration for Deploying Multiple VMs on GCP

This Terraform configuration allows you to deploy multiple virtual machines (VMs) on Google Cloud Platform (GCP). The configuration uses variables to externalize values that might differ across projects, making it easy to customize and reuse.

Prerequisites

Setup

  1. Clone the repository or copy the configuration files to your local machine.

  2. Navigate to the project directory:

    cd path/to/terraform_project
  3. Initialize the Terraform project:

    terraform init
  4. Create a terraform.tfvars file to define the values for the variables:

    touch terraform.tfvars

    Populate the terraform.tfvars file with the required values:

    project_id              = "your-project-id"
    region                  = "your-region"
    disk_image              = "projects/debian-cloud/global/images/debian-12-bookworm-v20240701"
    disk_size_gb            = 10
    disk_type               = "pd-balanced"
    machine_type            = "e2-medium"
    instance_name           = "instance"
    instance_count          = 3
    network_tier            = "PREMIUM"
    subnetwork              = "default"
    service_account_email   = "your-service-account-email"
    service_account_scopes  = ["https://www.googleapis.com/auth/cloud-platform"]
    tags                    = ["http-server", "https-server", "test-vm"]
    zone                    = "us-central1-c"
  5. Review the Terraform plan to see what resources will be created:

    terraform plan
  6. Apply the Terraform configuration to create the resources:

    terraform apply

    Confirm the apply action by typing yes when prompted.

Configuration Details

main.tf

This file contains the main Terraform configuration for creating the VM instances. It includes the resource definition for google_compute_instance, with the count parameter used to create multiple instances based on the value of instance_count.

variables.tf

This file defines the variables used in the Terraform configuration. Each variable has a description and a type, with some having default values.

terraform.tfvars

This file contains the values for the variables defined in variables.tf. By externalizing these values, you can easily customize the configuration for different projects or environments.

Customization

To customize the configuration for your needs, modify the values in the terraform.tfvars file. You can change the number of instances, machine type, disk size, and other parameters as required.

Cleanup

To destroy the resources created by this Terraform configuration, run:

terraform destroy

gcp_terraform's People

Contributors

akhil120 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.