github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/openstack/r/compute_floatingip_associate_v2.html.markdown (about)

     1  ---
     2  layout: "openstack"
     3  page_title: "OpenStack: openstack_compute_floatingip_associate_v2"
     4  sidebar_current: "docs-openstack-resource-compute-floatingip-associate-v2"
     5  description: |-
     6    Associate a floating IP to an instance
     7  ---
     8  
     9  # openstack\_compute\_floatingip_associate_v2
    10  
    11  Associate a floating IP to an instance. This can be used instead of the
    12  `floating_ip` options in `openstack_compute_instance_v2`.
    13  
    14  ## Example Usage
    15  
    16  ### Automatically detect the correct network
    17  
    18  ```hcl
    19  resource "openstack_compute_instance_v2" "instance_1" {
    20    name            = "instance_1"
    21    image_id        = "ad091b52-742f-469e-8f3c-fd81cadf0743"
    22    flavor_id       = 3
    23    key_pair        = "my_key_pair_name"
    24    security_groups = ["default"]
    25  }
    26  
    27  resource "openstack_networking_floatingip_v2" "fip_1" {
    28    pool = "my_pool"
    29  }
    30  
    31  resource "openstack_compute_floatingip_associate_v2" "fip_1" {
    32    floating_ip = "${openstack_networking_floatingip_v2.fip_1.address}"
    33    instance_id = "${openstack_compute_instance_v2.instance_1.id}"
    34  }
    35  ```
    36  
    37  ### Explicitly set the network to attach to
    38  
    39  ```hcl
    40  resource "openstack_compute_instance_v2" "instance_1" {
    41    name            = "instance_1"
    42    image_id        = "ad091b52-742f-469e-8f3c-fd81cadf0743"
    43    flavor_id       = 3
    44    key_pair        = "my_key_pair_name"
    45    security_groups = ["default"]
    46  
    47    network {
    48      name = "my_network"
    49    }
    50  
    51    network {
    52      name = "default"
    53    }
    54  }
    55  
    56  resource "openstack_networking_floatingip_v2" "fip_1" {
    57    pool = "my_pool"
    58  }
    59  
    60  resource "openstack_compute_floatingip_associate_v2" "fip_1" {
    61    floating_ip = "${openstack_networking_floatingip_v2.fip_1.address}"
    62    instance_id = "${openstack_compute_instance_v2.instance_1.id}"
    63    fixed_ip    = "${openstack_compute_instance_v2.instance_1.network.1.fixed_ip_v4}"
    64  }
    65  ```
    66  
    67  ## Argument Reference
    68  
    69  The following arguments are supported:
    70  
    71  * `region` - (Required) The region in which to obtain the V2 Compute client.
    72      Keypairs are associated with accounts, but a Compute client is needed to
    73      create one. If omitted, the `OS_REGION_NAME` environment variable is used.
    74      Changing this creates a new floatingip_associate.
    75  
    76  * `floating_ip` - (Required) The floating IP to associate.
    77  
    78  * `instance_id` - (Required) The instance to associte the floating IP with.
    79  
    80  * `fixed_ip` - (Optional) The specific IP address to direct traffic to.
    81  
    82  ## Attributes Reference
    83  
    84  The following attributes are exported:
    85  
    86  * `region` - See Argument Reference above.
    87  * `floating_ip` - See Argument Reference above.
    88  * `instance_id` - See Argument Reference above.
    89  * `fixed_ip` - See Argument Reference above.
    90  
    91  ## Import
    92  
    93  This resource can be imported by specifying all three arguments, separated
    94  by a forward slash:
    95  
    96  ```
    97  $ terraform import openstack_compute_floatingip_associate_v2.fip_1 <floating_ip>/<instance_id>/<fixed_ip>
    98  ```