diff --git a/go.mod b/go.mod index 179067f..47959a6 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/davecgh/go-spew v1.1.1 github.com/hashicorp/terraform-plugin-docs v0.14.1 github.com/hashicorp/terraform-plugin-sdk v1.14.0 - github.com/signalsciences/go-sigsci v0.1.13 + github.com/signalsciences/go-sigsci v0.1.14 golang.org/x/lint v0.0.0-20190409202823-959b441ac422 honnef.co/go/tools v0.4.2 ) diff --git a/go.sum b/go.sum index 80e65b0..987262c 100644 --- a/go.sum +++ b/go.sum @@ -259,6 +259,8 @@ github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5g github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/signalsciences/go-sigsci v0.1.13 h1:S8YVQ7ei0hybgWqGj0krle6GkA7l8k23VFgNP3ipQwc= github.com/signalsciences/go-sigsci v0.1.13/go.mod h1:CXwoXk81ZwFdne6o8cnAYwxvke5kcLg7zE6Bl/e1KUo= +github.com/signalsciences/go-sigsci v0.1.14 h1:a2ucWDWDjXn93NXrVBcd7zyOMjxUcPEznTpCg0CLB+g= +github.com/signalsciences/go-sigsci v0.1.14/go.mod h1:CXwoXk81ZwFdne6o8cnAYwxvke5kcLg7zE6Bl/e1KUo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= diff --git a/provider/resource_edge_deployment_service.go b/provider/resource_edge_deployment_service.go index 80c262c..4b44950 100644 --- a/provider/resource_edge_deployment_service.go +++ b/provider/resource_edge_deployment_service.go @@ -2,13 +2,14 @@ package provider import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/signalsciences/go-sigsci" ) func resourceEdgeDeploymentService() *schema.Resource { return &schema.Resource{ Create: createOrUpdateEdgeDeploymentService, Read: readEdgeDeploymentService, - Update: updateEdgeDeploymentBackends, + Update: createOrUpdateEdgeDeploymentService, Delete: detachEdgeDeploymentService, Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ @@ -23,6 +24,20 @@ func resourceEdgeDeploymentService() *schema.Resource { Description: "Fastly service ID", Required: true, }, + + "activate_version": { + Type: schema.TypeBool, + Description: "activate Fastly service version after clone. Possible values are true or false", + Optional: true, + Default: true, + }, + + "percent_enabled": { + Type: schema.TypeInt, + Description: "percentage of traffic to send to NGWAF@Edge. Possible values are integers values 0 to 100", + Optional: true, + Default: 0, + }, }, } } @@ -32,19 +47,17 @@ func createOrUpdateEdgeDeploymentService(d *schema.ResourceData, m interface{}) d.SetId(d.Get("fastly_sid").(string)) - return pm.Client.CreateOrUpdateEdgeDeploymentService(pm.Corp, d.Get("site_short_name").(string), d.Get("fastly_sid").(string)) + activateVersion := d.Get("activate_version").(bool) + return pm.Client.CreateOrUpdateEdgeDeploymentService(pm.Corp, d.Get("site_short_name").(string), d.Get("fastly_sid").(string), sigsci.CreateOrUpdateEdgeDeploymentServiceBody{ + ActivateVersion: &activateVersion, + PercentEnabled: d.Get("percent_enabled").(int), + }) } func readEdgeDeploymentService(d *schema.ResourceData, m interface{}) error { return nil } -func updateEdgeDeploymentBackends(d *schema.ResourceData, m interface{}) error { - pm := m.(providerMetadata) - - return pm.Client.CreateOrUpdateEdgeDeploymentService(pm.Corp, d.Get("site_short_name").(string), d.Get("fastly_sid").(string)) -} - func detachEdgeDeploymentService(d *schema.ResourceData, m interface{}) error { pm := m.(providerMetadata)