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

Enable creation of resource under non-default container path #67

Open scross01 opened 7 years ago

scross01 commented 7 years ago

Terraform Version

terraform v0.10.0 opc provider v0.1.2

Affected Resource(s)

All resources

The opc provider currently creates all resources under the users specific container e.g. for a user with ID user@example.com all resources will be created under /Compute-mydomain/user@example.com. This matches the compute console UI behavior, however using the APIs it's possible to create resources under a custom container. Terraform provider also need to support this behavior

e.g. explicitly setting the name of the resource to name = "/Compute-mydomain/mycontainer/myresource" should create the resource under the specifically named container path. Omitting the fully qualified container path would revert to using the default user id based container.

Example config:

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

resource "opc_compute_storage_volume" "volume1" {
  size             = "12"
  description      = "Example bootable storage volume"
  name             = "/Compute-${var.domain}/mycontainer/boot-from-storage-example"
  bootable         = true
  image_list       = "/oracle/public/OL_6.8_UEKR3_x86_64"
  image_list_entry = 3
}

resource "opc_compute_instance" "instance1" {
  name  = "/Compute-${var.domain}/mycontainer/boot-from-storage-instance1"
  label = "Example instance with bootable storage"
  shape = "oc3"

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

  boot_order = [1]
}
scross01 commented 7 years ago

For discussion: alternative could be to explicitly add container_path as an optional attribute to all resources. Plus all resources should probably have separate attributes to distinguish between the fully qualified name /Compute-mydomain/mycontainer/myresourcename and just the name part myresourcename

cameronsenese commented 6 years ago

For discussion: alternative could be to explicitly add container_path as an optional attribute to all resources. Plus all resources should probably have separate attributes to distinguish between the fully qualified name /Compute-mydomain/mycontainer/myresourcename and just the name part myresourcename

This would be excellent. Classic IaaS can recreate (delete then create) instances in certain circumstances where an object is provisioned by one user (using user's specific container), and is then updated by another - for example attaching an additional storage volume to a compute instance. Ability to provision resources using custom/generic resource containers would be a great help in avoiding this problem.