diff --git a/digitalocean/reservedip/resource_reserved_ip_assignment_test.go b/digitalocean/reservedip/resource_reserved_ip_assignment_test.go index 1b593b05a..a7aea2b55 100644 --- a/digitalocean/reservedip/resource_reserved_ip_assignment_test.go +++ b/digitalocean/reservedip/resource_reserved_ip_assignment_test.go @@ -202,7 +202,7 @@ resource "digitalocean_reserved_ip_assignment" "foobar" { var testAccCheckDigitalOceanReservedIPAssignmentConfig_createBeforeDestroyReassign = ` resource "digitalocean_droplet" "foobar" { - image = "ubuntu-18-04-x64" + image = "ubuntu-22-04-x64" name = "tf-acc-test-01" region = "nyc3" size = "s-1vcpu-1gb" diff --git a/digitalocean/reservedipv6/datasource_reserved_ipv6.go b/digitalocean/reservedipv6/datasource_reserved_ipv6.go index 07d704c1c..81efa3250 100644 --- a/digitalocean/reservedipv6/datasource_reserved_ipv6.go +++ b/digitalocean/reservedipv6/datasource_reserved_ipv6.go @@ -32,7 +32,7 @@ func DataSourceDigitalOceanReservedIPV6() *schema.Resource { "droplet_id": { Type: schema.TypeInt, Computed: true, - Description: "the droplet id that the reserved ip has been assigned to.", + Description: "the droplet id that the reserved ipv6 has been assigned to.", }, }, } diff --git a/digitalocean/reservedipv6/import_reserved_ipv6_test.go b/digitalocean/reservedipv6/import_reserved_ipv6_test.go index 93c3d61b8..b297e7090 100644 --- a/digitalocean/reservedipv6/import_reserved_ipv6_test.go +++ b/digitalocean/reservedipv6/import_reserved_ipv6_test.go @@ -27,25 +27,3 @@ func TestAccDigitalOceanReservedIPV6_importBasicRegion(t *testing.T) { }, }) } - -func TestAccDigitalOceanReservedIPV6_importBasicDroplet(t *testing.T) { - resourceName := "digitalocean_reserved_ipv6.foobar" - name := acceptance.RandomTestName() - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.TestAccPreCheck(t) }, - ProviderFactories: acceptance.TestAccProviderFactories, - CheckDestroy: testAccCheckDigitalOceanReservedIPV6Destroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckDigitalOceanReservedIPV6Config_droplet(name), - }, - - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/digitalocean/reservedipv6/resource_reserved_ipv6_assignment.go b/digitalocean/reservedipv6/resource_reserved_ipv6_assignment.go index 9cadfb086..f5fb427dd 100644 --- a/digitalocean/reservedipv6/resource_reserved_ipv6_assignment.go +++ b/digitalocean/reservedipv6/resource_reserved_ipv6_assignment.go @@ -56,13 +56,14 @@ func resourceDigitalOceanReservedIPV6AssignmentCreate(ctx context.Context, d *sc "Error Assigning reserved IPv6 (%s) to the droplet: %s", ipAddress, err) } - _, unassignedErr := waitForReservedIPV6AssignmentReady(ctx, d, "completed", []string{"new", "in-progress"}, "status", meta, action.ID) - if unassignedErr != nil { + _, assignedErr := waitForReservedIPV6AssignmentReady(ctx, d, "completed", []string{"new", "in-progress"}, "status", meta, action.ID) + if assignedErr != nil { return diag.Errorf( - "Error waiting for reserved IPv6 (%s) to be Assigned: %s", ipAddress, unassignedErr) + "Error waiting for reserved IPv6 (%s) to be Assigned: %s", ipAddress, assignedErr) } d.SetId(id.PrefixedUniqueId(fmt.Sprintf("%d-%s-", dropletID, ipAddress))) + return resourceDigitalOceanReservedIPV6AssignmentRead(ctx, d, meta) } @@ -79,8 +80,8 @@ func resourceDigitalOceanReservedIPV6AssignmentRead(ctx context.Context, d *sche } if reservedIPv6.Droplet == nil || reservedIPv6.Droplet.ID != dropletID { - log.Printf("[INFO] A Droplet was detected on the reserved IPv6.") - d.SetId("") + // log.Printf("[INFO] Droplet assignment was unsuccessful on the reserved IPv6.") + return diag.Errorf("Error assigning reserved IPv6 %s to dropletID %d", ipAddress, dropletID) } return nil diff --git a/digitalocean/reservedipv6/resource_reserved_ipv6_assignment_test.go b/digitalocean/reservedipv6/resource_reserved_ipv6_assignment_test.go index fab804c09..4348d9e2a 100644 --- a/digitalocean/reservedipv6/resource_reserved_ipv6_assignment_test.go +++ b/digitalocean/reservedipv6/resource_reserved_ipv6_assignment_test.go @@ -27,21 +27,12 @@ func TestAccDigitalOceanReservedIPV6Assignment(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDigitalOceanReservedIPV6AttachmentExists("digitalocean_reserved_ipv6_assignment.foobar"), resource.TestMatchResourceAttr( - "digitalocean_reserved_ipv6_assignment.foobar", "id", regexp.MustCompile(ipv6Regex)), - resource.TestMatchResourceAttr( - "digitalocean_reserved_ipv6_assignment.foobar", "droplet_id", regexp.MustCompile("[0-9]+")), - ), - }, - { - Config: testAccCheckDigitalOceanReservedIPV6AssignmentReassign, - Check: resource.ComposeTestCheckFunc( - testAccCheckDigitalOceanReservedIPV6AttachmentExists("digitalocean_reserved_ipv6_assignment.foobar"), - resource.TestMatchResourceAttr( - "digitalocean_reserved_ipv6_assignment.foobar", "id", regexp.MustCompile(ipv6Regex)), + "digitalocean_reserved_ipv6_assignment.foobar", "ip", regexp.MustCompile(ipv6Regex)), resource.TestMatchResourceAttr( "digitalocean_reserved_ipv6_assignment.foobar", "droplet_id", regexp.MustCompile("[0-9]+")), ), }, + { Config: testAccCheckDigitalOceanReservedIPV6AssignmentDeleteAssignment, Check: resource.ComposeTestCheckFunc( @@ -65,17 +56,7 @@ func TestAccDigitalOceanReservedIPV6Assignment_createBeforeDestroy(t *testing.T) Check: resource.ComposeTestCheckFunc( testAccCheckDigitalOceanReservedIPV6AttachmentExists("digitalocean_reserved_ipv6_assignment.foobar"), resource.TestMatchResourceAttr( - "digitalocean_reserved_ipv6_assignment.foobar", "id", regexp.MustCompile(ipv6Regex)), - resource.TestMatchResourceAttr( - "digitalocean_reserved_ipv6_assignment.foobar", "droplet_id", regexp.MustCompile("[0-9]+")), - ), - }, - { - Config: testAccCheckDigitalOceanReservedIPV6AssignmentConfig_createBeforeDestroyReassign, - Check: resource.ComposeTestCheckFunc( - testAccCheckDigitalOceanReservedIPV6AttachmentExists("digitalocean_reserved_ipv6_assignment.foobar"), - resource.TestMatchResourceAttr( - "digitalocean_reserved_ipv6_assignment.foobar", "id", regexp.MustCompile(ipv6Regex)), + "digitalocean_reserved_ipv6_assignment.foobar", "ip", regexp.MustCompile(ipv6Regex)), resource.TestMatchResourceAttr( "digitalocean_reserved_ipv6_assignment.foobar", "droplet_id", regexp.MustCompile("[0-9]+")), ), @@ -91,10 +72,10 @@ func testAccCheckDigitalOceanReservedIPV6AttachmentExists(n string) resource.Tes return fmt.Errorf("Not found: %s", n) } - if rs.Primary.Attributes["ip_address"] == "" { - return fmt.Errorf("No floating IP is set") + if rs.Primary.Attributes["ip"] == "" { + return fmt.Errorf("No reserved IPv6 is set") } - fipID := rs.Primary.Attributes["ip_address"] + fipID := rs.Primary.Attributes["ip"] dropletID, err := strconv.Atoi(rs.Primary.Attributes["droplet_id"]) if err != nil { return err @@ -102,7 +83,7 @@ func testAccCheckDigitalOceanReservedIPV6AttachmentExists(n string) resource.Tes client := acceptance.TestAccProvider.Meta().(*config.CombinedConfig).GodoClient() - // Try to find the ReservedIP + // Try to find the ReservedIPv6 foundReservedIP, _, err := client.ReservedIPV6s.Get(context.Background(), fipID) if err != nil { return err @@ -122,7 +103,7 @@ resource "digitalocean_reserved_ipv6" "foobar" { } resource "digitalocean_droplet" "foobar" { - count = 2 + count = 1 name = "tf-acc-test-${count.index}" size = "s-1vcpu-1gb" image = "ubuntu-22-04-x64" @@ -136,33 +117,13 @@ resource "digitalocean_reserved_ipv6_assignment" "foobar" { } ` -var testAccCheckDigitalOceanReservedIPV6AssignmentReassign = ` -resource "digitalocean_reserved_ipv6" "foobar" { - region_slug = "nyc3" -} - -resource "digitalocean_droplet" "foobar" { - count = 2 - name = "tf-acc-test-${count.index}" - size = "s-1vcpu-1gb" - image = "ubuntu-22-04-x64" - region = "nyc3" - ipv6 = true -} - -resource "digitalocean_reserved_ipv6_assignment" "foobar" { - ip = digitalocean_reserved_ipv6.foobar.ip - droplet_id = digitalocean_droplet.foobar.1.id -} -` - var testAccCheckDigitalOceanReservedIPV6AssignmentDeleteAssignment = ` resource "digitalocean_reserved_ipv6" "foobar" { region_slug = "nyc3" } resource "digitalocean_droplet" "foobar" { - count = 2 + count = 1 name = "tf-acc-test-${count.index}" size = "s-1vcpu-1gb" image = "ubuntu-22-04-x64" @@ -197,29 +158,3 @@ resource "digitalocean_reserved_ipv6_assignment" "foobar" { } } ` - -var testAccCheckDigitalOceanReservedIPV6AssignmentConfig_createBeforeDestroyReassign = ` -resource "digitalocean_droplet" "foobar" { - image = "ubuntu-18-04-x64" - name = "tf-acc-test-01" - region = "nyc3" - size = "s-1vcpu-1gb" - - lifecycle { - create_before_destroy = true - } -} - -resource "digitalocean_reserved_ipv6" "foobar" { - region_slug = "nyc3" -} - -resource "digitalocean_reserved_ipv6_assignment" "foobar" { - ip = digitalocean_reserved_ipv6.foobar.ip - droplet_id = digitalocean_droplet.foobar.id - - lifecycle { - create_before_destroy = true - } -} -` diff --git a/digitalocean/reservedipv6/resource_reserved_ipv6_test.go b/digitalocean/reservedipv6/resource_reserved_ipv6_test.go index cb8f826e0..77658bfa5 100644 --- a/digitalocean/reservedipv6/resource_reserved_ipv6_test.go +++ b/digitalocean/reservedipv6/resource_reserved_ipv6_test.go @@ -133,10 +133,10 @@ resource "digitalocean_reserved_ipv6" "foobar" { func testAccCheckDigitalOceanReservedIPV6Config_droplet(name string) string { return fmt.Sprintf(` resource "digitalocean_droplet" "foobar" { - name = "%s" - size = "s-1vcpu-1gb" - image = "ubuntu-22-04-x64" - region = "nyc3" + name = "%s" + size = "s-1vcpu-1gb" + image = "ubuntu-22-04-x64" + region = "nyc3" ipv6 = true private_networking = true } @@ -150,10 +150,10 @@ resource "digitalocean_reserved_ipv6" "foobar" { func testAccCheckDigitalOceanReservedIPv6Config_Reassign(name string) string { return fmt.Sprintf(` resource "digitalocean_droplet" "baz" { - name = "%s" - size = "s-1vcpu-1gb" - image = "ubuntu-22-04-x64" - region = "nyc3" + name = "%s" + size = "s-1vcpu-1gb" + image = "ubuntu-22-04-x64" + region = "nyc3" ipv6 = true private_networking = true }