Let's Reconnect, thank you for making 2022 our best year yet.

Look Back
Using TF to attach block volumes over a loop — Cloud Customer Connect
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Using TF to attach block volumes over a loop

Accepted answer
edited Jun 1, 2019 8:02PM in Oracle Cloud Infrastructure - General 1 comment


I can use Terraform to create a set of identical compute instances but am struggling to attach a block volume to each


I have used Terraform's count meta-parameter to provision a set of indentical compute instances:

resource "oci_core_instance" "myserver" {
count = "${var.qty_servers}"
display_name = "myserver${count.index}" ...

I have also used the same approach to create a block storage volume for each.

However I now need to attach the instance's extra volume to each instance. I'm trying something like this:

resource "oci_core_volume_attachment" "data-01" {
count = "${var.qty_servers}"
attachment_type = "paravirtualized"
instance_id = "${oci_core_instance.myserver.*.id}"

Howdy, Stranger!

Log In

To view full details, sign in.


Don't have an account? Click here to get started!