Skip to content

Commit 3e329a5

Browse files
committed
feat: support mysql ssl
1 parent b9cfcbe commit 3e329a5

5 files changed

+18
-39
lines changed

tencentcloud/services/cdb/resource_tc_mysql_dr_instance.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ func ResourceTencentCloudMysqlDrInstance() *schema.Resource {
205205
},
206206
"ssl_status": {
207207
Optional: true,
208+
Computed: true,
208209
Type: schema.TypeString,
209210
Description: "Whether to enable SSL. `ON` means enabled, `OFF` means not enabled. Default: `OFF`.",
210211
},

tencentcloud/services/cdb/resource_tc_mysql_instance.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,6 @@ func TencentMsyqlBasicInfo() map[string]*schema.Schema {
173173
Optional: true,
174174
Description: "Switch the method of accessing new instances, default is `0`. Supported values include: `0` - switch immediately, `1` - switch in time window.",
175175
},
176-
"ssl_status": {
177-
Optional: true,
178-
Type: schema.TypeString,
179-
Description: "Whether to enable SSL. `ON` means enabled, `OFF` means not enabled. Default: `OFF`.",
180-
},
181176
// Computed values
182177
"intranet_ip": {
183178
Type: schema.TypeString,
@@ -206,12 +201,6 @@ func TencentMsyqlBasicInfo() map[string]*schema.Schema {
206201
Computed: true,
207202
Description: "Indicates whether GTID is enable. `0` - Not enabled; `1` - Enabled.",
208203
},
209-
210-
"ssl_url": {
211-
Computed: true,
212-
Type: schema.TypeString,
213-
Description: "The certificate download link. Example value: http://testdownload.url.",
214-
},
215204
}
216205
}
217206

@@ -292,6 +281,12 @@ func ResourceTencentCloudMysqlInstance() *schema.Resource {
292281
Default: 0,
293282
Description: "Project ID, default value is 0.",
294283
},
284+
"ssl_status": {
285+
Optional: true,
286+
Computed: true,
287+
Type: schema.TypeString,
288+
Description: "Whether to enable SSL. `ON` means enabled, `OFF` means not enabled. Default: `OFF`.",
289+
},
295290

296291
// Computed values
297292
"internet_host": {
@@ -304,6 +299,12 @@ func ResourceTencentCloudMysqlInstance() *schema.Resource {
304299
Computed: true,
305300
Description: "Access port for public access.",
306301
},
302+
303+
"ssl_url": {
304+
Computed: true,
305+
Type: schema.TypeString,
306+
Description: "The certificate download link. Example value: http://testdownload.url.",
307+
},
307308
}
308309

309310
basic := TencentMsyqlBasicInfo()
@@ -1295,7 +1296,7 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met
12951296
}
12961297
}
12971298

1298-
if d.HasChange("ssl_status") {
1299+
if !isReadonly && d.HasChange("ssl_status") {
12991300
if err := mysqlInstanceSSLUpdate(ctx, d, meta); err != nil {
13001301
log.Printf("[CRITAL]%s update mysql ssl fail, reason:%s\n ", logId, err.Error())
13011302
return err

tencentcloud/services/cdb/resource_tc_mysql_readonly_instance.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,6 @@ func resourceTencentCloudMysqlReadonlyInstanceCreate(d *schema.ResourceData, met
259259
return err
260260
}
261261

262-
// ssl
263-
if err := mysqlInstanceSSLUpdate(ctx, d, meta); err != nil {
264-
log.Printf("[CRITAL]%s update mysql ssl fail, reason:%s\n ", logId, err.Error())
265-
return err
266-
}
267-
268262
if tags := helper.GetTags(d, "tags"); len(tags) > 0 {
269263
tcClient := meta.(tccommon.ProviderMeta).GetAPIV3Conn()
270264
tagService := svctag.NewTagService(tcClient)
@@ -382,27 +376,6 @@ func resourceTencentCloudMysqlReadonlyInstanceRead(d *schema.ResourceData, meta
382376
_ = d.Set("status", mysqlInfo.Status)
383377
_ = d.Set("task_status", mysqlInfo.TaskStatus)
384378

385-
ssl, err := mysqlService.DescribeMysqlSslById(ctx, d.Id())
386-
if err != nil {
387-
return err
388-
}
389-
390-
if ssl == nil {
391-
d.SetId("")
392-
log.Printf("[WARN]%s resource `tencentcloud_mysql_ssl` [%s] not found, please check if it has been deleted.",
393-
logId, d.Id(),
394-
)
395-
return nil
396-
}
397-
398-
if ssl.Status != nil {
399-
_ = d.Set("ssl_status", ssl.Status)
400-
}
401-
402-
if ssl.Url != nil {
403-
_ = d.Set("ssl_url", ssl.Url)
404-
}
405-
406379
return nil
407380
}
408381

website/docs/r/mysql_dr_instance.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ The following arguments are supported:
6767
* `security_groups` - (Optional, Set: [`String`]) Security groups to use.
6868
* `slave_deploy_mode` - (Optional, Int) Availability zone deployment method. Available values: 0 - Single availability zone; 1 - Multiple availability zones.
6969
* `slave_sync_mode` - (Optional, Int) Data replication mode. 0 - Async replication; 1 - Semisync replication; 2 - Strongsync replication.
70+
* `ssl_status` - (Optional, String) Whether to enable SSL. `ON` means enabled, `OFF` means not enabled. Default: `OFF`.
7071
* `subnet_id` - (Optional, String) Private network ID. If `vpc_id` is set, this value is required.
7172
* `tags` - (Optional, Map) Instance tags.
7273
* `vpc_id` - (Optional, String) ID of VPC, which can be modified once every 24 hours and can't be removed.
@@ -77,6 +78,7 @@ In addition to all arguments above, the following attributes are exported:
7778

7879
* `id` - ID of the resource.
7980
* `intranet_ip` - instance intranet IP.
81+
* `ssl_url` - The certificate download link. Example value: http://testdownload.url.
8082

8183

8284
## Import

website/docs/r/mysql_instance.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ The following arguments are supported:
162162
* `security_groups` - (Optional, Set: [`String`]) Security groups to use.
163163
* `slave_deploy_mode` - (Optional, Int) Availability zone deployment method. Available values: 0 - Single availability zone; 1 - Multiple availability zones.
164164
* `slave_sync_mode` - (Optional, Int) Data replication mode. 0 - Async replication; 1 - Semisync replication; 2 - Strongsync replication.
165+
* `ssl_status` - (Optional, String) Whether to enable SSL. `ON` means enabled, `OFF` means not enabled. Default: `OFF`.
165166
* `subnet_id` - (Optional, String) Private network ID. If `vpc_id` is set, this value is required.
166167
* `tags` - (Optional, Map) Instance tags.
167168
* `upgrade_subversion` - (Optional, Int) Whether it is a kernel subversion upgrade, supported values: 1 - upgrade the kernel subversion; 0 - upgrade the database engine version. Only need to fill in when upgrading kernel subversion and engine version.
@@ -178,6 +179,7 @@ In addition to all arguments above, the following attributes are exported:
178179
* `internet_port` - Access port for public access.
179180
* `intranet_ip` - instance intranet IP.
180181
* `locked` - Indicates whether the instance is locked. Valid values: `0`, `1`. `0` - No; `1` - Yes.
182+
* `ssl_url` - The certificate download link. Example value: http://testdownload.url.
181183
* `status` - Instance status. Valid values: `0`, `1`, `4`, `5`. `0` - Creating; `1` - Running; `4` - Isolating; `5` - Isolated.
182184
* `task_status` - Indicates which kind of operations is being executed.
183185

0 commit comments

Comments
 (0)