@@ -18,6 +18,7 @@ import (
1818 "strconv"
1919
2020 cam "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam/v20190116"
21+ "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
2122 "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/ratelimit"
2223
2324 "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
@@ -48,6 +49,11 @@ func datasourceTencentCloudUserInfo() *schema.Resource {
4849 Computed : true ,
4950 Description : "Current account OwnerUIN." ,
5051 },
52+ "name" : {
53+ Type : schema .TypeString ,
54+ Computed : true ,
55+ Description : "Current account Name. NOTE: only support subaccount." ,
56+ },
5157 "result_output_file" : {
5258 Type : schema .TypeString ,
5359 Optional : true ,
@@ -100,7 +106,17 @@ func datasourceTencentCloudUserInfoRead(d *schema.ResourceData, meta interface{}
100106 _ = d .Set ("app_id" , appId )
101107 _ = d .Set ("uin" , uin )
102108 _ = d .Set ("owner_uin" , ownerUin )
103-
109+ accountInfoRequest := cam .NewDescribeSubAccountsRequest ()
110+ accountInfoRequest .FilterSubAccountUin = []* uint64 {helper .Uint64 (helper .StrToUInt64 (uin ))}
111+ accountInfoResponse , err := client .UseCamClient ().DescribeSubAccounts (accountInfoRequest )
112+ if err != nil {
113+ return err
114+ }
115+ subAccounts := accountInfoResponse .Response .SubAccounts
116+ if len (subAccounts ) > 0 {
117+ name := * subAccounts [0 ].Name
118+ _ = d .Set ("name" , name )
119+ }
104120 output , ok := d .GetOk ("result_output_file" )
105121 if ok && output .(string ) != "" {
106122 if e := writeToFile (output .(string ), map [string ]interface {}{
0 commit comments