@@ -1425,42 +1425,32 @@ func resourceTencentCloudCosBucketWebsiteUpdate(ctx context.Context, meta interf
1425
1425
w = make (map [string ]interface {})
1426
1426
}
1427
1427
1428
- websiteConfiguration := & s3.WebsiteConfiguration {}
1429
- endPointUrl := fmt .Sprintf ("%s.cos-website.%s.myqcloud.com" , d .Id (), meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().Region )
1430
- var redirectAllRequestsTo = "http"
1428
+ websiteConfiguration := cos.BucketPutWebsiteOptions {}
1431
1429
if v , ok := w ["index_document" ].(string ); ok && v != "" {
1432
- websiteConfiguration .IndexDocument = & s3.IndexDocument {
1433
- Suffix : aws .String (v ),
1434
- }
1430
+ websiteConfiguration .Index = v
1435
1431
}
1436
1432
1437
1433
if v , ok := w ["error_document" ].(string ); ok && v != "" {
1438
- websiteConfiguration .ErrorDocument = & s3 .ErrorDocument {
1439
- Key : aws . String ( v ) ,
1434
+ websiteConfiguration .Error = & cos .ErrorDocument {
1435
+ Key : v ,
1440
1436
}
1441
1437
}
1442
1438
1443
1439
if v , ok := w ["redirect_all_requests_to" ].(string ); ok && v != "" {
1444
- websiteConfiguration .RedirectAllRequestsTo = & s3.RedirectAllRequestsTo {
1445
- HostName : aws .String (endPointUrl ),
1446
- Protocol : aws .String (redirectAllRequestsTo ),
1440
+ websiteConfiguration .RedirectProtocol = & cos.RedirectRequestsProtocol {
1441
+ Protocol : v ,
1447
1442
}
1448
1443
}
1449
1444
1450
- request := s3.PutBucketWebsiteInput {
1451
- Bucket : aws .String (bucket ),
1452
- WebsiteConfiguration : websiteConfiguration ,
1453
- }
1454
-
1455
- response , err := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseCosClientNew (cdcId ).PutBucketWebsite (& request )
1445
+ request := websiteConfiguration
1446
+ response , err := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseTencentCosClientNew (bucket , cdcId ).Bucket .PutWebsite (ctx , & request )
1456
1447
if err != nil {
1457
- log .Printf ("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n " ,
1458
- logId , "put bucket website" , request .String (), err .Error ())
1459
1448
return fmt .Errorf ("cos put bucket website error: %s, bucket: %s" , err .Error (), bucket )
1460
1449
}
1461
1450
1462
- log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " ,
1463
- logId , "put bucket website" , request .String (), response .String ())
1451
+ reqBytes , _ := json .Marshal (request )
1452
+ respBytes , _ := json .Marshal (response )
1453
+ log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , "put bucket website" , string (reqBytes ), string (respBytes ))
1464
1454
}
1465
1455
1466
1456
return nil
0 commit comments