Skip to content

Commit

Permalink
support mongodb account import
Browse files Browse the repository at this point in the history
  • Loading branch information
mikatong committed Feb 22, 2024
1 parent f5c47c8 commit d1eb290
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func ResourceTencentCloudMongodbInstanceAccount() *schema.Resource {
Read: resourceTencentCloudMongodbInstanceAccountRead,
Update: resourceTencentCloudMongodbInstanceAccountUpdate,
Delete: resourceTencentCloudMongodbInstanceAccountDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"instance_id": {
Required: true,
Expand All @@ -40,13 +43,15 @@ func ResourceTencentCloudMongodbInstanceAccount() *schema.Resource {
},

"password": {
Required: true,
Optional: true,
Sensitive: true,
Type: schema.TypeString,
Description: "New account password. Password complexity requirements are as follows: character length range [8,32]. Contains at least letters, numbers and special characters (exclamation point!, at@, pound sign #, percent sign %, caret ^, asterisk *, parentheses (), underscore _).",
},

"mongo_user_password": {
Required: true,
Optional: true,
Sensitive: true,
Type: schema.TypeString,
ForceNew: true,
Description: "The password corresponding to the mongouser account. mongouser is the system default account, which is the password set when creating an instance.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,39 @@ func TestAccTencentCloudNeedFixMongodbInstanceAccountResource_basic(t *testing.T
Config: testAccMongodbInstanceAccount,
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_mongodb_instance_account.instance_account", "id")),
},
{
ResourceName: "tencentcloud_mongodb_instance_account.instance_account",
ImportState: true,
ImportStateVerifyIgnore: []string{"password", "mongo_user_password"},
},
},
})
}

const testAccMongodbInstanceAccount = `
const testAccMongodbInstanceAccount = tcacctest.DefaultMongoDBSpec + `
resource "tencentcloud_mongodb_instance" "mongodb" {
instance_name = "tf-mongodb-test"
memory = local.memory
volume = local.volume
engine_version = local.engine_version
machine_type = local.machine_type
security_groups = [local.security_group_id]
available_zone = "ap-guangzhou-3"
project_id = 0
password = "test1234"
vpc_id = var.vpc_id
subnet_id = var.subnet_id
}
resource "tencentcloud_mongodb_instance_account" "instance_account" {
instance_id = "cmgo-lxaz2c9b"
instance_id = tencentcloud_mongodb_instance.mongodb.id
user_name = "test_account"
password = "xxxxxxxx"
mongo_user_password = "xxxxxxxxx"
password = "test1234"
mongo_user_password = "test1234"
user_desc = "test account"
auth_role {
mask = 0
namespace = "*"
}
}
`
4 changes: 2 additions & 2 deletions website/docs/r/mongodb_instance_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ resource "tencentcloud_mongodb_instance_account" "instance_account" {
The following arguments are supported:

* `instance_id` - (Required, String, ForceNew) Instance ID, the format is: cmgo-9d0p6umb.Same as the instance ID displayed in the cloud database console page.
* `mongo_user_password` - (Required, String, ForceNew) The password corresponding to the mongouser account. mongouser is the system default account, which is the password set when creating an instance.
* `password` - (Required, String) New account password. Password complexity requirements are as follows: character length range [8,32]. Contains at least letters, numbers and special characters (exclamation point!, at@, pound sign #, percent sign %, caret ^, asterisk *, parentheses (), underscore _).
* `user_name` - (Required, String, ForceNew) The new account name. Its format requirements are as follows: character range [1,32]. Characters in the range of [A,Z], [a,z], [1,9] as well as underscore _ and dash - can be input.
* `auth_role` - (Optional, List) The read and write permission information of the account.
* `mongo_user_password` - (Optional, String, ForceNew) The password corresponding to the mongouser account. mongouser is the system default account, which is the password set when creating an instance.
* `password` - (Optional, String) New account password. Password complexity requirements are as follows: character length range [8,32]. Contains at least letters, numbers and special characters (exclamation point!, at@, pound sign #, percent sign %, caret ^, asterisk *, parentheses (), underscore _).
* `user_desc` - (Optional, String) Account remarks.

The `auth_role` object supports the following:
Expand Down

0 comments on commit d1eb290

Please sign in to comment.