diff --git a/builtin/providers/openstack/resource_openstack_compute_instance_v2.go b/builtin/providers/openstack/resource_openstack_compute_instance_v2.go index 7d4bafaff..5fb2be254 100644 --- a/builtin/providers/openstack/resource_openstack_compute_instance_v2.go +++ b/builtin/providers/openstack/resource_openstack_compute_instance_v2.go @@ -114,26 +114,31 @@ func resourceComputeInstanceV2() *schema.Resource { "uuid": &schema.Schema{ Type: schema.TypeString, Optional: true, + ForceNew: true, Computed: true, }, "name": &schema.Schema{ Type: schema.TypeString, Optional: true, + ForceNew: true, Computed: true, }, "port": &schema.Schema{ Type: schema.TypeString, Optional: true, + ForceNew: true, Computed: true, }, "fixed_ip_v4": &schema.Schema{ Type: schema.TypeString, Optional: true, + ForceNew: true, Computed: true, }, "fixed_ip_v6": &schema.Schema{ Type: schema.TypeString, Optional: true, + ForceNew: true, Computed: true, }, "floating_ip": &schema.Schema{ diff --git a/builtin/providers/openstack/resource_openstack_compute_instance_v2_test.go b/builtin/providers/openstack/resource_openstack_compute_instance_v2_test.go index b87e80757..0ba4817e5 100644 --- a/builtin/providers/openstack/resource_openstack_compute_instance_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_compute_instance_v2_test.go @@ -557,6 +557,53 @@ func TestAccComputeV2Instance_accessIPv4(t *testing.T) { }) } +func TestAccComputeV2Instance_ChangeFixedIP(t *testing.T) { + var instance1_1 servers.Server + var instance1_2 servers.Server + var testAccComputeV2Instance_ChangeFixedIP_1 = fmt.Sprintf(` + resource "openstack_compute_instance_v2" "instance_1" { + name = "instance_1" + security_groups = ["default"] + network { + uuid = "%s" + fixed_ip_v4 = "10.0.0.24" + } + }`, + os.Getenv("OS_NETWORK_ID")) + + var testAccComputeV2Instance_ChangeFixedIP_2 = fmt.Sprintf(` + resource "openstack_compute_instance_v2" "instance_1" { + name = "instance_1" + security_groups = ["default"] + network { + uuid = "%s" + fixed_ip_v4 = "10.0.0.25" + } + }`, + os.Getenv("OS_NETWORK_ID")) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckComputeV2InstanceDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccComputeV2Instance_ChangeFixedIP_1, + Check: resource.ComposeTestCheckFunc( + testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.instance_1", &instance1_1), + ), + }, + resource.TestStep{ + Config: testAccComputeV2Instance_ChangeFixedIP_2, + Check: resource.ComposeTestCheckFunc( + testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.instance_1", &instance1_2), + testAccCheckComputeV2InstanceInstanceIDsDoNotMatch(&instance1_1, &instance1_2), + ), + }, + }, + }) +} + func testAccCheckComputeV2InstanceDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) computeClient, err := config.computeV2Client(OS_REGION_NAME) @@ -726,6 +773,15 @@ func testAccCheckComputeV2InstanceFloatingIPAttach( } return fmt.Errorf("Floating IP %s was not attached to instance %s", fip.ID, instance.ID) - + } +} +func testAccCheckComputeV2InstanceInstanceIDsDoNotMatch( + instance1, instance2 *servers.Server) resource.TestCheckFunc { + return func(s *terraform.State) error { + if instance1.ID == instance2.ID { + return fmt.Errorf("Instance was not recreated.") + } + + return nil } } diff --git a/website/source/docs/providers/openstack/r/compute_instance_v2.html.markdown b/website/source/docs/providers/openstack/r/compute_instance_v2.html.markdown index 8baf17a54..52e545f5f 100644 --- a/website/source/docs/providers/openstack/r/compute_instance_v2.html.markdown +++ b/website/source/docs/providers/openstack/r/compute_instance_v2.html.markdown @@ -267,16 +267,19 @@ The following arguments are supported: The `network` block supports: * `uuid` - (Required unless `port` or `name` is provided) The network UUID to - attach to the server. + attach to the server. Changing this creates a new server. * `name` - (Required unless `uuid` or `port` is provided) The human-readable - name of the network. + name of the network. Changing this creates a new server. * `port` - (Required unless `uuid` or `name` is provided) The port UUID of a - network to attach to the server. + network to attach to the server. Changing this creates a new server. * `fixed_ip_v4` - (Optional) Specifies a fixed IPv4 address to be used on this - network. + network. Changing this creates a new server. + +* `fixed_ip_v6` - (Optional) Specifies a fixed IPv6 address to be used on this + network. Changing this creates a new server. * `floating_ip` - (Optional) Specifies a floating IP address to be associated with this network. Cannot be combined with a top-level floating IP. See