From b0fe9cd253c63143138ba2b0124d5d8cc9988cda Mon Sep 17 00:00:00 2001 From: KGSN Date: Mon, 10 Oct 2022 17:43:08 +0800 Subject: [PATCH 1/3] fix: free ssl - set auth method optional but required when creating --- tencentcloud/resource_tc_ssl_free_certificate.go | 8 ++++++-- website/docs/r/ssl_free_certificate.html.markdown | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tencentcloud/resource_tc_ssl_free_certificate.go b/tencentcloud/resource_tc_ssl_free_certificate.go index 82acba3fea..8367010e46 100644 --- a/tencentcloud/resource_tc_ssl_free_certificate.go +++ b/tencentcloud/resource_tc_ssl_free_certificate.go @@ -53,9 +53,9 @@ func resourceTencentCloudSSLFreeCertificate() *schema.Resource { Schema: map[string]*schema.Schema{ "dv_auth_method": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, - Description: "Specify DV authorize method, available values: `DNS_AUTO` - automatic DNS auth, `DNS` - manual DNS auth, `FILE` - auth by file.", + Description: "Specify DV authorize method, required when creating. Available values: `DNS_AUTO` - automatic DNS auth, `DNS` - manual DNS auth, `FILE` - auth by file.", }, "domain": { Type: schema.TypeString, @@ -282,6 +282,10 @@ func resourceTencentCloudFreeCertificateCreate(d *schema.ResourceData, meta inte request.DvAuthMethod = &authMethod request.DomainName = &domain + if authMethod != "DNS" && authMethod != "FILE" { + return fmt.Errorf("invalid value of dv_auth_method: `%s` expected `DNS` or `FILE`", authMethod) + } + if v, ok := d.GetOk("package_type"); ok { request.PackageType = helper.String(v.(string)) } diff --git a/website/docs/r/ssl_free_certificate.html.markdown b/website/docs/r/ssl_free_certificate.html.markdown index a8c6acd20c..34ea4f3af1 100644 --- a/website/docs/r/ssl_free_certificate.html.markdown +++ b/website/docs/r/ssl_free_certificate.html.markdown @@ -35,13 +35,13 @@ resource "tencentcloud_ssl_free_certificate" "foo" { The following arguments are supported: * `domain` - (Required, String, ForceNew) Specify domain name. -* `dv_auth_method` - (Required, String, ForceNew) Specify DV authorize method, available values: `DNS_AUTO` - automatic DNS auth, `DNS` - manual DNS auth, `FILE` - auth by file. * `alias` - (Optional, String) Specify alias for remark. * `contact_email` - (Optional, String) Email address. * `contact_phone` - (Optional, String) Phone number. * `csr_encrypt_algo` - (Optional, String) Specify CSR encrypt algorithm, only support `RSA` for now. * `csr_key_parameter` - (Optional, String) Specify CSR key parameter, only support `"2048"` for now. * `csr_key_password` - (Optional, String) Specify CSR key password. +* `dv_auth_method` - (Optional, String, ForceNew) Specify DV authorize method, required when creating. Available values: `DNS_AUTO` - automatic DNS auth, `DNS` - manual DNS auth, `FILE` - auth by file. * `old_certificate_id` - (Optional, String, ForceNew) Specify old certificate ID, used for re-apply. * `package_type` - (Optional, String) Type of package. Only support `"2"` (TrustAsia TLS RSA CA). * `project_id` - (Optional, Int) ID of projects which this certification belong to. From 96d45acd51d5647692724bf387f27c5ae156127d Mon Sep 17 00:00:00 2001 From: KGSN Date: Tue, 11 Oct 2022 15:27:56 +0800 Subject: [PATCH 2/3] fix: free ssl - add dv_auth_method update --- tencentcloud/resource_tc_ssl_free_certificate.go | 5 ++++- tencentcloud/resource_tc_ssl_free_certificate_test.go | 5 +++++ website/docs/r/ssl_free_certificate.html.markdown | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tencentcloud/resource_tc_ssl_free_certificate.go b/tencentcloud/resource_tc_ssl_free_certificate.go index 8367010e46..ef809b914f 100644 --- a/tencentcloud/resource_tc_ssl_free_certificate.go +++ b/tencentcloud/resource_tc_ssl_free_certificate.go @@ -54,7 +54,6 @@ func resourceTencentCloudSSLFreeCertificate() *schema.Resource { "dv_auth_method": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "Specify DV authorize method, required when creating. Available values: `DNS_AUTO` - automatic DNS auth, `DNS` - manual DNS auth, `FILE` - auth by file.", }, "domain": { @@ -203,6 +202,10 @@ func resourceTencentCloudFreeCertificateRead(d *schema.ResourceData, meta interf d.SetId(id) + if detail.VerifyType != nil { + _ = d.Set("dv_auth_method", detail.VerifyType) + } + if detail.Domain != nil { _ = d.Set("domain", detail.Domain) } diff --git a/tencentcloud/resource_tc_ssl_free_certificate_test.go b/tencentcloud/resource_tc_ssl_free_certificate_test.go index c59d7d8f2e..6d1a7f250b 100644 --- a/tencentcloud/resource_tc_ssl_free_certificate_test.go +++ b/tencentcloud/resource_tc_ssl_free_certificate_test.go @@ -70,6 +70,11 @@ func TestAccTencentCloudNeedFixSSLFreeCertificate(t *testing.T) { resource.TestCheckResourceAttrSet("tencentcloud_ssl_free_certificate.foo", "domain"), ), }, + { + ImportState: true, + ImportStateVerify: true, + ResourceName: "tencentcloud_ssl_free_certificate.foo", + }, }, }) } diff --git a/website/docs/r/ssl_free_certificate.html.markdown b/website/docs/r/ssl_free_certificate.html.markdown index 34ea4f3af1..c4240f64c7 100644 --- a/website/docs/r/ssl_free_certificate.html.markdown +++ b/website/docs/r/ssl_free_certificate.html.markdown @@ -41,7 +41,7 @@ The following arguments are supported: * `csr_encrypt_algo` - (Optional, String) Specify CSR encrypt algorithm, only support `RSA` for now. * `csr_key_parameter` - (Optional, String) Specify CSR key parameter, only support `"2048"` for now. * `csr_key_password` - (Optional, String) Specify CSR key password. -* `dv_auth_method` - (Optional, String, ForceNew) Specify DV authorize method, required when creating. Available values: `DNS_AUTO` - automatic DNS auth, `DNS` - manual DNS auth, `FILE` - auth by file. +* `dv_auth_method` - (Optional, String) Specify DV authorize method, required when creating. Available values: `DNS_AUTO` - automatic DNS auth, `DNS` - manual DNS auth, `FILE` - auth by file. * `old_certificate_id` - (Optional, String, ForceNew) Specify old certificate ID, used for re-apply. * `package_type` - (Optional, String) Type of package. Only support `"2"` (TrustAsia TLS RSA CA). * `project_id` - (Optional, Int) ID of projects which this certification belong to. From 374958a32ad296d6592755dfe522235e2b8b45cc Mon Sep 17 00:00:00 2001 From: Kagashino Date: Wed, 12 Oct 2022 11:02:56 +0800 Subject: [PATCH 3/3] fix: free ssl - reset auth method to required --- tencentcloud/resource_tc_ssl_free_certificate.go | 9 +++------ website/docs/r/ssl_free_certificate.html.markdown | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tencentcloud/resource_tc_ssl_free_certificate.go b/tencentcloud/resource_tc_ssl_free_certificate.go index ef809b914f..f896aba470 100644 --- a/tencentcloud/resource_tc_ssl_free_certificate.go +++ b/tencentcloud/resource_tc_ssl_free_certificate.go @@ -53,8 +53,8 @@ func resourceTencentCloudSSLFreeCertificate() *schema.Resource { Schema: map[string]*schema.Schema{ "dv_auth_method": { Type: schema.TypeString, - Optional: true, - Description: "Specify DV authorize method, required when creating. Available values: `DNS_AUTO` - automatic DNS auth, `DNS` - manual DNS auth, `FILE` - auth by file.", + Required: true, + Description: "Specify DV authorize method. Available values: `DNS_AUTO` - automatic DNS auth, `DNS` - manual DNS auth, `FILE` - auth by file.", }, "domain": { Type: schema.TypeString, @@ -285,10 +285,6 @@ func resourceTencentCloudFreeCertificateCreate(d *schema.ResourceData, meta inte request.DvAuthMethod = &authMethod request.DomainName = &domain - if authMethod != "DNS" && authMethod != "FILE" { - return fmt.Errorf("invalid value of dv_auth_method: `%s` expected `DNS` or `FILE`", authMethod) - } - if v, ok := d.GetOk("package_type"); ok { request.PackageType = helper.String(v.(string)) } @@ -369,6 +365,7 @@ func resourceTencentCloudFreeCertificateUpdate(d *schema.ResourceData, meta inte } immutableFields := []string{ + "dv_auth_method", "package_type", "contact_email", "contact_phone", diff --git a/website/docs/r/ssl_free_certificate.html.markdown b/website/docs/r/ssl_free_certificate.html.markdown index c4240f64c7..5f1758e05e 100644 --- a/website/docs/r/ssl_free_certificate.html.markdown +++ b/website/docs/r/ssl_free_certificate.html.markdown @@ -35,13 +35,13 @@ resource "tencentcloud_ssl_free_certificate" "foo" { The following arguments are supported: * `domain` - (Required, String, ForceNew) Specify domain name. +* `dv_auth_method` - (Required, String) Specify DV authorize method. Available values: `DNS_AUTO` - automatic DNS auth, `DNS` - manual DNS auth, `FILE` - auth by file. * `alias` - (Optional, String) Specify alias for remark. * `contact_email` - (Optional, String) Email address. * `contact_phone` - (Optional, String) Phone number. * `csr_encrypt_algo` - (Optional, String) Specify CSR encrypt algorithm, only support `RSA` for now. * `csr_key_parameter` - (Optional, String) Specify CSR key parameter, only support `"2048"` for now. * `csr_key_password` - (Optional, String) Specify CSR key password. -* `dv_auth_method` - (Optional, String) Specify DV authorize method, required when creating. Available values: `DNS_AUTO` - automatic DNS auth, `DNS` - manual DNS auth, `FILE` - auth by file. * `old_certificate_id` - (Optional, String, ForceNew) Specify old certificate ID, used for re-apply. * `package_type` - (Optional, String) Type of package. Only support `"2"` (TrustAsia TLS RSA CA). * `project_id` - (Optional, Int) ID of projects which this certification belong to.