terraform-providers / terraform-provider-opc

Terraform Oracle Public Cloud provider
https://www.terraform.io/docs/providers/opc/
Mozilla Public License 2.0
29 stars 25 forks source link

userdata for opc_compute_orchestrated_instance #150

Closed tseoracle closed 5 years ago

tseoracle commented 6 years ago

Hi there, We want to use "userdata" feature on the Instance created by opc_compute_orchestrated_instance resource. How can we do it?

Terraform Version

Terraform v0.11.7 terraform-provider-opc_v1.1.2_x4

Affected Resource(s)

opc_compute_orchestrated_instance

Panic Output

None

Expected Behavior

"userdata" works on orchestrated Instance.

Actual Behavior

Cannot set "userdata" Error: opc_compute_orchestrated_instance.name: "instance.0.instance_attributes": this field cannot be set.

What actually happened?

The document, https://www.terraform.io/docs/providers/opc/r/opc_compute_orchestrated_instance.html, said "Instance Instance supports the arguments found in opc_compute_instance and the following:" and opc_compute_instance (https://www.terraform.io/docs/providers/opc/r/opc_compute_instance.html) have "instance_attributes" parameter where we would set "userdata". But "instance_attributes" cannot be used.

Steps to Reproduce

terraform apply these codes. resource "opc_compute_orchestrated_instance" "default" { ... instance { instance_attributes = ... } }

Important Factoids

References

scross01 commented 6 years ago

@mbfrahry can you take a look at this.

mtjakobczyk commented 5 years ago

Hi, we are exepriencing the same issue with 1.3.2 Error: opc_compute_orchestrated_instance.devkubeworker1: "instance.0.instance_attributes": this field cannot be set Could you issue a fix? Thanks! Michal

scross01 commented 5 years ago

The following example reproduces the issue. The same configuration in an opc_compute_instance resource works okay.

variable "user" {}
variable "password" {}
variable "domain" {}
variable "endpoint" {}

provider "opc" {
  user            = "${var.user}"
  password        = "${var.password}"
  identity_domain = "${var.domain}"
  endpoint        = "${var.endpoint}"
}

resource "opc_compute_ip_reservation" "orchestration-test" {
  name        = "orchestration-test"
  parent_pool = "/oracle/public/ippool"
  permanent   = true
}

resource "opc_compute_storage_volume" "boot-volume" {
  size             = "12"
  name             = "orchestration-test-boot-storage"
  bootable         = true
  image_list       = "/oracle/public/OL_7.2_UEKR4_x86_64"
  image_list_entry = 1
}

resource "opc_compute_ssh_key" "sshkey" {
  name    = "orchestration-test"
  key     = "${file("~/.ssh/id_rsa.pub")}"
  enabled = true
}

resource "opc_compute_orchestrated_instance" "orchestrated-instance-test" {
  name          = "orchestrated-instance-test"
  description   = "orchestrated-instance-test"
  desired_state = "active"

  instance {
    name       = "orchestration-test"
    hostname   = "orchestration-test"
    label      = "orchestration-test"
    image_list = "/oracle/public/OL_7.2_UEKR4_x86_64"
    shape      = "oc3"
    ssh_keys   = ["${opc_compute_ssh_key.sshkey.name}"]

    instance_attributes = <<JSON
{
  "userdata": {
    "pre-bootstrap": {
      "script": [
        "echo 'This instance was provisioned by Terraform.' >> /etc/motd"
      ]
    }
  }
}
JSON

    networking_info {
      index          = 0
      nat            = ["${opc_compute_ip_reservation.orchestration-test.name}"]
      shared_network = true
    }

    storage {
      index  = 1
      volume = "${opc_compute_storage_volume.boot-volume.name}"
    }

    boot_order = [1]
  }
}

output "public_ip_address" {
  value = "${opc_compute_ip_reservation.orchestration-test.ip}"
}
$ terraform plan

Error: opc_compute_orchestrated_instance.orchestrated-instance-test: "instance.0.instance_attributes": this field cannot be set
mbfrahry commented 5 years ago

This fix has just been released in 1.3.3 of the provider. Feel free to reopen this issue if you continue to have problems!