Skip to content

Commit 38fbc49

Browse files
authored
Feat/support endpoint field for cos static website (#1535)
* update dts mode * feat:add endpoint for cos bucket static website * add changelog
1 parent 1244d6c commit 38fbc49

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

.changelog/1535.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_cos_bucket: add `endpoint` field for static website
3+
```

tencentcloud/resource_tc_cos_bucket.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ resource "tencentcloud_cos_bucket" "mycos" {
7373
error_document = "error.html"
7474
}
7575
}
76+
77+
output "endpoint_test" {
78+
value = tencentcloud_cos_bucket.mycos.website.0.endpoint
79+
}
7680
```
7781
7882
Using CORS
@@ -682,6 +686,11 @@ func resourceTencentCloudCosBucket() *schema.Resource {
682686
Optional: true,
683687
Description: "An absolute path to the document to return in case of a 4XX error.",
684688
},
689+
"endpoint": {
690+
Type: schema.TypeString,
691+
Computed: true,
692+
Description: "`Endpoint` of the static website.",
693+
},
685694
},
686695
},
687696
},
@@ -869,6 +878,11 @@ func resourceTencentCloudCosBucketRead(d *schema.ResourceData, meta interface{})
869878
if err != nil {
870879
return err
871880
}
881+
if len(website) > 0 {
882+
// {bucket}.cos-website.{region}.myqcloud.com
883+
endPointUrl := fmt.Sprintf("%s.cos-website.%s.myqcloud.com", d.Id(), meta.(*TencentCloudClient).apiV3Conn.Region)
884+
website[0]["endpoint"] = endPointUrl
885+
}
872886
if err = d.Set("website", website); err != nil {
873887
return fmt.Errorf("setting website error: %v", err)
874888
}

tencentcloud/resource_tc_cos_bucket_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ func TestAccTencentCloudCosBucketResource_website(t *testing.T) {
286286
resource.TestCheckResourceAttr("tencentcloud_cos_bucket.bucket_website", "website.#", "1"),
287287
resource.TestCheckResourceAttr("tencentcloud_cos_bucket.bucket_website", "website.0.index_document", "index.html"),
288288
resource.TestCheckResourceAttr("tencentcloud_cos_bucket.bucket_website", "website.0.error_document", "error.html"),
289+
resource.TestCheckResourceAttrSet("tencentcloud_cos_bucket.bucket_website", "website.0.endpoint"),
289290
),
290291
},
291292
// test update bucket website
@@ -296,6 +297,7 @@ func TestAccTencentCloudCosBucketResource_website(t *testing.T) {
296297
resource.TestCheckResourceAttr("tencentcloud_cos_bucket.bucket_website", "website.#", "1"),
297298
resource.TestCheckResourceAttr("tencentcloud_cos_bucket.bucket_website", "website.0.index_document", "testindex.html"),
298299
resource.TestCheckResourceAttr("tencentcloud_cos_bucket.bucket_website", "website.0.error_document", "testerror.html"),
300+
resource.TestCheckResourceAttrSet("tencentcloud_cos_bucket.bucket_website", "website.0.endpoint"),
299301
),
300302
},
301303
{

website/docs/r/cos_bucket.html.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ resource "tencentcloud_cos_bucket" "mycos" {
8383
error_document = "error.html"
8484
}
8585
}
86+
87+
output "endpoint_test" {
88+
value = tencentcloud_cos_bucket.mycos.website.0.endpoint
89+
}
8690
```
8791

8892
Using CORS

0 commit comments

Comments
 (0)