Skip to content

fix(bh): [116555803] Fix errors in querying user group members #2564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/2564.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_dasb_user_group_members: Fix errors in querying user group members
```
1 change: 0 additions & 1 deletion tencentcloud/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -2088,7 +2088,6 @@ Bastion Host(BH)
tencentcloud_dasb_device_group_members
tencentcloud_dasb_user_group_members
tencentcloud_dasb_bind_device_resource
tencentcloud_dasb_resource
tencentcloud_dasb_device
tencentcloud_dasb_user_group
tencentcloud_dasb_reset_user
Expand Down
2 changes: 2 additions & 0 deletions tencentcloud/services/bh/resource_tc_dasb_acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ func ResourceTencentCloudDasbAcl() *schema.Resource {
},
"validate_from": {
Optional: true,
Computed: true,
Type: schema.TypeString,
Description: "Access permission effective time, such as: 2021-09-22T00:00:00+08:00If the effective and expiry time are not filled in, the access rights will be valid for a long time.",
},
"validate_to": {
Optional: true,
Computed: true,
Type: schema.TypeString,
Description: "Access permission expiration time, such as: 2021-09-23T00:00:00+08:00If the effective and expiry time are not filled in, the access rights will be valid for a long time.",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@ Provides a resource to create a dasb bind_device_account_password
Example Usage

```hcl
resource "tencentcloud_dasb_device" "example" {
os_name = "Linux"
ip = "192.168.0.1"
port = 80
name = "tf_example"
}

resource "tencentcloud_dasb_device_account" "example" {
device_id = tencentcloud_dasb_device.example.id
account = "root"
}

resource "tencentcloud_dasb_bind_device_account_password" "example" {
device_account_id = 16
device_account_id = tencentcloud_dasb_device_account.example.id
password = "TerraformPassword"
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@ Provides a resource to create a dasb bind_device_account_private_key
Example Usage

```hcl
resource "tencentcloud_dasb_device" "example" {
os_name = "Linux"
ip = "192.168.0.1"
port = 80
name = "tf_example"
}

resource "tencentcloud_dasb_device_account" "example" {
device_id = tencentcloud_dasb_device.example.id
account = "root"
}

resource "tencentcloud_dasb_bind_device_account_private_key" "example" {
device_account_id = 16
device_account_id = tencentcloud_dasb_device_account.example.id
private_key = "MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUpwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ51s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh"
private_key_password = "TerraformPassword"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Example Usage

```hcl
resource "tencentcloud_dasb_bind_device_resource" "example" {
resource_id = "bh-saas-ocmzo6lgxiv"
resource_id = "bh-saas-weyosfym"
device_id_set = [17, 18]
}
```
5 changes: 3 additions & 2 deletions tencentcloud/services/bh/resource_tc_dasb_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func ResourceTencentCloudDasbDevice() *schema.Resource {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Computed: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个字段不是输入参数吗

Description: "Asset multi-node: fields ip and port.",
},
},
Expand Down Expand Up @@ -159,8 +160,8 @@ func resourceTencentCloudDasbDeviceRead(d *schema.ResourceData, meta interface{}
_ = d.Set("os_name", device.OsName)
}

if device.PublicIp != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有这个字段吗?为啥要删掉

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个字段病不返回IP 改为PrivateIp

_ = d.Set("ip", device.PublicIp)
if device.PrivateIp != nil {
_ = d.Set("ip", device.PrivateIp)
}

if device.Port != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func resourceTencentCloudDasbDeviceAccountCreate(d *schema.ResourceData, meta in
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
}

if result == nil || result.Response.Id != nil {
if result == nil || result.Response.Id == nil {
e = fmt.Errorf("dasb DeviceAccount not exists")
return resource.NonRetryableError(e)
}
Expand Down
9 changes: 8 additions & 1 deletion tencentcloud/services/bh/resource_tc_dasb_device_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ Provides a resource to create a dasb device_account
Example Usage

```hcl
resource "tencentcloud_dasb_device" "example" {
os_name = "Linux"
ip = "192.168.0.1"
port = 80
name = "tf_example"
}

resource "tencentcloud_dasb_device_account" "example" {
device_id = 100
device_id = tencentcloud_dasb_device.example.id
account = "root"
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ func resourceTencentCloudDasbDeviceGroupMembersRead(d *schema.ResourceData, meta
return nil
}

_ = d.Set("device_group_id", deviceGroupId)
deviceGroupIdInt, _ := strconv.Atoi(deviceGroupId)
_ = d.Set("device_group_id", deviceGroupIdInt)
_ = d.Set("member_id_set", DeviceGroupMembers)

return nil
Expand Down
17 changes: 14 additions & 3 deletions tencentcloud/services/bh/resource_tc_dasb_device_group_members.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@ Provides a resource to create a dasb device_group_members
Example Usage

```hcl
resource "tencentcloud_dasb_device" "example" {
os_name = "Linux"
ip = "192.168.0.1"
port = 80
name = "tf_example"
}

resource "tencentcloud_dasb_device_group" "example" {
name = "tf_example"
}

resource "tencentcloud_dasb_device_group_members" "example" {
device_group_id = 3
member_id_set = [1, 2, 3]
device_group_id = tencentcloud_dasb_device_group.example.id
member_id_set = [tencentcloud_dasb_device.example.id]
}
```

Expand All @@ -14,5 +25,5 @@ Import
dasb device_group_members can be imported using the id, e.g.

```
terraform import tencentcloud_dasb_device_group_members.example 3#1,2,3
terraform import tencentcloud_dasb_device_group_members.example 53#102
```
4 changes: 3 additions & 1 deletion tencentcloud/services/bh/resource_tc_dasb_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func resourceTencentCloudDasbResourceCreate(d *schema.ResourceData, meta interfa
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
}

if result == nil || result.Response.ResourceId == nil {
if result == nil || *result.Response.ResourceId == "" {
e = fmt.Errorf("dasb Resource not exists")
return resource.NonRetryableError(e)
}
Expand All @@ -166,6 +166,8 @@ func resourceTencentCloudDasbResourceCreate(d *schema.ResourceData, meta interfa
resourceId = *response.Response.ResourceId
d.SetId(resourceId)

// deploy resource

// wait
describeRequest.ResourceIds = helper.Strings([]string{resourceId})
err = resource.Retry(tccommon.WriteRetryTimeout*4, func() *resource.RetryError {
Expand Down
6 changes: 3 additions & 3 deletions tencentcloud/services/bh/resource_tc_dasb_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Example Usage
```hcl
resource "tencentcloud_dasb_resource" "example" {
deploy_region = "ap-guangzhou"
vpc_id = "vpc-q1of50wz"
subnet_id = "subnet-7uhvm46o"
vpc_id = "vpc-fmz6l9nz"
subnet_id = "subnet-g7jhwhi2"
resource_edition = "standard"
resource_node = 2
resource_node = 50
time_unit = "m"
time_span = 1
auto_renew_flag = 1
Expand Down
3 changes: 3 additions & 0 deletions tencentcloud/services/bh/resource_tc_dasb_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,19 @@ func ResourceTencentCloudDasbUser() *schema.Resource {
},
"validate_from": {
Optional: true,
Computed: true,
Type: schema.TypeString,
Description: "User effective time, such as: 2021-09-22T00:00:00+00:00If the effective and expiry time are not filled in, the user will be valid for a long time.",
},
"validate_to": {
Optional: true,
Computed: true,
Type: schema.TypeString,
Description: "User expiration time, such as: 2021-09-23T00:00:00+00:00If the effective and expiry time are not filled in, the user will be valid for a long time.",
},
"group_id_set": {
Optional: true,
Computed: true,
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeInt},
Description: "The set of user group IDs to which it belongs.",
Expand Down
4 changes: 2 additions & 2 deletions tencentcloud/services/bh/resource_tc_dasb_user_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Example Usage

```hcl
resource "tencentcloud_dasb_user_group" "example" {
name = "tf_example_update"
name = "tf_example"
}
```

Or

```hcl
resource "tencentcloud_dasb_user_group" "example" {
name = "tf_example_update"
name = "tf_example"
department_id = "1.2"
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ func resourceTencentCloudDasbUserGroupMembersRead(d *schema.ResourceData, meta i
return nil
}

_ = d.Set("user_group_id", userGroupId)
userGroupIdInt, _ := strconv.Atoi(userGroupId)
_ = d.Set("user_group_id", userGroupIdInt)
_ = d.Set("member_id_set", UserGroupMembers)

return nil
Expand Down
18 changes: 15 additions & 3 deletions tencentcloud/services/bh/resource_tc_dasb_user_group_members.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@ Provides a resource to create a dasb user_group_members
Example Usage

```hcl
resource "tencentcloud_dasb_user" "example" {
user_name = "tf_example"
real_name = "terraform"
phone = "+86|18345678782"
email = "[email protected]"
auth_type = 0
}

resource "tencentcloud_dasb_user_group" "example" {
name = "tf_example"
}

resource "tencentcloud_dasb_user_group_members" "example" {
user_group_id = 3
member_id_set = [1, 2, 3]
user_group_id = tencentcloud_dasb_user_group.example.id
member_id_set = [tencentcloud_dasb_user.example.id]
}
```

Expand All @@ -14,5 +26,5 @@ Import
dasb user_group_members can be imported using the id, e.g.

```
terraform import tencentcloud_dasb_user_group_members.example 3#1,2,3
terraform import tencentcloud_dasb_user_group_members.example 3#14
```
2 changes: 2 additions & 0 deletions tencentcloud/services/bh/service_tencentcloud_dasb.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ func (me *DasbService) DescribeDasbDeviceGroupMembersById(ctx context.Context, d
request := dasb.NewDescribeDeviceGroupMembersRequest()
deviceGroupIdInt, _ := strconv.ParseUint(deviceGroupId, 10, 64)
request.Id = &deviceGroupIdInt
request.Bound = common.BoolPtr(true)

defer func() {
if errRet != nil {
Expand Down Expand Up @@ -378,6 +379,7 @@ func (me *DasbService) DescribeDasbUserGroupMembersById(ctx context.Context, use
request := dasb.NewDescribeUserGroupMembersRequest()
userGroupIdInt, _ := strconv.ParseUint(userGroupId, 10, 64)
request.Id = &userGroupIdInt
request.Bound = common.BoolPtr(true)

defer func() {
if errRet != nil {
Expand Down
14 changes: 13 additions & 1 deletion website/docs/r/dasb_bind_device_account_password.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,20 @@ Provides a resource to create a dasb bind_device_account_password
## Example Usage

```hcl
resource "tencentcloud_dasb_device" "example" {
os_name = "Linux"
ip = "192.168.0.1"
port = 80
name = "tf_example"
}

resource "tencentcloud_dasb_device_account" "example" {
device_id = tencentcloud_dasb_device.example.id
account = "root"
}

resource "tencentcloud_dasb_bind_device_account_password" "example" {
device_account_id = 16
device_account_id = tencentcloud_dasb_device_account.example.id
password = "TerraformPassword"
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,20 @@ Provides a resource to create a dasb bind_device_account_private_key
## Example Usage

```hcl
resource "tencentcloud_dasb_device" "example" {
os_name = "Linux"
ip = "192.168.0.1"
port = 80
name = "tf_example"
}

resource "tencentcloud_dasb_device_account" "example" {
device_id = tencentcloud_dasb_device.example.id
account = "root"
}

resource "tencentcloud_dasb_bind_device_account_private_key" "example" {
device_account_id = 16
device_account_id = tencentcloud_dasb_device_account.example.id
private_key = "MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUpwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ51s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh"
private_key_password = "TerraformPassword"
}
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/dasb_bind_device_resource.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Provides a resource to create a dasb bind_device_resource

```hcl
resource "tencentcloud_dasb_bind_device_resource" "example" {
resource_id = "bh-saas-ocmzo6lgxiv"
resource_id = "bh-saas-weyosfym"
device_id_set = [17, 18]
}
```
Expand Down
9 changes: 8 additions & 1 deletion website/docs/r/dasb_device_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ Provides a resource to create a dasb device_account
## Example Usage

```hcl
resource "tencentcloud_dasb_device" "example" {
os_name = "Linux"
ip = "192.168.0.1"
port = 80
name = "tf_example"
}

resource "tencentcloud_dasb_device_account" "example" {
device_id = 100
device_id = tencentcloud_dasb_device.example.id
account = "root"
}
```
Expand Down
17 changes: 14 additions & 3 deletions website/docs/r/dasb_device_group_members.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@ Provides a resource to create a dasb device_group_members
## Example Usage

```hcl
resource "tencentcloud_dasb_device" "example" {
os_name = "Linux"
ip = "192.168.0.1"
port = 80
name = "tf_example"
}

resource "tencentcloud_dasb_device_group" "example" {
name = "tf_example"
}

resource "tencentcloud_dasb_device_group_members" "example" {
device_group_id = 3
member_id_set = [1, 2, 3]
device_group_id = tencentcloud_dasb_device_group.example.id
member_id_set = [tencentcloud_dasb_device.example.id]
}
```

Expand All @@ -40,6 +51,6 @@ In addition to all arguments above, the following attributes are exported:
dasb device_group_members can be imported using the id, e.g.

```
terraform import tencentcloud_dasb_device_group_members.example 3#1,2,3
terraform import tencentcloud_dasb_device_group_members.example 53#102
```

Loading