Skip to content

Commit 3197183

Browse files
gitmknanonymous
andauthored
feat: support import (#1598)
* feat: support import * feat: add changelog --------- Co-authored-by: anonymous <anonymous@mail.org>
1 parent ffb9d3e commit 3197183

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

.changelog/1598.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_mysql_account: support import
3+
```

tencentcloud/resource_tc_mysql_account.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ resource "tencentcloud_mysql_account" "default" {
1111
description = "My test account"
1212
}
1313
```
14+
15+
Import
16+
17+
mysql account can be imported using the mysqlId#accountName, e.g.
18+
19+
```
20+
terraform import tencentcloud_mysql_account.default cdb-gqg6j82x#tf_account
21+
```
1422
*/
1523
package tencentcloud
1624

@@ -31,7 +39,9 @@ func resourceTencentCloudMysqlAccount() *schema.Resource {
3139
Read: resourceTencentCloudMysqlAccountRead,
3240
Update: resourceTencentCloudMysqlAccountUpdate,
3341
Delete: resourceTencentCloudMysqlAccountDelete,
34-
42+
Importer: &schema.ResourceImporter{
43+
State: schema.ImportStatePassthrough,
44+
},
3545
Schema: map[string]*schema.Schema{
3646
"mysql_id": {
3747
Type: schema.TypeString,

tencentcloud/resource_tc_mysql_account_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ func TestAccTencentCloudMysqlAccountResource_basic(t *testing.T) {
9393
resource.TestCheckResourceAttr("tencentcloud_mysql_account.mysql_account", "description", "test from terraform"),
9494
),
9595
},
96+
{
97+
ResourceName: "tencentcloud_mysql_account.mysql_account",
98+
ImportState: true,
99+
ImportStateVerify: true,
100+
ImportStateVerifyIgnore: []string{
101+
"password",
102+
},
103+
},
96104
},
97105
})
98106
}

website/docs/r/mysql_account.html.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,11 @@ In addition to all arguments above, the following attributes are exported:
4040

4141

4242

43+
## Import
44+
45+
mysql account can be imported using the mysqlId#accountName, e.g.
46+
47+
```
48+
terraform import tencentcloud_mysql_account.default cdb-gqg6j82x#tf_account
49+
```
50+

0 commit comments

Comments
 (0)