From 18dc4902824919b399860f3666f03b793260651b Mon Sep 17 00:00:00 2001 From: "guimin.hgm" Date: Fri, 27 Dec 2024 09:14:54 +0800 Subject: [PATCH] ADB: Improves the invoking adb api method and supports refreshing credential automatically --- alicloud/connectivity/client.go | 53 ------- ...e_alicloud_adb_db_cluster_lake_versions.go | 11 +- ...cloud_adb_db_cluster_lake_versions_test.go | 11 +- .../data_source_alicloud_adb_db_clusters.go | 52 ++++++- ...ta_source_alicloud_adb_db_clusters_test.go | 1 + ...ata_source_alicloud_adb_resource_groups.go | 11 +- alicloud/resource_alicloud_adb_db_cluster.go | 141 +++++++++--------- ...ce_alicloud_adb_db_cluster_lake_version.go | 58 ++----- .../resource_alicloud_adb_db_cluster_test.go | 28 ++-- .../resource_alicloud_adb_lake_account.go | 44 +----- .../resource_alicloud_adb_resource_group.go | 30 +--- alicloud/service_alicloud_adb.go | 108 ++++++-------- alicloud/service_alicloud_adb_v2.go | 17 +-- ...adb_db_cluster_lake_versions.html.markdown | 74 ++++++--- website/docs/d/adb_db_clusters.html.markdown | 91 +++++------ website/docs/r/adb_db_cluster.html.markdown | 4 + 16 files changed, 313 insertions(+), 421 deletions(-) diff --git a/alicloud/connectivity/client.go b/alicloud/connectivity/client.go index 4f3c8e396e0a..f94f99167048 100644 --- a/alicloud/connectivity/client.go +++ b/alicloud/connectivity/client.go @@ -2021,35 +2021,6 @@ func (client *AliyunClient) WithHbaseClient(do func(*hbase.Client) (interface{}, return do(client.hbaseconn) } -func (client *AliyunClient) NewAdbClient() (*rpc.Client, error) { - productCode := "ads" - endpoint := "" - if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { - if v := client.config.AdbEndpoint; v != "" { - client.config.Endpoints.Store(productCode, v) - } - if err := client.loadEndpoint(productCode); err != nil { - return nil, err - } - } - if v, exist := client.config.Endpoints.Load(productCode); exist && v.(string) != "" { - endpoint = v.(string) - } - if endpoint == "" { - return nil, fmt.Errorf("[ERROR] missing the product %s endpoint.", productCode) - } - - sdkConfig := client.teaSdkConfig - sdkConfig.SetEndpoint(endpoint) - - conn, err := rpc.NewClient(&sdkConfig) - if err != nil { - return nil, fmt.Errorf("unable to initialize the %s client: %#v", productCode, err) - } - - return conn, nil -} - func (client *AliyunClient) WithAdbClient(do func(*adb.Client) (interface{}, error)) (interface{}, error) { // Initialize the adb client if necessary if client.adbconn == nil { @@ -3001,30 +2972,6 @@ func (client *AliyunClient) NewHcsSgwClient() (*rpc.Client, error) { } return conn, nil } - -func (client *AliyunClient) NewAdsClient() (*rpc.Client, error) { - productCode := "ads" - endpoint := "" - if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" { - if err := client.loadEndpoint(productCode); err != nil { - return nil, err - } - } - if v, ok := client.config.Endpoints.Load(productCode); ok && v.(string) != "" { - endpoint = v.(string) - } - if endpoint == "" { - return nil, fmt.Errorf("[ERROR] missing the product %s endpoint.", productCode) - } - sdkConfig := client.teaSdkConfig - sdkConfig.SetEndpoint(endpoint) - conn, err := rpc.NewClient(&sdkConfig) - if err != nil { - return nil, fmt.Errorf("unable to initialize the %s client: %#v", productCode, err) - } - return conn, nil -} - func (client *AliyunClient) NewDdoscooClient() (*rpc.Client, error) { productCode := "ddoscoo" endpoint := "" diff --git a/alicloud/data_source_alicloud_adb_db_cluster_lake_versions.go b/alicloud/data_source_alicloud_adb_db_cluster_lake_versions.go index a6d8740044e1..84b4461f65b8 100644 --- a/alicloud/data_source_alicloud_adb_db_cluster_lake_versions.go +++ b/alicloud/data_source_alicloud_adb_db_cluster_lake_versions.go @@ -5,7 +5,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -182,20 +181,15 @@ func dataSourceAlicloudAdbDbClusterLakeVersionsRead(d *schema.ResourceData, meta } } - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } var objects []interface{} var response map[string]interface{} + var err error for { action := "DescribeDBClusters" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -203,7 +197,6 @@ func dataSourceAlicloudAdbDbClusterLakeVersionsRead(d *schema.ResourceData, meta } return resource.NonRetryableError(err) } - response = resp addDebug(action, response, request) return nil }) diff --git a/alicloud/data_source_alicloud_adb_db_cluster_lake_versions_test.go b/alicloud/data_source_alicloud_adb_db_cluster_lake_versions_test.go index 796739aecfe9..e0b58d01eed6 100644 --- a/alicloud/data_source_alicloud_adb_db_cluster_lake_versions_test.go +++ b/alicloud/data_source_alicloud_adb_db_cluster_lake_versions_test.go @@ -109,17 +109,16 @@ variable "name" { data "alicloud_resource_manager_resource_groups" "default" {} -data "alicloud_zones" "default" { - available_resource_creation = "VSwitch" +data "alicloud_adb_zones" "default" { } data "alicloud_vpcs" "default" { - name_regex = "^default-NODELETING$" + name_regex = "^default-NODELETING$" } data "alicloud_vswitches" "default" { - vpc_id = data.alicloud_vpcs.default.ids.0 - zone_id = data.alicloud_zones.default.ids[length(data.alicloud_zones.default.ids) - 1] + vpc_id = data.alicloud_vpcs.default.ids.0 + zone_id = data.alicloud_adb_zones.default.ids.0 } resource "alicloud_adb_db_cluster_lake_version" "default" { @@ -129,7 +128,7 @@ resource "alicloud_adb_db_cluster_lake_version" "default" { storage_resource = "0ACU" vswitch_id = data.alicloud_vswitches.default.ids.0 vpc_id = data.alicloud_vpcs.default.ids.0 - zone_id = data.alicloud_zones.default.ids[length(data.alicloud_zones.default.ids) - 1] + zone_id = data.alicloud_adb_zones.default.ids.0 } data "alicloud_adb_db_cluster_lake_versions" "default" { diff --git a/alicloud/data_source_alicloud_adb_db_clusters.go b/alicloud/data_source_alicloud_adb_db_clusters.go index 9e2cc3a1cacd..3e37d108873b 100644 --- a/alicloud/data_source_alicloud_adb_db_clusters.go +++ b/alicloud/data_source_alicloud_adb_db_clusters.go @@ -6,7 +6,6 @@ import ( "strings" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -242,6 +241,30 @@ func dataSourceAlicloudAdbDbClusters() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "kernel_version": { + Type: schema.TypeString, + Computed: true, + }, + "available_kernel_versions": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "kernel_version": { + Type: schema.TypeString, + Computed: true, + }, + "release_date": { + Type: schema.TypeString, + Computed: true, + }, + "expire_date": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, }, }, }, @@ -313,14 +336,9 @@ func dataSourceAlicloudAdbDbClustersRead(d *schema.ResourceData, meta interface{ } } var response map[string]interface{} - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } + var err error for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { return WrapErrorf(err, DataDefaultErrorMsg, "alicloud_adb_db_clusters", action, AlibabaCloudSdkGoERROR) } @@ -440,6 +458,24 @@ func dataSourceAlicloudAdbDbClustersRead(d *schema.ResourceData, meta interface{ } mapping["engine_version"] = getResp2["EngineVersion"] mapping["maintain_time"] = getResp2["MaintainTime"] + getResp3, err := adbService.DescribeAdbDbClusterKernelVersion(id) + if err != nil { + return WrapError(err) + } + mapping["kernel_version"] = getResp3["KernelVersion"] + availableKernelVersion := getResp3["AvailableKernelVersion"] + availKernels := make([]map[string]interface{}, 0) + if availableKernelVersion != nil { + for _, v := range availableKernelVersion.([]interface{}) { + object := v.(map[string]interface{}) + availKernels = append(availKernels, map[string]interface{}{ + "kernel_version": object["KernelVersion"], + "release_date": object["ReleaseDate"], + "expire_date": object["ExpireDate"], + }) + } + mapping["available_kernel_versions"] = availKernels + } ids = append(ids, fmt.Sprint(object["DBClusterId"])) s = append(s, mapping) diff --git a/alicloud/data_source_alicloud_adb_db_clusters_test.go b/alicloud/data_source_alicloud_adb_db_clusters_test.go index 5e906ebba01a..96dddb4f149b 100644 --- a/alicloud/data_source_alicloud_adb_db_clusters_test.go +++ b/alicloud/data_source_alicloud_adb_db_clusters_test.go @@ -88,6 +88,7 @@ func TestAccAlicloudADBDbClustersDataSource(t *testing.T) { "clusters.0.maintain_time": "23:00Z-00:00Z", "clusters.0.security_ips.#": "2", "clusters.0.mode": "flexible", + "clusters.0.kernel_version": CHECKSET, } } diff --git a/alicloud/data_source_alicloud_adb_resource_groups.go b/alicloud/data_source_alicloud_adb_resource_groups.go index 460e764340a1..f6d876278bd4 100644 --- a/alicloud/data_source_alicloud_adb_resource_groups.go +++ b/alicloud/data_source_alicloud_adb_resource_groups.go @@ -5,7 +5,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -99,18 +98,13 @@ func dataSourceAlicloudAdbResourceGroupsRead(d *schema.ResourceData, meta interf } } - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } var objects []interface{} var response map[string]interface{} + var err error action := "DescribeDBResourceGroup" - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -118,7 +112,6 @@ func dataSourceAlicloudAdbResourceGroupsRead(d *schema.ResourceData, meta interf } return resource.NonRetryableError(err) } - response = resp addDebug(action, response, request) return nil }) diff --git a/alicloud/resource_alicloud_adb_db_cluster.go b/alicloud/resource_alicloud_adb_db_cluster.go index b808868c8b23..0c077ac15201 100644 --- a/alicloud/resource_alicloud_adb_db_cluster.go +++ b/alicloud/resource_alicloud_adb_db_cluster.go @@ -8,7 +8,6 @@ import ( "strings" "time" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -63,6 +62,16 @@ func resourceAliCloudAdbDbCluster() *schema.Resource { ValidateFunc: StringInSlice([]string{"3.0"}, false), Default: "3.0", }, + "kernel_version": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "switch_mode": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: IntInSlice([]int{0, 1}), + }, "db_node_class": { Type: schema.TypeString, Optional: true, @@ -214,12 +223,9 @@ func resourceAliCloudAdbDbClusterCreate(d *schema.ResourceData, meta interface{} client := meta.(*connectivity.AliyunClient) adbService := AdbService{client} var response map[string]interface{} + var err error action := "CreateDBCluster" request := make(map[string]interface{}) - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } if v, ok := d.GetOk("compute_resource"); ok { request["ComputeResource"] = v } @@ -322,12 +328,10 @@ func resourceAliCloudAdbDbClusterCreate(d *schema.ResourceData, meta interface{} request["EnableSSL"] = v } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) request["ClientToken"] = buildClientToken("CreateDBCluster") wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutCreate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -345,7 +349,7 @@ func resourceAliCloudAdbDbClusterCreate(d *schema.ResourceData, meta interface{} d.SetId(fmt.Sprint(response["DBClusterId"])) - stateConf := BuildStateConf([]string{"Preparing", "Creating"}, []string{"Running"}, d.Timeout(schema.TimeoutCreate), 300*time.Second, adbService.AdbDbClusterStateRefreshFunc(d.Id(), "DBClusterStatus", []string{"Deleting"})) + stateConf := BuildStateConf([]string{}, []string{"Running"}, d.Timeout(schema.TimeoutCreate), 300*time.Second, adbService.AdbDbClusterStateRefreshFunc(d.Id(), "DBClusterStatus", []string{"Deleting"})) if _, err := stateConf.WaitForState(); err != nil { return WrapErrorf(err, IdMsg, d.Id()) } @@ -420,11 +424,17 @@ func resourceAliCloudAdbDbClusterRead(d *schema.ResourceData, meta interface{}) d.Set("security_ips", strings.Split(describeDBClusterAccessWhiteListObject["SecurityIPList"].(string), ",")) sslObject, err := adbService.DescribeAdbDbClusterSSL(d.Id()) + if err != nil { + log.Printf("[WARN] Resource alicloud_adb_db_cluster DescribeAdbDbClusterSSL Failed!!! %s", err) + } else { + d.Set("enable_ssl", sslObject["SSLEnabled"]) + } + kernelObject, err := adbService.DescribeAdbDbClusterKernelVersion(d.Id()) if err != nil { return WrapError(err) } - d.Set("enable_ssl", sslObject["SSLEnabled"]) + d.Set("kernel_version", kernelObject["KernelVersion"]) return nil } @@ -433,6 +443,7 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} client := meta.(*connectivity.AliyunClient) adbService := AdbService{client} var response map[string]interface{} + var err error d.Partial(true) if d.HasChange("tags") { @@ -448,13 +459,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} } request["DBClusterDescription"] = d.Get("description") action := "ModifyDBClusterDescription" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -479,13 +486,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} } request["MaintainTime"] = d.Get("maintain_time") action := "ModifyDBClusterMaintainTime" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -510,13 +513,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} } request["NewResourceGroupId"] = d.Get("resource_group_id") action := "ModifyDBClusterResourceGroup" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -562,14 +561,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} if update { action := "ModifyDBClusterPayType" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) || IsExpectedErrors(err, []string{"OperationDenied.OrderProcessing"}) { wait() @@ -617,13 +611,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} } if update { action := "ModifyAutoRenewAttribute" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -658,17 +648,13 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} modifyDBClusterAccessWhiteListReq["SecurityIps"] = convertListToCommaSeparate(d.Get("security_ips").(*schema.Set).List()) if update { action := "ModifyDBClusterAccessWhiteList" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } if modifyDBClusterAccessWhiteListReq["SecurityIps"].(string) == "" { modifyDBClusterAccessWhiteListReq["SecurityIps"] = LOCAL_HOST_IP } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, modifyDBClusterAccessWhiteListReq, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, modifyDBClusterAccessWhiteListReq, false) if err != nil { if NeedRetry(err) { wait() @@ -734,13 +720,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} modifyDBClusterReq["ModifyType"] = d.Get("modify_type") } action := "ModifyDBCluster" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, modifyDBClusterReq, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, modifyDBClusterReq, false) if err != nil { if NeedRetry(err) || IsExpectedErrors(err, []string{"IncorrectDBInstanceState", "OperationDenied.OrderProcessing"}) { wait() @@ -795,13 +777,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} modifyDBClusterReq["ModifyType"] = d.Get("modify_type") } action := "ModifyDBCluster" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, modifyDBClusterReq, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, modifyDBClusterReq, false) if err != nil { // There is service bug and needs checking IncorrectDBInstanceState. // If the bug is fixed, the IncorrectDBInstanceState checking can be removed. @@ -849,13 +827,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} modifyDBClusterReq["ModifyType"] = d.Get("modify_type") } action := "ModifyDBCluster" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, modifyDBClusterReq, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, modifyDBClusterReq, false) if err != nil { // There is service bug and needs checking IncorrectDBInstanceState. // If the bug is fixed, the IncorrectDBInstanceState checking can be removed. @@ -881,6 +855,45 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} d.SetPartial("disk_performance_level") } + update = false + upgradeKernelVersionReq := map[string]interface{}{ + "DBClusterId": d.Id(), + } + + if !d.IsNewResource() && d.HasChange("kernel_version") { + update = true + upgradeKernelVersionReq["DBVersion"] = d.Get("kernel_version") + if v, ok := d.GetOkExists("switch_mode"); ok { + upgradeKernelVersionReq["SwitchMode"] = v + } + } + + if update { + action := "UpgradeKernelVersion" + wait := incrementalWait(3*time.Second, 3*time.Second) + err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { + response, err = client.RpcPost("adb", "2019-03-15", action, nil, upgradeKernelVersionReq, false) + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + addDebug(action, response, upgradeKernelVersionReq) + return nil + }) + + if err != nil { + return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) + } + + stateConf := BuildStateConf([]string{}, []string{"Running"}, d.Timeout(schema.TimeoutUpdate), 1*time.Second, adbService.AdbDbClusterStateRefreshFunc(d.Id(), "DBClusterStatus", []string{})) + if _, err := stateConf.WaitForState(); err != nil { + return WrapErrorf(err, IdMsg, d.Id()) + } + } + update = false modifyDBClusterSSLReq := map[string]interface{}{ "DBClusterId": d.Id(), @@ -900,16 +913,9 @@ func resourceAliCloudAdbDbClusterUpdate(d *schema.ResourceData, meta interface{} if update { action := "ModifyDBClusterSSL" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, modifyDBClusterSSLReq, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, modifyDBClusterSSLReq, false) if err != nil { if NeedRetry(err) { wait() @@ -948,17 +954,14 @@ func resourceAliCloudAdbDbClusterDelete(d *schema.ResourceData, meta interface{} adbService := AdbService{client} action := "DeleteDBCluster" var response map[string]interface{} - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } + var err error request := map[string]interface{}{ "DBClusterId": d.Id(), } var taskId string wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) || IsExpectedErrors(err, []string{"IncorrectDBInstanceState", "OperationDenied.OrderProcessing"}) { wait() diff --git a/alicloud/resource_alicloud_adb_db_cluster_lake_version.go b/alicloud/resource_alicloud_adb_db_cluster_lake_version.go index 78bf9b2da252..d65e6e661596 100644 --- a/alicloud/resource_alicloud_adb_db_cluster_lake_version.go +++ b/alicloud/resource_alicloud_adb_db_cluster_lake_version.go @@ -150,13 +150,9 @@ func resourceAliCloudAdbDbClusterLakeVersionCreate(d *schema.ResourceData, meta client := meta.(*connectivity.AliyunClient) adbService := AdbService{client} var response map[string]interface{} + var err error action := "CreateDBCluster" request := make(map[string]interface{}) - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - request["RegionId"] = client.RegionId request["DBClusterVersion"] = d.Get("db_cluster_version") request["VPCId"] = d.Get("vpc_id") @@ -194,11 +190,9 @@ func resourceAliCloudAdbDbClusterLakeVersionCreate(d *schema.ResourceData, meta request["RestoreToTime"] = v } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutCreate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -277,6 +271,7 @@ func resourceAliCloudAdbDbClusterLakeVersionUpdate(d *schema.ResourceData, meta client := meta.(*connectivity.AliyunClient) adbService := AdbService{client} var response map[string]interface{} + var err error d.Partial(true) update := false @@ -297,18 +292,11 @@ func resourceAliCloudAdbDbClusterLakeVersionUpdate(d *schema.ResourceData, meta if update { action := "ModifyDBCluster" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, request, false) if err != nil { - if NeedRetry(err) { + if NeedRetry(err) || IsExpectedErrors(err, []string{"OperationDenied.OrderProcessing"}) { wait() return resource.RetryableError(err) } @@ -345,16 +333,9 @@ func resourceAliCloudAdbDbClusterLakeVersionUpdate(d *schema.ResourceData, meta if update { action := "ModifyClusterAccessWhiteList" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, modifyClusterAccessWhiteListReq, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, modifyClusterAccessWhiteListReq, false) if err != nil { if NeedRetry(err) { wait() @@ -392,16 +373,9 @@ func resourceAliCloudAdbDbClusterLakeVersionUpdate(d *schema.ResourceData, meta if update { action := "ModifyDBClusterDescription" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, modifyDBClusterDescriptionReq, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, modifyDBClusterDescriptionReq, false) if err != nil { if NeedRetry(err) { wait() @@ -439,16 +413,9 @@ func resourceAliCloudAdbDbClusterLakeVersionUpdate(d *schema.ResourceData, meta if update { action := "ModifyDBClusterResourceGroup" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, modifyDBClusterResourceGroupReq, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, modifyDBClusterResourceGroupReq, false) if err != nil { if NeedRetry(err) { wait() @@ -481,12 +448,7 @@ func resourceAliCloudAdbDbClusterLakeVersionDelete(d *schema.ResourceData, meta client := meta.(*connectivity.AliyunClient) action := "DeleteDBCluster" var response map[string]interface{} - - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - + var err error request := map[string]interface{}{ "DBClusterId": d.Id(), "RegionId": client.RegionId, @@ -496,7 +458,7 @@ func resourceAliCloudAdbDbClusterLakeVersionDelete(d *schema.ResourceData, meta runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutDelete)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_adb_db_cluster_test.go b/alicloud/resource_alicloud_adb_db_cluster_test.go index 29da808f64ce..2fa2ee999e4d 100644 --- a/alicloud/resource_alicloud_adb_db_cluster_test.go +++ b/alicloud/resource_alicloud_adb_db_cluster_test.go @@ -8,7 +8,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" @@ -40,14 +39,8 @@ func testSweepAdbDbInstances(region string) error { request["PageSize"] = PageSizeLarge request["PageNumber"] = 1 var response map[string]interface{} - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { log.Println(WrapErrorf(err, DataDefaultErrorMsg, "alicloud_adb_db_clusters", action, AlibabaCloudSdkGoERROR)) break @@ -78,17 +71,12 @@ func testSweepAdbDbInstances(region string) error { } log.Printf("[INFO] Deleting adb Instance: %s (%s)", name, id) action := "DeleteDBCluster" - conn, err := client.NewAdsClient() - if err != nil { - log.Println(WrapError(err)) - break - } request := map[string]interface{}{ "DBClusterId": id, } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - _, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + _, err = client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -148,6 +136,7 @@ func TestAccAliCloudADBDbCluster_basic0(t *testing.T) { "db_node_storage": "100", "mode": "reserver", "vswitch_id": CHECKSET, + "kernel_version": CHECKSET, }), ), }, @@ -335,6 +324,7 @@ func TestAccAliCloudADBDbCluster_flexible8C(t *testing.T) { "mode": "flexible", "compute_resource": "8Core32GB", "vswitch_id": CHECKSET, + "kernel_version": CHECKSET, }), ), }, @@ -390,6 +380,16 @@ func TestAccAliCloudADBDbCluster_flexible8C(t *testing.T) { }), ), }, + //{ + // Config: testAccConfig(map[string]interface{}{ + // "kernel_version": "3.2.1", + // }), + // Check: resource.ComposeTestCheckFunc( + // testAccCheck(map[string]string{ + // "kernel_version": "3.2.1", + // }), + // ), + //}, { Config: testAccConfig(map[string]interface{}{ "enable_ssl": "true", diff --git a/alicloud/resource_alicloud_adb_lake_account.go b/alicloud/resource_alicloud_adb_lake_account.go index 662bb8ab7b5c..9fc0a16887fa 100644 --- a/alicloud/resource_alicloud_adb_lake_account.go +++ b/alicloud/resource_alicloud_adb_lake_account.go @@ -9,7 +9,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -111,11 +110,8 @@ func resourceAliCloudAdbLakeAccountCreate(d *schema.ResourceData, meta interface action := "CreateAccount" var request map[string]interface{} var response map[string]interface{} + var err error query := make(map[string]interface{}) - conn, err := client.NewAdbClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query["AccountName"] = d.Get("account_name") query["DBClusterId"] = d.Get("db_cluster_id") @@ -127,11 +123,9 @@ func resourceAliCloudAdbLakeAccountCreate(d *schema.ResourceData, meta interface request["AccountType"] = v } request["AccountPassword"] = d.Get("account_password") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, false) if err != nil { if NeedRetry(err) { @@ -218,15 +212,12 @@ func resourceAliCloudAdbLakeAccountUpdate(d *schema.ResourceData, meta interface client := meta.(*connectivity.AliyunClient) var request map[string]interface{} var response map[string]interface{} + var err error var query map[string]interface{} update := false d.Partial(true) parts := strings.Split(d.Id(), ":") action := "ModifyAccountDescription" - conn, err := client.NewAdbClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["DBClusterId"] = parts[0] @@ -237,11 +228,9 @@ func resourceAliCloudAdbLakeAccountUpdate(d *schema.ResourceData, meta interface } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, false) if err != nil { if NeedRetry(err) { @@ -261,10 +250,6 @@ func resourceAliCloudAdbLakeAccountUpdate(d *schema.ResourceData, meta interface update = false parts = strings.Split(d.Id(), ":") action = "ResetAccountPassword" - conn, err = client.NewAdbClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["AccountName"] = parts[1] @@ -279,11 +264,9 @@ func resourceAliCloudAdbLakeAccountUpdate(d *schema.ResourceData, meta interface } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, false) if err != nil { if NeedRetry(err) { @@ -304,10 +287,6 @@ func resourceAliCloudAdbLakeAccountUpdate(d *schema.ResourceData, meta interface update = false parts = strings.Split(d.Id(), ":") action = "ModifyAccountPrivileges" - conn, err = client.NewAdbClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["DBClusterId"] = parts[0] @@ -341,11 +320,9 @@ func resourceAliCloudAdbLakeAccountUpdate(d *schema.ResourceData, meta interface } if update { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, false) if err != nil { if NeedRetry(err) { @@ -373,20 +350,15 @@ func resourceAliCloudAdbLakeAccountDelete(d *schema.ResourceData, meta interface action := "DeleteAccount" var request map[string]interface{} var response map[string]interface{} + var err error query := make(map[string]interface{}) - conn, err := client.NewAdbClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) query["AccountName"] = parts[1] query["DBClusterId"] = parts[0] - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, false) if err != nil { if NeedRetry(err) { diff --git a/alicloud/resource_alicloud_adb_resource_group.go b/alicloud/resource_alicloud_adb_resource_group.go index e209f76f07e6..5bf9f3f417f2 100644 --- a/alicloud/resource_alicloud_adb_resource_group.go +++ b/alicloud/resource_alicloud_adb_resource_group.go @@ -6,7 +6,6 @@ import ( "strings" "time" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -77,13 +76,9 @@ func resourceAliCloudAdbResourceGroup() *schema.Resource { func resourceAliCloudAdbResourceGroupCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} + var err error action := "CreateDBResourceGroup" request := make(map[string]interface{}) - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - request["DBClusterId"] = d.Get("db_cluster_id") request["GroupName"] = d.Get("group_name") @@ -95,11 +90,9 @@ func resourceAliCloudAdbResourceGroupCreate(d *schema.ResourceData, meta interfa request["NodeNum"] = v } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutCreate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if IsExpectedErrors(err, []string{"ResourceNotEnough"}) || NeedRetry(err) { wait() @@ -190,16 +183,9 @@ func resourceAliCloudAdbResourceGroupUpdate(d *schema.ResourceData, meta interfa if update { action := "ModifyDBResourceGroup" - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if IsExpectedErrors(err, []string{"ResourceNotEnough"}) || NeedRetry(err) { wait() @@ -223,12 +209,6 @@ func resourceAliCloudAdbResourceGroupDelete(d *schema.ResourceData, meta interfa client := meta.(*connectivity.AliyunClient) action := "DeleteDBResourceGroup" var response map[string]interface{} - - conn, err := client.NewAdsClient() - if err != nil { - return WrapError(err) - } - parts, err := ParseResourceId(d.Id(), 2) if err != nil { return WrapError(err) @@ -239,11 +219,9 @@ func resourceAliCloudAdbResourceGroupDelete(d *schema.ResourceData, meta interfa "GroupName": parts[1], } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutDelete)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/service_alicloud_adb.go b/alicloud/service_alicloud_adb.go index 4c5b3a005d5c..8b2d30c33dcd 100644 --- a/alicloud/service_alicloud_adb.go +++ b/alicloud/service_alicloud_adb.go @@ -584,10 +584,7 @@ func (s *AdbService) AdbTaskStateRefreshFunc(id, taskId string) resource.StateRe func (s *AdbService) DescribeAutoRenewAttribute(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewAdsClient() - if err != nil { - return nil, WrapError(err) - } + action := "DescribeAutoRenewAttribute" request := map[string]interface{}{ "RegionId": s.client.RegionId, @@ -595,7 +592,7 @@ func (s *AdbService) DescribeAutoRenewAttribute(id string) (object map[string]in } runtime := util.RuntimeOptions{} runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { err = WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) return @@ -618,10 +615,6 @@ func (s *AdbService) DescribeAutoRenewAttribute(id string) (object map[string]in func (s *AdbService) DescribeDBClusterAccessWhiteList(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewAdsClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeDBClusterAccessWhiteList" request := map[string]interface{}{ "RegionId": s.client.RegionId, @@ -629,7 +622,7 @@ func (s *AdbService) DescribeDBClusterAccessWhiteList(id string) (object map[str } runtime := util.RuntimeOptions{} runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidDBCluster.NotFound"}) { err = WrapErrorf(Error(GetNotFoundMessage("AnalyticdbForMysql3.0DbCluster", id)), NotFoundMsg, ProviderERROR) @@ -660,14 +653,10 @@ func (s *AdbService) DescribeDBClusterAccessWhiteList(id string) (object map[str } func (s *AdbService) SetResourceTags(d *schema.ResourceData, resourceType string) error { - + var response map[string]interface{} + var err error if d.HasChange("tags") { added, removed := parsingTags(d) - conn, err := s.client.NewAdsClient() - if err != nil { - return WrapError(err) - } - removedTagKeys := make([]string, 0) for _, v := range removed { if !ignoredTags(v, "") { @@ -685,8 +674,8 @@ func (s *AdbService) SetResourceTags(d *schema.ResourceData, resourceType string request[fmt.Sprintf("TagKey.%d", i+1)] = key } wait := incrementalWait(2*time.Second, 1*time.Second) - err := resource.Retry(10*time.Minute, func() *resource.RetryError { - response, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + err = resource.Retry(10*time.Minute, func() *resource.RetryError { + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -717,8 +706,8 @@ func (s *AdbService) SetResourceTags(d *schema.ResourceData, resourceType string } wait := incrementalWait(2*time.Second, 1*time.Second) - err := resource.Retry(10*time.Minute, func() *resource.RetryError { - response, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + err = resource.Retry(10*time.Minute, func() *resource.RetryError { + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -741,18 +730,12 @@ func (s *AdbService) SetResourceTags(d *schema.ResourceData, resourceType string func (s *AdbService) DescribeAdbDbCluster(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewAdsClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeDBClusterAttribute" request := map[string]interface{}{ "RegionId": s.client.RegionId, "DBClusterId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"InvalidDBCluster.NotFound", "InvalidDBClusterId.NotFoundError"}) { err = WrapErrorf(Error(GetNotFoundMessage("AdbDbCluster", id)), NotFoundMsg, ProviderERROR) @@ -779,18 +762,12 @@ func (s *AdbService) DescribeAdbDbCluster(id string) (object map[string]interfac func (s *AdbService) DescribeDBClusters(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewAdsClient() - if err != nil { - return nil, WrapError(err) - } action := "DescribeDBClusters" request := map[string]interface{}{ "RegionId": s.client.RegionId, "DBClusterIds": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { err = WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) return @@ -834,12 +811,6 @@ func (s *AdbService) AdbDbClusterStateRefreshFunc(id string, stateField string, func (s *AdbService) DescribeAdbDbClusterLakeVersion(id string) (object map[string]interface{}, err error) { var response map[string]interface{} action := "DescribeDBClusterAttribute" - - conn, err := s.client.NewAdsClient() - if err != nil { - return object, WrapError(err) - } - request := map[string]interface{}{ "DBClusterId": id, } @@ -849,7 +820,7 @@ func (s *AdbService) DescribeAdbDbClusterLakeVersion(id string) (object map[stri runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2021-12-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -914,12 +885,6 @@ func (s *AdbService) AdbDbClusterLakeVersionStateRefreshFunc(d *schema.ResourceD func (s *AdbService) DescribeClusterAccessWhiteList(id string) (object map[string]interface{}, err error) { var response map[string]interface{} action := "DescribeClusterAccessWhiteList" - - conn, err := s.client.NewAdsClient() - if err != nil { - return object, WrapError(err) - } - request := map[string]interface{}{ "DBClusterId": id, } @@ -928,7 +893,7 @@ func (s *AdbService) DescribeClusterAccessWhiteList(id string) (object map[strin runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2021-12-01", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -964,12 +929,6 @@ func (s *AdbService) DescribeClusterAccessWhiteList(id string) (object map[strin func (s *AdbService) DescribeAdbResourceGroup(id string) (object map[string]interface{}, err error) { var response map[string]interface{} action := "DescribeDBResourceGroup" - - conn, err := s.client.NewAdsClient() - if err != nil { - return object, WrapError(err) - } - parts, err := ParseResourceId(id, 2) if err != nil { return object, WrapError(err) @@ -985,7 +944,7 @@ func (s *AdbService) DescribeAdbResourceGroup(id string) (object map[string]inte runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(5*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -1030,23 +989,50 @@ func (s *AdbService) DescribeAdbResourceGroup(id string) (object map[string]inte func (s *AdbService) DescribeAdbDbClusterSSL(id string) (object map[string]interface{}, err error) { var response map[string]interface{} action := "DescribeDBClusterSSL" + request := map[string]interface{}{ + "DBClusterId": id, + } + + wait := incrementalWait(3*time.Second, 3*time.Second) + err = resource.Retry(10*time.Minute, func() *resource.RetryError { + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) + if err != nil { + if IsExpectedErrors(err, []string{"ADBVersionNotSupport"}) || NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) - conn, err := s.client.NewAdsClient() if err != nil { - return object, WrapError(err) + return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) } + v, err := jsonpath.Get("$", response) + if err != nil { + return object, WrapErrorf(err, FailedGetAttributeMsg, id, "$", response) + } + + object = v.(map[string]interface{}) + + return object, nil +} + +func (s *AdbService) DescribeAdbDbClusterKernelVersion(id string) (object map[string]interface{}, err error) { + var response map[string]interface{} + action := "DescribeKernelVersion" request := map[string]interface{}{ "DBClusterId": id, } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(10*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-03-15"), StringPointer("AK"), nil, request, &runtime) + response, err = s.client.RpcPost("adb", "2019-03-15", action, nil, request, true) if err != nil { - if IsExpectedErrors(err, []string{"ADBVersionNotSupport"}) || NeedRetry(err) { + if NeedRetry(err) { wait() return resource.RetryableError(err) } diff --git a/alicloud/service_alicloud_adb_v2.go b/alicloud/service_alicloud_adb_v2.go index 9ab4d2534b9d..fd0da61d9533 100644 --- a/alicloud/service_alicloud_adb_v2.go +++ b/alicloud/service_alicloud_adb_v2.go @@ -6,7 +6,6 @@ import ( "time" "github.com/PaesslerAG/jsonpath" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) @@ -27,21 +26,15 @@ func (s *AdbServiceV2) DescribeAdbLakeAccount(id string) (object map[string]inte err = WrapError(fmt.Errorf("invalid Resource Id %s. Expected parts' length %d, got %d", id, 2, len(parts))) } action := "DescribeAccountAllPrivileges" - conn, err := client.NewAdbClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["AccountName"] = parts[1] query["DBClusterId"] = parts[0] request["RegionId"] = client.RegionId - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(1*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, true) if err != nil { if NeedRetry(err) { @@ -73,20 +66,14 @@ func (s *AdbServiceV2) DescribeDescribeAccounts(id string) (object map[string]in err = WrapError(fmt.Errorf("invalid Resource Id %s. Expected parts' length %d, got %d", id, 2, len(parts))) } action := "DescribeAccounts" - conn, err := client.NewAdbClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["AccountName"] = parts[1] query["DBClusterId"] = parts[0] - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(1*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2021-12-01"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("adb", "2021-12-01", action, query, request, true) if err != nil { if NeedRetry(err) { diff --git a/website/docs/d/adb_db_cluster_lake_versions.html.markdown b/website/docs/d/adb_db_cluster_lake_versions.html.markdown index 36739a7cae98..442d46b49e85 100644 --- a/website/docs/d/adb_db_cluster_lake_versions.html.markdown +++ b/website/docs/d/adb_db_cluster_lake_versions.html.markdown @@ -11,15 +11,41 @@ description: |- This data source provides the Adb DBCluster Lake Versions of the current Alibaba Cloud user. --> **NOTE:** Available in v1.190.0+. +-> **NOTE:** Available since v1.190.0. ## Example Usage Basic Usage ```terraform +provider "alicloud" { + region = "ap-southeast-1" +} + +data "alicloud_adb_zones" "default" { +} + +data "alicloud_vpcs" "default" { + name_regex = "^default-NODELETING$" +} + +data "alicloud_vswitches" "default" { + vpc_id = data.alicloud_vpcs.default.ids.0 + zone_id = data.alicloud_adb_zones.default.ids.0 +} + +resource "alicloud_adb_db_cluster_lake_version" "default" { + db_cluster_version = "5.0" + vpc_id = data.alicloud_vpcs.default.ids.0 + vswitch_id = data.alicloud_vswitches.default.ids.0 + zone_id = data.alicloud_adb_zones.default.ids.0 + compute_resource = "16ACU" + storage_resource = "0ACU" + payment_type = "PayAsYouGo" + enable_default_resource_group = false +} data "alicloud_adb_db_cluster_lake_versions" "ids" { - ids = ["example_id"] + ids = [alicloud_adb_db_cluster_lake_version.default.id] } output "adb_db_cluster_lake_version_id_1" { value = data.alicloud_adb_db_cluster_lake_versions.ids.versions.0.id @@ -36,29 +62,29 @@ The following arguments are supported: * `resource_group_id` - (Optional, ForceNew) The ID of the resource group. * `status` - (Optional, ForceNew) The status of the resource. Valid values: `Preparing`, `Creating`, `Restoring`, `Running`, `Deleting`, `ClassChanging`, `NetAddressCreating`, `NetAddressDeleting`. -## Argument Reference +## Attributes Reference The following attributes are exported in addition to the arguments listed above: * `versions` - A list of Adb Db Clusters. Each element contains the following attributes: - * `id` - The ID of the DBCluster. - * `db_cluster_id` - The ID of the DBCluster. - * `commodity_code` - The name of the service. - * `compute_resource` - The specifications of computing resources in elastic mode. The increase of resources can speed up queries. - * `connection_string` - The endpoint of the cluster. - * `create_time` - The CreateTime of the ADB cluster. - * `db_cluster_version` - The db cluster version. - * `engine` - The engine of the database. - * `engine_version` - The engine version of the database. - * `expire_time` - The time when the cluster expires. - * `expired` - Indicates whether the cluster has expired. - * `lock_mode` - The lock mode of the cluster. - * `lock_reason` - The reason why the cluster is locked. - * `payment_type` - The payment type of the resource. - * `port` - The port that is used to access the cluster. - * `status` - The status of the resource. - * `storage_resource` - The specifications of storage resources in elastic mode. The resources are used for data read and write operations. - * `vpc_id` - The vpc id. - * `vswitch_id` - The vswitch id. - * `zone_id` - The zone ID of the resource. - * `resource_group_id` - The ID of the resource group. \ No newline at end of file + * `id` - The ID of the DBCluster. + * `db_cluster_id` - The ID of the DBCluster. + * `commodity_code` - The name of the service. + * `compute_resource` - The specifications of computing resources in elastic mode. The increase of resources can speed up queries. + * `connection_string` - The endpoint of the cluster. + * `create_time` - The CreateTime of the ADB cluster. + * `db_cluster_version` - The db cluster version. + * `engine` - The engine of the database. + * `engine_version` - The engine version of the database. + * `expire_time` - The time when the cluster expires. + * `expired` - Indicates whether the cluster has expired. + * `lock_mode` - The lock mode of the cluster. + * `lock_reason` - The reason why the cluster is locked. + * `payment_type` - The payment type of the resource. + * `port` - The port that is used to access the cluster. + * `status` - The status of the resource. + * `storage_resource` - The specifications of storage resources in elastic mode. The resources are used for data read and write operations. + * `vpc_id` - The vpc id. + * `vswitch_id` - The vswitch id. + * `zone_id` - The zone ID of the resource. + * `resource_group_id` - The ID of the resource group. \ No newline at end of file diff --git a/website/docs/d/adb_db_clusters.html.markdown b/website/docs/d/adb_db_clusters.html.markdown index dcb0ca593a3d..9f9828ed5c56 100644 --- a/website/docs/d/adb_db_clusters.html.markdown +++ b/website/docs/d/adb_db_clusters.html.markdown @@ -45,46 +45,51 @@ The following attributes are exported in addition to the arguments listed above: * `descriptions` - A list of DBCluster descriptions. * `clusters` - A list of Adb Db Clusters. Each element contains the following attributes: - * `auto_renew_period` - Auto-renewal period of an cluster, in the unit of the month. - * `commodity_code` - The name of the service. - * `compute_resource` - The specifications of computing resources in elastic mode. The increase of resources can speed up queries. AnalyticDB for MySQL automatically scales computing resources. - * `connection_string` - The endpoint of the cluster. - * `create_time` - The CreateTime of the ADB cluster. - * `db_cluster_category` - The db cluster category. - * `db_cluster_id` - The db cluster id. - * `db_cluster_network_type` - The db cluster network type. - * `network_type` - The db cluster network type. - * `db_cluster_type` - The db cluster type. - * `db_cluster_version` - The db cluster version. - * `db_node_class` - The db node class. - * `db_node_count` - The db node count. - * `db_node_storage` - The db node storage. - * `description` - The description of DBCluster. - * `disk_type` - The type of the disk. - * `dts_job_id` - The ID of the data synchronization task in Data Transmission Service (DTS). This parameter is valid only for analytic instances. - * `elastic_io_resource` - The elastic io resource. - * `engine` - The engine of the database. - * `engine_version` - The engine version of the database. - * `executor_count` - The number of nodes. The node resources are used for data computing in elastic mode. - * `expire_time` - The time when the cluster expires. - * `expired` - Indicates whether the cluster has expired. - * `id` - The ID of the DBCluster. - * `lock_mode` - The lock mode of the cluster. - * `lock_reason` - The reason why the cluster is locked. - * `maintain_time` - The maintenance window of the cluster. - * `payment_type` - The payment type of the resource. - * `charge_type` - The payment type of the resource. - * `port` - The port that is used to access the cluster. - * `rds_instance_id` - The ID of the ApsaraDB RDS instance from which data is synchronized to the cluster. This parameter is valid only for analytic instances. - * `renewal_status` - The status of renewal. - * `resource_group_id` - The ID of the resource group. - * `security_ips` - List of IP addresses allowed to access all databases of an cluster. - * `status` - The status of the resource. - * `storage_resource` - The specifications of storage resources in elastic mode. The resources are used for data read and write operations. The increase of resources can improve the read and write performance of your cluster. - * `tags` - The tags of the resource. - * `vpc_cloud_instance_id` - The vpc cloud instance id. - * `vpc_id` - The vpc id. - * `vswitch_id` - The vswitch id. - * `zone_id` - The zone ID of the resource. - * `region_id` - The region ID of the resource. - * `mode` - The lock mode of the cluster. + * `auto_renew_period` - Auto-renewal period of an cluster, in the unit of the month. + * `commodity_code` - The name of the service. + * `compute_resource` - The specifications of computing resources in elastic mode. The increase of resources can speed up queries. AnalyticDB for MySQL automatically scales computing resources. + * `connection_string` - The endpoint of the cluster. + * `create_time` - The CreateTime of the ADB cluster. + * `db_cluster_category` - The db cluster category. + * `db_cluster_id` - The db cluster id. + * `db_cluster_network_type` - The db cluster network type. + * `network_type` - The db cluster network type. + * `db_cluster_type` - The db cluster type. + * `db_cluster_version` - The db cluster version. + * `db_node_class` - The db node class. + * `db_node_count` - The db node count. + * `db_node_storage` - The db node storage. + * `description` - The description of DBCluster. + * `disk_type` - The type of the disk. + * `dts_job_id` - The ID of the data synchronization task in Data Transmission Service (DTS). This parameter is valid only for analytic instances. + * `elastic_io_resource` - The elastic io resource. + * `engine` - The engine of the database. + * `engine_version` - The engine version of the database. + * `executor_count` - The number of nodes. The node resources are used for data computing in elastic mode. + * `expire_time` - The time when the cluster expires. + * `expired` - Indicates whether the cluster has expired. + * `id` - The ID of the DBCluster. + * `lock_mode` - The lock mode of the cluster. + * `lock_reason` - The reason why the cluster is locked. + * `maintain_time` - The maintenance window of the cluster. + * `payment_type` - The payment type of the resource. + * `charge_type` - The payment type of the resource. + * `port` - The port that is used to access the cluster. + * `rds_instance_id` - The ID of the ApsaraDB RDS instance from which data is synchronized to the cluster. This parameter is valid only for analytic instances. + * `renewal_status` - The status of renewal. + * `resource_group_id` - The ID of the resource group. + * `security_ips` - List of IP addresses allowed to access all databases of an cluster. + * `status` - The status of the resource. + * `storage_resource` - The specifications of storage resources in elastic mode. The resources are used for data read and write operations. The increase of resources can improve the read and write performance of your cluster. + * `tags` - The tags of the resource. + * `vpc_cloud_instance_id` - The vpc cloud instance id. + * `vpc_id` - The vpc id. + * `vswitch_id` - The vswitch id. + * `zone_id` - The zone ID of the resource. + * `region_id` - The region ID of the resource. + * `mode` - The lock mode of the cluster. + * `kernel_version` - The minor version of the cluster. Example: 3.1.8. + * `available_kernel_versions` - The minor versions to which you can update the current minor version of the cluster. + * `kernel_version` - The minor version. Example: 3.1.9. + * `release_date` - The time when the minor version was released. + * `expire_date` - The maintenance expiration time of the version \ No newline at end of file diff --git a/website/docs/r/adb_db_cluster.html.markdown b/website/docs/r/adb_db_cluster.html.markdown index 121cfce5b84b..cd1e0a05f31a 100644 --- a/website/docs/r/adb_db_cluster.html.markdown +++ b/website/docs/r/adb_db_cluster.html.markdown @@ -92,6 +92,10 @@ The following arguments are supported: * `disk_encryption` - (Optional, ForceNew, Bool, Available since v1.219.0) Specifies whether to enable disk encryption. Default Value: `false`. Valid values: `true`, `false`. * `kms_id` - (Optional, ForceNew, Available since v1.219.0) The Key Management Service (KMS) ID that is used for disk encryption. `kms_id` is valid only when `disk_encryption` is set to `true`. * `enable_ssl` - (Optional, Bool, Available since v1.230.0) Specifies whether to enable SSL encryption. Default Value: `false`. Valid values: `true`, `false`. +* `kernel_version` - (Optional, String, Available since v1.240.0) The minor version to which you want to update. +* `switch_mode` - (Optional, Int, Available since v1.240.0) The time when to perform the update. Valid values: + - `0` (default): immediately performs the update. + - `1`: performs the update during the maintenance window. * `tags` - (Optional) A mapping of tags to assign to the resource. - Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string. - Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.