Skip to content

Commit

Permalink
Add monitoring option to digitalocean provider
Browse files Browse the repository at this point in the history
  • Loading branch information
joshpurvis committed Apr 10, 2017
1 parent 07ff095 commit 70f4544
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ func resourceDigitalOceanDroplet() *schema.Resource {
Optional: true,
},

"monitoring": {
Type: schema.TypeBool,
Optional: true,
},

"ipv4_address": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -169,6 +174,10 @@ func resourceDigitalOceanDropletCreate(d *schema.ResourceData, meta interface{})
opts.PrivateNetworking = attr.(bool)
}

if attr, ok := d.GetOk("monitoring"); ok {
opts.Monitoring = attr.(bool)
}

if attr, ok := d.GetOk("user_data"); ok {
opts.UserData = attr.(string)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,27 @@ func TestAccDigitalOceanDroplet_PrivateNetworkingIpv6(t *testing.T) {
})
}

func testAccDigitalOceanDroplet_Monitoring(t *testing.T) {
var droplet godo.Droplet
rInt := acctest.RandInt()

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckDigitalOceanDropletConfig_Monitoring(rInt),
Check: resource.ComposeTestCheckFunc(
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &droplet),
resource.TestCheckResourceAttr(
"digitalocean_droplet.foobar", "monitoring", "true"),
),
},
},
})
}

func testAccCheckDigitalOceanDropletDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*godo.Client)

Expand Down Expand Up @@ -584,4 +605,16 @@ resource "digitalocean_droplet" "foobar" {
`, rInt)
}

func testAccCheckDigitalOceanDropletConfig_Monitoring(rInt int) string {
return fmt.Sprintf(`
resource "digitalocean_droplet" "foobar" {
name = "foo-%d"
size = "1gb"
image = "centos-7-x64"
region = "nyc3"
monitoring = true
}
`, rInt)
}

var testAccValidPublicKey = `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR`
2 changes: 2 additions & 0 deletions website/source/docs/providers/do/r/droplet.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ The following arguments are supported:
* `size` - (Required) The instance size to start
* `backups` - (Optional) Boolean controlling if backups are made. Defaults to
false.
* `monitoring` - (Optional) Boolean controlling whether monitoring agent is installed.
Defaults to false.
* `ipv6` - (Optional) Boolean controlling if IPv6 is enabled. Defaults to false.
* `private_networking` - (Optional) Boolean controlling if private networks are
enabled. Defaults to false.
Expand Down

0 comments on commit 70f4544

Please sign in to comment.