From d8feac8dfb63b2306919da62c518bbfb5a8d4a78 Mon Sep 17 00:00:00 2001 From: grokify Date: Mon, 19 Sep 2022 08:52:14 +0000 Subject: [PATCH 1/7] add Cloud WAF Certificate support --- go.mod | 4 +- go.sum | 4 +- provider/lib.go | 7 + provider/provider.go | 15 +- .../resource_corp_cloudwaf_certificate.go | 207 +++++++++++++++ ...resource_corp_cloudwaf_certificate_test.go | 237 ++++++++++++++++++ 6 files changed, 463 insertions(+), 11 deletions(-) create mode 100644 provider/resource_corp_cloudwaf_certificate.go create mode 100644 provider/resource_corp_cloudwaf_certificate_test.go diff --git a/go.mod b/go.mod index b9a901b..cb52ebb 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.17 require ( github.com/davecgh/go-spew v1.1.1 github.com/hashicorp/terraform-plugin-sdk v1.14.0 - github.com/signalsciences/go-sigsci v0.1.5 + github.com/signalsciences/go-sigsci v0.1.6 ) require ( @@ -70,4 +70,4 @@ require ( google.golang.org/grpc v1.27.1 // indirect ) -//replace github.com/signalsciences/go-sigsci v0.1.5 => ../go-sigsci +//replace github.com/signalsciences/go-sigsci v0.1.6 => ../go-sigsci diff --git a/go.sum b/go.sum index 48cd743..d97aee0 100644 --- a/go.sum +++ b/go.sum @@ -168,8 +168,8 @@ github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DK github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/signalsciences/go-sigsci v0.1.5 h1:sKAFGo70Bv/F1QYL5W9mmo4BAWX0B9xmVk0rWQwmKRA= -github.com/signalsciences/go-sigsci v0.1.5/go.mod h1:9eUL/FIXlslxnqtsf0yk67CSBiYdL4ToYjYybzWQ77A= +github.com/signalsciences/go-sigsci v0.1.6 h1:O3v1kQOA00d+HO4pD8ykymouojBe02bYy0gj15ow8jA= +github.com/signalsciences/go-sigsci v0.1.6/go.mod h1:9eUL/FIXlslxnqtsf0yk67CSBiYdL4ToYjYybzWQ77A= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= diff --git a/provider/lib.go b/provider/lib.go index 62a6ff5..0238520 100644 --- a/provider/lib.go +++ b/provider/lib.go @@ -12,6 +12,13 @@ import ( "github.com/signalsciences/go-sigsci" ) +func suppressEquivalentTrimSpaceDiffs(k, old, new string, d *schema.ResourceData) bool { + if strings.TrimSpace(old) == strings.TrimSpace(new) { + return true + } + return false +} + type providerMetadata struct { Corp string Client sigsci.Client diff --git a/provider/provider.go b/provider/provider.go index fc30958..cfc08fb 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -50,13 +50,14 @@ func Provider() terraform.ResourceProvider { "sigsci_site_blocklist": resourceSiteBlocklist(), "sigsci_site_allowlist": resourceSiteAllowlist(), //"sigsci_site_monitor": resourceSiteMonitor(), - "sigsci_site_header_link": resourceSiteHeaderLink(), - "sigsci_site_integration": resourceSiteIntegration(), - "sigsci_corp_list": resourceCorpList(), - "sigsci_corp_rule": resourceCorpRule(), - "sigsci_corp_signal_tag": resourceCorpSignalTag(), - "sigsci_corp_integration": resourceCorpIntegration(), - "sigsci_corp_cloudwaf_instance": resourceCorpCloudWAFInstance(), + "sigsci_site_header_link": resourceSiteHeaderLink(), + "sigsci_site_integration": resourceSiteIntegration(), + "sigsci_corp_list": resourceCorpList(), + "sigsci_corp_rule": resourceCorpRule(), + "sigsci_corp_signal_tag": resourceCorpSignalTag(), + "sigsci_corp_integration": resourceCorpIntegration(), + "sigsci_corp_cloudwaf_instance": resourceCorpCloudWAFInstance(), + "sigsci_corp_cloudwaf_certificate": resourceCorpCloudWAFCertificate(), }, } provider.ConfigureFunc = providerConfigure() diff --git a/provider/resource_corp_cloudwaf_certificate.go b/provider/resource_corp_cloudwaf_certificate.go new file mode 100644 index 0000000..20444ab --- /dev/null +++ b/provider/resource_corp_cloudwaf_certificate.go @@ -0,0 +1,207 @@ +package provider + +import ( + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/signalsciences/go-sigsci" +) + +func resourceCorpCloudWAFCertificate() *schema.Resource { + return &schema.Resource{ + Create: resourceCorpCloudWAFCertificateCreate, + Read: resourceCorpCloudWAFCertificateRead, + Update: resourceCorpCloudWAFCertificateUpdate, + Delete: resourceCorpCloudWAFCertificateDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Description: "Friendly name to identify a CloudWAF certificate", + Required: true, + }, + "certificate_body": { + Type: schema.TypeString, + Description: "Body of the certificate in PEM format", + Required: true, + DiffSuppressFunc: suppressEquivalentTrimSpaceDiffs, + }, + "certificate_chain": { + Type: schema.TypeString, + Description: "Certificate chain in PEM format", + Optional: true, + DiffSuppressFunc: suppressEquivalentTrimSpaceDiffs, + }, + "private_key": { + Type: schema.TypeString, + Description: "Private key of the certificate in PEM format - must be unencrypted", + Required: true, + Sensitive: true, + }, + "common_name": { + Type: schema.TypeString, + Description: "Common name of the uploaded certificate", + Computed: true, + }, + "expires_at": { + Type: schema.TypeString, + Description: "TimeStamp for when certificate expires in RFC3339 date time format", + Computed: true, + }, + "fingerprint": { + Type: schema.TypeString, + Description: "SHA1 fingerprint of the certififcate", + Computed: true, + }, + "status": { + Type: schema.TypeString, + Description: `Current status of the certificate - could be one of "unknown", "active", "pendingverification", "expired", "error"`, + Computed: true, + }, + "subject_alternative_names": { + Type: schema.TypeSet, + Description: "Subject alternative names from the uploaded certificate", + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "created_by": { + Type: schema.TypeString, + Description: "Email address of the user that created the certfificate", + Computed: true, + }, + "created": { + Type: schema.TypeString, + Description: "Created RFC3339 date time", + Computed: true, + }, + "updated_by": { + Type: schema.TypeString, + Description: "Email address of the user that updated the certificate", + Computed: true, + }, + "updated_at": { + Type: schema.TypeString, + Description: "Updated RFC3339 date time", + Computed: true, + }, + }, + } +} + +func resourceCorpCloudWAFCertificateCreate(d *schema.ResourceData, m interface{}) error { + pm := m.(providerMetadata) + sc := pm.Client + + resp, err := sc.UploadCloudWAFCertificate(pm.Corp, sigsci.UploadCloudWAFCertificateBody{ + CloudWAFCertificateBase: sigsci.CloudWAFCertificateBase{ + Name: d.Get("name").(string), + CertificateBody: strings.TrimSpace(d.Get("certificate_body").(string)), + CertificateChain: strings.TrimSpace(d.Get("certificate_chain").(string)), + }, + PrivateKey: strings.TrimSpace(d.Get("private_key").(string)), + }) + if err != nil { + return err + } + + d.SetId(resp.ID) + + return resourceCorpCloudWAFCertificateRead(d, m) +} + +func resourceCorpCloudWAFCertificateRead(d *schema.ResourceData, m interface{}) error { + pm := m.(providerMetadata) + sc := pm.Client + + cwaf, err := sc.GetCloudWAFCertificate(pm.Corp, d.Id()) + if err != nil { + d.SetId("") + return nil + } + + d.SetId(d.Id()) + err = d.Set("name", cwaf.Name) + if err != nil { + return err + } + err = d.Set("certificate_body", strings.TrimSpace(cwaf.CertificateBody)) + if err != nil { + return err + } + err = d.Set("certificate_chain", strings.TrimSpace(cwaf.CertificateChain)) + if err != nil { + return err + } + err = d.Set("common_name", cwaf.CommonName) + if err != nil { + return err + } + err = d.Set("expires_at", cwaf.ExpiresAt) + if err != nil { + return err + } + err = d.Set("fingerprint", cwaf.Fingerprint) + if err != nil { + return err + } + err = d.Set("status", cwaf.Status) + if err != nil { + return err + } + err = d.Set("subject_alternative_names", flattenStringArray(cwaf.SubjectAlternativeNames)) + if err != nil { + return err + } + err = d.Set("created_by", cwaf.CreatedBy) + if err != nil { + return err + } + err = d.Set("created", cwaf.Created) + if err != nil { + return err + } + err = d.Set("updated_by", cwaf.UpdatedBy) + if err != nil { + return err + } + err = d.Set("updated_at", cwaf.UpdatedAt) + if err != nil { + return err + } + + // set zero value for diff - https://github.com/hashicorp/terraform/issues/20985 + err = d.Set("private_key", "") + if err != nil { + return err + } + + return nil +} + +func resourceCorpCloudWAFCertificateUpdate(d *schema.ResourceData, m interface{}) error { + pm := m.(providerMetadata) + sc := pm.Client + + _, err := sc.UpdateCloudWAFCertificate(pm.Corp, d.Id(), sigsci.UpdateCloudWAFCertificateBody{ + Name: d.Get("name").(string), + }) + if err != nil { + return nil + } + + return resourceCorpCloudWAFCertificateRead(d, m) +} + +func resourceCorpCloudWAFCertificateDelete(d *schema.ResourceData, m interface{}) error { + pm := m.(providerMetadata) + sc := pm.Client + + err := sc.DeleteCloudWAFCertificate(pm.Corp, d.Id()) + if err != nil { + return err + } + d.SetId("") + return nil +} diff --git a/provider/resource_corp_cloudwaf_certificate_test.go b/provider/resource_corp_cloudwaf_certificate_test.go new file mode 100644 index 0000000..4bf945b --- /dev/null +++ b/provider/resource_corp_cloudwaf_certificate_test.go @@ -0,0 +1,237 @@ +package provider + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" +) + +func TestAccResourceCorpCloudWAFCertificateCRUD_basic(t *testing.T) { + t.Parallel() + + resourceName := "sigsci_corp_cloudwaf_certificate.test_cloudwaf_certificate" + certificateName := "Cloud WAF Certificate by SigSci Terraform provider test" + certificateBody := `-----BEGIN CERTIFICATE----- +MIICzDCCAbQCCQDV2NzCr6aPbDANBgkqhkiG9w0BAQsFADAoMQwwCgYDVQQLDAN3 +ZWIxGDAWBgNVBAMMD3d3dy5leGFtcGxlLm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9qKtdj +RvZXat5rqE6+nzxnCGi3TcFAkt/ea8/RzptHd6cFd9q7itfkuJ22oGmUA0kCgYEA +zmvUO+kr6wtr0czjhLA952rLbr/ateqviq65ZmxoiEWGbq+1rzKElacxIQFKRVrL +yTMS/5X6n52o1CKIgAP2tsCjeAT6u3o5XnTIFTbHs6yiZzS2rvmx8S8Xw1GICanz +EPxwj7BAmhueYkqlcErT7lT9N4m667vbdynYi/g3oHECgYEA5dCjPFl94ZGStHF2 +4+cI1NCbVTnQApFI1+Vmd4lED619KSnpk/77TaYTh2I8gsK3OZP4crvee5aL41TJ +Y20XmAq/Dvv3g7QR97ND/AghEU8nnpZo1fgHzCcyZSkaBzMFeYdsfaGDncM56I0B +65yblwYq9Vyzy3hBFY6XGaFdnZ0= +-----END PRIVATE KEY-----` + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckCorpCloudWAFCertificateDestroy, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(`resource "sigsci_corp_cloudwaf_certificate" "test_cloudwaf_certificate"{ + name = "%s" + certificate_body = < Date: Mon, 19 Sep 2022 10:09:59 +0000 Subject: [PATCH 2/7] add Cloud WAF Certificate docs --- docs/resources/corp_cloudwaf_certificate.md | 56 +++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 docs/resources/corp_cloudwaf_certificate.md diff --git a/docs/resources/corp_cloudwaf_certificate.md b/docs/resources/corp_cloudwaf_certificate.md new file mode 100644 index 0000000..a7db841 --- /dev/null +++ b/docs/resources/corp_cloudwaf_certificate.md @@ -0,0 +1,56 @@ +### Example Usage + +```hcl-terraform +resource "sigsci_corp_cloudwaf_certificate" "test_corp_cloudwaf_certificate" { + name = "Test Cloud WAF Certificate" + certificate_body = < Date: Fri, 23 Sep 2022 08:53:09 +0000 Subject: [PATCH 3/7] update Terraform Cloud WAF Certificate --- docs/resources/corp_cloudwaf_certificate.md | 11 ---- main.tf | 59 ++++++++++++++++++- .../resource_corp_cloudwaf_certificate.go | 43 +------------- ...resource_corp_cloudwaf_certificate_test.go | 36 ++++------- 4 files changed, 67 insertions(+), 82 deletions(-) diff --git a/docs/resources/corp_cloudwaf_certificate.md b/docs/resources/corp_cloudwaf_certificate.md index a7db841..e339d80 100644 --- a/docs/resources/corp_cloudwaf_certificate.md +++ b/docs/resources/corp_cloudwaf_certificate.md @@ -18,15 +18,8 @@ CHAIN [encoded privatekey]] ----END PRIVATE KEY----- PRIVATEKEY - lifecycle { - ignore_changes = [ - private_key - ] - } } ``` -|Warning: Changes for `private_key` must be ignored in your HCL as it is required for creation but not provided in a read response due to the sensitive nature of the private key.| -|---| ### Argument Reference - `name` - (Required) Friendly name to identify a CloudWAF certificate. @@ -42,10 +35,6 @@ In addition to all arguments, the following fields are also available - `fingerprint` - SHA1 fingerprint of the certififcate. - `status` - Current status of the certificate - could be one of "unknown", "active", "pendingverification", "expired", "error". - `subject_alternative_names` - Subject alternative names from the uploaded certificate. -- `created_by` - Email address of the user that created the certfificate. -- `created` - Created RFC3339 date time. -- `updated_by` - Email address of the user that updated the certificate. -- `updated_at` - Updated RFC3339 date time. ### Import You can import corp lists with the generic site import formula diff --git a/main.tf b/main.tf index 10db71a..6f42b9d 100644 --- a/main.tf +++ b/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { sigsci = { source = "signalsciences/sigsci" - version = "0.4.2" + version = "1.0.1" } } } @@ -13,7 +13,7 @@ terraform { // required_providers { // sigsci = { // source = "signalsciences/local/sigsci" -// version = "0.4.2" +// version = "1.0.1" // } // } //} @@ -334,4 +334,57 @@ resource "sigsci_site_integration" "test_integration" { type = "slack" url = "https://wat.slack.com" events = ["listCreated"] -} \ No newline at end of file +} + +resource "sigsci_corp_cloudwaf_certificate" "test_cloudwaf_certificate"{ + name = "Certificate Name" + certificate_body = < Date: Sat, 24 Sep 2022 00:07:38 +0000 Subject: [PATCH 4/7] update Cloud WAF Certificate schema and test --- .../resource_corp_cloudwaf_certificate.go | 1 + ...resource_corp_cloudwaf_certificate_test.go | 93 ++++++++++--------- 2 files changed, 50 insertions(+), 44 deletions(-) diff --git a/provider/resource_corp_cloudwaf_certificate.go b/provider/resource_corp_cloudwaf_certificate.go index 442be0d..054543a 100644 --- a/provider/resource_corp_cloudwaf_certificate.go +++ b/provider/resource_corp_cloudwaf_certificate.go @@ -39,6 +39,7 @@ func resourceCorpCloudWAFCertificate() *schema.Resource { Type: schema.TypeString, Description: "Private key of the certificate in PEM format - must be unencrypted", Required: true, + ForceNew: true, Sensitive: true, }, "common_name": { diff --git a/provider/resource_corp_cloudwaf_certificate_test.go b/provider/resource_corp_cloudwaf_certificate_test.go index 39f0257..75eee58 100644 --- a/provider/resource_corp_cloudwaf_certificate_test.go +++ b/provider/resource_corp_cloudwaf_certificate_test.go @@ -14,49 +14,54 @@ func TestAccResourceCorpCloudWAFCertificateCRUD_basic(t *testing.T) { resourceName := "sigsci_corp_cloudwaf_certificate.test_cloudwaf_certificate" certificateName := "Cloud WAF Certificate by SigSci Terraform provider test" certificateBody := `-----BEGIN CERTIFICATE----- -MIICzDCCAbQCCQDV2NzCr6aPbDANBgkqhkiG9w0BAQsFADAoMQwwCgYDVQQLDAN3 -ZWIxGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbTAeFw0yMjA5MDMxNzE5MTVaFw0z -MjA4MzExNzE5MTVaMCgxDDAKBgNVBAsMA3dlYjEYMBYGA1UEAwwPd3d3LmV4YW1w -bGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3xLllGg3Kl0S -W16pOwH4VXyGTyByWk3gShoSnEXqWYwoGDF18YhGFFMYLUBNfbDG/jy8MLiKY20R -BhV5hpObd4ZQq4PIlTl4ZNKy07CUPX/AufdbQzrFCQy96lXBVjo6gR10TD+F/CjC -tOkM83dxtZoSPzH86eHteos41+apjgpfvVai3vkBNuZeeoxuERkxuGsfpcK2qWTg -ZFuncrWt6Plvlu70qGEIPtiFiPfQ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BAubmkfynbml8FMTr9e6GFXIS2Ujwsdg5QQM3b0JqS +qDYSk5EXnWy5zy61Zz9LlGoqmLwEI9NEPtUpSctN1VglhRmW2L9XKnEJ7dgbHl+e +AcMPBI2ownETAClHg8qKm5hMsZsCgYEAwdnQTAtM3gInT6ItxmUIWjKmDQP2tVY0 +mIYpiPcoPnFe0IJCzwcWuBezdvgK3x0i2UY/HfRu+d93vMoiXt6ij+zab9ewXVHQ +PmytXelIJuQ4tA38L9HZGJW6yIzIaJT6laZiQStjTEN4lDeKNIpY4SEuqGzXaAl0 +CHk+DovJ1PUCgYB82Q6kZloe1QxgRelJeeuijBpZv/brARlNCdN6NVgt6kLxkyNi +uBUr1NDMxi/G/ARL7Bf8asnftV2MwtxukDX/bf6iIfZxS3aOp3++IGmWFZFVC7j4 +tfbqPLjkL52rk61I7Jjd3QKubb69FOG8ZKbD69I1V/iZSPaPeW195WIE7wKBgFN0 +6deDWfGOrcv7/4cVgjYK7jBWT4WceoJb6E/eUIYpmu9b1VV6MM7K7Wm/ujZ6PcGb +G5tS2+BZ1BwETi3X3dbm2tgh3P0gNu5ZLX5r67NKuBrUlokj6DpMZCDpc3KLCSMa +gdyayGJR/fyZuLeMBF3QQl0ils5km372a8ApcJhtAoGAfDup6P3pDp2Rjq3IRJod +NFJAJERVDnSYml2D9q/uitU51nqL1JcvAoWQJByMFOXuy8F97Olflw4MW/cjWnXJ +1IBEgPEGv5zlronLACOIynBo6/Iu8ULIZhx0BYDc4DXD++PxG2Dd0mbYD8vrlrUK +wOmYr1etSwJs1p3ESLrOscM= -----END PRIVATE KEY-----` resource.Test(t, resource.TestCase{ @@ -78,9 +83,9 @@ PRIVATEKEY resource.TestCheckResourceAttr(resourceName, "name", certificateName), resource.TestCheckResourceAttr(resourceName, "certificate_body", certificateBody), resource.TestCheckResourceAttr(resourceName, "certificate_chain", ""), - resource.TestCheckResourceAttr(resourceName, "common_name", "www.example.com"), - resource.TestCheckResourceAttr(resourceName, "expires_at", "2032-08-31T17:19:15Z"), - resource.TestCheckResourceAttr(resourceName, "fingerprint", "d3d246a79291ce3448f13b99d34d09066861c71a"), + resource.TestCheckResourceAttr(resourceName, "common_name", "example.com"), + resource.TestCheckResourceAttr(resourceName, "expires_at", "2022-10-24T00:01:39Z"), + resource.TestCheckResourceAttr(resourceName, "fingerprint", "56d4f213a9061be925445280a64865927df7f88f"), resource.TestCheckResourceAttr(resourceName, "status", "active"), ), }, From b625b9f0869378eda2cc7f1fee690042619f65c7 Mon Sep 17 00:00:00 2001 From: grokify Date: Sat, 24 Sep 2022 00:12:48 +0000 Subject: [PATCH 5/7] update Cloud WAF Certificate main.tf example --- main.tf | 87 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/main.tf b/main.tf index 6f42b9d..578720a 100644 --- a/main.tf +++ b/main.tf @@ -340,51 +340,56 @@ resource "sigsci_corp_cloudwaf_certificate" "test_cloudwaf_certificate"{ name = "Certificate Name" certificate_body = < Date: Sat, 24 Sep 2022 00:33:34 +0000 Subject: [PATCH 6/7] update Cloud WAF Certificate update test cert --- main.tf | 97 ++++++++++--------- ...resource_corp_cloudwaf_certificate_test.go | 95 +++++++++--------- 2 files changed, 97 insertions(+), 95 deletions(-) diff --git a/main.tf b/main.tf index 578720a..97a307f 100644 --- a/main.tf +++ b/main.tf @@ -2,18 +2,18 @@ terraform { required_providers { sigsci = { source = "signalsciences/sigsci" - version = "1.0.1" + version = "1.1.0" } } } // To build locally: -// make && cp terraform-provider-sigsci ~/.terraform.d/plugins/signalsciences/local/sigsci/0.4.2/darwin_amd64/terraform-provider-sigsci && rm .terraform.lock.hcl && tf init +// make && cp terraform-provider-sigsci ~/.terraform.d/plugins/signalsciences/local/sigsci/1.1.0/darwin_amd64/terraform-provider-sigsci && rm .terraform.lock.hcl && tf init //terraform { // required_providers { // sigsci = { // source = "signalsciences/local/sigsci" -// version = "1.0.1" +// version = "1.1.0" // } // } //} @@ -340,56 +340,57 @@ resource "sigsci_corp_cloudwaf_certificate" "test_cloudwaf_certificate"{ name = "Certificate Name" certificate_body = < Date: Sat, 24 Sep 2022 00:40:34 +0000 Subject: [PATCH 7/7] update README.md add Cloud WAF Certificate --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7b61245..a3007fe 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ provider "sigsci" { [Cloud WAF Instance](https://github.com/signalsciences/terraform-provider-sigsci/blob/main/docs/resources/corp_cloudwaf_instance.md) +[Cloud WAF Certificate](https://github.com/signalsciences/terraform-provider-sigsci/blob/main/docs/resources/corp_cloudwaf_certificate.md) + ## Site resources [Lists](https://github.com/signalsciences/terraform-provider-sigsci/blob/main/docs/resources/site_list.md)