Skip to content

Commit 2869265

Browse files
committed
providers/digitalocean: add user_data for create droplet
fixes hashicorp#267
1 parent bf52f38 commit 2869265

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
## 0.2.2 (unreleased)
22

3+
IMPROVEMENTS:
34

5+
* providers/digitalocean: Handle 404 on delete
6+
* providers/digitalocean: Add user_data argument for creating droplets
47

58
## 0.2.1 (August 31, 2014)
69

builtin/providers/digitalocean/resource_digitalocean_droplet.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func resource_digitalocean_droplet_create(
3434
PrivateNetworking: rs.Attributes["private_networking"],
3535
Region: rs.Attributes["region"],
3636
Size: rs.Attributes["size"],
37+
UserData: rs.Attributes["user_data"],
3738
}
3839

3940
// Only expand ssh_keys if we have them
@@ -249,6 +250,7 @@ func resource_digitalocean_droplet_diff(
249250
"region": diff.AttrTypeCreate,
250251
"size": diff.AttrTypeUpdate,
251252
"ssh_keys": diff.AttrTypeCreate,
253+
"user_data": diff.AttrTypeCreate,
252254
},
253255

254256
ComputedAttrs: []string{
@@ -322,6 +324,7 @@ func resource_digitalocean_droplet_validation() *config.Validator {
322324
},
323325
Optional: []string{
324326
"backups",
327+
"user_data",
325328
"ipv6",
326329
"private_networking",
327330
"ssh_keys.*",

builtin/providers/digitalocean/resource_digitalocean_droplet_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ func TestAccDigitalOceanDroplet_Basic(t *testing.T) {
3030
resource.TestCheckResourceAttr(
3131
"digitalocean_droplet.foobar", "image", "centos-5-8-x32"),
3232
resource.TestCheckResourceAttr(
33-
"digitalocean_droplet.foobar", "region", "nyc2"),
33+
"digitalocean_droplet.foobar", "region", "nyc3"),
34+
resource.TestCheckResourceAttr(
35+
"digitalocean_droplet.foobar", "user_data", "foobar"),
3436
),
3537
},
3638
},
@@ -242,7 +244,8 @@ resource "digitalocean_droplet" "foobar" {
242244
name = "foo"
243245
size = "512mb"
244246
image = "centos-5-8-x32"
245-
region = "nyc2"
247+
region = "nyc3"
248+
user_data = "foobar"
246249
}
247250
`
248251

website/source/docs/providers/do/r/droplet.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ The following arguments are supported:
3737
the format `[12345, 123456]`. To retrieve this info, use a tool such
3838
as `curl` with the [DigitalOcean API](https://developers.digitalocean.com/#keys),
3939
to retrieve them.
40+
* `user_data` (Optional) - A string of the desired User Data for the Droplet.
41+
User Data is currently only available in regions with metadata
42+
listed in their features.
4043

4144
## Attributes Reference
4245

0 commit comments

Comments
 (0)