@@ -5,30 +5,24 @@ Example Usage
55
66```hcl
77resource "tencentcloud_sms_sign" "sign" {
8- sign_name = "SignName "
9- sign_type = 0
10- document_type = 0
8+ sign_name = "terraform "
9+ sign_type = 1
10+ document_type = 4
1111 international = 0
12- sign_purpose = 0
13- proof_image = ""
14- commission_image = ""
15- remark = ""
12+ sign_purpose = 0
13+ proof_image = "dGhpcyBpcyBhIGV4YW1wbGU="
1614}
17-
1815```
19- Import
2016
21- sms sign can be imported using the id, e.g.
22- ```
23- $ terraform import tencentcloud_sms_sign.sign sign_id
24- ```
2517*/
2618package tencentcloud
2719
2820import (
2921 "context"
3022 "fmt"
3123 "log"
24+ "strconv"
25+ "strings"
3226
3327 "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
3428 "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
@@ -42,9 +36,6 @@ func resourceTencentCloudSmsSign() *schema.Resource {
4236 Create : resourceTencentCloudSmsSignCreate ,
4337 Update : resourceTencentCloudSmsSignUpdate ,
4438 Delete : resourceTencentCloudSmsSignDelete ,
45- Importer : & schema.ResourceImporter {
46- State : schema .ImportStatePassthrough ,
47- },
4839 Schema : map [string ]* schema.Schema {
4940 "sign_name" : {
5041 Type : schema .TypeString ,
@@ -104,9 +95,10 @@ func resourceTencentCloudSmsSignCreate(d *schema.ResourceData, meta interface{})
10495 logId := getLogId (contextNil )
10596
10697 var (
107- request = sms .NewAddSmsSignRequest ()
108- response * sms.AddSmsSignResponse
109- signId uint64
98+ request = sms .NewAddSmsSignRequest ()
99+ response * sms.AddSmsSignResponse
100+ signId uint64
101+ international int
110102 )
111103
112104 if v , ok := d .GetOk ("sign_name" ); ok {
@@ -122,7 +114,8 @@ func resourceTencentCloudSmsSignCreate(d *schema.ResourceData, meta interface{})
122114 }
123115
124116 if v , _ := d .GetOk ("international" ); v != nil {
125- request .International = helper .IntUint64 (v .(int ))
117+ international = v .(int )
118+ request .International = helper .IntUint64 (international )
126119 }
127120
128121 if v , _ := d .GetOk ("sign_purpose" ); v != nil {
@@ -159,7 +152,7 @@ func resourceTencentCloudSmsSignCreate(d *schema.ResourceData, meta interface{})
159152 }
160153
161154 signId = * response .Response .AddSignStatus .SignId
162- d .SetId (helper .UInt64ToStr (signId ))
155+ d .SetId (helper .UInt64ToStr (signId ) + FILED_SP + strconv . Itoa ( international ) )
163156 return resourceTencentCloudSmsSignRead (d , meta )
164157}
165158
@@ -172,9 +165,14 @@ func resourceTencentCloudSmsSignRead(d *schema.ResourceData, meta interface{}) e
172165
173166 service := SmsService {client : meta .(* TencentCloudClient ).apiV3Conn }
174167
175- signId := d .Id ()
168+ idSplit := strings .Split (d .Id (), FILED_SP )
169+ if len (idSplit ) != 2 {
170+ return fmt .Errorf ("id is broken,%s" , d .Id ())
171+ }
172+ signId := idSplit [0 ]
173+ international := idSplit [1 ]
176174
177- sign , err := service .DescribeSmsSign (ctx , signId )
175+ sign , err := service .DescribeSmsSign (ctx , signId , international )
178176
179177 if err != nil {
180178 return err
@@ -204,56 +202,44 @@ func resourceTencentCloudSmsSignUpdate(d *schema.ResourceData, meta interface{})
204202
205203 request := sms .NewModifySmsSignRequest ()
206204
207- signId := d .Id ()
205+ idSplit := strings .Split (d .Id (), FILED_SP )
206+ if len (idSplit ) != 2 {
207+ return fmt .Errorf ("id is broken,%s" , d .Id ())
208+ }
209+ signId := idSplit [0 ]
208210
209211 request .SignId = helper .Uint64 (helper .StrToUInt64 (signId ))
210212
211- if d .HasChange ("sign_name" ) {
212- if v , ok := d .GetOk ("sign_name" ); ok {
213- request .SignName = helper .String (v .(string ))
214- }
213+ if v , ok := d .GetOk ("sign_name" ); ok {
214+ request .SignName = helper .String (v .(string ))
215215 }
216216
217- if d .HasChange ("sign_type" ) {
218- if v , _ := d .GetOk ("sign_type" ); v != nil {
219- request .SignType = helper .IntUint64 (v .(int ))
220- }
217+ if v , _ := d .GetOk ("sign_type" ); v != nil {
218+ request .SignType = helper .IntUint64 (v .(int ))
221219 }
222220
223- if d .HasChange ("document_type" ) {
224- if v , _ := d .GetOk ("document_type" ); v != nil {
225- request .DocumentType = helper .IntUint64 (v .(int ))
226- }
221+ if v , _ := d .GetOk ("document_type" ); v != nil {
222+ request .DocumentType = helper .IntUint64 (v .(int ))
227223 }
228224
229- if d .HasChange ("international" ) {
230- if v , _ := d .GetOk ("international" ); v != nil {
231- request .International = helper .IntUint64 (v .(int ))
232- }
225+ if v , _ := d .GetOk ("international" ); v != nil {
226+ request .International = helper .IntUint64 (v .(int ))
233227 }
234228
235- if d .HasChange ("sign_purpose" ) {
236- if v , _ := d .GetOk ("sign_purpose" ); v != nil {
237- request .SignPurpose = helper .IntUint64 (v .(int ))
238- }
229+ if v , _ := d .GetOk ("sign_purpose" ); v != nil {
230+ request .SignPurpose = helper .IntUint64 (v .(int ))
239231 }
240232
241- if d .HasChange ("proof_image" ) {
242- if v , ok := d .GetOk ("proof_image" ); ok {
243- request .ProofImage = helper .String (v .(string ))
244- }
233+ if v , ok := d .GetOk ("proof_image" ); ok {
234+ request .ProofImage = helper .String (v .(string ))
245235 }
246236
247- if d .HasChange ("commission_image" ) {
248- if v , ok := d .GetOk ("commission_image" ); ok {
249- request .CommissionImage = helper .String (v .(string ))
250- }
237+ if v , ok := d .GetOk ("commission_image" ); ok {
238+ request .CommissionImage = helper .String (v .(string ))
251239 }
252240
253- if d .HasChange ("remark" ) {
254- if v , ok := d .GetOk ("remark" ); ok {
255- request .Remark = helper .String (v .(string ))
256- }
241+ if v , ok := d .GetOk ("remark" ); ok {
242+ request .Remark = helper .String (v .(string ))
257243 }
258244
259245 err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
@@ -284,7 +270,11 @@ func resourceTencentCloudSmsSignDelete(d *schema.ResourceData, meta interface{})
284270
285271 service := SmsService {client : meta .(* TencentCloudClient ).apiV3Conn }
286272
287- signId := d .Id ()
273+ idSplit := strings .Split (d .Id (), FILED_SP )
274+ if len (idSplit ) != 2 {
275+ return fmt .Errorf ("id is broken,%s" , d .Id ())
276+ }
277+ signId := idSplit [0 ]
288278
289279 if err := service .DeleteSmsSignById (ctx , signId ); err != nil {
290280 return err
0 commit comments