Skip to content

Commit

Permalink
Merge pull request #164 from volcengine/Feat/unsubscribe
Browse files Browse the repository at this point in the history
Feat/unsubscribe
  • Loading branch information
msq177 committed May 16, 2024
2 parents 0670150 + 23e8c20 commit 8d6cc21
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 17 deletions.
2 changes: 1 addition & 1 deletion common/common_volcengine_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func ResourceFlowLimitExceededError(err error) bool {
}

func UnsubscribeProductError(err error) bool {
return strings.Contains(err.Error(), "The product code is inconsistent with the instance product")
return strings.Contains(err.Error(), "The product code does not match the instance's product")
}

func UnsubscribeProductConflictError(err error) bool {
Expand Down
2 changes: 1 addition & 1 deletion common/common_volcengine_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package common

const (
TerraformProviderName = "terraform-provider-volcengine"
TerraformProviderVersion = "0.0.143"
TerraformProviderVersion = "0.0.144"
)
7 changes: 7 additions & 0 deletions example/dataPrivatelinkVpcEndpointConnections/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ resource "volcengine_privatelink_vpc_endpoint" "foo" {
description = "acc-test"
}

resource "volcengine_privatelink_vpc_endpoint_zone" "foo" {
endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
subnet_id = volcengine_subnet.foo.id
private_ip_address = "172.16.0.251"
}

resource "volcengine_privatelink_vpc_endpoint_connection" "foo" {
endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
service_id = volcengine_privatelink_vpc_endpoint_service.foo.id
depends_on = [volcengine_privatelink_vpc_endpoint_zone.foo]
}

data "volcengine_privatelink_vpc_endpoint_connections" "foo"{
Expand Down
12 changes: 12 additions & 0 deletions example/privatelinkVpcEndpointConnection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,19 @@ resource "volcengine_privatelink_vpc_endpoint" "foo" {
description = "acc-test"
}

#resource "volcengine_privatelink_vpc_endpoint_connection" "foo" {
# endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
# service_id = volcengine_privatelink_vpc_endpoint_service.foo.id
#}

resource "volcengine_privatelink_vpc_endpoint_zone" "foo" {
endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
subnet_id = volcengine_subnet.foo.id
private_ip_address = "172.16.0.251"
}

resource "volcengine_privatelink_vpc_endpoint_connection" "foo" {
endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
service_id = volcengine_privatelink_vpc_endpoint_service.foo.id
depends_on = [volcengine_privatelink_vpc_endpoint_zone.foo]
}
9 changes: 4 additions & 5 deletions volcengine/clb/clb/resource_volcengine_clb.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,10 @@ func ResourceVolcengineClb() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"isp": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"BGP"}, false),
Description: "The ISP of the EIP which automatically associated to CLB, the value can be `BGP`.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The ISP of the EIP which automatically associated to CLB, the value can be `BGP` or `ChinaMobile` or `ChinaUnicom` or `ChinaTelecom` or `SingleLine_BGP` or `Static_BGP` or `Fusion_BGP`.",
},
"eip_billing_type": {
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ resource "volcengine_privatelink_vpc_endpoint" "foo" {
description = "acc-test"
}
resource "volcengine_privatelink_vpc_endpoint_zone" "foo" {
endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
subnet_id = volcengine_subnet.foo.id
private_ip_address = "172.16.0.251"
}
resource "volcengine_privatelink_vpc_endpoint_connection" "foo" {
endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
service_id = volcengine_privatelink_vpc_endpoint_service.foo.id
depends_on = [volcengine_privatelink_vpc_endpoint_zone.foo]
}
data "volcengine_privatelink_vpc_endpoint_connections" "foo"{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ resource "volcengine_privatelink_vpc_endpoint" "foo" {
description = "acc-test"
}
resource "volcengine_privatelink_vpc_endpoint_zone" "foo" {
endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
subnet_id = volcengine_subnet.foo.id
private_ip_address = "172.16.0.251"
}
resource "volcengine_privatelink_vpc_endpoint_connection" "foo" {
endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
service_id = volcengine_privatelink_vpc_endpoint_service.foo.id
depends_on = [volcengine_privatelink_vpc_endpoint_zone.foo]
}
`

Expand Down
13 changes: 8 additions & 5 deletions volcengine/tos/object/resource_volcengine_tos_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ func ResourceVolcengineTosObject() *schema.Resource {
},
"file_path": {
Type: schema.TypeString,
Required: true,
Optional: true,
//ForceNew: true,
Description: "The file path for upload.",
Description: "The file path for upload. Only one of `file_path,content` can be specified.",
ExactlyOneOf: []string{"file_path", "content"},
},
"content_md5": {
Type: schema.TypeString,
Expand Down Expand Up @@ -163,9 +164,11 @@ func ResourceVolcengineTosObject() *schema.Resource {
Description: "The flag of enable tos version.",
},
"content": {
Type: schema.TypeString,
Computed: true,
Description: "The content the TOS Object when content type is json or text and xml.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ExactlyOneOf: []string{"file_path", "content"},
Description: "The content of the TOS Object when content type is json or text and xml. Only one of `file_path,content` can be specified.",
},
},
}
Expand Down
29 changes: 27 additions & 2 deletions volcengine/tos/object/service_volcengine_tos_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"fmt"
"net/http"
"os"
"strings"
"time"

Expand Down Expand Up @@ -252,7 +253,7 @@ func (s *VolcengineTosObjectService) CreateResource(resourceData *schema.Resourc
func (s *VolcengineTosObjectService) ModifyResource(data *schema.ResourceData, resource *schema.Resource) []ve.Callback {
var callbacks []ve.Callback

if data.HasChange("file_path") || data.HasChanges("content_md5") {
if data.HasChange("file_path") || data.HasChanges("content_md5") || data.HasChanges("content") {
callbacks = append(callbacks, s.createOrReplaceObject(data, resource, true))
callbacks = append(callbacks, s.createOrUpdateObjectAcl(data, resource, true))
} else {
Expand Down Expand Up @@ -511,6 +512,7 @@ func (s *VolcengineTosObjectService) createOrUpdateObjectAcl(resourceData *schem
}

func (s *VolcengineTosObjectService) createOrReplaceObject(resourceData *schema.ResourceData, resource *schema.Resource, isUpdate bool) ve.Callback {
name := fmt.Sprintf("./%d-temp", time.Now().Unix())
return ve.Callback{
Call: ve.SdkCall{
ServiceCategory: ve.ServiceBypass,
Expand Down Expand Up @@ -558,6 +560,13 @@ func (s *VolcengineTosObjectService) createOrReplaceObject(resourceData *schema.
},
ForceGet: isUpdate,
},
"content": {
ConvertType: ve.ConvertDefault,
TargetField: "Content",
SpecialParam: &ve.SpecialParam{
Type: ve.HeaderParam,
},
},
"content_md5": {
ConvertType: ve.ConvertDefault,
TargetField: "Content-MD5",
Expand Down Expand Up @@ -591,6 +600,15 @@ func (s *VolcengineTosObjectService) createOrReplaceObject(resourceData *schema.
if _, ok := (*call.SdkParam)[ve.BypassHeader].(map[string]string)["Content-MD5"]; ok {
(*call.SdkParam)[ve.BypassHeader].(map[string]string)["x-tos-meta-content-md5"] = d.Get("content_md5").(string)
}
if _, ok := (*call.SdkParam)[ve.BypassHeader].(map[string]string)["Content"]; ok {
content := []byte(d.Get("content").(string))
err := os.WriteFile(name, content, 0644)
if err != nil {
return false, err
}
(*call.SdkParam)[ve.BypassFilePath] = name
delete((*call.SdkParam)[ve.BypassHeader].(map[string]string), "Content")
}
return true, nil
},
ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) {
Expand All @@ -606,7 +624,14 @@ func (s *VolcengineTosObjectService) createOrReplaceObject(resourceData *schema.
},
AfterCall: func(d *schema.ResourceData, client *ve.SdkClient, resp *map[string]interface{}, call ve.SdkCall) error {
d.SetId((*call.SdkParam)[ve.BypassDomain].(string) + ":" + (*call.SdkParam)[ve.BypassPath].([]string)[0])
return nil
_, err := os.Stat(name)
if err == nil {
return os.Remove(name)
}
if os.IsNotExist(err) {
return nil
}
return err
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ resource "volcengine_privatelink_vpc_endpoint" "foo" {
description = "acc-test"
}
resource "volcengine_privatelink_vpc_endpoint_zone" "foo" {
endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
subnet_id = volcengine_subnet.foo.id
private_ip_address = "172.16.0.251"
}
resource "volcengine_privatelink_vpc_endpoint_connection" "foo" {
endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
service_id = volcengine_privatelink_vpc_endpoint_service.foo.id
depends_on = [volcengine_privatelink_vpc_endpoint_zone.foo]
}
data "volcengine_privatelink_vpc_endpoint_connections" "foo" {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/clb.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ When the value of this field is `DualStack`, the type of the CLB must be `privat
The `eip_billing_config` object supports the following:

* `eip_billing_type` - (Required, ForceNew) The billing type of the EIP which automatically assigned to CLB. And optional choice contains `PostPaidByBandwidth` or `PostPaidByTraffic` or `PrePaid`.When creating a `PrePaid` public CLB, this field must be specified as `PrePaid` simultaneously.When the LoadBalancerBillingType changes from `PostPaid` to `PrePaid`, please manually modify the value of this field to `PrePaid` simultaneously.
* `isp` - (Required, ForceNew) The ISP of the EIP which automatically associated to CLB, the value can be `BGP`.
* `isp` - (Required, ForceNew) The ISP of the EIP which automatically associated to CLB, the value can be `BGP` or `ChinaMobile` or `ChinaUnicom` or `ChinaTelecom` or `SingleLine_BGP` or `Static_BGP` or `Fusion_BGP`.
* `bandwidth` - (Optional) The peek bandwidth of the EIP which automatically assigned to CLB.

The `tags` object supports the following:
Expand Down
12 changes: 12 additions & 0 deletions website/docs/r/privatelink_vpc_endpoint_connection.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,21 @@ resource "volcengine_privatelink_vpc_endpoint" "foo" {
description = "acc-test"
}
#resource "volcengine_privatelink_vpc_endpoint_connection" "foo" {
# endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
# service_id = volcengine_privatelink_vpc_endpoint_service.foo.id
#}
resource "volcengine_privatelink_vpc_endpoint_zone" "foo" {
endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
subnet_id = volcengine_subnet.foo.id
private_ip_address = "172.16.0.251"
}
resource "volcengine_privatelink_vpc_endpoint_connection" "foo" {
endpoint_id = volcengine_privatelink_vpc_endpoint.foo.id
service_id = volcengine_privatelink_vpc_endpoint_service.foo.id
depends_on = [volcengine_privatelink_vpc_endpoint_zone.foo]
}
```
## Argument Reference
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/tos_object.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ resource "volcengine_tos_object" "default" {
## Argument Reference
The following arguments are supported:
* `bucket_name` - (Required, ForceNew) The name of the bucket.
* `file_path` - (Required) The file path for upload.
* `object_name` - (Required, ForceNew) The name of the object.
* `account_acl` - (Optional) The user set of grant full control.
* `content_md5` - (Optional) The file md5 sum (32-bit hexadecimal string) for upload.
* `content_type` - (Optional, ForceNew) The content type of the object.
* `content` - (Optional) The content of the TOS Object when content type is json or text and xml. Only one of `file_path,content` can be specified.
* `encryption` - (Optional, ForceNew) The encryption of the object.Valid value is AES256.
* `file_path` - (Optional) The file path for upload. Only one of `file_path,content` can be specified.
* `public_acl` - (Optional) The public acl control of object.Valid value is private|public-read|public-read-write|authenticated-read|bucket-owner-read.
* `storage_class` - (Optional, ForceNew) The storage type of the object.Valid value is STANDARD|IA.

Expand All @@ -52,7 +53,6 @@ The `account_acl` object supports the following:
## Attributes Reference
In addition to all arguments above, the following attributes are exported:
* `id` - ID of the resource.
* `content` - The content the TOS Object when content type is json or text and xml.
* `enable_version` - The flag of enable tos version.
* `version_ids` - The version ids of the object if exist.

Expand Down

0 comments on commit 8d6cc21

Please sign in to comment.