@@ -1425,42 +1425,32 @@ func resourceTencentCloudCosBucketWebsiteUpdate(ctx context.Context, meta interf
14251425 w = make (map [string ]interface {})
14261426 }
14271427
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 {}
14311429 if v , ok := w ["index_document" ].(string ); ok && v != "" {
1432- websiteConfiguration .IndexDocument = & s3.IndexDocument {
1433- Suffix : aws .String (v ),
1434- }
1430+ websiteConfiguration .Index = v
14351431 }
14361432
14371433 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 ,
14401436 }
14411437 }
14421438
14431439 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 ,
14471442 }
14481443 }
14491444
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 )
14561447 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 ())
14591448 return fmt .Errorf ("cos put bucket website error: %s, bucket: %s" , err .Error (), bucket )
14601449 }
14611450
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 .Response .Body )
1453+ log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , "put bucket website" , string (reqBytes ), string (respBytes ))
14641454 }
14651455
14661456 return nil
0 commit comments