DigitalOcean: Export droplet prices (#13720)

Note: In DO, Droplets are about the only thing you pay. DNS/Float IP are
free.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
Julien Pivotto 2017-04-18 13:52:40 +02:00 committed by Paul Stack
parent 74129323bd
commit c2d1a37334
3 changed files with 22 additions and 0 deletions

View File

@ -63,6 +63,16 @@ func resourceDigitalOceanDroplet() *schema.Resource {
Computed: true,
},
"price_hourly": {
Type: schema.TypeFloat,
Computed: true,
},
"price_monthly": {
Type: schema.TypeFloat,
Computed: true,
},
"resize_disk": {
Type: schema.TypeBool,
Optional: true,
@ -259,6 +269,8 @@ func resourceDigitalOceanDropletRead(d *schema.ResourceData, meta interface{}) e
d.Set("name", droplet.Name)
d.Set("region", droplet.Region.Slug)
d.Set("size", droplet.Size.Slug)
d.Set("price_hourly", droplet.Size.PriceHourly)
d.Set("price_monthly", droplet.Size.PriceMonthly)
d.Set("disk", droplet.Disk)
d.Set("vcpus", droplet.Vcpus)
d.Set("status", droplet.Status)

View File

@ -333,6 +333,14 @@ func testAccCheckDigitalOceanDropletAttributes(droplet *godo.Droplet) resource.T
return fmt.Errorf("Bad size_slug: %s", droplet.Size.Slug)
}
if droplet.Size.PriceHourly != 0.00744 {
return fmt.Errorf("Bad price_hourly: %s", droplet.Size.PriceHourly)
}
if droplet.Size.PriceMonthly != 5.0 {
return fmt.Errorf("Bad price_monthly: %s", droplet.Size.PriceMonthly)
}
if droplet.Region.Slug != "nyc3" {
return fmt.Errorf("Bad region_slug: %s", droplet.Region.Slug)
}

View File

@ -65,6 +65,8 @@ The following attributes are exported:
* `ipv4_address_private` - The private networking IPv4 address
* `locked` - Is the Droplet locked
* `private_networking` - Is private networking enabled
* `price_hourly` - Droplet hourly price
* `price_monthly` - Droplet monthly price
* `size` - The instance size
* `disk` - The size of the instance's disk in GB
* `vcpus` - The number of the instance's virtual CPUs