sureshyadav76 / terraform-google-vm

Provisioning VMs (Virtual Machines) on Google Cloud Platform (GCP)

Home Page:https://registry.terraform.io/modules/sureshyadav76/vm/google/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform-google-vm

Terraform Google Cloud vm Module

Table of Contents

Introduction

This project deploys a Google Cloud infrastructure using Terraform to create a VPC, subnets, firewall rules, and compute instances.

Usage

This section configures a compute instance. It specifies the name, environment, project, instance tags, machine type, GCP zone, service account scopes, subnetwork (retrieved from the subnet module), and SSH keys for access.

Example: compute_instance

module "compute_instance" {
  source                 = "git@github.com:sureshyadav76/terraform-google-vm.git"
  name                   = "app"
  environment            = "test"
  instance_count         = 1
  instance_tags          = ["foo", "bar"]
  machine_type           = "e2-small"
  image                  = "ubuntu-2204-jammy-v20230908"
  gcp_zone               = "asia-northeast1-a"
  service_account_scopes = ["cloud-platform"]
  subnetwork             = var.subnetwork

  # Enable public IP only if enable_public_ip is true
  enable_public_ip = true
  metadata = {
    ssh-keys = <<EOF
      test:ssh-rsa AAAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxbLLNM= suresh@suresh
    EOF
  }
}

You can customize the input variables according to your specific requirements.

Examples

For detailed examples on how to use this module, please refer to the Examples directory within this repository.

Author

Your Name Replace MIT and sureshyadav76 with the appropriate license and your information. Feel free to expand this README with additional details or usage instructions as needed for your specific use case.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Requirements

Name Version
terraform >= 1.6.6
google >= 3.50, < 5.11.0

Providers

Name Version
google >= 3.50, < 5.11.0

Modules

Name Source Version
labels git::https://github.com/sureshyadav76/terraform-google-labels.git v1.0.0

Resources

Name Type
google_compute_instance.default resource
google_client_config.current data source

Inputs

Name Description Type Default Required
allow_stopping_for_update must be set to true or your instance must have a desired_status of TERMINATED in order to update this field. bool true no
create_instances Toggle to determine whether instances should be created or not. Set to 'true' to create instances, 'false' to skip instance creation. bool true no
enable_public_ip Predefined enable_public_ip address for the instance. bool false no
environment Environment (e.g. prod, dev, staging). string "" no
gcp_zone The GCP zone to create resources in string "" no
image Source image family. If neither source_image nor source_image_family is specified, defaults to the latest public CentOS image. string "ubuntu-2204-jammy-v20230908" no
instance_count The number of instances to create. number 1 no
instance_tags Network tags, provided as a list list(string) [] no
label_order Label order, e.g. sequence of application name and environment name,environment,'attribute' [webserver,qa,devops,public,] . list(any)
[
"name",
"environment"
]
no
machine_type Machine type to create, e.g. n1-standard-1 string "" no
managedby ManagedBy, eg 'sureshyadav76'. string "sureshyadav76" no
metadata Metadata, provided as a map map(string) {} no
metadata_startup_script User startup script to run when instances spin up string "" no
name Name of the resource. Provided by the client when the resource is created. string "test" no
repository Terraform current module repo string "https://github.com/sureshyadav76/terraform-google-vm" no
service_account_email The service account e-mail address. string "" no
service_account_scopes A list of service scopes. list(string) [] no
subnetwork Subnet to deploy to. Only one of network or subnetwork should be specified. string "" no

Outputs

Name Description
cpu_platform The CPU platform used by this instance.
current_status The current status of the instance.
instance_count The value of the instance_count variable.
instance_count_output The value of the instance_count variable.
instance_id The server-assigned unique identifier of this instance.
label_fingerprint The unique fingerprint of the labels.
metadata_fingerprint The unique fingerprint of the metadata.
name The name of the instance.
self_link The URI of the created resource.
tags_fingerprint The unique fingerprint of the tags.

About

Provisioning VMs (Virtual Machines) on Google Cloud Platform (GCP)

https://registry.terraform.io/modules/sureshyadav76/vm/google/latest


Languages

Language:HCL 100.0%