Making user_data force a new droplet for DigitalOcean

This commit is contained in:
stack72 2015-11-03 20:53:54 +00:00
parent 9e9d4b2c72
commit ffdd4de326
2 changed files with 41 additions and 0 deletions

View File

@ -100,6 +100,7 @@ func resourceDigitalOceanDroplet() *schema.Resource {
"user_data": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
},
}

View File

@ -71,6 +71,36 @@ func TestAccDigitalOceanDroplet_Update(t *testing.T) {
})
}
func TestAccDigitalOceanDroplet_UpdateUserData(t *testing.T) {
var droplet 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", &droplet),
testAccCheckDigitalOceanDropletAttributes(&droplet),
),
},
resource.TestStep{
Config: testAccCheckDigitalOceanDropletConfig_userdata_update,
Check: resource.ComposeTestCheckFunc(
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &droplet),
resource.TestCheckResourceAttr(
"digitalocean_droplet.foobar",
"user_data",
"foobar foobar"),
),
},
},
})
}
func TestAccDigitalOceanDroplet_PrivateNetworkingIpv6(t *testing.T) {
var droplet godo.Droplet
@ -261,6 +291,16 @@ resource "digitalocean_droplet" "foobar" {
}
`
const testAccCheckDigitalOceanDropletConfig_userdata_update = `
resource "digitalocean_droplet" "foobar" {
name = "foo"
size = "512mb"
image = "centos-5-8-x32"
region = "nyc3"
user_data = "foobar foobar"
}
`
const testAccCheckDigitalOceanDropletConfig_RenameAndResize = `
resource "digitalocean_droplet" "foobar" {
name = "baz"