openstack_blockstorage_volume_attach_v2

Creates a general purpose attachment connection to a Block Storage volume using the OpenStack Block Storage (Cinder) v2 API.

Depending on your Block Storage service configuration, this resource can assist in attaching a volume to a non-OpenStack resource such as a bare-metal server or a remote virtual machine in a different cloud provider.

Example Usage

resource "openstack_blockstorage_volume_v2" "volume_1" {
  name = "volume_1"
  size = 1
}

resource "openstack_blockstorage_volume_attach_v2" "va_1" {
  volume_id  = openstack_blockstorage_volume_v2.volume_1.id
  device     = "auto"
  host_name  = "devstack"
  ip_address = "192.168.255.10"
  initiator  = "iqn.1993-08.org.debian:01:e9861fb1859"
  os_type    = "linux2"
  platform   = "x86_64"
}

Argument Reference

The following arguments are supported:

Attributes Reference

In addition to the above, the following attributes are exported:

Volume Connection Data

Upon creation of this resource, a data exported attribute will be available. This attribute is a set of key/value pairs that contains the information required to complete the block storage connection.

As an example, creating an iSCSI-based volume will return the following:

data.access_mode = rw
data.auth_method = CHAP
data.auth_password = xUhbGKQ8QCwKmHQ2
data.auth_username = Sphn5X4EoyFUUMYVYSA4
data.target_iqn = iqn.2010-10.org.openstack:volume-2d87ed25-c312-4f42-be1d-3b36b014561d
data.target_portal = 192.168.255.10:3260
data.volume_id = 2d87ed25-c312-4f42-be1d-3b36b014561d

This information can then be fed into a provisioner or a template shell script, where the final result would look something like:

iscsiadm -m node -T ${self.data.target_iqn} -p ${self.data.target_portal} --interface default --op new
iscsiadm -m node -T ${self.data.target_iqn} -p ${self.data.target_portal} --op update -n node.session.auth.authmethod -v ${self.data.auth_method}
iscsiadm -m node -T ${self.data.target_iqn} -p ${self.data.target_portal} --op update -n node.session.auth.username -v ${self.data.auth_username}
iscsiadm -m node -T ${self.data.target_iqn} -p ${self.data.target_portal} --op update -n node.session.auth.password -v ${self.data.auth_password}
iscsiadm -m node -T ${self.data.target_iqn} -p ${self.data.target_portal} --login
iscsiadm -m node -T ${self.data.target_iqn} -p ${self.data.target_portal} --op update -n node.startup -v automatic
iscsiadm -m node -T ${self.data.target_iqn} -p ${self.data.target_portal} --rescan

The contents of data will vary from each Block Storage service. You must have a good understanding of how the service is configured and how to make the appropriate final connection. However, if used correctly, this has the flexibility to be able to attach OpenStack Block Storage volumes to non-OpenStack resources.

Import

It is not possible to import this resource.