HPE Morpheus VM Essentials Software
1864708 Members
1052 Online
110474 Solutions
New Discussion

Re: terraform provider

 
rismoneyman
Occasional Contributor

terraform provider

I am using https://github.com/HPE/terraform-provider-hpe 1.5.0 and trying to create a VM instance.  That repo does not have an issue tracker so I am posting here.

terraform {
  backend "local" {
    path = "terraform.tfstate"
  }

  required_providers {
    hpe = {
      source  = "HPE/hpe"
      version = "= 1.5.0"
    }
  }
}

provider "hpe" {
  # Provide morpheus block if you want to create morpheus resources
  morpheus {
    username = "admin"
    password = "xyz!"
    url      = "https://1.1.1.1/"
    insecure = "true"
  }
}




data "hpe_morpheus_cloud" "vme_cloud" {
  name = "VME Cloud"
}

data "hpe_morpheus_service_plan" "vme_16gb" {
  name                = "4 CPU, 16GB Memory"
  provision_type_code = "kvm"
}

resource "hpe_morpheus_instance" "example" {
  name             = "TestInstance"
  cloud_id         = data.hpe_morpheus_cloud.vme_cloud.id
  layout_id        = 32 # Single HVM
  instance_type_id = 10 # HVM (code: mvm)

  group_id = 1
  plan_id  = data.hpe_morpheus_service_plan.vme_16gb.id # kvm-vm-512

  instance_context = "dev"
  network_interfaces = [
    {
      network_id = 7
    }
  ]

  #evars = [
  #  {
  #   name  = "EXAMPLE_VAR"
  #    value = "example_value"
  # }
  #]

  volumes = [
    {
      root_volume     = true
      name            = "AlletraHpeDS"
      size            = 80
      storage_type_id = 1
      datastore_id    = 4
    }
  ]

  tags = [
    {
      name  = "terraform"
      value = "true"
    },
    {
      name  = "acctest"
      value = "true"
    },
    {
      name  = "hpe_morpheus_instance"
      value = "true"
    },
    {
      name  = "sweepable"
      value = "true"
    },
    {
      name  = "managed_by"
      value = "terraform"
    }
  ]

  config = {
    imageId                = 212 # packerimg
    resourcePoolId          = "pool-1" # General Cluster (only kvm pool in VME Cloud)
    nestedVirtualization    = "on"
    noAgent                 = true
    createUser              = false
  }
}
 

hpe_morpheus_instance.example: Still creating... [16m41s elapsed]

│ Error: Plugin did not respond

│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.

Stack trace from the terraform-provider-hpe_v1.5.0.exe plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x7ff6563f8a50]

goroutine 149 [running]:
github.com/HPE/terraform-provider-hpe/morpheus/framework/resources/instance.getInstanceEnvVars({0x7ff65747fd38?, 0x1701d2569500?}, 0x1701d291d388?, 0x1701d255c5b8?)
github.com/HPE/terraform-provider-hpe/morpheus/framework/resources/instance/instance_read.go:909 +0x30
github.com/HPE/terraform-provider-hpe/morpheus/framework/resources/instance.getInstanceAsState({_, _}, _, _, {{0x2, 0x1}, {{0x7ff657487708, 0x1701d288a498}, 0x2}, {{0x0, ...}, ...}, ...})
github.com/HPE/terraform-provider-hpe/morpheus/framework/resources/instance/instance_read.go:234 +0x14e5
github.com/HPE/terraform-provider-hpe/morpheus/framework/resources/instance.(*Resource).Create(0x1701d2452f30, {0x7ff65747fc90, 0x1701d26fb1d0}, {{{{0x7ff6574a4bb8, 0x1701d2a038c0}, {0x7ff656dc9460, 0x1701d29d16b0}}, {0x7ff6574b4a58, 0x1701d257dc70}}, {{{0x7ff6574a4bb8, ...}, ...}, ...}, ...}, ...)
github.com/HPE/terraform-provider-hpe/morpheus/framework/resources/instance/instance_create.go:504 +0x2a25
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).CreateResource(0x1701d2520388, {0x7ff65747fc90, 0x1701d26fb1d0}, 0x1701d2889468, 0x1701d2889438)
github.com/hashicorp/[email protected]/internal/fwserver/server_createresource.go:127 +0x8e2
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ApplyResourceChange(0x1701d2520388, {0x7ff65747fc90, 0x1701d26fb1d0}, 0x1701d2780460, 0x1701d2889590)
github.com/hashicorp/[email protected]/internal/fwserver/server_applyresourcechange.go:63 +0x535
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ApplyResourceChange(0x1701d2520388, {0x7ff65747fc90?, 0x1701d26fb0b0?}, 0x1701d2d0a460)
github.com/hashicorp/[email protected]/internal/proto6server/server_applyresourcechange.go:71 +0x585
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x1701d24526c0, {0x7ff65747fc90?, 0x1701d26fade0?}, 0x1701d2d0a460)
github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x18d
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0x1701d24512c0, {0x7ff65747fc90?, 0x1701d26fa240?}, 0x1701d27ee280)
github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:945 +0x3b9
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x7ff6572ac3a0, 0x1701d24512c0}, {0x7ff65747fc90, 0x1701d26fa240}, 0x1701d27ee200, 0x0)
github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:961 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0x1701d243e908, {0x7ff65747fc90, 0x1701d26fa1b0}, 0x1701d26a8000, 0x1701d2562cf0, 0x7ff659297be8, 0x0)
google.golang.org/[email protected]/server.go:1429 +0x11d2
google.golang.org/grpc.(*Server).handleStream(0x1701d243e908, {0x7ff657481278, 0x1701d2514ea0}, 0x1701d26a8000)
google.golang.org/[email protected]/server.go:1855 +0xbc6
google.golang.org/grpc.(*Server).serveStreams.func2.1()
google.golang.org/[email protected]/server.go:1064 +0x7f
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 42
google.golang.org/[email protected]/server.go:1075 +0x11d

Error: The terraform-provider-hpe_v1.5.0.exe plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

 

1 REPLY 1
rismoneyman
Occasional Contributor

Re: terraform provider

So I got this to work on the dev-1.6.0 branch.

However, that branch has schema issues I think if I create a VM.  If I edit a service_plan_options for say max_memory, it proposes changes to network_interfaces, labels, connection_info and volumes, and that is not in the surface area of the change.

This is not ready for actual use.

If I apply the change it seemingly does the right thing, but you can't have a plan itemizing out things that will change unnecessarily.