Coder Social home page Coder Social logo

Comments (8)

morgante avatar morgante commented on June 5, 2024 2

Can you try a configuration like this?

module "instance_template" {
  source          = "../../../modules/instance_template"
  project_id      = var.project_id
  subnetwork      = var.subnetwork
  service_account = var.service_account
  name_prefix     = "simple"
  tags            = var.tags
  labels          = var.labels
  access_config   = [{
    nat_ip = null
    network_tier = "PREMIUM"
  }]
}

from terraform-google-vm.

Mayeu avatar Mayeu commented on June 5, 2024

I would also be interested in the possibility to generate ephemeral IP with this module.

This may require a change in the Terraform provider itself, like adding an access_config option such as ephemeral_external_ip = true.

from terraform-google-vm.

shraddhajain01 avatar shraddhajain01 commented on June 5, 2024

I tried the above provided possible solution, but it did not create the ephemeral IP address.

from terraform-google-vm.

morgante avatar morgante commented on June 5, 2024

Can you share the Terraform plan for creating the VM when you created this?

from terraform-google-vm.

shraddhajain01 avatar shraddhajain01 commented on June 5, 2024

Here is the plan:

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # module.compute_instance.google_compute_instance_from_template.compute_instance[0] will be created
  + resource "google_compute_instance_from_template" "compute_instance" {
      + allow_stopping_for_update = (known after apply)
      + attached_disk             = (known after apply)
      + can_ip_forward            = (known after apply)
      + cpu_platform              = (known after apply)
      + deletion_protection       = (known after apply)
      + description               = (known after apply)
      + guest_accelerator         = (known after apply)
      + hostname                  = (known after apply)
      + id                        = (known after apply)
      + instance_id               = (known after apply)
      + label_fingerprint         = (known after apply)
      + labels                    = (known after apply)
      + machine_type              = (known after apply)
      + metadata                  = (known after apply)
      + metadata_fingerprint      = (known after apply)
      + metadata_startup_script   = (known after apply)
      + min_cpu_platform          = (known after apply)
      + name                      = "instance-simple-001"
      + project                   = (known after apply)
      + scratch_disk              = (known after apply)
      + self_link                 = (known after apply)
      + service_account           = (known after apply)
      + source_instance_template  = (known after apply)
      + tags                      = (known after apply)
      + tags_fingerprint          = (known after apply)
      + zone                      = "us-west1-a"

      + boot_disk {
          + auto_delete                = (known after apply)
          + device_name                = (known after apply)
          + disk_encryption_key_raw    = (sensitive value)
          + disk_encryption_key_sha256 = (known after apply)
          + kms_key_self_link          = (known after apply)
          + source                     = (known after apply)

          + initialize_params {
              + image = (known after apply)
              + size  = (known after apply)
              + type  = (known after apply)
            }
        }

      + network_interface {
          + access_config      = (known after apply)
          + address            = (known after apply)
          + alias_ip_range     = (known after apply)
          + name               = (known after apply)
          + network            = (known after apply)
          + network_ip         = (known after apply)
          + subnetwork         = "default"
          + subnetwork_project = (known after apply)
        }

      + scheduling {
          + automatic_restart   = (known after apply)
          + on_host_maintenance = (known after apply)
          + preemptible         = (known after apply)

          + node_affinities {
              + key      = (known after apply)
              + operator = (known after apply)
              + values   = (known after apply)
            }
        }
    }

  # module.instance_template.google_compute_instance_template.tpl will be created
  + resource "google_compute_instance_template" "tpl" {
      + can_ip_forward       = false
      + id                   = (known after apply)
      + machine_type         = "n1-standard-1"
      + metadata_fingerprint = (known after apply)
      + name                 = (known after apply)
      + name_prefix          = "test"
      + project              = (known after apply)
      + region               = "us-west1"
      + self_link            = (known after apply)
      + tags_fingerprint     = (known after apply)

      + disk {
          + auto_delete  = true
          + boot         = true
          + device_name  = (known after apply)
          + disk_size_gb = 100
          + disk_type    = "pd-standard"
          + interface    = (known after apply)
          + mode         = (known after apply)
          + source_image = "https://www.googleapis.com/compute/v1/projects/gce-uefi-images/global/images/centos-7-v20200403"
          + type         = (known after apply)
        }

      + network_interface {
          + address            = (known after apply)
          + network            = (known after apply)
          + subnetwork         = "default"
          + subnetwork_project = (known after apply)

          + access_config {
              + assigned_nat_ip = (known after apply)
              + nat_ip          = (known after apply)
              + network_tier    = "PREMIUM"
            }
        }

      + scheduling {
          + automatic_restart   = true
          + on_host_maintenance = (known after apply)
          + preemptible         = false
        }

      + service_account {
          + email  = "XXXXXXXXXXXX"
          + scopes = [
              + "https://www.googleapis.com/auth/compute.readonly",
              + "https://www.googleapis.com/auth/devstorage.read_only",
              + "https://www.googleapis.com/auth/userinfo.email",
            ]
        }
    }

Plan: 2 to add, 0 to change, 0 to destroy.

from terraform-google-vm.

morgante avatar morgante commented on June 5, 2024

Hmm, based on the plan it definitely looks like an external IP should be getting assigned. Can you clarify where it's not getting one?

      + network_interface {
          + address            = (known after apply)
          + network            = (known after apply)
          + subnetwork         = "default"
          + subnetwork_project = (known after apply)

          + access_config {
              + assigned_nat_ip = (known after apply)
              + nat_ip          = (known after apply)
              + network_tier    = "PREMIUM"
            }
        }

from terraform-google-vm.

shraddhajain01 avatar shraddhajain01 commented on June 5, 2024

I have attached the screenshot for reference.

Screen Shot 2020-05-14 at 4 23 51 PM

from terraform-google-vm.

NilsTellow avatar NilsTellow commented on June 5, 2024

Applied changes. Has an ephemeral external IP now. Thanks @morgante.
Closing issue.

from terraform-google-vm.

Related Issues (20)

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.