TritonDataCenter / terraform-provider-triton

Terraform Joyent Triton provider
https://www.terraform.io/docs/providers/triton/
Mozilla Public License 2.0
15 stars 24 forks source link

Networks attribute missing from tfstate file when importing existing machine. #115

Open amalleo25 opened 6 years ago

amalleo25 commented 6 years ago

Hello,

When using "terraform import" on an already existing machine, the "networks" attribute is not created in the terraform.tfstate file. This causes terraform to think that the network needs to modified upon running "terraform plan".

Terraform Version

Terraform version: 0.11.7 Triton provider: 0.5.1

Terraform Configuration Files

provider "triton" {
  account = "omitted"
  key_material = "/root/.ssh/id_rsa"
  key_id = "omitted"
  url = "omitted"
  insecure_skip_tls_verify = "true"
}

resource "triton_machine" "network-test4" {
  name                 = "network-test4"
  package              = "sdc_512"
  image                = "63d6e664-3f1f-11e8-aef6-a3120cf8dd9d"
  networks             = ["bedef3af-49b1-445c-b3ac-0b7f0112afcf"]
}

Terraform.tfstate file: https://gist.github.com/amalleo25/ed6400e04d1a5300d8d9458b5b4eb0c1#file-terraform-tfstate

Debug Output

https://gist.github.com/amalleo25/226b93c44873d9197d5f2eeb90b40f64#file-terraform-debug-txt

Expected Behavior

Terraform should pull the networks attribute similar to how the nic attributes are created on import.

Actual Behavior

Terraform does not currently create a networks attribute which causes terraform to report that it will modify the network when running "terraform plan". These are snippets from debug output:

Terraform will perform the following actions:

  ~ triton_machine.network-test4
      networks.#: "0" => "1"
      networks.0: "" => "bedef3af-49b1-445c-b3ac-0b7f0112afcf"

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

triton_machine.network-test4: Modifying... (ID: 3773107d-8396-e319-820f-f17448ecd7b3)
  networks.#: "0" => "1"
  networks.0: "" => "bedef3af-49b1-445c-b3ac-0b7f0112afcf"

Error: Error applying plan:

1 error(s) occurred:

* triton_machine.network-test4: 1 error(s) occurred:

* triton_machine.network-test4: unable to add NIC to machine: unable to decode error response: EOF

Steps to Reproduce

  1. terraform import triton_machine.network-test4 3773107d-8396-e319-820f-f17448ecd7b3
  2. terraform plan
  3. terraform apply

Important Factoids

This is on a private instance of triton not the triton public cloud.

Thank you.