From e2c2f4617299cc381c0c8855c8087915f900ebc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AF=9B=E5=B8=85?= Date: Thu, 22 Dec 2022 10:14:51 +0000 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20support=20Tags=20and=20ProjectName?= =?UTF-8?q?=20for=20vpc=E3=80=81eip=E3=80=81clb=20and=20ecs=20instance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/common_volcengine_callback.go | 13 +++- common/common_volcengine_tags.go | 59 ++++++++++++++++++ common/common_volcengine_version.go | 2 +- .../clb/acl/data_source_volcengine_acls.go | 10 +++ volcengine/clb/acl/resource_volcengine_acl.go | 6 ++ .../data_source_volcengine_certificates.go | 10 +++ .../resource_volcengine_certificate.go | 6 ++ .../clb/clb/data_source_volcengine_clbs.go | 12 ++++ volcengine/clb/clb/resource_volcengine_clb.go | 7 +++ volcengine/clb/clb/service_volcengine_clb.go | 34 +++++++++- .../listener/service_volcengine_listener.go | 62 +++++++++++++++++++ .../data_source_volcengine_ecs_instances.go | 12 ++++ .../resource_volcengine_ecs_instance.go | 7 +++ .../service_volcengine_ecs_instance.go | 18 ++++++ .../data_source_volcengine_eip_addresses.go | 12 ++++ .../resource_volcengine_eip_address.go | 7 +++ .../service_volcengine_eip_address.go | 19 ++++++ ...ta_source_volcengine_network_interfaces.go | 12 ++++ .../resource_volcengine_network_interface.go | 7 +++ .../service_volcengine_network_interface.go | 34 +++++++++- .../data_source_volcengine_route_tables.go | 10 +++ .../resource_volcengine_route_table.go | 5 ++ .../data_source_volcengine_security_groups.go | 12 ++++ .../resource_volcengine_security_group.go | 7 +++ .../service_volcengine_security_group.go | 36 ++++++++++- .../vpc/vpc/data_source_volcengine_vpcs.go | 12 ++++ volcengine/vpc/vpc/resource_volcengine_vpc.go | 7 +++ volcengine/vpc/vpc/service_volcengine_vpc.go | 34 +++++++++- website/docs/d/acls.html.markdown | 2 + website/docs/d/certificates.html.markdown | 2 + website/docs/d/clbs.html.markdown | 11 ++++ website/docs/d/ecs_instances.html.markdown | 11 ++++ website/docs/d/eip_addresses.html.markdown | 11 ++++ .../docs/d/network_interfaces.html.markdown | 11 ++++ website/docs/d/route_tables.html.markdown | 2 + website/docs/d/security_groups.html.markdown | 11 ++++ website/docs/d/vpcs.html.markdown | 11 ++++ website/docs/r/acl.html.markdown | 1 + website/docs/r/certificate.html.markdown | 1 + website/docs/r/clb.html.markdown | 7 +++ website/docs/r/ecs_instance.html.markdown | 7 +++ website/docs/r/eip_address.html.markdown | 7 +++ .../docs/r/network_interface.html.markdown | 7 +++ website/docs/r/route_table.html.markdown | 1 + website/docs/r/security_group.html.markdown | 7 +++ website/docs/r/vpc.html.markdown | 7 +++ 46 files changed, 583 insertions(+), 6 deletions(-) diff --git a/common/common_volcengine_callback.go b/common/common_volcengine_callback.go index 1826e94f..97852ffa 100644 --- a/common/common_volcengine_callback.go +++ b/common/common_volcengine_callback.go @@ -28,8 +28,10 @@ type SdkCall struct { RequestIdField string Refresh *StateRefresh ExtraRefresh map[ResourceService]*StateRefresh + AfterRefresh CallFunc ContentType RequestContentType LockId LockId + AfterLocked CallFunc ServiceCategory ServiceCategory } @@ -44,6 +46,7 @@ type ExecuteCallFunc func(d *schema.ResourceData, client *SdkClient, call SdkCal type AfterCallFunc func(d *schema.ResourceData, client *SdkClient, resp *map[string]interface{}, call SdkCall) error type BeforeCallFunc func(d *schema.ResourceData, client *SdkClient, call SdkCall) (bool, error) type ReadResourceFunc func(d *schema.ResourceData, resourceId string) (map[string]interface{}, error) +type CallFunc func(d *schema.ResourceData, client *SdkClient, call SdkCall) error type LockId func(d *schema.ResourceData) string @@ -194,7 +197,12 @@ func CallProcess(calls []SdkCall, d *schema.ResourceData, client *SdkClient, ser TryLock(key) } } - resp, err = fn.ExecuteCall(d, client, fn) + if fn.AfterLocked != nil { + err = fn.AfterLocked(d, client, fn) + } + if err == nil { + resp, err = fn.ExecuteCall(d, client, fn) + } } if err != nil { if fn.CallError != nil { @@ -220,6 +228,9 @@ func CallProcess(calls []SdkCall, d *schema.ResourceData, client *SdkClient, ser } } } + if doExecute && fn.AfterRefresh != nil && err == nil { + err = fn.AfterRefresh(d, client, fn) + } if doExecute && fn.LockId != nil { key := fn.LockId(d) diff --git a/common/common_volcengine_tags.go b/common/common_volcengine_tags.go index 343b531c..366c857d 100644 --- a/common/common_volcengine_tags.go +++ b/common/common_volcengine_tags.go @@ -3,6 +3,8 @@ package common import ( "bytes" "fmt" + "github.com/volcengine/terraform-provider-volcengine/logger" + "strconv" "strings" "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" @@ -80,3 +82,60 @@ var VkeTagsResponseHash = func(v interface{}) int { buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(m["type"].(string)))) return hashcode.String(buf.String()) } + +type GetUniversalInfo func(actionName string) UniversalInfo + +func SetResourceTags(serviceClient *SdkClient, addAction, RemoveAction, resourceType string, + resourceData *schema.ResourceData, getUniversalInfo GetUniversalInfo) []Callback { + var callbacks []Callback + addedTags, removedTags, _, _ := GetSetDifference("tags", resourceData, TagsHash, false) + + removeCallback := Callback{ + Call: SdkCall{ + Action: RemoveAction, + ConvertMode: RequestConvertIgnore, + BeforeCall: func(d *schema.ResourceData, client *SdkClient, call SdkCall) (bool, error) { + if removedTags != nil && len(removedTags.List()) > 0 { + (*call.SdkParam)["ResourceIds.1"] = resourceData.Id() + (*call.SdkParam)["ResourceType"] = resourceType + for index, tag := range removedTags.List() { + (*call.SdkParam)["TagKeys."+strconv.Itoa(index+1)] = tag.(map[string]interface{})["key"].(string) + } + return true, nil + } + return false, nil + }, + ExecuteCall: func(d *schema.ResourceData, client *SdkClient, call SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.ReqFormat, call.Action, call.SdkParam) + return serviceClient.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) + }, + }, + } + callbacks = append(callbacks, removeCallback) + + addCallback := Callback{ + Call: SdkCall{ + Action: addAction, + ConvertMode: RequestConvertIgnore, + BeforeCall: func(d *schema.ResourceData, client *SdkClient, call SdkCall) (bool, error) { + if addedTags != nil && len(addedTags.List()) > 0 { + (*call.SdkParam)["ResourceIds.1"] = resourceData.Id() + (*call.SdkParam)["ResourceType"] = resourceType + for index, tag := range addedTags.List() { + (*call.SdkParam)["Tags."+strconv.Itoa(index+1)+".Key"] = tag.(map[string]interface{})["key"].(string) + (*call.SdkParam)["Tags."+strconv.Itoa(index+1)+".Value"] = tag.(map[string]interface{})["value"].(string) + } + return true, nil + } + return false, nil + }, + ExecuteCall: func(d *schema.ResourceData, client *SdkClient, call SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.ReqFormat, call.Action, call.SdkParam) + return serviceClient.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) + }, + }, + } + callbacks = append(callbacks, addCallback) + + return callbacks +} diff --git a/common/common_volcengine_version.go b/common/common_volcengine_version.go index 2a7322be..5c0f3a8b 100644 --- a/common/common_volcengine_version.go +++ b/common/common_volcengine_version.go @@ -2,5 +2,5 @@ package common const ( TerraformProviderName = "terraform-provider-volcengine" - TerraformProviderVersion = "0.0.42" + TerraformProviderVersion = "0.0.43" ) diff --git a/volcengine/clb/acl/data_source_volcengine_acls.go b/volcengine/clb/acl/data_source_volcengine_acls.go index 21d776ac..8bffd7c4 100644 --- a/volcengine/clb/acl/data_source_volcengine_acls.go +++ b/volcengine/clb/acl/data_source_volcengine_acls.go @@ -25,6 +25,11 @@ func DataSourceVolcengineAcls() *schema.Resource { ValidateFunc: validation.StringIsValidRegExp, Description: "A Name Regex of Acl.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of Acl.", + }, "output_file": { Type: schema.TypeString, Optional: true, @@ -90,6 +95,11 @@ func DataSourceVolcengineAcls() *schema.Resource { }, Set: schema.HashString, }, + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The ProjectName of Acl.", + }, }, }, }, diff --git a/volcengine/clb/acl/resource_volcengine_acl.go b/volcengine/clb/acl/resource_volcengine_acl.go index c47afab2..cf3989d5 100644 --- a/volcengine/clb/acl/resource_volcengine_acl.go +++ b/volcengine/clb/acl/resource_volcengine_acl.go @@ -64,6 +64,12 @@ func ResourceVolcengineAcl() *schema.Resource { }, }, }, + "project_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The ProjectName of the Acl.", + }, "create_time": { Type: schema.TypeString, Computed: true, diff --git a/volcengine/clb/certificate/data_source_volcengine_certificates.go b/volcengine/clb/certificate/data_source_volcengine_certificates.go index e221085f..30e0fe6c 100644 --- a/volcengine/clb/certificate/data_source_volcengine_certificates.go +++ b/volcengine/clb/certificate/data_source_volcengine_certificates.go @@ -25,6 +25,11 @@ func DataSourceVolcengineCertificates() *schema.Resource { ValidateFunc: validation.StringIsValidRegExp, Description: "The Name Regex of Certificate.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of Certificate.", + }, "output_file": { Type: schema.TypeString, @@ -83,6 +88,11 @@ func DataSourceVolcengineCertificates() *schema.Resource { Computed: true, Description: "The domain name of the Certificate.", }, + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The ProjectName of the Certificate.", + }, "listeners": { Type: schema.TypeSet, Elem: &schema.Schema{ diff --git a/volcengine/clb/certificate/resource_volcengine_certificate.go b/volcengine/clb/certificate/resource_volcengine_certificate.go index 59b80035..a67384a5 100644 --- a/volcengine/clb/certificate/resource_volcengine_certificate.go +++ b/volcengine/clb/certificate/resource_volcengine_certificate.go @@ -55,6 +55,12 @@ func ResourceVolcengineCertificate() *schema.Resource { ForceNew: true, Description: "The description of the Certificate.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The ProjectName of the Certificate.", + }, }, } } diff --git a/volcengine/clb/clb/data_source_volcengine_clbs.go b/volcengine/clb/clb/data_source_volcengine_clbs.go index 4fc14804..e34dddca 100644 --- a/volcengine/clb/clb/data_source_volcengine_clbs.go +++ b/volcengine/clb/clb/data_source_volcengine_clbs.go @@ -25,6 +25,12 @@ func DataSourceVolcengineClbs() *schema.Resource { ValidateFunc: validation.StringIsValidRegExp, Description: "A Name Regex of Clb.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of Clb.", + }, + "tags": ve.TagsSchema(), "output_file": { Type: schema.TypeString, @@ -168,6 +174,12 @@ func DataSourceVolcengineClbs() *schema.Resource { Computed: true, Description: "The billing type of the Clb.", }, + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The ProjectName of the Clb.", + }, + "tags": ve.TagsSchemaComputed(), }, }, }, diff --git a/volcengine/clb/clb/resource_volcengine_clb.go b/volcengine/clb/clb/resource_volcengine_clb.go index b22cbaf3..d0049a6c 100644 --- a/volcengine/clb/clb/resource_volcengine_clb.go +++ b/volcengine/clb/clb/resource_volcengine_clb.go @@ -103,6 +103,13 @@ func ResourceVolcengineClb() *schema.Resource { Description: "The billing type of the CLB, the value can be `PostPaid`.", ValidateFunc: validation.StringInSlice([]string{"PostPaid"}, false), }, + "project_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The ProjectName of the CLB.", + }, + "tags": ve.TagsSchema(), //"period_unit": { // Type: schema.TypeString, // Optional: true, diff --git a/volcengine/clb/clb/service_volcengine_clb.go b/volcengine/clb/clb/service_volcengine_clb.go index 0c315419..9c7b01dc 100644 --- a/volcengine/clb/clb/service_volcengine_clb.go +++ b/volcengine/clb/clb/service_volcengine_clb.go @@ -173,6 +173,10 @@ func (s *VolcengineClbService) CreateResource(resourceData *schema.ResourceData, return i }, }, + "tags": { + TargetField: "Tags", + ConvertType: ve.ConvertListN, + }, }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { if regionId, ok := (*call.SdkParam)["RegionId"]; !ok { @@ -204,6 +208,8 @@ func (s *VolcengineClbService) CreateResource(resourceData *schema.ResourceData, } func (s *VolcengineClbService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { + var callbacks []ve.Callback + callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifyLoadBalancerAttributes", @@ -228,6 +234,7 @@ func (s *VolcengineClbService) ModifyResource(resourceData *schema.ResourceData, }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { (*call.SdkParam)["LoadBalancerId"] = d.Id() + delete(*call.SdkParam, "Tags") return true, nil }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { @@ -241,7 +248,13 @@ func (s *VolcengineClbService) ModifyResource(resourceData *schema.ResourceData, }, }, } - return []ve.Callback{callback} + callbacks = append(callbacks, callback) + + // 更新Tags + setResourceTagsCallbacks := ve.SetResourceTags(s.Client, "TagResources", "UntagResources", "CLB", resourceData, getUniversalInfo) + callbacks = append(callbacks, setResourceTagsCallbacks...) + + return callbacks } func (s *VolcengineClbService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { @@ -287,6 +300,15 @@ func (s *VolcengineClbService) DatasourceResources(*schema.ResourceData, *schema TargetField: "LoadBalancerIds", ConvertType: ve.ConvertWithN, }, + "tags": { + TargetField: "TagFilters", + ConvertType: ve.ConvertListN, + NextLevelConvert: map[string]ve.RequestConvert{ + "value": { + TargetField: "Values.1", + }, + }, + }, }, NameField: "LoadBalancerName", IdField: "LoadBalancerId", @@ -325,3 +347,13 @@ func (s *VolcengineClbService) DatasourceResources(*schema.ResourceData, *schema func (s *VolcengineClbService) ReadResourceId(id string) string { return id } + +func getUniversalInfo(actionName string) ve.UniversalInfo { + return ve.UniversalInfo{ + ServiceName: "clb", + Version: "2020-04-01", + HttpMethod: ve.GET, + ContentType: ve.Default, + Action: actionName, + } +} diff --git a/volcengine/clb/listener/service_volcengine_listener.go b/volcengine/clb/listener/service_volcengine_listener.go index 666818b7..c536ae61 100644 --- a/volcengine/clb/listener/service_volcengine_listener.go +++ b/volcengine/clb/listener/service_volcengine_listener.go @@ -3,6 +3,7 @@ package listener import ( "errors" "fmt" + "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -10,6 +11,8 @@ import ( ve "github.com/volcengine/terraform-provider-volcengine/common" "github.com/volcengine/terraform-provider-volcengine/logger" "github.com/volcengine/terraform-provider-volcengine/volcengine/clb/clb" + clbSDK "github.com/volcengine/volcengine-go-sdk/service/clb" + "github.com/volcengine/volcengine-go-sdk/volcengine" ) type VolcengineListenerService struct { @@ -163,6 +166,61 @@ func (*VolcengineListenerService) WithResourceResponseHandlers(listener map[stri } +func (s *VolcengineListenerService) refreshAclStatus() ve.CallFunc { + return func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) error { + var aclIds []string + for k, v := range *call.SdkParam { + if strings.HasPrefix(k, "AclIds.") { + aclIds = append(aclIds, v.(string)) + } + } + if len(aclIds) > 0 { + if err := s.checkAcl(aclIds); err != nil { + return err + } + } + return nil + } +} + +func (s *VolcengineListenerService) checkAcl(aclIds []string) error { + return resource.Retry(20*time.Minute, func() *resource.RetryError { + logger.Debug(logger.ReqFormat, "DescribeAcls", aclIds) + // create 的时候上限为5个,无需翻页 + resp, err := s.Client.ClbClient.DescribeAcls(&clbSDK.DescribeAclsInput{ + AclIds: volcengine.StringSlice(aclIds), + PageNumber: volcengine.Int64(1), + PageSize: volcengine.Int64(100), + }) + if err != nil { + return resource.NonRetryableError(err) + } + logger.Debug(logger.RespFormat, "DescribeAcls", aclIds, *resp) + + statusOK := true + aclIdMap := make(map[string]bool) + for _, element := range resp.Acls { + aclIdMap[*element.AclId] = true + if *element.Status == "Deleting" { + return resource.NonRetryableError(fmt.Errorf("acl is in deleting status")) + } else if *element.Status != "Active" { // Creating / Configuring + statusOK = false + break + } + } + if !statusOK { + return resource.RetryableError(fmt.Errorf("acl still in waiting status")) + } + + for _, aclId := range aclIds { + if _, exist := aclIdMap[aclId]; !exist { + return resource.NonRetryableError(errors.New(fmt.Sprintf("cannot find acl: %s", aclId))) + } + } + return nil + }) +} + func (s *VolcengineListenerService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ @@ -193,6 +251,7 @@ func (s *VolcengineListenerService) CreateResource(resourceData *schema.Resource return true, nil }, + AfterLocked: s.refreshAclStatus(), ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) //创建listener @@ -215,6 +274,7 @@ func (s *VolcengineListenerService) CreateResource(resourceData *schema.Resource ResourceId: resourceData.Get("load_balancer_id").(string), }, }, + AfterRefresh: s.refreshAclStatus(), LockId: func(d *schema.ResourceData) string { return resourceData.Get("load_balancer_id").(string) }, @@ -276,6 +336,7 @@ func (s *VolcengineListenerService) ModifyResource(resourceData *schema.Resource } return true, nil }, + AfterLocked: s.refreshAclStatus(), ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) //修改 listener 属性 @@ -292,6 +353,7 @@ func (s *VolcengineListenerService) ModifyResource(resourceData *schema.Resource ResourceId: clbId, }, }, + AfterRefresh: s.refreshAclStatus(), LockId: func(d *schema.ResourceData) string { return clbId }, diff --git a/volcengine/ecs/ecs_instance/data_source_volcengine_ecs_instances.go b/volcengine/ecs/ecs_instance/data_source_volcengine_ecs_instances.go index 3c0c25de..6128cd29 100644 --- a/volcengine/ecs/ecs_instance/data_source_volcengine_ecs_instances.go +++ b/volcengine/ecs/ecs_instance/data_source_volcengine_ecs_instances.go @@ -60,6 +60,12 @@ func DataSourceVolcengineEcsInstances() *schema.Resource { ValidateFunc: validation.StringIsValidRegExp, Description: "A Name Regex of ECS instance.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of ECS instance.", + }, + "tags": ve.TagsSchema(), "output_file": { Type: schema.TypeString, @@ -284,6 +290,12 @@ func DataSourceVolcengineEcsInstances() *schema.Resource { }, }, }, + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The ProjectName of ECS instance.", + }, + "tags": ve.TagsSchemaComputed(), }, }, }, diff --git a/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go b/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go index 57c9ae4e..848a5167 100644 --- a/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go +++ b/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go @@ -282,6 +282,13 @@ func ResourceVolcengineEcsInstance() *schema.Resource { }, }, }, + "project_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The ProjectName of the VPC.", + }, + "tags": ve.TagsSchema(), }, } dataSource := DataSourceVolcengineEcsInstances().Schema["instances"].Elem.(*schema.Resource).Schema diff --git a/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go b/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go index acb1ea25..f44b03e4 100644 --- a/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go +++ b/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go @@ -393,6 +393,10 @@ func (s *VolcengineEcsService) CreateResource(resourceData *schema.ResourceData, } }, }, + "tags": { + TargetField: "Tags", + ConvertType: ve.ConvertListN, + }, }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { (*call.SdkParam)["ClientToken"] = uuid.New().String() @@ -481,6 +485,7 @@ func (s *VolcengineEcsService) ModifyResource(resourceData *schema.ResourceData, delete(*call.SdkParam, "Password") } if len(*call.SdkParam) > 1 { + delete(*call.SdkParam, "Tags") return true, nil } return false, nil @@ -799,6 +804,10 @@ func (s *VolcengineEcsService) ModifyResource(resourceData *schema.ResourceData, startInstance := s.StartOrStopInstanceCallback(resourceData, false, &flag) callbacks = append(callbacks, startInstance) + // 更新Tags + setResourceTagsCallbacks := ve.SetResourceTags(s.Client, "CreateTags", "DeleteTags", "instance", resourceData, getUniversalInfo) + callbacks = append(callbacks, setResourceTagsCallbacks...) + return callbacks } @@ -849,6 +858,15 @@ func (s *VolcengineEcsService) DatasourceResources(data *schema.ResourceData, re TargetField: "InstanceIds", ConvertType: ve.ConvertWithN, }, + "tags": { + TargetField: "TagFilters", + ConvertType: ve.ConvertListN, + NextLevelConvert: map[string]ve.RequestConvert{ + "value": { + TargetField: "Values.1", + }, + }, + }, }, NameField: "InstanceName", IdField: "InstanceId", diff --git a/volcengine/eip/eip_address/data_source_volcengine_eip_addresses.go b/volcengine/eip/eip_address/data_source_volcengine_eip_addresses.go index 0212de1b..b2f04c23 100644 --- a/volcengine/eip/eip_address/data_source_volcengine_eip_addresses.go +++ b/volcengine/eip/eip_address/data_source_volcengine_eip_addresses.go @@ -56,6 +56,12 @@ func DataSourceVolcengineEipAddresses() *schema.Resource { Optional: true, Description: "An id of associated instance.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of EIP.", + }, + "tags": ve.TagsSchema(), "output_file": { Type: schema.TypeString, @@ -163,6 +169,12 @@ func DataSourceVolcengineEipAddresses() *schema.Resource { Computed: true, Description: "The expired time of the EIP.", }, + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The ProjectName of the EIP.", + }, + "tags": ve.TagsSchemaComputed(), }, }, }, diff --git a/volcengine/eip/eip_address/resource_volcengine_eip_address.go b/volcengine/eip/eip_address/resource_volcengine_eip_address.go index f9bc8499..df6b2c55 100644 --- a/volcengine/eip/eip_address/resource_volcengine_eip_address.go +++ b/volcengine/eip/eip_address/resource_volcengine_eip_address.go @@ -65,6 +65,13 @@ func ResourceVolcengineEipAddress() *schema.Resource { Optional: true, Description: "The description of the EIP.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The ProjectName of the EIP.", + }, + "tags": ve.TagsSchema(), "status": { Type: schema.TypeString, Computed: true, diff --git a/volcengine/eip/eip_address/service_volcengine_eip_address.go b/volcengine/eip/eip_address/service_volcengine_eip_address.go index 3ca03f33..19dd8e2e 100644 --- a/volcengine/eip/eip_address/service_volcengine_eip_address.go +++ b/volcengine/eip/eip_address/service_volcengine_eip_address.go @@ -167,6 +167,10 @@ func (s *VolcengineEipAddressService) CreateResource(resourceData *schema.Resour "isp": { TargetField: "ISP", }, + "tags": { + TargetField: "Tags", + ConvertType: ve.ConvertListN, + }, }, }, } @@ -183,6 +187,7 @@ func (s *VolcengineEipAddressService) ModifyResource(resourceData *schema.Resour BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { if len(*call.SdkParam) > 0 { (*call.SdkParam)["AllocationId"] = d.Id() + delete(*call.SdkParam, "Tags") return true, nil } return false, nil @@ -237,6 +242,11 @@ func (s *VolcengineEipAddressService) ModifyResource(resourceData *schema.Resour } callbacks = append(callbacks, chargeTypeCall) } + + // 更新Tags + setResourceTagsCallbacks := ve.SetResourceTags(s.Client, "TagResources", "UntagResources", "eip", resourceData, getUniversalInfo) + callbacks = append(callbacks, setResourceTagsCallbacks...) + return callbacks } @@ -292,6 +302,15 @@ func (s *VolcengineEipAddressService) DatasourceResources(*schema.ResourceData, "isp": { TargetField: "ISP", }, + "tags": { + TargetField: "TagFilters", + ConvertType: ve.ConvertListN, + NextLevelConvert: map[string]ve.RequestConvert{ + "value": { + TargetField: "Values.1", + }, + }, + }, }, NameField: "Name", IdField: "AllocationId", diff --git a/volcengine/vpc/network_interface/data_source_volcengine_network_interfaces.go b/volcengine/vpc/network_interface/data_source_volcengine_network_interfaces.go index 9be14e2f..5a28f16d 100644 --- a/volcengine/vpc/network_interface/data_source_volcengine_network_interfaces.go +++ b/volcengine/vpc/network_interface/data_source_volcengine_network_interfaces.go @@ -64,6 +64,12 @@ func DataSourceVolcengineNetworkInterfaces() *schema.Resource { Optional: true, Description: "A name of ENI.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of the ENI.", + }, + "tags": ve.TagsSchema(), "output_file": { Type: schema.TypeString, @@ -184,6 +190,12 @@ func DataSourceVolcengineNetworkInterfaces() *schema.Resource { Computed: true, Description: "The IP address of the EIP to which the ENI associates.", }, + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The ProjectName of the ENI.", + }, + "tags": ve.TagsSchemaComputed(), }, }, }, diff --git a/volcengine/vpc/network_interface/resource_volcengine_network_interface.go b/volcengine/vpc/network_interface/resource_volcengine_network_interface.go index fa95cb23..ee1726f2 100644 --- a/volcengine/vpc/network_interface/resource_volcengine_network_interface.go +++ b/volcengine/vpc/network_interface/resource_volcengine_network_interface.go @@ -73,6 +73,13 @@ func ResourceVolcengineNetworkInterface() *schema.Resource { Computed: true, Description: "Set port security enable or disable.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The ProjectName of the ENI.", + }, + "tags": ve.TagsSchema(), "status": { Type: schema.TypeString, Computed: true, diff --git a/volcengine/vpc/network_interface/service_volcengine_network_interface.go b/volcengine/vpc/network_interface/service_volcengine_network_interface.go index 8af70ae2..d721e1fe 100644 --- a/volcengine/vpc/network_interface/service_volcengine_network_interface.go +++ b/volcengine/vpc/network_interface/service_volcengine_network_interface.go @@ -153,6 +153,10 @@ func (s *VolcengineNetworkInterfaceService) CreateResource(resourceData *schema. TargetField: "SecurityGroupIds", ConvertType: ve.ConvertWithN, }, + "tags": { + TargetField: "Tags", + ConvertType: ve.ConvertListN, + }, }, }, } @@ -160,12 +164,15 @@ func (s *VolcengineNetworkInterfaceService) CreateResource(resourceData *schema. } func (s *VolcengineNetworkInterfaceService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { + var callbacks []ve.Callback + callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifyNetworkInterfaceAttributes", ConvertMode: ve.RequestConvertAll, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { (*call.SdkParam)["NetworkInterfaceId"] = d.Id() + delete(*call.SdkParam, "Tags") return true, nil }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { @@ -180,7 +187,13 @@ func (s *VolcengineNetworkInterfaceService) ModifyResource(resourceData *schema. }, }, } - return []ve.Callback{callback} + callbacks = append(callbacks, callback) + + // 更新Tags + setResourceTagsCallbacks := ve.SetResourceTags(s.Client, "TagResources", "UntagResources", "eni", resourceData, getUniversalInfo) + callbacks = append(callbacks, setResourceTagsCallbacks...) + + return callbacks } func (s *VolcengineNetworkInterfaceService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { @@ -232,6 +245,15 @@ func (s *VolcengineNetworkInterfaceService) DatasourceResources(*schema.Resource TargetField: "PrimaryIpAddresses", ConvertType: ve.ConvertWithN, }, + "tags": { + TargetField: "TagFilters", + ConvertType: ve.ConvertListN, + NextLevelConvert: map[string]ve.RequestConvert{ + "value": { + TargetField: "Values.1", + }, + }, + }, }, NameField: "NetworkInterfaceName", IdField: "NetworkInterfaceId", @@ -254,3 +276,13 @@ func (s *VolcengineNetworkInterfaceService) DatasourceResources(*schema.Resource func (s *VolcengineNetworkInterfaceService) ReadResourceId(id string) string { return id } + +func getUniversalInfo(actionName string) ve.UniversalInfo { + return ve.UniversalInfo{ + ServiceName: "vpc", + Version: "2020-04-01", + HttpMethod: ve.GET, + ContentType: ve.Default, + Action: actionName, + } +} diff --git a/volcengine/vpc/route_table/data_source_volcengine_route_tables.go b/volcengine/vpc/route_table/data_source_volcengine_route_tables.go index 594fd89e..ba343a85 100644 --- a/volcengine/vpc/route_table/data_source_volcengine_route_tables.go +++ b/volcengine/vpc/route_table/data_source_volcengine_route_tables.go @@ -27,6 +27,11 @@ func DataSourceVolcengineRouteTables() *schema.Resource { Optional: true, Description: "A name of route table.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of the route table.", + }, "output_file": { Type: schema.TypeString, @@ -102,6 +107,11 @@ func DataSourceVolcengineRouteTables() *schema.Resource { Computed: true, Description: "The description of the route table.", }, + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The ProjectName of the route table.", + }, }, }, }, diff --git a/volcengine/vpc/route_table/resource_volcengine_route_table.go b/volcengine/vpc/route_table/resource_volcengine_route_table.go index c6d51815..c3c012cd 100644 --- a/volcengine/vpc/route_table/resource_volcengine_route_table.go +++ b/volcengine/vpc/route_table/resource_volcengine_route_table.go @@ -50,6 +50,11 @@ func ResourceVolcengineRouteTable() *schema.Resource { Optional: true, Description: "The description of the route table.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of the route table.", + }, }, } } diff --git a/volcengine/vpc/security_group/data_source_volcengine_security_groups.go b/volcengine/vpc/security_group/data_source_volcengine_security_groups.go index 983b725f..a559ec36 100644 --- a/volcengine/vpc/security_group/data_source_volcengine_security_groups.go +++ b/volcengine/vpc/security_group/data_source_volcengine_security_groups.go @@ -25,6 +25,12 @@ func DataSourceVolcengineSecurityGroups() *schema.Resource { ValidateFunc: validation.StringIsValidRegExp, Description: "A Name Regex of SecurityGroup.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of SecurityGroup.", + }, + "tags": ve.TagsSchema(), "output_file": { Type: schema.TypeString, Optional: true, @@ -81,6 +87,12 @@ func DataSourceVolcengineSecurityGroups() *schema.Resource { Computed: true, Description: "A Name Regex of SecurityGroup.", }, + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The ProjectName of SecurityGroup.", + }, + "tags": ve.TagsSchemaComputed(), }, }, }, diff --git a/volcengine/vpc/security_group/resource_volcengine_security_group.go b/volcengine/vpc/security_group/resource_volcengine_security_group.go index d9dd2e79..a1acfe4f 100644 --- a/volcengine/vpc/security_group/resource_volcengine_security_group.go +++ b/volcengine/vpc/security_group/resource_volcengine_security_group.go @@ -60,6 +60,13 @@ func ResourceVolcengineSecurityGroup() *schema.Resource { Computed: true, Description: "Name of SecurityGroup.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The ProjectName of SecurityGroup.", + }, + "tags": ve.TagsSchema(), }, } } diff --git a/volcengine/vpc/security_group/service_volcengine_security_group.go b/volcengine/vpc/security_group/service_volcengine_security_group.go index c07381c3..086d9e60 100644 --- a/volcengine/vpc/security_group/service_volcengine_security_group.go +++ b/volcengine/vpc/security_group/service_volcengine_security_group.go @@ -140,6 +140,12 @@ func (s *VolcengineSecurityGroupService) CreateResource(resourceData *schema.Res Call: ve.SdkCall{ Action: "CreateSecurityGroup", ConvertMode: ve.RequestConvertAll, + Convert: map[string]ve.RequestConvert{ + "tags": { + TargetField: "Tags", + ConvertType: ve.ConvertListN, + }, + }, LockId: func(d *schema.ResourceData) string { return d.Get("vpc_id").(string) }, @@ -171,6 +177,8 @@ func (s *VolcengineSecurityGroupService) CreateResource(resourceData *schema.Res } func (s *VolcengineSecurityGroupService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { + var callbacks []ve.Callback + callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifySecurityGroupAttributes", @@ -180,6 +188,7 @@ func (s *VolcengineSecurityGroupService) ModifyResource(resourceData *schema.Res }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { (*call.SdkParam)["SecurityGroupId"] = d.Id() + delete(*call.SdkParam, "Tags") return true, nil }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { @@ -199,7 +208,13 @@ func (s *VolcengineSecurityGroupService) ModifyResource(resourceData *schema.Res }, }, } - return []ve.Callback{callback} + callbacks = append(callbacks, callback) + + // 更新Tags + setResourceTagsCallbacks := ve.SetResourceTags(s.Client, "TagResources", "UntagResources", "securitygroup", resourceData, getUniversalInfo) + callbacks = append(callbacks, setResourceTagsCallbacks...) + + return callbacks } func (s *VolcengineSecurityGroupService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { @@ -251,6 +266,15 @@ func (s *VolcengineSecurityGroupService) DatasourceResources(*schema.ResourceDat TargetField: "SecurityGroupNames", ConvertType: ve.ConvertWithN, }, + "tags": { + TargetField: "TagFilters", + ConvertType: ve.ConvertListN, + NextLevelConvert: map[string]ve.RequestConvert{ + "value": { + TargetField: "Values.1", + }, + }, + }, }, NameField: "SecurityGroupName", IdField: "SecurityGroupId", @@ -267,3 +291,13 @@ func (s *VolcengineSecurityGroupService) DatasourceResources(*schema.ResourceDat func (s *VolcengineSecurityGroupService) ReadResourceId(id string) string { return id } + +func getUniversalInfo(actionName string) ve.UniversalInfo { + return ve.UniversalInfo{ + ServiceName: "vpc", + Version: "2020-04-01", + HttpMethod: ve.GET, + ContentType: ve.Default, + Action: actionName, + } +} diff --git a/volcengine/vpc/vpc/data_source_volcengine_vpcs.go b/volcengine/vpc/vpc/data_source_volcengine_vpcs.go index 0ae4a50a..3c19bdb6 100644 --- a/volcengine/vpc/vpc/data_source_volcengine_vpcs.go +++ b/volcengine/vpc/vpc/data_source_volcengine_vpcs.go @@ -25,6 +25,12 @@ func DataSourceVolcengineVpcs() *schema.Resource { ValidateFunc: validation.StringIsValidRegExp, Description: "A Name Regex of Vpc.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of the VPC.", + }, + "tags": ve.TagsSchema(), "output_file": { Type: schema.TypeString, @@ -164,6 +170,12 @@ func DataSourceVolcengineVpcs() *schema.Resource { Set: schema.HashString, Description: "The auxiliary cidr block list of VPC.", }, + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The ProjectName of the VPC.", + }, + "tags": ve.TagsSchemaComputed(), }, }, }, diff --git a/volcengine/vpc/vpc/resource_volcengine_vpc.go b/volcengine/vpc/vpc/resource_volcengine_vpc.go index 9ae34180..37da5869 100644 --- a/volcengine/vpc/vpc/resource_volcengine_vpc.go +++ b/volcengine/vpc/vpc/resource_volcengine_vpc.go @@ -62,6 +62,13 @@ func ResourceVolcengineVpc() *schema.Resource { Set: schema.HashString, Description: "The DNS server list of the VPC. And you can specify 0 to 5 servers to this list.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The ProjectName of the VPC.", + }, + "tags": ve.TagsSchema(), "status": { Type: schema.TypeString, Computed: true, diff --git a/volcengine/vpc/vpc/service_volcengine_vpc.go b/volcengine/vpc/vpc/service_volcengine_vpc.go index d203ae52..d2c85a94 100644 --- a/volcengine/vpc/vpc/service_volcengine_vpc.go +++ b/volcengine/vpc/vpc/service_volcengine_vpc.go @@ -146,6 +146,10 @@ func (s *VolcengineVpcService) CreateResource(resourceData *schema.ResourceData, TargetField: "DnsServers", ConvertType: ve.ConvertWithN, }, + "tags": { + TargetField: "Tags", + ConvertType: ve.ConvertListN, + }, }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) @@ -169,6 +173,8 @@ func (s *VolcengineVpcService) CreateResource(resourceData *schema.ResourceData, } func (s *VolcengineVpcService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { + var callbacks []ve.Callback + callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifyVpcAttributes", @@ -181,6 +187,7 @@ func (s *VolcengineVpcService) ModifyResource(resourceData *schema.ResourceData, }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { (*call.SdkParam)["VpcId"] = d.Id() + delete(*call.SdkParam, "Tags") return true, nil }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { @@ -194,7 +201,13 @@ func (s *VolcengineVpcService) ModifyResource(resourceData *schema.ResourceData, }, }, } - return []ve.Callback{callback} + callbacks = append(callbacks, callback) + + // 更新Tags + setResourceTagsCallbacks := ve.SetResourceTags(s.Client, "TagResources", "UntagResources", "vpc", resourceData, getUniversalInfo) + callbacks = append(callbacks, setResourceTagsCallbacks...) + + return callbacks } func (s *VolcengineVpcService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { @@ -240,6 +253,15 @@ func (s *VolcengineVpcService) DatasourceResources(*schema.ResourceData, *schema TargetField: "VpcIds", ConvertType: ve.ConvertWithN, }, + "tags": { + TargetField: "TagFilters", + ConvertType: ve.ConvertListN, + NextLevelConvert: map[string]ve.RequestConvert{ + "value": { + TargetField: "Values.1", + }, + }, + }, }, NameField: "VpcName", IdField: "VpcId", @@ -256,3 +278,13 @@ func (s *VolcengineVpcService) DatasourceResources(*schema.ResourceData, *schema func (s *VolcengineVpcService) ReadResourceId(id string) string { return id } + +func getUniversalInfo(actionName string) ve.UniversalInfo { + return ve.UniversalInfo{ + ServiceName: "vpc", + Version: "2020-04-01", + HttpMethod: ve.GET, + ContentType: ve.Default, + Action: actionName, + } +} diff --git a/website/docs/d/acls.html.markdown b/website/docs/d/acls.html.markdown index f23c4958..30329ca2 100644 --- a/website/docs/d/acls.html.markdown +++ b/website/docs/d/acls.html.markdown @@ -20,6 +20,7 @@ The following arguments are supported: * `ids` - (Optional) A list of Acl IDs. * `name_regex` - (Optional) A Name Regex of Acl. * `output_file` - (Optional) File name where to save data source results. +* `project_name` - (Optional) The ProjectName of Acl. ## Attributes Reference In addition to all arguments above, the following attributes are exported: @@ -31,6 +32,7 @@ In addition to all arguments above, the following attributes are exported: * `description` - The description of Acl. * `id` - The ID of Acl. * `listeners` - The listeners of Acl. + * `project_name` - The ProjectName of Acl. * `update_time` - Update time of Acl. * `total_count` - The total count of Acl query. diff --git a/website/docs/d/certificates.html.markdown b/website/docs/d/certificates.html.markdown index ac986893..e73793dc 100644 --- a/website/docs/d/certificates.html.markdown +++ b/website/docs/d/certificates.html.markdown @@ -20,6 +20,7 @@ The following arguments are supported: * `ids` - (Optional) The list of Certificate IDs. * `name_regex` - (Optional) The Name Regex of Certificate. * `output_file` - (Optional) File name where to save data source results. +* `project_name` - (Optional) The ProjectName of Certificate. ## Attributes Reference In addition to all arguments above, the following attributes are exported: @@ -32,6 +33,7 @@ In addition to all arguments above, the following attributes are exported: * `expired_at` - The expire time of the Certificate. * `id` - The ID of the Certificate. * `listeners` - The ID list of the Listener. + * `project_name` - The ProjectName of the Certificate. * `total_count` - The total count of Certificate query. diff --git a/website/docs/d/clbs.html.markdown b/website/docs/d/clbs.html.markdown index cef891d4..967ec9d5 100644 --- a/website/docs/d/clbs.html.markdown +++ b/website/docs/d/clbs.html.markdown @@ -21,8 +21,15 @@ The following arguments are supported: * `load_balancer_name` - (Optional) The name of the Clb. * `name_regex` - (Optional) A Name Regex of Clb. * `output_file` - (Optional) File name where to save data source results. +* `project_name` - (Optional) The ProjectName of Clb. +* `tags` - (Optional) Tags. * `vpc_id` - (Optional) The id of the VPC. +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: * `clbs` - The collection of Clb query. @@ -43,8 +50,12 @@ In addition to all arguments above, the following attributes are exported: * `modification_protection_reason` - The modification protection reason of the Clb. * `modification_protection_status` - The modification protection status of the Clb. * `overdue_time` - The overdue time of the Clb. + * `project_name` - The ProjectName of the Clb. * `status` - The status of the Clb. * `subnet_id` - The subnet ID of the Clb. + * `tags` - Tags. + * `key` - The Key of Tags. + * `value` - The Value of Tags. * `type` - The type of the Clb. * `update_time` - The update time of the Clb. * `vpc_id` - The vpc ID of the Clb. diff --git a/website/docs/d/ecs_instances.html.markdown b/website/docs/d/ecs_instances.html.markdown index a7d85bdc..de1ec6ef 100644 --- a/website/docs/d/ecs_instances.html.markdown +++ b/website/docs/d/ecs_instances.html.markdown @@ -23,10 +23,17 @@ The following arguments are supported: * `name_regex` - (Optional) A Name Regex of ECS instance. * `output_file` - (Optional) File name where to save data source results. * `primary_ip_address` - (Optional) The primary ip address of ECS instance. +* `project_name` - (Optional) The ProjectName of ECS instance. * `status` - (Optional) The status of ECS instance. +* `tags` - (Optional) Tags. * `vpc_id` - (Optional) The VPC ID of ECS instance. * `zone_id` - (Optional) The available zone ID of ECS instance. +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: * `instances` - The collection of ECS instance query. @@ -57,8 +64,12 @@ In addition to all arguments above, the following attributes are exported: * `vpc_id` - The ID of networkInterface. * `os_name` - The os name of ECS instance. * `os_type` - The os type of ECS instance. + * `project_name` - The ProjectName of ECS instance. * `status` - The status of ECS instance. * `stopped_mode` - The stop mode of ECS instance. + * `tags` - Tags. + * `key` - The Key of Tags. + * `value` - The Value of Tags. * `updated_at` - The update time of ECS instance. * `volumes` - The volume detail collection of volume. * `delete_with_instance` - The delete with instance flag of volume. diff --git a/website/docs/d/eip_addresses.html.markdown b/website/docs/d/eip_addresses.html.markdown index 50cf3b37..456d08da 100644 --- a/website/docs/d/eip_addresses.html.markdown +++ b/website/docs/d/eip_addresses.html.markdown @@ -23,7 +23,14 @@ The following arguments are supported: * `isp` - (Optional) An ISP of EIP Address, the value can be `BGP` or `ChinaMobile` or `ChinaUnicom` or `ChinaTelecom`. * `name` - (Optional) A name of EIP. * `output_file` - (Optional) File name where to save data source results. +* `project_name` - (Optional) The ProjectName of EIP. * `status` - (Optional) A status of EIP, the value can be `Attaching` or `Detaching` or `Attached` or `Available`. +* `tags` - (Optional) Tags. + +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. ## Attributes Reference In addition to all arguments above, the following attributes are exported: @@ -44,7 +51,11 @@ In addition to all arguments above, the following attributes are exported: * `lock_reason` - The lock reason of the EIP. * `name` - The name of the EIP. * `overdue_time` - The overdue time of the EIP. + * `project_name` - The ProjectName of the EIP. * `status` - The status of the EIP. + * `tags` - Tags. + * `key` - The Key of Tags. + * `value` - The Value of Tags. * `updated_at` - The last update time of the EIP. * `total_count` - The total count of EIP addresses query. diff --git a/website/docs/d/network_interfaces.html.markdown b/website/docs/d/network_interfaces.html.markdown index 774f0103..87cbb2c6 100644 --- a/website/docs/d/network_interfaces.html.markdown +++ b/website/docs/d/network_interfaces.html.markdown @@ -21,12 +21,19 @@ The following arguments are supported: * `network_interface_name` - (Optional) A name of ENI. * `output_file` - (Optional) File name where to save data source results. * `primary_ip_addresses` - (Optional) A list of primary IP address of ENI. +* `project_name` - (Optional) The ProjectName of the ENI. * `security_group_id` - (Optional) An id of the security group to which the secondary ENI belongs. * `status` - (Optional) A status of ENI, Optional choice contains `Creating`, `Available`, `Attaching`, `InUse`, `Detaching`, `Deleting`. * `subnet_id` - (Optional) An id of the subnet to which the ENI is connected. +* `tags` - (Optional) Tags. * `type` - (Optional) A type of ENI, Optional choice contains `primary`, `secondary`. * `vpc_id` - (Optional) An id of the virtual private cloud (VPC) to which the ENI belongs. +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: * `network_interfaces` - The collection of ENI. @@ -42,9 +49,13 @@ In addition to all arguments above, the following attributes are exported: * `network_interface_name` - The name of the ENI. * `port_security_enabled` - The enable of port security. * `primary_ip_address` - The primary IP address of the ENI. + * `project_name` - The ProjectName of the ENI. * `security_group_ids` - The list of the security group id to which the secondary ENI belongs. * `status` - The status of the ENI. * `subnet_id` - The id of the subnet to which the ENI is connected. + * `tags` - Tags. + * `key` - The Key of Tags. + * `value` - The Value of Tags. * `type` - The type of the ENI. * `updated_at` - The last update time of the ENI. * `vpc_id` - The id of the virtual private cloud (VPC) to which the ENI belongs. diff --git a/website/docs/d/route_tables.html.markdown b/website/docs/d/route_tables.html.markdown index 4552abc2..ea51ee4a 100644 --- a/website/docs/d/route_tables.html.markdown +++ b/website/docs/d/route_tables.html.markdown @@ -19,6 +19,7 @@ data "volcengine_route_tables" "default" { The following arguments are supported: * `ids` - (Optional) A list of route table ids. * `output_file` - (Optional) File name where to save data source results. +* `project_name` - (Optional) The ProjectName of the route table. * `route_table_name` - (Optional) A name of route table. * `vpc_id` - (Optional) An id of VPC. @@ -29,6 +30,7 @@ In addition to all arguments above, the following attributes are exported: * `creation_time` - The create time of the route table. * `description` - The description of the route table. * `id` - The id of the route table. + * `project_name` - The ProjectName of the route table. * `route_table_id` - The id of the route table. * `route_table_name` - The name of the route table. * `route_table_type` - The type of the route table. diff --git a/website/docs/d/security_groups.html.markdown b/website/docs/d/security_groups.html.markdown index bc9ee671..7454738a 100644 --- a/website/docs/d/security_groups.html.markdown +++ b/website/docs/d/security_groups.html.markdown @@ -19,6 +19,13 @@ The following arguments are supported: * `ids` - (Optional) A list of SecurityGroup IDs. * `name_regex` - (Optional) A Name Regex of SecurityGroup. * `output_file` - (Optional) File name where to save data source results. +* `project_name` - (Optional) The ProjectName of SecurityGroup. +* `tags` - (Optional) Tags. + +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. ## Attributes Reference In addition to all arguments above, the following attributes are exported: @@ -26,9 +33,13 @@ In addition to all arguments above, the following attributes are exported: * `creation_time` - The creation time of SecurityGroup. * `description` - The description of SecurityGroup. * `id` - The ID of SecurityGroup. + * `project_name` - The ProjectName of SecurityGroup. * `security_group_id` - The ID of SecurityGroup. * `security_group_name` - The Name of SecurityGroup. * `status` - The Status of SecurityGroup. + * `tags` - Tags. + * `key` - The Key of Tags. + * `value` - The Value of Tags. * `type` - A Name Regex of SecurityGroup. * `vpc_id` - The ID of Vpc. * `total_count` - The total count of SecurityGroup query. diff --git a/website/docs/d/vpcs.html.markdown b/website/docs/d/vpcs.html.markdown index e3acaa59..07d6bed5 100644 --- a/website/docs/d/vpcs.html.markdown +++ b/website/docs/d/vpcs.html.markdown @@ -19,6 +19,13 @@ The following arguments are supported: * `ids` - (Optional) A list of VPC IDs. * `name_regex` - (Optional) A Name Regex of Vpc. * `output_file` - (Optional) File name where to save data source results. +* `project_name` - (Optional) The ProjectName of the VPC. +* `tags` - (Optional) Tags. + +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. ## Attributes Reference In addition to all arguments above, the following attributes are exported: @@ -35,10 +42,14 @@ In addition to all arguments above, the following attributes are exported: * `description` - The description of VPC. * `dns_servers` - The dns server list of VPC. * `nat_gateway_ids` - The nat gateway ID list of VPC. + * `project_name` - The ProjectName of the VPC. * `route_table_ids` - The route table ID list of VPC. * `security_group_ids` - The security group ID list of VPC. * `status` - The status of VPC. * `subnet_ids` - The subnet ID list of VPC. + * `tags` - Tags. + * `key` - The Key of Tags. + * `value` - The Value of Tags. * `update_time` - The update time of VPC. * `vpc_id` - The ID of VPC. * `vpc_name` - The name of VPC. diff --git a/website/docs/r/acl.html.markdown b/website/docs/r/acl.html.markdown index 33a5dc73..5e9fadce 100644 --- a/website/docs/r/acl.html.markdown +++ b/website/docs/r/acl.html.markdown @@ -28,6 +28,7 @@ The following arguments are supported: * `acl_entries` - (Optional) The acl entry set of the Acl. * `acl_name` - (Optional) The name of Acl. * `description` - (Optional) The description of the Acl. +* `project_name` - (Optional, ForceNew) The ProjectName of the Acl. The `acl_entries` object supports the following: diff --git a/website/docs/r/certificate.html.markdown b/website/docs/r/certificate.html.markdown index 55276eea..976f5bdf 100644 --- a/website/docs/r/certificate.html.markdown +++ b/website/docs/r/certificate.html.markdown @@ -23,6 +23,7 @@ The following arguments are supported: * `public_key` - (Required, ForceNew) The public key of the Certificate. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `certificate_name` - (Optional, ForceNew) The name of the Certificate. * `description` - (Optional, ForceNew) The description of the Certificate. +* `project_name` - (Optional, ForceNew) The ProjectName of the Certificate. ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/website/docs/r/clb.html.markdown b/website/docs/r/clb.html.markdown index 66459941..b41173f7 100644 --- a/website/docs/r/clb.html.markdown +++ b/website/docs/r/clb.html.markdown @@ -29,9 +29,16 @@ The following arguments are supported: * `load_balancer_name` - (Optional) The name of the CLB. * `modification_protection_reason` - (Optional) The reason of the console modification protection. * `modification_protection_status` - (Optional) The status of the console modification protection, the value can be `NonProtection` or `ConsoleProtection`. +* `project_name` - (Optional, ForceNew) The ProjectName of the CLB. * `region_id` - (Optional, ForceNew) The region of the request. +* `tags` - (Optional) Tags. * `vpc_id` - (Optional, ForceNew) The id of the VPC. +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: * `id` - ID of the resource. diff --git a/website/docs/r/ecs_instance.html.markdown b/website/docs/r/ecs_instance.html.markdown index 6512d88d..d51a8971 100644 --- a/website/docs/r/ecs_instance.html.markdown +++ b/website/docs/r/ecs_instance.html.markdown @@ -71,8 +71,10 @@ The following arguments are supported: * `key_pair_name` - (Optional, ForceNew) The ssh key name of ECS instance. * `password` - (Optional) The password of ECS instance. * `period` - (Optional) The period of ECS instance.Only effective when instance_charge_type is PrePaid. Default is 12. Unit is Month. +* `project_name` - (Optional, ForceNew) The ProjectName of the VPC. * `secondary_network_interfaces` - (Optional) The secondary networkInterface detail collection of ECS instance. * `security_enhancement_strategy` - (Optional, ForceNew) The security enhancement strategy of ECS instance. The value can be Active or InActive. Default is Active.When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. +* `tags` - (Optional) Tags. * `user_data` - (Optional) The user data of ECS instance, this field must be encrypted with base64. * `zone_id` - (Optional, ForceNew) The available zone ID of ECS instance. @@ -87,6 +89,11 @@ The `secondary_network_interfaces` object supports the following: * `security_group_ids` - (Required, ForceNew) The security group ID set of secondary networkInterface. * `subnet_id` - (Required, ForceNew) The subnet ID of secondary networkInterface. +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: * `id` - ID of the resource. diff --git a/website/docs/r/eip_address.html.markdown b/website/docs/r/eip_address.html.markdown index 51dc1ac3..ad5b687b 100644 --- a/website/docs/r/eip_address.html.markdown +++ b/website/docs/r/eip_address.html.markdown @@ -25,6 +25,13 @@ The following arguments are supported: * `description` - (Optional) The description of the EIP. * `isp` - (Optional, ForceNew) The ISP of the EIP, the value can be `BGP` or `ChinaMobile` or `ChinaUnicom` or `ChinaTelecom`. * `name` - (Optional) The name of the EIP Address. +* `project_name` - (Optional, ForceNew) The ProjectName of the EIP. +* `tags` - (Optional) Tags. + +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/website/docs/r/network_interface.html.markdown b/website/docs/r/network_interface.html.markdown index aaa9fd9f..61ca84ca 100644 --- a/website/docs/r/network_interface.html.markdown +++ b/website/docs/r/network_interface.html.markdown @@ -27,6 +27,13 @@ The following arguments are supported: * `network_interface_name` - (Optional) The name of the ENI. * `port_security_enabled` - (Optional) Set port security enable or disable. * `primary_ip_address` - (Optional, ForceNew) The primary IP address of the ENI. +* `project_name` - (Optional, ForceNew) The ProjectName of the ENI. +* `tags` - (Optional) Tags. + +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/website/docs/r/route_table.html.markdown b/website/docs/r/route_table.html.markdown index dab8ea5a..ed73a01f 100644 --- a/website/docs/r/route_table.html.markdown +++ b/website/docs/r/route_table.html.markdown @@ -20,6 +20,7 @@ resource "volcengine_route_table" "foo" { The following arguments are supported: * `vpc_id` - (Required, ForceNew) The id of the VPC. * `description` - (Optional) The description of the route table. +* `project_name` - (Optional) The ProjectName of the route table. * `route_table_name` - (Optional) The name of the route table. ## Attributes Reference diff --git a/website/docs/r/security_group.html.markdown b/website/docs/r/security_group.html.markdown index 824550af..eb4958e1 100644 --- a/website/docs/r/security_group.html.markdown +++ b/website/docs/r/security_group.html.markdown @@ -18,7 +18,14 @@ resource "volcengine_security_group" "g1test1" { The following arguments are supported: * `vpc_id` - (Required, ForceNew) Id of the VPC. * `description` - (Optional) Description of SecurityGroup. +* `project_name` - (Optional, ForceNew) The ProjectName of SecurityGroup. * `security_group_name` - (Optional) Name of SecurityGroup. +* `tags` - (Optional) Tags. + +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/website/docs/r/vpc.html.markdown b/website/docs/r/vpc.html.markdown index 3e1cc474..3a6b4697 100644 --- a/website/docs/r/vpc.html.markdown +++ b/website/docs/r/vpc.html.markdown @@ -21,8 +21,15 @@ The following arguments are supported: * `cidr_block` - (Required, ForceNew) A network address block which should be a subnet of the three internal network segments (10.0.0.0/16, 172.16.0.0/12 and 192.168.0.0/16). * `description` - (Optional) The description of the VPC. * `dns_servers` - (Optional) The DNS server list of the VPC. And you can specify 0 to 5 servers to this list. +* `project_name` - (Optional, ForceNew) The ProjectName of the VPC. +* `tags` - (Optional) Tags. * `vpc_name` - (Optional) The name of the VPC. +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: * `id` - ID of the resource. From 3094aab8d42f52b3f68564d681454f226859b179 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Tue, 27 Dec 2022 15:27:40 +0800 Subject: [PATCH 2/3] feat: comp k8s version --- .../cluster/resource_volcengine_vke_cluster.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/volcengine/vke/cluster/resource_volcengine_vke_cluster.go b/volcengine/vke/cluster/resource_volcengine_vke_cluster.go index 9b452f90..e48c5b2a 100644 --- a/volcengine/vke/cluster/resource_volcengine_vke_cluster.go +++ b/volcengine/vke/cluster/resource_volcengine_vke_cluster.go @@ -2,6 +2,7 @@ package cluster import ( "fmt" + "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -55,10 +56,16 @@ func ResourceVolcengineVkeCluster() *schema.Resource { Description: "The delete protection of the cluster, the value is `true` or `false`.", }, "kubernetes_version": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + if k == "kubernetes_version" && strings.Contains(old, new) { + return true + } + return false + }, Description: "The version of Kubernetes specified when creating a VKE cluster (specified to patch version), if not specified, the latest Kubernetes version supported by VKE is used by default, which is a 3-segment version format starting with a lowercase v, that is, KubernetesVersion with IsLatestVersion=True in the return value of ListSupportedVersions.", }, "tags": ve.TagsSchema(), From 24d36a6fdab14c052a280f5786d68593ddc817fc Mon Sep 17 00:00:00 2001 From: xuyaming Date: Tue, 27 Dec 2022 16:38:59 +0800 Subject: [PATCH 3/3] feat: comp k8s version --- common/common_volcengine_version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/common_volcengine_version.go b/common/common_volcengine_version.go index 5c0f3a8b..9a2b6408 100644 --- a/common/common_volcengine_version.go +++ b/common/common_volcengine_version.go @@ -2,5 +2,5 @@ package common const ( TerraformProviderName = "terraform-provider-volcengine" - TerraformProviderVersion = "0.0.43" + TerraformProviderVersion = "0.0.44" )