2014-07-19 02:20:28 +02:00
|
|
|
package digitalocean
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-09-27 06:06:51 +02:00
|
|
|
"strconv"
|
2014-07-19 02:20:28 +02:00
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
"github.com/digitalocean/godo"
|
2014-07-19 02:20:28 +02:00
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
2014-07-19 18:33:25 +02:00
|
|
|
func TestAccDigitalOceanDroplet_Basic(t *testing.T) {
|
2015-09-27 06:06:51 +02:00
|
|
|
var droplet godo.Droplet
|
2014-07-19 02:20:28 +02:00
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
|
|
|
Config: testAccCheckDigitalOceanDropletConfig_basic,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &droplet),
|
|
|
|
testAccCheckDigitalOceanDropletAttributes(&droplet),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"digitalocean_droplet.foobar", "name", "foo"),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"digitalocean_droplet.foobar", "size", "512mb"),
|
|
|
|
resource.TestCheckResourceAttr(
|
2016-08-08 02:08:37 +02:00
|
|
|
"digitalocean_droplet.foobar", "image", "centos-7-x64"),
|
2014-07-19 02:20:28 +02:00
|
|
|
resource.TestCheckResourceAttr(
|
2014-09-05 17:16:12 +02:00
|
|
|
"digitalocean_droplet.foobar", "region", "nyc3"),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"digitalocean_droplet.foobar", "user_data", "foobar"),
|
2014-07-19 02:20:28 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-19 18:33:25 +02:00
|
|
|
func TestAccDigitalOceanDroplet_Update(t *testing.T) {
|
2015-09-27 06:06:51 +02:00
|
|
|
var droplet godo.Droplet
|
2014-07-19 18:33:25 +02:00
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
|
|
|
Config: testAccCheckDigitalOceanDropletConfig_basic,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &droplet),
|
|
|
|
testAccCheckDigitalOceanDropletAttributes(&droplet),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
|
|
|
|
resource.TestStep{
|
|
|
|
Config: testAccCheckDigitalOceanDropletConfig_RenameAndResize,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &droplet),
|
|
|
|
testAccCheckDigitalOceanDropletRenamedAndResized(&droplet),
|
|
|
|
resource.TestCheckResourceAttr(
|
2014-07-21 17:05:24 +02:00
|
|
|
"digitalocean_droplet.foobar", "name", "baz"),
|
2014-07-19 18:33:25 +02:00
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"digitalocean_droplet.foobar", "size", "1gb"),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-11-03 21:53:54 +01:00
|
|
|
func TestAccDigitalOceanDroplet_UpdateUserData(t *testing.T) {
|
2015-11-04 22:20:52 +01:00
|
|
|
var afterCreate, afterUpdate godo.Droplet
|
2015-11-03 21:53:54 +01:00
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
|
|
|
Config: testAccCheckDigitalOceanDropletConfig_basic,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
2015-11-04 22:20:52 +01:00
|
|
|
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &afterCreate),
|
|
|
|
testAccCheckDigitalOceanDropletAttributes(&afterCreate),
|
2015-11-03 21:53:54 +01:00
|
|
|
),
|
|
|
|
},
|
|
|
|
|
|
|
|
resource.TestStep{
|
|
|
|
Config: testAccCheckDigitalOceanDropletConfig_userdata_update,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
2015-11-04 22:20:52 +01:00
|
|
|
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &afterUpdate),
|
2015-11-03 21:53:54 +01:00
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"digitalocean_droplet.foobar",
|
|
|
|
"user_data",
|
|
|
|
"foobar foobar"),
|
2015-11-04 22:20:52 +01:00
|
|
|
testAccCheckDigitalOceanDropletRecreated(
|
|
|
|
t, &afterCreate, &afterUpdate),
|
2015-11-03 21:53:54 +01:00
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-07-11 13:09:06 +02:00
|
|
|
func TestAccDigitalOceanDroplet_UpdateTags(t *testing.T) {
|
|
|
|
var afterCreate, afterUpdate godo.Droplet
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
|
|
|
Config: testAccCheckDigitalOceanDropletConfig_basic,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &afterCreate),
|
|
|
|
testAccCheckDigitalOceanDropletAttributes(&afterCreate),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
|
|
|
|
resource.TestStep{
|
|
|
|
Config: testAccCheckDigitalOceanDropletConfig_tag_update,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &afterUpdate),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"digitalocean_droplet.foobar",
|
|
|
|
"tags.#",
|
|
|
|
"1"),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"digitalocean_droplet.foobar",
|
|
|
|
"tags.0",
|
|
|
|
"barbaz"),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-30 00:58:48 +02:00
|
|
|
func TestAccDigitalOceanDroplet_PrivateNetworkingIpv6(t *testing.T) {
|
2015-09-27 06:06:51 +02:00
|
|
|
var droplet godo.Droplet
|
2014-07-30 00:58:48 +02:00
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
|
|
|
Config: testAccCheckDigitalOceanDropletConfig_PrivateNetworkingIpv6,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &droplet),
|
|
|
|
testAccCheckDigitalOceanDropletAttributes_PrivateNetworkingIpv6(&droplet),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"digitalocean_droplet.foobar", "private_networking", "true"),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"digitalocean_droplet.foobar", "ipv6", "true"),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-19 02:20:28 +02:00
|
|
|
func testAccCheckDigitalOceanDropletDestroy(s *terraform.State) error {
|
2015-09-27 06:06:51 +02:00
|
|
|
client := testAccProvider.Meta().(*godo.Client)
|
2014-07-19 02:20:28 +02:00
|
|
|
|
2014-09-17 02:28:22 +02:00
|
|
|
for _, rs := range s.RootModule().Resources {
|
2014-07-19 02:20:28 +02:00
|
|
|
if rs.Type != "digitalocean_droplet" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
id, err := strconv.Atoi(rs.Primary.ID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2014-07-19 02:20:28 +02:00
|
|
|
// Try to find the Droplet
|
2015-09-27 06:06:51 +02:00
|
|
|
_, _, err = client.Droplets.Get(id)
|
2014-07-19 02:20:28 +02:00
|
|
|
|
2014-07-19 15:45:42 +02:00
|
|
|
// Wait
|
2014-07-19 02:20:28 +02:00
|
|
|
|
|
|
|
if err != nil && !strings.Contains(err.Error(), "404") {
|
|
|
|
return fmt.Errorf(
|
|
|
|
"Error waiting for droplet (%s) to be destroyed: %s",
|
2014-09-17 02:28:22 +02:00
|
|
|
rs.Primary.ID, err)
|
2014-07-19 02:20:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
func testAccCheckDigitalOceanDropletAttributes(droplet *godo.Droplet) resource.TestCheckFunc {
|
2014-07-19 02:20:28 +02:00
|
|
|
return func(s *terraform.State) error {
|
|
|
|
|
2016-08-08 02:08:37 +02:00
|
|
|
if droplet.Image.Slug != "centos-7-x64" {
|
2015-09-27 06:06:51 +02:00
|
|
|
return fmt.Errorf("Bad image_slug: %s", droplet.Image.Slug)
|
2014-07-19 02:20:28 +02:00
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
if droplet.Size.Slug != "512mb" {
|
|
|
|
return fmt.Errorf("Bad size_slug: %s", droplet.Size.Slug)
|
2014-07-19 02:20:28 +02:00
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
if droplet.Region.Slug != "nyc3" {
|
|
|
|
return fmt.Errorf("Bad region_slug: %s", droplet.Region.Slug)
|
2014-07-19 02:20:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if droplet.Name != "foo" {
|
|
|
|
return fmt.Errorf("Bad name: %s", droplet.Name)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
func testAccCheckDigitalOceanDropletRenamedAndResized(droplet *godo.Droplet) resource.TestCheckFunc {
|
2014-07-19 18:33:25 +02:00
|
|
|
return func(s *terraform.State) error {
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
if droplet.Size.Slug != "1gb" {
|
2014-11-02 23:48:40 +01:00
|
|
|
return fmt.Errorf("Bad size_slug: %s", droplet.SizeSlug)
|
2014-07-19 18:33:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if droplet.Name != "baz" {
|
|
|
|
return fmt.Errorf("Bad name: %s", droplet.Name)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
2014-07-30 00:58:48 +02:00
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
func testAccCheckDigitalOceanDropletAttributes_PrivateNetworkingIpv6(droplet *godo.Droplet) resource.TestCheckFunc {
|
2014-07-30 00:58:48 +02:00
|
|
|
return func(s *terraform.State) error {
|
|
|
|
|
2016-08-08 02:08:37 +02:00
|
|
|
if droplet.Image.Slug != "centos-7-x64" {
|
2015-09-27 06:06:51 +02:00
|
|
|
return fmt.Errorf("Bad image_slug: %s", droplet.Image.Slug)
|
2014-07-30 00:58:48 +02:00
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
if droplet.Size.Slug != "1gb" {
|
|
|
|
return fmt.Errorf("Bad size_slug: %s", droplet.Size.Slug)
|
2014-07-30 00:58:48 +02:00
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
if droplet.Region.Slug != "sgp1" {
|
|
|
|
return fmt.Errorf("Bad region_slug: %s", droplet.Region.Slug)
|
2014-07-30 00:58:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if droplet.Name != "baz" {
|
|
|
|
return fmt.Errorf("Bad name: %s", droplet.Name)
|
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
if findIPv4AddrByType(droplet, "private") == "" {
|
|
|
|
return fmt.Errorf("No ipv4 private: %s", findIPv4AddrByType(droplet, "private"))
|
2014-07-30 00:58:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// if droplet.IPV6Address("private") == "" {
|
|
|
|
// return fmt.Errorf("No ipv6 private: %s", droplet.IPV6Address("private"))
|
|
|
|
// }
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
if findIPv4AddrByType(droplet, "public") == "" {
|
|
|
|
return fmt.Errorf("No ipv4 public: %s", findIPv4AddrByType(droplet, "public"))
|
2014-07-30 00:58:48 +02:00
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
if findIPv6AddrByType(droplet, "public") == "" {
|
|
|
|
return fmt.Errorf("No ipv6 public: %s", findIPv6AddrByType(droplet, "public"))
|
2014-07-30 00:58:48 +02:00
|
|
|
}
|
|
|
|
|
2016-08-15 16:52:48 +02:00
|
|
|
for _, rs := range s.RootModule().Resources {
|
|
|
|
if rs.Type != "digitalocean_droplet" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if rs.Primary.Attributes["ipv6_address"] != strings.ToLower(findIPv6AddrByType(droplet, "public")) {
|
|
|
|
return fmt.Errorf("IPV6 Address should be lowercase")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-30 00:58:48 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
func testAccCheckDigitalOceanDropletExists(n string, droplet *godo.Droplet) resource.TestCheckFunc {
|
2014-07-19 02:20:28 +02:00
|
|
|
return func(s *terraform.State) error {
|
2014-09-17 02:28:22 +02:00
|
|
|
rs, ok := s.RootModule().Resources[n]
|
2014-07-19 02:20:28 +02:00
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("Not found: %s", n)
|
|
|
|
}
|
|
|
|
|
2014-09-17 02:28:22 +02:00
|
|
|
if rs.Primary.ID == "" {
|
2014-07-19 02:20:28 +02:00
|
|
|
return fmt.Errorf("No Droplet ID is set")
|
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
client := testAccProvider.Meta().(*godo.Client)
|
|
|
|
|
|
|
|
id, err := strconv.Atoi(rs.Primary.ID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2014-07-19 02:20:28 +02:00
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
// Try to find the Droplet
|
|
|
|
retrieveDroplet, _, err := client.Droplets.Get(id)
|
2014-07-19 02:20:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
if strconv.Itoa(retrieveDroplet.ID) != rs.Primary.ID {
|
2014-07-19 02:20:28 +02:00
|
|
|
return fmt.Errorf("Droplet not found")
|
|
|
|
}
|
|
|
|
|
2015-09-27 06:06:51 +02:00
|
|
|
*droplet = *retrieveDroplet
|
2014-07-19 02:20:28 +02:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-04 22:20:52 +01:00
|
|
|
func testAccCheckDigitalOceanDropletRecreated(t *testing.T,
|
|
|
|
before, after *godo.Droplet) resource.TestCheckFunc {
|
|
|
|
return func(s *terraform.State) error {
|
|
|
|
if before.ID == after.ID {
|
|
|
|
t.Fatalf("Expected change of droplet IDs, but both were %v", before.ID)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-17 18:55:45 +01:00
|
|
|
// Not sure if this check should remain here as the underlaying
|
|
|
|
// function is changed and is tested indirectly by almost all
|
|
|
|
// other test already
|
|
|
|
//
|
|
|
|
//func Test_new_droplet_state_refresh_func(t *testing.T) {
|
2015-09-27 06:06:51 +02:00
|
|
|
// droplet := godo.Droplet{
|
2014-11-17 18:55:45 +01:00
|
|
|
// Name: "foobar",
|
|
|
|
// }
|
|
|
|
// resourceMap, _ := resource_digitalocean_droplet_update_state(
|
|
|
|
// &terraform.InstanceState{Attributes: map[string]string{}}, &droplet)
|
|
|
|
//
|
|
|
|
// // See if we can access our attribute
|
|
|
|
// if _, ok := resourceMap.Attributes["name"]; !ok {
|
|
|
|
// t.Fatalf("bad name: %s", resourceMap.Attributes)
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//}
|
2014-07-19 15:45:42 +02:00
|
|
|
|
2016-01-04 22:21:38 +01:00
|
|
|
var testAccCheckDigitalOceanDropletConfig_basic = fmt.Sprintf(`
|
|
|
|
resource "digitalocean_ssh_key" "foobar" {
|
|
|
|
name = "foobar"
|
|
|
|
public_key = "%s"
|
|
|
|
}
|
|
|
|
|
2014-07-19 02:20:28 +02:00
|
|
|
resource "digitalocean_droplet" "foobar" {
|
2016-01-04 22:21:38 +01:00
|
|
|
name = "foo"
|
|
|
|
size = "512mb"
|
2016-08-08 02:08:37 +02:00
|
|
|
image = "centos-7-x64"
|
2016-01-04 22:21:38 +01:00
|
|
|
region = "nyc3"
|
|
|
|
user_data = "foobar"
|
|
|
|
ssh_keys = ["${digitalocean_ssh_key.foobar.id}"]
|
|
|
|
}
|
|
|
|
`, testAccValidPublicKey)
|
|
|
|
|
2016-07-11 13:09:06 +02:00
|
|
|
var testAccCheckDigitalOceanDropletConfig_tag_update = fmt.Sprintf(`
|
|
|
|
resource "digitalocean_tag" "barbaz" {
|
|
|
|
name = "barbaz"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "digitalocean_ssh_key" "foobar" {
|
|
|
|
name = "foobar"
|
|
|
|
public_key = "%s"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "digitalocean_droplet" "foobar" {
|
|
|
|
name = "foo"
|
|
|
|
size = "512mb"
|
2016-08-08 02:08:37 +02:00
|
|
|
image = "centos-7-x64"
|
2016-07-11 13:09:06 +02:00
|
|
|
region = "nyc3"
|
|
|
|
user_data = "foobar"
|
|
|
|
ssh_keys = ["${digitalocean_ssh_key.foobar.id}"]
|
|
|
|
tags = ["${digitalocean_tag.barbaz.id}"]
|
|
|
|
}
|
|
|
|
`, testAccValidPublicKey)
|
|
|
|
|
2016-01-04 22:21:38 +01:00
|
|
|
var testAccCheckDigitalOceanDropletConfig_userdata_update = fmt.Sprintf(`
|
|
|
|
resource "digitalocean_ssh_key" "foobar" {
|
|
|
|
name = "foobar"
|
|
|
|
public_key = "%s"
|
2014-07-19 02:20:28 +02:00
|
|
|
}
|
2014-07-19 18:33:25 +02:00
|
|
|
|
2015-11-03 21:53:54 +01:00
|
|
|
resource "digitalocean_droplet" "foobar" {
|
2016-01-04 22:21:38 +01:00
|
|
|
name = "foo"
|
|
|
|
size = "512mb"
|
2016-08-08 02:08:37 +02:00
|
|
|
image = "centos-7-x64"
|
2016-01-04 22:21:38 +01:00
|
|
|
region = "nyc3"
|
|
|
|
user_data = "foobar foobar"
|
|
|
|
ssh_keys = ["${digitalocean_ssh_key.foobar.id}"]
|
|
|
|
}
|
|
|
|
`, testAccValidPublicKey)
|
|
|
|
|
|
|
|
var testAccCheckDigitalOceanDropletConfig_RenameAndResize = fmt.Sprintf(`
|
|
|
|
resource "digitalocean_ssh_key" "foobar" {
|
|
|
|
name = "foobar"
|
|
|
|
public_key = "%s"
|
2015-11-03 21:53:54 +01:00
|
|
|
}
|
|
|
|
|
2014-07-19 18:33:25 +02:00
|
|
|
resource "digitalocean_droplet" "foobar" {
|
2016-01-04 22:21:38 +01:00
|
|
|
name = "baz"
|
|
|
|
size = "1gb"
|
2016-08-08 02:08:37 +02:00
|
|
|
image = "centos-7-x64"
|
2016-01-04 22:21:38 +01:00
|
|
|
region = "nyc3"
|
|
|
|
ssh_keys = ["${digitalocean_ssh_key.foobar.id}"]
|
2014-07-19 18:33:25 +02:00
|
|
|
}
|
2016-01-04 22:21:38 +01:00
|
|
|
`, testAccValidPublicKey)
|
2014-07-30 00:58:48 +02:00
|
|
|
|
|
|
|
// IPV6 only in singapore
|
2016-01-04 22:21:38 +01:00
|
|
|
var testAccCheckDigitalOceanDropletConfig_PrivateNetworkingIpv6 = fmt.Sprintf(`
|
|
|
|
resource "digitalocean_ssh_key" "foobar" {
|
|
|
|
name = "foobar"
|
|
|
|
public_key = "%s"
|
|
|
|
}
|
|
|
|
|
2014-07-30 00:58:48 +02:00
|
|
|
resource "digitalocean_droplet" "foobar" {
|
2016-01-04 22:21:38 +01:00
|
|
|
name = "baz"
|
|
|
|
size = "1gb"
|
2016-08-08 02:08:37 +02:00
|
|
|
image = "centos-7-x64"
|
2016-01-04 22:21:38 +01:00
|
|
|
region = "sgp1"
|
|
|
|
ipv6 = true
|
|
|
|
private_networking = true
|
|
|
|
ssh_keys = ["${digitalocean_ssh_key.foobar.id}"]
|
2014-07-30 00:58:48 +02:00
|
|
|
}
|
2016-01-04 22:21:38 +01:00
|
|
|
`, testAccValidPublicKey)
|