Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/digitalocean: Add monitoring option to digitalocean droplets #13494

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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