From 4f0b220c370d323396695a32fec98723ee560463 Mon Sep 17 00:00:00 2001 From: "guimin.hgm" Date: Thu, 26 Dec 2024 15:34:57 +0800 Subject: [PATCH] Config: Improves the invoking config api method and supports refreshing credential automatically --- alicloud/connectivity/client.go | 1 + alicloud/connectivity/config.go | 14 ++- ...cloud_config_aggregate_compliance_packs.go | 10 +- ..._config_aggregate_compliance_packs_test.go | 17 ++- ..._alicloud_config_aggregate_config_rules.go | 11 +- ...loud_config_aggregate_config_rules_test.go | 69 +++++++++- ...ce_alicloud_config_aggregate_deliveries.go | 11 +- ...icloud_config_aggregate_deliveries_test.go | 4 +- ...data_source_alicloud_config_aggregators.go | 11 +- ...source_alicloud_config_aggregators_test.go | 2 +- ...source_alicloud_config_compliance_packs.go | 10 +- ...e_alicloud_config_compliance_packs_test.go | 2 +- ...alicloud_config_configuration_recorders.go | 8 +- ...oud_config_configuration_recorders_test.go | 4 +- .../data_source_alicloud_config_deliveries.go | 10 +- ..._source_alicloud_config_deliveries_test.go | 2 +- ...ource_alicloud_config_delivery_channels.go | 8 +- ..._alicloud_config_delivery_channels_test.go | 3 +- alicloud/data_source_alicloud_config_rules.go | 11 +- .../data_source_alicloud_config_rules_test.go | 2 +- ...icloud_config_aggregate_compliance_pack.go | 43 +------ ...d_config_aggregate_compliance_pack_test.go | 23 ++-- ...e_alicloud_config_aggregate_config_rule.go | 28 ++--- ...cloud_config_aggregate_config_rule_test.go | 104 +++++++++++---- ...urce_alicloud_config_aggregate_delivery.go | 41 +++--- .../resource_alicloud_config_aggregator.go | 34 ++--- ...esource_alicloud_config_aggregator_test.go | 14 +-- ...esource_alicloud_config_compliance_pack.go | 45 ++----- ...ce_alicloud_config_compliance_pack_test.go | 16 +-- ..._alicloud_config_configuration_recorder.go | 16 +-- ...loud_config_configuration_recorder_test.go | 4 +- alicloud/resource_alicloud_config_delivery.go | 40 +++--- ...source_alicloud_config_delivery_channel.go | 26 ++-- ...e_alicloud_config_delivery_channel_test.go | 9 +- .../resource_alicloud_config_remediation.go | 27 ++-- ...source_alicloud_config_remediation_test.go | 2 +- alicloud/resource_alicloud_config_rule.go | 35 ++---- .../resource_alicloud_config_rule_test.go | 11 +- alicloud/service_alicloud_config.go | 118 ++++-------------- alicloud/service_alicloud_config_v2.go | 29 +---- alicloud/service_alicloud_sls_v2.go | 2 +- ...g_aggregate_compliance_packs.html.markdown | 36 +++--- ...onfig_aggregate_config_rules.html.markdown | 57 ++++----- .../config_aggregate_deliveries.html.markdown | 39 +++--- .../docs/d/config_aggregators.html.markdown | 26 ++-- .../d/config_compliance_packs.html.markdown | 34 ++--- ...nfig_configuration_recorders.html.markdown | 20 ++- .../docs/d/config_deliveries.html.markdown | 35 +++--- .../d/config_delivery_channels.html.markdown | 22 ++-- website/docs/d/config_rules.html.markdown | 76 ++++++----- 50 files changed, 532 insertions(+), 690 deletions(-) diff --git a/alicloud/connectivity/client.go b/alicloud/connectivity/client.go index 2d2b93d85519..4f3c8e396e0a 100644 --- a/alicloud/connectivity/client.go +++ b/alicloud/connectivity/client.go @@ -5194,6 +5194,7 @@ func (client *AliyunClient) NewSlsClient() (*openapi.Client, error) { AccessKeyId: tea.String(client.config.AccessKey), AccessKeySecret: tea.String(client.config.SecretKey), SecurityToken: tea.String(client.config.SecurityToken), + UserAgent: tea.String(client.config.getUserAgent()), } endpoint := client.config.LogEndpoint diff --git a/alicloud/connectivity/config.go b/alicloud/connectivity/config.go index a06ba15c3b10..a7922b251d87 100644 --- a/alicloud/connectivity/config.go +++ b/alicloud/connectivity/config.go @@ -344,7 +344,7 @@ func (c *Config) setAuthCredentialByOidc() (err error) { conf := &openapi.Config{ RegionId: tea.String(c.RegionId), Endpoint: tea.String(c.StsEndpoint), - UserAgent: tea.String(fmt.Sprintf("%s/%s %s/%s %s/%s %s/%s", Terraform, c.TerraformVersion, Provider, providerVersion, Module, c.ConfigurationSource, TerraformTraceId, c.TerraformTraceId)), + UserAgent: tea.String(c.getUserAgent()), // currently, sts endpoint only supports https Protocol: tea.String("HTTPS"), ReadTimeout: tea.Int(c.ClientReadTimeout), @@ -465,7 +465,7 @@ func (c *Config) RefreshAuthCredential() error { func (c *Config) getTeaDslSdkConfig(stsSupported bool) (config rpc.Config, err error) { config.SetRegionId(c.RegionId) - config.SetUserAgent(fmt.Sprintf("%s/%s %s/%s %s/%s %s/%s", Terraform, c.TerraformVersion, Provider, providerVersion, Module, c.ConfigurationSource, TerraformTraceId, c.TerraformTraceId)) + config.SetUserAgent(c.getUserAgent()) credential, err := credential.NewCredential(c.getCredentialConfig(stsSupported)) config.SetCredential(credential). SetRegionId(c.RegionId). @@ -484,7 +484,7 @@ func (c *Config) getTeaDslSdkConfig(stsSupported bool) (config rpc.Config, err e } func (c *Config) getTeaRoaDslSdkConfig(stsSupported bool) (config roa.Config, err error) { config.SetRegionId(c.RegionId) - config.SetUserAgent(fmt.Sprintf("%s/%s %s/%s %s/%s %s/%s", Terraform, c.TerraformVersion, Provider, providerVersion, Module, c.ConfigurationSource, TerraformTraceId, c.TerraformTraceId)) + config.SetUserAgent(c.getUserAgent()) credential, err := credential.NewCredential(c.getCredentialConfig(stsSupported)) config.SetCredential(credential). SetRegionId(c.RegionId). @@ -502,7 +502,7 @@ func (c *Config) getTeaRoaDslSdkConfig(stsSupported bool) (config roa.Config, er } func (c *Config) getTeaRpcOpenapiConfig(stsSupported bool) (config openapi.Config, err error) { config.SetRegionId(c.RegionId) - config.SetUserAgent(fmt.Sprintf("%s/%s %s/%s %s/%s %s/%s", Terraform, c.TerraformVersion, Provider, providerVersion, Module, c.ConfigurationSource, TerraformTraceId, c.TerraformTraceId)) + config.SetUserAgent(c.getUserAgent()) credential, err := credential.NewCredential(c.getCredentialConfig(stsSupported)) config.SetCredential(credential). SetRegionId(c.RegionId). @@ -527,7 +527,7 @@ func (c *Config) getTeaRpcOpenapiConfig(stsSupported bool) (config openapi.Confi } func (c *Config) getTeaRoaOpenapiConfig(stsSupported bool) (config openapi.Config, err error) { config.SetRegionId(c.RegionId) - config.SetUserAgent(fmt.Sprintf("%s/%s %s/%s %s/%s %s/%s", Terraform, c.TerraformVersion, Provider, providerVersion, Module, c.ConfigurationSource, TerraformTraceId, c.TerraformTraceId)) + config.SetUserAgent(c.getUserAgent()) credential, err := credential.NewCredential(c.getCredentialConfig(stsSupported)) config.SetCredential(credential). SetRegionId(c.RegionId). @@ -578,3 +578,7 @@ func (c *Config) getCredentialConfig(stsSupported bool) *credential.Config { credentialConfig.Type = &credentialType return credentialConfig } + +func (c *Config) getUserAgent() string { + return fmt.Sprintf("%s/%s %s/%s %s/%s %s/%s", Terraform, c.TerraformVersion, Provider, providerVersion, Module, c.ConfigurationSource, TerraformTraceId, c.TerraformTraceId) +} diff --git a/alicloud/data_source_alicloud_config_aggregate_compliance_packs.go b/alicloud/data_source_alicloud_config_aggregate_compliance_packs.go index 4b8474b4846e..1fc9432a0430 100644 --- a/alicloud/data_source_alicloud_config_aggregate_compliance_packs.go +++ b/alicloud/data_source_alicloud_config_aggregate_compliance_packs.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" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -164,16 +163,11 @@ func dataSourceAlicloudConfigAggregateCompliancePacksRead(d *schema.ResourceData } status, statusOk := d.GetOk("status") var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + var err error for { - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_config_aggregate_compliance_packs_test.go b/alicloud/data_source_alicloud_config_aggregate_compliance_packs_test.go index ad1a6fae9c9a..60513041dfca 100644 --- a/alicloud/data_source_alicloud_config_aggregate_compliance_packs_test.go +++ b/alicloud/data_source_alicloud_config_aggregate_compliance_packs_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" ) -func TestAccAlicloudConfigAggregateCompliancePacksDataSource(t *testing.T) { +func TestAccAliCloudConfigAggregateCompliancePacksDataSource(t *testing.T) { rand := acctest.RandInt() idsConf := dataSourceTestAccConfig{ existConfig: testAccCheckAlicloudConfigAggregateCompliancePacksDataSourceName(rand, map[string]string{ @@ -92,11 +92,22 @@ variable "name" { default = "tf-testAccAggregateCompliancePack-%d" } -data "alicloud_config_aggregators" "default" {} +data "alicloud_resource_manager_accounts" "default" { + status = "CreateSuccess" +} +resource "alicloud_config_aggregator" "default" { + aggregator_accounts { + account_id = data.alicloud_resource_manager_accounts.default.accounts.1.account_id + account_name = data.alicloud_resource_manager_accounts.default.accounts.1.display_name + account_type = "ResourceDirectory" + } + aggregator_name = var.name + description = var.name +} resource "alicloud_config_aggregate_compliance_pack" "default" { aggregate_compliance_pack_name = var.name - aggregator_id = data.alicloud_config_aggregators.default.ids.0 + aggregator_id = alicloud_config_aggregator.default.id compliance_pack_template_id = "ct-3d20ff4e06a30027f76e" description = var.name risk_level = "1" diff --git a/alicloud/data_source_alicloud_config_aggregate_config_rules.go b/alicloud/data_source_alicloud_config_aggregate_config_rules.go index eccb106f03df..6edf26b8e65c 100644 --- a/alicloud/data_source_alicloud_config_aggregate_config_rules.go +++ b/alicloud/data_source_alicloud_config_aggregate_config_rules.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" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -205,6 +204,7 @@ func dataSourceAlicloudConfigAggregateConfigRulesRead(d *schema.ResourceData, me request["PageSize"] = PageSizeLarge request["PageNumber"] = 1 var objects []map[string]interface{} + var err error var aggregateConfigRuleNameRegex *regexp.Regexp if v, ok := d.GetOk("name_regex"); ok { r, err := regexp.Compile(v.(string)) @@ -224,16 +224,11 @@ func dataSourceAlicloudConfigAggregateConfigRulesRead(d *schema.ResourceData, me } } var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + for { - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_config_aggregate_config_rules_test.go b/alicloud/data_source_alicloud_config_aggregate_config_rules_test.go index 2add90462957..7d1e850299e2 100644 --- a/alicloud/data_source_alicloud_config_aggregate_config_rules_test.go +++ b/alicloud/data_source_alicloud_config_aggregate_config_rules_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" ) -func TestAccAlicloudConfigAggregateConfigRulesDataSource(t *testing.T) { +func TestAccAliCloudConfigAggregateConfigRulesDataSource(t *testing.T) { rand := acctest.RandInt() idsConf := dataSourceTestAccConfig{ existConfig: testAccCheckAlicloudConfigAggregateConfigRulesDataSourceName(rand, map[string]string{ @@ -136,12 +136,73 @@ data "alicloud_resource_manager_resource_groups" "default" { status = "OK" } -data "alicloud_instances" "default" {} +data "alicloud_zones" default { + available_resource_creation = "Instance" +} + +data "alicloud_instance_types" "default" { + availability_zone = "${data.alicloud_zones.default.zones.0.id}" + instance_type_family = "ecs.sn1ne" +} + +data "alicloud_images" "default" { + name_regex = "^ubuntu" + most_recent = true + owners = "system" +} + +resource "alicloud_vpc" "foo" { + cidr_block = "172.16.0.0/12" + name = "${var.name}" +} + +resource "alicloud_vswitch" "foo" { + vpc_id = "${alicloud_vpc.foo.id}" + cidr_block = "172.16.0.0/21" + availability_zone = "${data.alicloud_zones.default.zones.0.id}" + name = "${var.name}" +} -data "alicloud_config_aggregators" "default" {} +resource "alicloud_security_group" "tf_test_foo" { + name = "${var.name}" + description = "foo" + vpc_id = "${alicloud_vpc.foo.id}" +} + +resource "alicloud_instance" "default" { + + availability_zone = "${data.alicloud_zones.default.zones.0.id}" + vswitch_id = "${alicloud_vswitch.foo.id}" + image_id = "${data.alicloud_images.default.images.0.id}" + # series III + instance_type = "${data.alicloud_instance_types.default.instance_types.0.id}" + system_disk_category = "cloud_efficiency" + internet_charge_type = "PayByTraffic" + internet_max_bandwidth_out = 5 + security_groups = ["${alicloud_security_group.tf_test_foo.id}"] + instance_name = "${var.name}" + user_data = "echo 'net.ipv4.ip_forward=1'>> /etc/sysctl.conf" +} + +data "alicloud_instances" "default" { + name_regex = "${alicloud_instance.default.instance_name}" +} + +data "alicloud_resource_manager_accounts" "default" { + status = "CreateSuccess" +} +resource "alicloud_config_aggregator" "default" { + aggregator_accounts { + account_id = data.alicloud_resource_manager_accounts.default.accounts.1.account_id + account_name = data.alicloud_resource_manager_accounts.default.accounts.1.display_name + account_type = "ResourceDirectory" + } + aggregator_name = var.name + description = var.name +} resource "alicloud_config_aggregate_config_rule" "default" { - aggregator_id = data.alicloud_config_aggregators.default.ids.0 + aggregator_id = alicloud_config_aggregator.default.id aggregate_config_rule_name = var.name source_owner = "ALIYUN" source_identifier = "ecs-cpu-min-count-limit" diff --git a/alicloud/data_source_alicloud_config_aggregate_deliveries.go b/alicloud/data_source_alicloud_config_aggregate_deliveries.go index f73e57106a92..5d8e5342dcff 100644 --- a/alicloud/data_source_alicloud_config_aggregate_deliveries.go +++ b/alicloud/data_source_alicloud_config_aggregate_deliveries.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" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -129,6 +128,7 @@ func dataSourceAlicloudConfigAggregateDeliveriesRead(d *schema.ResourceData, met request := make(map[string]interface{}) request["AggregatorId"] = d.Get("aggregator_id") var objects []map[string]interface{} + var err error var channelNameRegex *regexp.Regexp if v, ok := d.GetOk("name_regex"); ok { r, err := regexp.Compile(v.(string)) @@ -148,15 +148,10 @@ func dataSourceAlicloudConfigAggregateDeliveriesRead(d *schema.ResourceData, met } status, statusOk := d.GetOkExists("status") var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } - runtime := util.RuntimeOptions{} - 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("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_config_aggregate_deliveries_test.go b/alicloud/data_source_alicloud_config_aggregate_deliveries_test.go index a9322a8afa84..393af83a6e41 100644 --- a/alicloud/data_source_alicloud_config_aggregate_deliveries_test.go +++ b/alicloud/data_source_alicloud_config_aggregate_deliveries_test.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" ) -func TestAccAlicloudConfigAggregateDeliveriesDataSource(t *testing.T) { +func TestAccAliCloudConfigAggregateDeliveriesDataSource(t *testing.T) { rand := acctest.RandInt() checkoutSupportedRegions(t, true, connectivity.CloudConfigSupportedRegions) nameRegexConf := dataSourceTestAccConfig{ @@ -135,7 +135,7 @@ resource "alicloud_config_aggregate_delivery" "default" { } data "alicloud_config_aggregate_deliveries" "default" { - aggregator_id = alicloud_config_aggregator.default.id + aggregator_id = alicloud_config_aggregate_delivery.default.aggregator_id %s } `, rand, defaultRegionToTest, strings.Join(pairs, " \n ")) diff --git a/alicloud/data_source_alicloud_config_aggregators.go b/alicloud/data_source_alicloud_config_aggregators.go index 6018a9c95b00..50758e6bdad9 100644 --- a/alicloud/data_source_alicloud_config_aggregators.go +++ b/alicloud/data_source_alicloud_config_aggregators.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" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -137,16 +136,12 @@ func dataSourceAlicloudConfigAggregatorsRead(d *schema.ResourceData, meta interf } status, statusOk := d.GetOk("status") var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + var err error + for { - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_config_aggregators_test.go b/alicloud/data_source_alicloud_config_aggregators_test.go index d433add94acb..d3d58295531b 100644 --- a/alicloud/data_source_alicloud_config_aggregators_test.go +++ b/alicloud/data_source_alicloud_config_aggregators_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" ) -func TestAccAlicloudConfigAggregatorsDataSource(t *testing.T) { +func TestAccAliCloudConfigAggregatorsDataSource(t *testing.T) { rand := acctest.RandInt() idsConf := dataSourceTestAccConfig{ existConfig: testAccCheckAlicloudConfigAggregatorsDataSourceName(rand, map[string]string{ diff --git a/alicloud/data_source_alicloud_config_compliance_packs.go b/alicloud/data_source_alicloud_config_compliance_packs.go index 3b3056e79565..95fc2291b157 100644 --- a/alicloud/data_source_alicloud_config_compliance_packs.go +++ b/alicloud/data_source_alicloud_config_compliance_packs.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" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -158,16 +157,11 @@ func dataSourceAlicloudConfigCompliancePacksRead(d *schema.ResourceData, meta in } status, statusOk := d.GetOk("status") var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + var err error for { - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_config_compliance_packs_test.go b/alicloud/data_source_alicloud_config_compliance_packs_test.go index 1b3e0bd8fd78..05e9b22e2e1b 100644 --- a/alicloud/data_source_alicloud_config_compliance_packs_test.go +++ b/alicloud/data_source_alicloud_config_compliance_packs_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" ) -func TestAccAlicloudConfigCompliancePacksDataSource(t *testing.T) { +func TestAccAliCloudConfigCompliancePacksDataSource(t *testing.T) { rand := acctest.RandInt() idsConf := dataSourceTestAccConfig{ existConfig: testAccCheckAlicloudConfigCompliancePacksDataSourceName(rand, map[string]string{ diff --git a/alicloud/data_source_alicloud_config_configuration_recorders.go b/alicloud/data_source_alicloud_config_configuration_recorders.go index d1c107d58e85..223d86e45bdc 100644 --- a/alicloud/data_source_alicloud_config_configuration_recorders.go +++ b/alicloud/data_source_alicloud_config_configuration_recorders.go @@ -5,7 +5,6 @@ import ( "strconv" "time" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) @@ -60,12 +59,7 @@ func dataSourceAlicloudConfigConfigurationRecordersRead(d *schema.ResourceData, action := "DescribeConfigurationRecorder" request := make(map[string]interface{}) - var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("GET"), StringPointer("2019-01-08"), StringPointer("AK"), request, nil, &util.RuntimeOptions{}) + response, err := client.RpcGet("Config", "2019-01-08", action, request, nil) if err != nil { return WrapErrorf(err, DataDefaultErrorMsg, "alicloud_config_configuration_recorders", action, AlibabaCloudSdkGoERROR) } diff --git a/alicloud/data_source_alicloud_config_configuration_recorders_test.go b/alicloud/data_source_alicloud_config_configuration_recorders_test.go index 6aeb88644efd..76d23c865744 100644 --- a/alicloud/data_source_alicloud_config_configuration_recorders_test.go +++ b/alicloud/data_source_alicloud_config_configuration_recorders_test.go @@ -10,7 +10,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" ) -func TestAccAlicloudConfigConfigurationRecordersDataSource(t *testing.T) { +// alicloud_config_configuration_recorder used to open CloudConfig service. +// There can stop the service manually first before running the testcase. +func SkipTestAccAliCloudConfigConfigurationRecordersDataSource(t *testing.T) { rand := acctest.RandIntRange(1000000, 9999999) resourceId := "data.alicloud_config_configuration_recorders.example" diff --git a/alicloud/data_source_alicloud_config_deliveries.go b/alicloud/data_source_alicloud_config_deliveries.go index f74d877e90de..6d3f6f347f4c 100644 --- a/alicloud/data_source_alicloud_config_deliveries.go +++ b/alicloud/data_source_alicloud_config_deliveries.go @@ -7,7 +7,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" @@ -140,15 +139,10 @@ func dataSourceAlicloudConfigDeliveriesRead(d *schema.ResourceData, meta interfa } status, statusOk := d.GetOkExists("status") var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) + var err error 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("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_config_deliveries_test.go b/alicloud/data_source_alicloud_config_deliveries_test.go index b0b21a5f2b3d..cc108a3e7833 100644 --- a/alicloud/data_source_alicloud_config_deliveries_test.go +++ b/alicloud/data_source_alicloud_config_deliveries_test.go @@ -10,7 +10,7 @@ import ( "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" ) -func TestAccAlicloudConfigDeliveriesDataSource(t *testing.T) { +func TestAccAliCloudConfigDeliveriesDataSource(t *testing.T) { rand := acctest.RandIntRange(10000, 99999) checkoutSupportedRegions(t, true, connectivity.CloudConfigSupportedRegions) nameRegexConf := dataSourceTestAccConfig{ diff --git a/alicloud/data_source_alicloud_config_delivery_channels.go b/alicloud/data_source_alicloud_config_delivery_channels.go index 1ef98e39f696..a4c5a9fd12b7 100644 --- a/alicloud/data_source_alicloud_config_delivery_channels.go +++ b/alicloud/data_source_alicloud_config_delivery_channels.go @@ -5,7 +5,6 @@ import ( "regexp" "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" @@ -116,12 +115,7 @@ func dataSourceAlicloudConfigDeliveryChannelsRead(d *schema.ResourceData, meta i } } status, statusOk := d.GetOkExists("status") - var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("GET"), StringPointer("2019-01-08"), StringPointer("AK"), request, nil, &util.RuntimeOptions{}) + response, err := client.RpcGet("Config", "2019-01-08", action, request, nil) if err != nil { return WrapErrorf(err, DataDefaultErrorMsg, "alicloud_config_delivery_channels", action, AlibabaCloudSdkGoERROR) } diff --git a/alicloud/data_source_alicloud_config_delivery_channels_test.go b/alicloud/data_source_alicloud_config_delivery_channels_test.go index b2e4c77a8de0..d4a833e88896 100644 --- a/alicloud/data_source_alicloud_config_delivery_channels_test.go +++ b/alicloud/data_source_alicloud_config_delivery_channels_test.go @@ -10,7 +10,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" ) -func TestAccAlicloudConfigDeliveryChannelsDataSource(t *testing.T) { +// Skipped: The resource and its apis have deprecated +func SkipTestAccAliCloudConfigDeliveryChannelsDataSource(t *testing.T) { rand := acctest.RandIntRange(1000000, 9999999) resourceId := "data.alicloud_config_delivery_channels.example" diff --git a/alicloud/data_source_alicloud_config_rules.go b/alicloud/data_source_alicloud_config_rules.go index 217d9aa13e40..90e953d55029 100644 --- a/alicloud/data_source_alicloud_config_rules.go +++ b/alicloud/data_source_alicloud_config_rules.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" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -260,16 +259,12 @@ func dataSourceAlicloudConfigRulesRead(d *schema.ResourceData, meta interface{}) } } var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + var err error + for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(6*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("GET"), StringPointer("2019-01-08"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2019-01-08", action, request, nil) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/data_source_alicloud_config_rules_test.go b/alicloud/data_source_alicloud_config_rules_test.go index 8143e0d73f02..757bdc1c23cf 100644 --- a/alicloud/data_source_alicloud_config_rules_test.go +++ b/alicloud/data_source_alicloud_config_rules_test.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" ) -func TestAccAlicloudConfigRulesDataSource(t *testing.T) { +func TestAccAliCloudConfigRulesDataSource(t *testing.T) { rand := acctest.RandIntRange(1000000, 9999999) resourceId := "data.alicloud_config_rules.example" diff --git a/alicloud/resource_alicloud_config_aggregate_compliance_pack.go b/alicloud/resource_alicloud_config_aggregate_compliance_pack.go index 5be54e5e5adb..5cbb269fbba4 100644 --- a/alicloud/resource_alicloud_config_aggregate_compliance_pack.go +++ b/alicloud/resource_alicloud_config_aggregate_compliance_pack.go @@ -5,7 +5,6 @@ import ( "log" "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" @@ -108,12 +107,9 @@ func resourceAliCloudConfigAggregateCompliancePackCreate(d *schema.ResourceData, client := meta.(*connectivity.AliyunClient) configService := ConfigService{client} var response map[string]interface{} + var err error action := "CreateAggregateCompliancePack" request := make(map[string]interface{}) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } request["ClientToken"] = buildClientToken("CreateAggregateCompliancePack") request["AggregatorId"] = d.Get("aggregator_id") @@ -180,11 +176,9 @@ func resourceAliCloudConfigAggregateCompliancePackCreate(d *schema.ResourceData, request["ConfigRules"] = configRulesJson } - 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("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -367,16 +361,9 @@ func resourceAliCloudConfigAggregateCompliancePackUpdate(d *schema.ResourceData, if update { action := "UpdateAggregateCompliancePack" - conn, err := client.NewConfigClient() - 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("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -407,12 +394,6 @@ func resourceAliCloudConfigAggregateCompliancePackUpdate(d *schema.ResourceData, oldConfigRuleIds, newConfigRuleIds := d.GetChange("config_rule_ids") remove := oldConfigRuleIds.(*schema.Set).Difference(newConfigRuleIds.(*schema.Set)).List() create := newConfigRuleIds.(*schema.Set).Difference(oldConfigRuleIds.(*schema.Set)).List() - - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } - if len(remove) > 0 { action := "DetachAggregateConfigRuleToCompliancePack" @@ -431,12 +412,9 @@ func resourceAliCloudConfigAggregateCompliancePackUpdate(d *schema.ResourceData, } detachAggregateConfigRuleReq["ConfigRuleIds"] = convertListToCommaSeparate(configRuleIds) - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-09-07"), StringPointer("AK"), nil, detachAggregateConfigRuleReq, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, detachAggregateConfigRuleReq, false) if err != nil { if NeedRetry(err) { wait() @@ -473,11 +451,9 @@ func resourceAliCloudConfigAggregateCompliancePackUpdate(d *schema.ResourceData, attachAggregateConfigRuleReq["ConfigRuleIds"] = convertListToCommaSeparate(configRuleIds) - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-09-07"), StringPointer("AK"), nil, attachAggregateConfigRuleReq, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, attachAggregateConfigRuleReq, false) if err != nil { if NeedRetry(err) { wait() @@ -507,11 +483,6 @@ func resourceAliCloudConfigAggregateCompliancePackDelete(d *schema.ResourceData, action := "DeleteAggregateCompliancePacks" var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } - parts, err := ParseResourceId(d.Id(), 2) if err != nil { return WrapError(err) @@ -523,11 +494,9 @@ func resourceAliCloudConfigAggregateCompliancePackDelete(d *schema.ResourceData, "CompliancePackIds": 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("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_config_aggregate_compliance_pack_test.go b/alicloud/resource_alicloud_config_aggregate_compliance_pack_test.go index af991ab9905d..0b39051f454e 100644 --- a/alicloud/resource_alicloud_config_aggregate_compliance_pack_test.go +++ b/alicloud/resource_alicloud_config_aggregate_compliance_pack_test.go @@ -41,10 +41,6 @@ func testSweepConfigAggregateCompliancePack(region string) error { "tf-testAcc", "tf_testAcc", } - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } // Get all AggregatorId aggregatorIds := make([]string, 0) @@ -54,11 +50,9 @@ func testSweepConfigAggregateCompliancePack(region string) error { } var response map[string]interface{} for { - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -111,11 +105,9 @@ func testSweepConfigAggregateCompliancePack(region string) error { } compliancePackIds := make([]string, 0) for { - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -163,7 +155,7 @@ func testSweepConfigAggregateCompliancePack(region string) error { } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(time.Minute*10, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-09-07"), StringPointer("AK"), nil, deleteRequest, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, deleteRequest, false) if err != nil { if NeedRetry(err) { wait() @@ -333,7 +325,7 @@ func TestAccAliCloudConfigAggregateCompliancePack_basic0_twin(t *testing.T) { "aggregate_compliance_pack_name": name, "description": name, "risk_level": "1", - "compliance_pack_template_id": "${data.alicloud_config_compliance_packs.default.packs.0.compliance_pack_template_id}", + "compliance_pack_template_id": "${var.compliance_pack_template_id}", "config_rules": []map[string]interface{}{ { "managed_rule_identifier": "ecs-snapshot-retention-days", @@ -466,14 +458,15 @@ func AliCloudConfigAggregateCompliancePackBasicDependence0(name string) string { variable "name" { default = "%s" } + + variable "compliance_pack_template_id" { + default = "ct-3d20ff4e06a30027f76e" + } data "alicloud_resource_manager_accounts" "default" { status = "CreateSuccess" } - data "alicloud_config_compliance_packs" "default" { - } - resource "alicloud_config_aggregator" "default" { aggregator_accounts { account_id = data.alicloud_resource_manager_accounts.default.accounts.0.account_id diff --git a/alicloud/resource_alicloud_config_aggregate_config_rule.go b/alicloud/resource_alicloud_config_aggregate_config_rule.go index a9f5b906535a..2e8b51fed14e 100644 --- a/alicloud/resource_alicloud_config_aggregate_config_rule.go +++ b/alicloud/resource_alicloud_config_aggregate_config_rule.go @@ -5,7 +5,6 @@ import ( "log" "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" @@ -119,12 +118,10 @@ func resourceAlicloudConfigAggregateConfigRule() *schema.Resource { func resourceAlicloudConfigAggregateConfigRuleCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} + var err error action := "CreateAggregateConfigRule" request := make(map[string]interface{}) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request["ConfigRuleName"] = d.Get("aggregate_config_rule_name") request["AggregatorId"] = d.Get("aggregator_id") request["ConfigRuleTriggerTypes"] = d.Get("config_rule_trigger_types") @@ -161,11 +158,9 @@ func resourceAlicloudConfigAggregateConfigRuleCreate(d *schema.ResourceData, met request["TagValueScope"] = v } request["ClientToken"] = buildClientToken("CreateAggregateConfigRule") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -221,10 +216,7 @@ func resourceAlicloudConfigAggregateConfigRuleRead(d *schema.ResourceData, meta } func resourceAlicloudConfigAggregateConfigRuleUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + configService := ConfigService{client} d.Partial(true) var response map[string]interface{} @@ -283,16 +275,15 @@ func resourceAlicloudConfigAggregateConfigRuleUpdate(d *schema.ResourceData, met } if !d.IsNewResource() && d.HasChange("tag_value_scope") { update = true + request["TagKeyScope"] = d.Get("tag_key_scope") request["TagValueScope"] = d.Get("tag_value_scope") } if update { action := "UpdateAggregateConfigRule" request["ClientToken"] = buildClientToken("UpdateAggregateConfigRule") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -350,10 +341,7 @@ func resourceAlicloudConfigAggregateConfigRuleDelete(d *schema.ResourceData, met } action := "DeleteAggregateConfigRules" var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request := map[string]interface{}{ "AggregatorId": parts[0], "ConfigRuleIds": parts[1], @@ -361,7 +349,7 @@ func resourceAlicloudConfigAggregateConfigRuleDelete(d *schema.ResourceData, met 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("2020-09-07"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_config_aggregate_config_rule_test.go b/alicloud/resource_alicloud_config_aggregate_config_rule_test.go index 8403ad349e41..5e2ab9a5a54d 100644 --- a/alicloud/resource_alicloud_config_aggregate_config_rule_test.go +++ b/alicloud/resource_alicloud_config_aggregate_config_rule_test.go @@ -42,11 +42,6 @@ func testSweepConfigAggregateConfigRule(region string) error { "tf_testAcc", } - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } - // Get all AggregatorId aggregatorIds := make([]string, 0) action := "ListAggregators" @@ -55,11 +50,9 @@ func testSweepConfigAggregateConfigRule(region string) error { } var response map[string]interface{} for { - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -112,11 +105,9 @@ func testSweepConfigAggregateConfigRule(region string) error { "PageNumber": 1, } for { - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -161,7 +152,7 @@ func testSweepConfigAggregateConfigRule(region string) error { } 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("2020-09-07"), StringPointer("AK"), nil, deleteRequest, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, deleteRequest, false) if err != nil { if NeedRetry(err) { wait() @@ -180,7 +171,7 @@ func testSweepConfigAggregateConfigRule(region string) error { return nil } -func TestAccAlicloudConfigAggregateConfigRule_basic(t *testing.T) { +func TestAccAliCloudConfigAggregateConfigRule_basic(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_config_aggregate_config_rule.default" ra := resourceAttrInit(resourceId, AlicloudConfigAggregateConfigRuleMap0) @@ -205,7 +196,7 @@ func TestAccAlicloudConfigAggregateConfigRule_basic(t *testing.T) { { Config: testAccConfig(map[string]interface{}{ "aggregate_config_rule_name": "${var.name}", - "aggregator_id": "${data.alicloud_config_aggregators.default.ids.0}", + "aggregator_id": "${alicloud_config_aggregator.default.id}", "config_rule_trigger_types": "ConfigurationItemChangeNotification", "source_owner": "ALIYUN", "source_identifier": "ecs-cpu-min-count-limit", @@ -347,7 +338,7 @@ func TestAccAlicloudConfigAggregateConfigRule_basic(t *testing.T) { }) } -func TestAccAlicloudConfigAggregateConfigRule_status(t *testing.T) { +func TestAccAliCloudConfigAggregateConfigRule_status(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_config_aggregate_config_rule.default" ra := resourceAttrInit(resourceId, AlicloudConfigAggregateConfigRuleMap0) @@ -372,7 +363,7 @@ func TestAccAlicloudConfigAggregateConfigRule_status(t *testing.T) { { Config: testAccConfig(map[string]interface{}{ "aggregate_config_rule_name": "${var.name}", - "aggregator_id": "${data.alicloud_config_aggregators.default.ids.0}", + "aggregator_id": "${alicloud_config_aggregator.default.id}", "config_rule_trigger_types": "ConfigurationItemChangeNotification", "source_owner": "ALIYUN", "source_identifier": "ecs-cpu-min-count-limit", @@ -450,19 +441,79 @@ variable "name" { default = "%s" } -data "alicloud_instances" "default" {} +data "alicloud_zones" default { + available_resource_creation = "Instance" +} + +data "alicloud_instance_types" "default" { + availability_zone = "${data.alicloud_zones.default.zones.0.id}" + instance_type_family = "ecs.sn1ne" +} + +data "alicloud_images" "default" { + name_regex = "^ubuntu" + most_recent = true + owners = "system" +} + +resource "alicloud_vpc" "foo" { + cidr_block = "172.16.0.0/12" + name = "${var.name}" +} + +resource "alicloud_vswitch" "foo" { + vpc_id = "${alicloud_vpc.foo.id}" + cidr_block = "172.16.0.0/21" + availability_zone = "${data.alicloud_zones.default.zones.0.id}" + name = "${var.name}" +} + +resource "alicloud_security_group" "tf_test_foo" { + name = "${var.name}" + description = "foo" + vpc_id = "${alicloud_vpc.foo.id}" +} + +resource "alicloud_instance" "default" { + availability_zone = "${data.alicloud_zones.default.zones.0.id}" + vswitch_id = "${alicloud_vswitch.foo.id}" + image_id = "${data.alicloud_images.default.images.0.id}" + # series III + instance_type = "${data.alicloud_instance_types.default.instance_types.0.id}" + system_disk_category = "cloud_efficiency" + internet_charge_type = "PayByTraffic" + internet_max_bandwidth_out = 5 + security_groups = ["${alicloud_security_group.tf_test_foo.id}"] + instance_name = "${var.name}" + user_data = "echo 'net.ipv4.ip_forward=1'>> /etc/sysctl.conf" +} + +data "alicloud_instances" "default" { + name_regex = "${alicloud_instance.default.instance_name}" +} data "alicloud_resource_manager_resource_groups" "default" { status = "OK" } -data "alicloud_config_aggregators" "default" {} +data "alicloud_resource_manager_accounts" "default" { + status = "CreateSuccess" +} +resource "alicloud_config_aggregator" "default" { + aggregator_accounts { + account_id = data.alicloud_resource_manager_accounts.default.accounts.1.account_id + account_name = data.alicloud_resource_manager_accounts.default.accounts.1.display_name + account_type = "ResourceDirectory" + } + aggregator_name = var.name + description = var.name +} `, name) } // Test this case need use a custom `source_identifier` -func SkipTestAccAlicloudConfigAggregateConfigRule_basic1(t *testing.T) { +func SkipTestAccAliCloudConfigAggregateConfigRule_basic1(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_config_aggregate_config_rule.default" ra := resourceAttrInit(resourceId, AlicloudConfigAggregateConfigRuleMap1) @@ -487,7 +538,7 @@ func SkipTestAccAlicloudConfigAggregateConfigRule_basic1(t *testing.T) { { Config: testAccConfig(map[string]interface{}{ "aggregate_config_rule_name": "${var.name}", - "aggregator_id": "${data.alicloud_config_aggregators.default.ids.0}", + "aggregator_id": "${alicloud_config_aggregator.default.id}", "config_rule_trigger_types": "ConfigurationItemChangeNotification", "source_owner": "CUSTOM_FC", "source_identifier": "*** your_fc_function_arn ***", @@ -672,7 +723,18 @@ data "alicloud_resource_manager_resource_groups" "default" { status = "OK" } -data "alicloud_config_aggregators" "default" {} +data "alicloud_resource_manager_accounts" "default" { + status = "CreateSuccess" +} +resource "alicloud_config_aggregator" "default" { + aggregator_accounts { + account_id = data.alicloud_resource_manager_accounts.default.accounts.1.account_id + account_name = data.alicloud_resource_manager_accounts.default.accounts.1.display_name + account_type = "ResourceDirectory" + } + aggregator_name = var.name + description = var.name +} `, name) } diff --git a/alicloud/resource_alicloud_config_aggregate_delivery.go b/alicloud/resource_alicloud_config_aggregate_delivery.go index f78d5c0645db..41be1a11966a 100644 --- a/alicloud/resource_alicloud_config_aggregate_delivery.go +++ b/alicloud/resource_alicloud_config_aggregate_delivery.go @@ -7,7 +7,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" @@ -91,11 +90,9 @@ func resourceAliCloudConfigAggregateDeliveryCreate(d *schema.ResourceData, meta action := "CreateAggregateConfigDeliveryChannel" var request map[string]interface{} var response map[string]interface{} + var err error query := make(map[string]interface{}) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request = make(map[string]interface{}) query["AggregatorId"] = d.Get("aggregator_id") @@ -124,11 +121,9 @@ func resourceAliCloudConfigAggregateDeliveryCreate(d *schema.ResourceData, meta if v, ok := d.GetOk("oversized_data_oss_target_arn"); ok { request["OversizedDataOSSTargetArn"] = v } - 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("2020-09-07"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, query, request, true) if err != nil { if NeedRetry(err) { wait() @@ -209,16 +204,18 @@ func resourceAliCloudConfigAggregateDeliveryRead(d *schema.ResourceData, meta in func resourceAliCloudConfigAggregateDeliveryUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) + configServiceV2 := ConfigServiceV2{client} + objectRaw, err := configServiceV2.DescribeConfigAggregateDelivery(d.Id()) + if err != nil { + return WrapError(err) + } var request map[string]interface{} var response map[string]interface{} var query map[string]interface{} update := false parts := strings.Split(d.Id(), ":") action := "UpdateAggregateConfigDeliveryChannel" - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request = make(map[string]interface{}) query = make(map[string]interface{}) query["AggregatorId"] = parts[0] @@ -263,18 +260,16 @@ func resourceAliCloudConfigAggregateDeliveryUpdate(d *schema.ResourceData, meta update = true request["OversizedDataOSSTargetArn"] = d.Get("oversized_data_oss_target_arn") } - - if d.IsNewResource() || d.HasChange("status") { + // status default to 1 after creating + if v, ok := d.GetOkExists("status"); ok && fmt.Sprint(objectRaw["Status"]) != fmt.Sprint(v) { update = true - request["Status"] = d.Get("status") + request["Status"] = v } 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("2020-09-07"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, query, request, true) if err != nil { if NeedRetry(err) { wait() @@ -300,20 +295,16 @@ func resourceAliCloudConfigAggregateDeliveryDelete(d *schema.ResourceData, meta action := "DeleteAggregateConfigDeliveryChannel" var request map[string]interface{} var response map[string]interface{} + var err error query := make(map[string]interface{}) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request = make(map[string]interface{}) query["AggregatorId"] = parts[0] query["DeliveryChannelId"] = parts[1] - 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("2020-09-07"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, query, request, false) if err != nil { if NeedRetry(err) { diff --git a/alicloud/resource_alicloud_config_aggregator.go b/alicloud/resource_alicloud_config_aggregator.go index c7f64eb61947..ba0bae4f5111 100644 --- a/alicloud/resource_alicloud_config_aggregator.go +++ b/alicloud/resource_alicloud_config_aggregator.go @@ -73,10 +73,6 @@ func resourceAlicloudConfigAggregatorCreate(d *schema.ResourceData, meta interfa client := meta.(*connectivity.AliyunClient) configService := ConfigService{client} request := make(map[string]interface{}) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } aggregatorAccountsMaps := make([]map[string]interface{}, 0) for _, aggregatorAccounts := range d.Get("aggregator_accounts").(*schema.Set).List() { @@ -106,10 +102,11 @@ func resourceAlicloudConfigAggregatorCreate(d *schema.ResourceData, meta interfa runtime := util.RuntimeOptions{} runtime.SetAutoretry(true) var response map[string]interface{} + var err error action := "CreateAggregator" wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -117,8 +114,7 @@ func resourceAlicloudConfigAggregatorCreate(d *schema.ResourceData, meta interfa } return resource.NonRetryableError(err) } - response = resp - addDebug(action, resp, request) + addDebug(action, response, request) return nil }) if err != nil { @@ -170,11 +166,6 @@ func resourceAlicloudConfigAggregatorRead(d *schema.ResourceData, meta interface } func resourceAlicloudConfigAggregatorUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } - update := false request := map[string]interface{}{ "AggregatorId": d.Id(), @@ -212,11 +203,9 @@ func resourceAlicloudConfigAggregatorUpdate(d *schema.ResourceData, meta interfa if update { action := "UpdateAggregator" request["ClientToken"] = buildClientToken("UpdateAggregator") - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 3*time.Second) - err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + err := resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { + response, err := client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -224,7 +213,7 @@ func resourceAlicloudConfigAggregatorUpdate(d *schema.ResourceData, meta interfa } return resource.NonRetryableError(err) } - addDebug(action, resp, request) + addDebug(action, response, request) return nil }) if err != nil { @@ -235,10 +224,7 @@ func resourceAlicloudConfigAggregatorUpdate(d *schema.ResourceData, meta interfa } func resourceAlicloudConfigAggregatorDelete(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request := map[string]interface{}{ "AggregatorIds": d.Id(), } @@ -248,8 +234,8 @@ func resourceAlicloudConfigAggregatorDelete(d *schema.ResourceData, meta interfa runtime.SetAutoretry(true) action := "DeleteAggregators" wait := incrementalWait(3*time.Second, 3*time.Second) - err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { - resp, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + err := resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { + response, err := client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -257,7 +243,7 @@ func resourceAlicloudConfigAggregatorDelete(d *schema.ResourceData, meta interfa } return resource.NonRetryableError(err) } - addDebug(action, resp, request) + addDebug(action, response, request) return nil }) if err != nil { diff --git a/alicloud/resource_alicloud_config_aggregator_test.go b/alicloud/resource_alicloud_config_aggregator_test.go index e1c40dc5ed34..873132521f04 100644 --- a/alicloud/resource_alicloud_config_aggregator_test.go +++ b/alicloud/resource_alicloud_config_aggregator_test.go @@ -45,10 +45,6 @@ func testSweepConfigAggregator(region string) error { "tf-testAcc", "tf_testAcc", } - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } // Get all AggregatorId aggregatorIds := make([]string, 0) @@ -58,11 +54,9 @@ func testSweepConfigAggregator(region string) error { } var response map[string]interface{} for { - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -110,7 +104,7 @@ func testSweepConfigAggregator(region string) error { } 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("2020-09-07"), StringPointer("AK"), nil, deleteRequest, &util.RuntimeOptions{}) + _, err = client.RpcPost("Config", "2020-09-07", action, nil, deleteRequest, false) if err != nil { if NeedRetry(err) { wait() @@ -126,7 +120,7 @@ func testSweepConfigAggregator(region string) error { return nil } -func TestAccAlicloudConfigAggregator_basic(t *testing.T) { +func TestAccAliCloudConfigAggregator_basic(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_config_aggregator.default" ra := resourceAttrInit(resourceId, AlicloudConfigAggregatorMap0) @@ -240,7 +234,7 @@ func TestAccAlicloudConfigAggregator_basic(t *testing.T) { }) } -func TestAccAlicloudConfigAggregator_aggregator_accounts_update(t *testing.T) { +func TestAccAliCloudConfigAggregator_aggregator_accounts_update(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_config_aggregator.default" ra := resourceAttrInit(resourceId, AlicloudConfigAggregatorMap0) diff --git a/alicloud/resource_alicloud_config_compliance_pack.go b/alicloud/resource_alicloud_config_compliance_pack.go index 308e0305a0ce..ea5444f9b529 100644 --- a/alicloud/resource_alicloud_config_compliance_pack.go +++ b/alicloud/resource_alicloud_config_compliance_pack.go @@ -5,7 +5,6 @@ import ( "log" "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" @@ -99,12 +98,9 @@ func resourceAliCloudConfigCompliancePackCreate(d *schema.ResourceData, meta int client := meta.(*connectivity.AliyunClient) configService := ConfigService{client} var response map[string]interface{} + var err error action := "CreateCompliancePack" request := make(map[string]interface{}) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } request["ClientToken"] = buildClientToken("CreateCompliancePack") request["CompliancePackName"] = d.Get("compliance_pack_name") @@ -170,11 +166,9 @@ func resourceAliCloudConfigCompliancePackCreate(d *schema.ResourceData, meta int request["ConfigRules"] = configRulesJson } - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 30*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutCreate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() @@ -281,6 +275,7 @@ func resourceAliCloudConfigCompliancePackUpdate(d *schema.ResourceData, meta int client := meta.(*connectivity.AliyunClient) configService := ConfigService{client} var response map[string]interface{} + var err error d.Partial(true) update := false @@ -349,16 +344,9 @@ func resourceAliCloudConfigCompliancePackUpdate(d *schema.ResourceData, meta int if update { action := "UpdateCompliancePack" - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 30*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if IsExpectedErrors(err, []string{"CompliancePackAlreadyPending"}) || NeedRetry(err) { wait() @@ -390,11 +378,6 @@ func resourceAliCloudConfigCompliancePackUpdate(d *schema.ResourceData, meta int remove := oldConfigRuleIds.(*schema.Set).Difference(newConfigRuleIds.(*schema.Set)).List() create := newConfigRuleIds.(*schema.Set).Difference(oldConfigRuleIds.(*schema.Set)).List() - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } - if len(remove) > 0 { action := "DetachConfigRuleToCompliancePack" @@ -413,11 +396,9 @@ func resourceAliCloudConfigCompliancePackUpdate(d *schema.ResourceData, meta int detachConfigRuleReq["ConfigRuleIds"] = convertListToCommaSeparate(configRuleIds) - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-09-07"), StringPointer("AK"), nil, detachConfigRuleReq, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, detachConfigRuleReq, false) if err != nil { if NeedRetry(err) { wait() @@ -451,12 +432,9 @@ func resourceAliCloudConfigCompliancePackUpdate(d *schema.ResourceData, meta int } attachConfigRuleReq["ConfigRuleIds"] = convertListToCommaSeparate(configRuleIds) - - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-09-07"), StringPointer("AK"), nil, attachConfigRuleReq, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, attachConfigRuleReq, false) if err != nil { if NeedRetry(err) { wait() @@ -485,22 +463,15 @@ func resourceAliCloudConfigCompliancePackDelete(d *schema.ResourceData, meta int client := meta.(*connectivity.AliyunClient) action := "DeleteCompliancePacks" var response map[string]interface{} - - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } - + var err error request := map[string]interface{}{ "ClientToken": buildClientToken("DeleteCompliancePacks"), "CompliancePackIds": d.Id(), } - 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("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_config_compliance_pack_test.go b/alicloud/resource_alicloud_config_compliance_pack_test.go index 1d706f3b22f7..0ec1cecee42f 100644 --- a/alicloud/resource_alicloud_config_compliance_pack_test.go +++ b/alicloud/resource_alicloud_config_compliance_pack_test.go @@ -46,10 +46,7 @@ func testSweepConfigCompliancePack(region string) error { } compliancePackIds := make([]string, 0) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + action := "ListCompliancePacks" var response map[string]interface{} request := map[string]interface{}{ @@ -57,11 +54,9 @@ func testSweepConfigCompliancePack(region string) error { "PageNumber": 1, } for { - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -111,7 +106,7 @@ func testSweepConfigCompliancePack(region string) error { } 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("2020-09-07"), StringPointer("AK"), nil, deleteRequest, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, deleteRequest, false) if err != nil { if NeedRetry(err) { wait() @@ -283,7 +278,7 @@ func TestAccAliCloudConfigCompliancePack_basic0_twin(t *testing.T) { "compliance_pack_name": name, "description": name, "risk_level": "1", - "compliance_pack_template_id": "${data.alicloud_config_compliance_packs.default.packs.0.compliance_pack_template_id}", + "compliance_pack_template_id": "${var.compliance_pack_template_id}", "config_rules": []map[string]interface{}{ { "managed_rule_identifier": "ecs-snapshot-retention-days", @@ -413,7 +408,8 @@ func AliCloudConfigCompliancePackBasicDependence0(name string) string { default = "%s" } - data "alicloud_config_compliance_packs" "default" { + variable "compliance_pack_template_id" { + default = "ct-3d20ff4e06a30027f76e" } `, name) } diff --git a/alicloud/resource_alicloud_config_configuration_recorder.go b/alicloud/resource_alicloud_config_configuration_recorder.go index 49ec25cd709c..d208d14981c9 100644 --- a/alicloud/resource_alicloud_config_configuration_recorder.go +++ b/alicloud/resource_alicloud_config_configuration_recorder.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - util "github.com/alibabacloud-go/tea-utils/service" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) @@ -58,18 +57,16 @@ func resourceAlicloudConfigConfigurationRecorder() *schema.Resource { func resourceAlicloudConfigConfigurationRecorderCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} + var err error action := "StartConfigurationRecorder" request := make(map[string]interface{}) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + if v, ok := d.GetOkExists("enterprise_edition"); ok { request["EnterpriseEdition"] = v } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-01-08"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2019-01-08", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -111,6 +108,7 @@ func resourceAlicloudConfigConfigurationRecorderUpdate(d *schema.ResourceData, m client := meta.(*connectivity.AliyunClient) configService := ConfigService{client} var response map[string]interface{} + var err error update := false request := make(map[string]interface{}) if !d.IsNewResource() && d.HasChange("resource_types") { @@ -119,13 +117,9 @@ func resourceAlicloudConfigConfigurationRecorderUpdate(d *schema.ResourceData, m request["ResourceTypes"] = convertListToCommaSeparate(d.Get("resource_types").(*schema.Set).List()) if update { action := "PutConfigurationRecorder" - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-01-08"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2019-01-08", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/resource_alicloud_config_configuration_recorder_test.go b/alicloud/resource_alicloud_config_configuration_recorder_test.go index 27c22583c134..42946d0fbe7a 100644 --- a/alicloud/resource_alicloud_config_configuration_recorder_test.go +++ b/alicloud/resource_alicloud_config_configuration_recorder_test.go @@ -17,7 +17,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccAlicloudConfigConfigurationRecorder_basic(t *testing.T) { +// alicloud_config_configuration_recorder used to open CloudConfig service. +// There can stop the service manually first before running the testcase. +func SkipTestAccAliCloudConfigConfigurationRecorder_basic(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_config_configuration_recorder.default" ra := resourceAttrInit(resourceId, ConfigConfigurationRecorderMap) diff --git a/alicloud/resource_alicloud_config_delivery.go b/alicloud/resource_alicloud_config_delivery.go index 78ac9d5c9619..82aafa302a54 100644 --- a/alicloud/resource_alicloud_config_delivery.go +++ b/alicloud/resource_alicloud_config_delivery.go @@ -6,7 +6,6 @@ import ( "log" "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" @@ -81,11 +80,9 @@ func resourceAliCloudConfigDeliveryCreate(d *schema.ResourceData, meta interface action := "CreateConfigDeliveryChannel" var request map[string]interface{} var response map[string]interface{} + var err error query := make(map[string]interface{}) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request = make(map[string]interface{}) request["ClientToken"] = buildClientToken(action) @@ -113,11 +110,9 @@ func resourceAliCloudConfigDeliveryCreate(d *schema.ResourceData, meta interface if v, ok := d.GetOk("oversized_data_oss_target_arn"); ok { request["OversizedDataOSSTargetArn"] = v } - 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("2020-09-07"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, query, request, true) if err != nil { if NeedRetry(err) { wait() @@ -188,15 +183,17 @@ func resourceAliCloudConfigDeliveryRead(d *schema.ResourceData, meta interface{} func resourceAliCloudConfigDeliveryUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) + configServiceV2 := ConfigServiceV2{client} + objectRaw, err := configServiceV2.DescribeConfigDelivery(d.Id()) + if err != nil { + return WrapError(err) + } var request map[string]interface{} var response map[string]interface{} var query map[string]interface{} update := false action := "UpdateConfigDeliveryChannel" - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request = make(map[string]interface{}) query = make(map[string]interface{}) query["DeliveryChannelId"] = d.Id() @@ -241,17 +238,16 @@ func resourceAliCloudConfigDeliveryUpdate(d *schema.ResourceData, meta interface request["OversizedDataOSSTargetArn"] = d.Get("oversized_data_oss_target_arn") } - if d.HasChange("status") || d.IsNewResource() { + // status default to 1 after creating + if v, ok := d.GetOkExists("status"); ok && fmt.Sprint(objectRaw["Status"]) != fmt.Sprint(v) { update = true - request["Status"] = d.Get("status") + request["Status"] = v } 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("2020-09-07"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, query, request, true) if err != nil { if NeedRetry(err) { wait() @@ -276,19 +272,15 @@ func resourceAliCloudConfigDeliveryDelete(d *schema.ResourceData, meta interface action := "DeleteConfigDeliveryChannel" var request map[string]interface{} var response map[string]interface{} + var err error query := make(map[string]interface{}) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request = make(map[string]interface{}) query["DeliveryChannelId"] = d.Id() - 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("2020-09-07"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, query, request, false) if err != nil { if NeedRetry(err) { diff --git a/alicloud/resource_alicloud_config_delivery_channel.go b/alicloud/resource_alicloud_config_delivery_channel.go index 08d26cdf515c..67f72f241487 100644 --- a/alicloud/resource_alicloud_config_delivery_channel.go +++ b/alicloud/resource_alicloud_config_delivery_channel.go @@ -5,7 +5,6 @@ import ( "log" "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" @@ -68,12 +67,10 @@ func resourceAlicloudConfigDeliveryChannel() *schema.Resource { func resourceAlicloudConfigDeliveryChannelCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} + var err error action := "PutDeliveryChannel" request := make(map[string]interface{}) - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request["DeliveryChannelAssumeRoleArn"] = d.Get("delivery_channel_assume_role_arn") if v, ok := d.GetOk("delivery_channel_condition"); ok { request["DeliveryChannelCondition"] = v @@ -93,11 +90,9 @@ func resourceAlicloudConfigDeliveryChannelCreate(d *schema.ResourceData, meta in request["Status"] = v } - 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("2019-01-08"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2019-01-08", action, nil, request, false) if err != nil { if IsExpectedErrors(err, []string{"DeliveryChannelSlsUnreachableError"}) { wait() @@ -139,11 +134,11 @@ func resourceAlicloudConfigDeliveryChannelRead(d *schema.ResourceData, meta inte } func resourceAlicloudConfigDeliveryChannelUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) - conn, err := client.NewConfigClient() + configService := ConfigService{client} + object, err := configService.DescribeConfigDeliveryChannel(d.Id()) if err != nil { return WrapError(err) } - var response map[string]interface{} update := false request := map[string]interface{}{ "DeliveryChannelId": d.Id(), @@ -169,17 +164,16 @@ func resourceAlicloudConfigDeliveryChannelUpdate(d *schema.ResourceData, meta in update = true request["Description"] = d.Get("description") } - if d.HasChange("status") { + // status default to 1 after creating + if v, ok := d.GetOkExists("status"); ok && fmt.Sprint(object["Status"]) != fmt.Sprint(v) { update = true - request["Status"] = d.Get("status") + request["Status"] = v } if update { action := "PutDeliveryChannel" - 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("2019-01-08"), StringPointer("AK"), nil, request, &runtime) + err := resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { + response, err := client.RpcPost("Config", "2019-01-08", action, nil, request, true) if err != nil { if NeedRetry(err) || IsExpectedErrors(err, []string{"DeliveryChannelSlsUnreachableError"}) { wait() diff --git a/alicloud/resource_alicloud_config_delivery_channel_test.go b/alicloud/resource_alicloud_config_delivery_channel_test.go index 543da4cd44de..d6805c152709 100644 --- a/alicloud/resource_alicloud_config_delivery_channel_test.go +++ b/alicloud/resource_alicloud_config_delivery_channel_test.go @@ -21,7 +21,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccAlicloudConfigDeliveryChannel_basic(t *testing.T) { +// Skipped: The resource and its apis have deprecated +func SkipTestAccAliCloudConfigDeliveryChannel_basic(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_config_delivery_channel.default" ra := resourceAttrInit(resourceId, ConfigDeliveryChannelMap) @@ -140,7 +141,8 @@ func TestAccAlicloudConfigDeliveryChannel_basic(t *testing.T) { }) } -func TestAccAlicloudConfigDeliveryChannel_MNS(t *testing.T) { +// Skipped: The resource and its apis have deprecated +func SkipTestAccAliCloudConfigDeliveryChannel_MNS(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_config_delivery_channel.default" ra := resourceAttrInit(resourceId, ConfigDeliveryChannelMap) @@ -258,7 +260,8 @@ func TestAccAlicloudConfigDeliveryChannel_MNS(t *testing.T) { }) } -func TestAccAlicloudConfigDeliveryChannel_SLS(t *testing.T) { +// Skipped: The resource and its apis have deprecated +func SkipTestAccAliCloudConfigDeliveryChannel_SLS(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_config_delivery_channel.default" ra := resourceAttrInit(resourceId, ConfigDeliveryChannelMap) diff --git a/alicloud/resource_alicloud_config_remediation.go b/alicloud/resource_alicloud_config_remediation.go index 1497b0e579ee..cef05227b776 100644 --- a/alicloud/resource_alicloud_config_remediation.go +++ b/alicloud/resource_alicloud_config_remediation.go @@ -6,7 +6,6 @@ import ( "log" "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" @@ -74,10 +73,7 @@ func resourceAlicloudConfigRemediationCreate(d *schema.ResourceData, meta interf action := "CreateRemediation" var request map[string]interface{} var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + var err error request = make(map[string]interface{}) request["ClientToken"] = buildClientToken(action) @@ -102,7 +98,7 @@ func resourceAlicloudConfigRemediationCreate(d *schema.ResourceData, meta interf } 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("2020-09-07"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) request["ClientToken"] = buildClientToken(action) if err != nil { @@ -153,14 +149,10 @@ func resourceAlicloudConfigRemediationRead(d *schema.ResourceData, meta interfac func resourceAlicloudConfigRemediationUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var request map[string]interface{} - var response map[string]interface{} update := false update = false action := "UpdateRemediation" - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request = make(map[string]interface{}) request["RemediationId"] = d.Id() @@ -187,8 +179,8 @@ func resourceAlicloudConfigRemediationUpdate(d *schema.ResourceData, meta interf } if update { 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("2020-09-07"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + err := resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { + response, err := client.RpcPost("Config", "2020-09-07", action, nil, request, true) request["ClientToken"] = buildClientToken(action) if err != nil { @@ -218,18 +210,13 @@ func resourceAlicloudConfigRemediationDelete(d *schema.ResourceData, meta interf action := "DeleteRemediations" var request map[string]interface{} - var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) request["RemediationIds"] = d.Id() 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("2020-09-07"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + err := resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { + response, err := client.RpcPost("Config", "2020-09-07", action, nil, request, true) if err != nil { if NeedRetry(err) { diff --git a/alicloud/resource_alicloud_config_remediation_test.go b/alicloud/resource_alicloud_config_remediation_test.go index 3e02d3b4971f..9ab224a01b1c 100644 --- a/alicloud/resource_alicloud_config_remediation_test.go +++ b/alicloud/resource_alicloud_config_remediation_test.go @@ -11,7 +11,7 @@ import ( // Test Config Remediation. >>> Resource test cases, automatically generated. // Case 2979 -func TestAccAlicloudConfigRemediation_basic2979(t *testing.T) { +func TestAccAliCloudConfigRemediation_basic2979(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_config_remediation.default" ra := resourceAttrInit(resourceId, AlicloudConfigRemediationMap2979) diff --git a/alicloud/resource_alicloud_config_rule.go b/alicloud/resource_alicloud_config_rule.go index 247b7b836c0d..7e0554ee4081 100644 --- a/alicloud/resource_alicloud_config_rule.go +++ b/alicloud/resource_alicloud_config_rule.go @@ -7,7 +7,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" @@ -184,10 +183,7 @@ func resourceAlicloudConfigRuleCreate(d *schema.ResourceData, meta interface{}) action := "CreateConfigRule" var request map[string]interface{} var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + var err error request = make(map[string]interface{}) request["ClientToken"] = buildClientToken(action) @@ -243,7 +239,7 @@ func resourceAlicloudConfigRuleCreate(d *schema.ResourceData, meta interface{}) 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("2020-09-07"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) request["ClientToken"] = buildClientToken(action) if err != nil { @@ -351,14 +347,12 @@ func resourceAlicloudConfigRuleUpdate(d *schema.ResourceData, meta interface{}) client := meta.(*connectivity.AliyunClient) var request map[string]interface{} var response map[string]interface{} + var err error update := false d.Partial(true) update = false action := "UpdateConfigRule" - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request = make(map[string]interface{}) request["ConfigRuleId"] = d.Id() @@ -444,7 +438,7 @@ func resourceAlicloudConfigRuleUpdate(d *schema.ResourceData, meta interface{}) if update { 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("2020-09-07"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, true) request["ClientToken"] = buildClientToken(action) if err != nil { @@ -492,17 +486,13 @@ func resourceAlicloudConfigRuleUpdate(d *schema.ResourceData, meta interface{}) if object["ConfigRuleState"].(string) != target { if target == "INACTIVE" { action = "StopConfigRules" - conn, err = client.NewConfigClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) request["ConfigRuleIds"] = d.Id() 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("2019-01-08"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2019-01-08", action, nil, request, false) if err != nil { if NeedRetry(err) { @@ -521,17 +511,13 @@ func resourceAlicloudConfigRuleUpdate(d *schema.ResourceData, meta interface{}) } if target == "ACTIVE" { action = "ActiveConfigRules" - conn, err = client.NewConfigClient() - if err != nil { - return WrapError(err) - } request = make(map[string]interface{}) request["ConfigRuleIds"] = d.Id() 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("2019-01-08"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2019-01-08", action, nil, request, false) if err != nil { if NeedRetry(err) { @@ -562,17 +548,14 @@ func resourceAlicloudConfigRuleDelete(d *schema.ResourceData, meta interface{}) action := "DeleteConfigRules" var request map[string]interface{} var response map[string]interface{} - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + var err error request = make(map[string]interface{}) request["ConfigRuleIds"] = d.Id() 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("2019-01-08"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2019-01-08", action, nil, request, false) if err != nil { if NeedRetry(err) { diff --git a/alicloud/resource_alicloud_config_rule_test.go b/alicloud/resource_alicloud_config_rule_test.go index 6d89781f1412..3f0ab7f2e45f 100644 --- a/alicloud/resource_alicloud_config_rule_test.go +++ b/alicloud/resource_alicloud_config_rule_test.go @@ -47,19 +47,14 @@ func testSweepConfigRuleByPrefixes(region string, prefixes []string) error { request := make(map[string]interface{}) var response map[string]interface{} action := "ListConfigRules" - conn, err := client.NewConfigClient() - if err != nil { - return WrapError(err) - } + request["PageSize"] = PageSizeLarge request["PageNumber"] = 1 var ruleIds []string for { - runtime := util.RuntimeOptions{} - runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) err := resource.Retry(3*time.Minute, func() *resource.RetryError { - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("GET"), StringPointer("2019-01-08"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2019-01-08", action, request, nil) if err != nil { if IsExpectedErrors(err, []string{"Throttling.User"}) { wait() @@ -105,7 +100,7 @@ func testSweepConfigRuleByPrefixes(region string, prefixes []string) error { request := map[string]interface{}{ "ConfigRuleIds": ruleId, } - _, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-01-08"), StringPointer("AK"), nil, request, &util.RuntimeOptions{}) + _, err = client.RpcPost("Config", "2019-01-08", action, nil, request, false) if err != nil { log.Printf("[ERROR] Failed to retrieve config rule (%s): %s", ruleId, err) continue diff --git a/alicloud/service_alicloud_config.go b/alicloud/service_alicloud_config.go index fa9c7912a7d8..d0917c175057 100644 --- a/alicloud/service_alicloud_config.go +++ b/alicloud/service_alicloud_config.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "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" ) @@ -19,20 +18,15 @@ type ConfigService struct { func (s *ConfigService) DescribeConfigRule(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewConfigClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetConfigRule" request := map[string]interface{}{ "RegionId": s.client.RegionId, "ConfigRuleId": id, } - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -59,16 +53,13 @@ func (s *ConfigService) DescribeConfigRule(id string) (object map[string]interfa func (s *ConfigService) DescribeConfigDeliveryChannel(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewConfigClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeDeliveryChannels" request := map[string]interface{}{ "RegionId": s.client.RegionId, "DeliveryChannelIds": id, } - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("GET"), StringPointer("2019-01-08"), StringPointer("AK"), request, nil, &util.RuntimeOptions{}) + response, err = client.RpcGet("Config", "2019-01-08", action, request, nil) if err != nil { if IsExpectedErrors(err, []string{"AccountNotExisted", "DeliveryChannelNotExists"}) { err = WrapErrorf(Error(GetNotFoundMessage("ConfigDeliveryChannel", id)), NotFoundMsg, ProviderERROR) @@ -95,15 +86,12 @@ func (s *ConfigService) DescribeConfigDeliveryChannel(id string) (object map[str func (s *ConfigService) DescribeConfigConfigurationRecorder(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewConfigClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "DescribeConfigurationRecorder" request := map[string]interface{}{ "RegionId": s.client.RegionId, } - response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("GET"), StringPointer("2019-01-08"), StringPointer("AK"), request, nil, &util.RuntimeOptions{}) + response, err = client.RpcGet("Config", "2019-01-08", action, request, nil) if err != nil { if IsExpectedErrors(err, []string{"AccountNotExisted"}) { err = WrapErrorf(Error(GetNotFoundMessage("ConfigConfigurationRecorder", id)), NotFoundMsg, ProviderERROR) @@ -159,22 +147,16 @@ func (s *ConfigService) convertAggregatorAccountsToString(v []interface{}) (stri } func (s *ConfigService) DescribeConfigAggregator(id string) (object map[string]interface{}, err error) { - conn, err := s.client.NewConfigClient() - if err != nil { - return object, WrapError(err) - } - + client := s.client request := map[string]interface{}{ "AggregatorId": id, } var response map[string]interface{} action := "GetAggregator" - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -182,8 +164,7 @@ func (s *ConfigService) DescribeConfigAggregator(id string) (object map[string]i } return resource.NonRetryableError(err) } - response = resp - addDebug(action, resp, request) + addDebug(action, response, request) return nil }) if err != nil { @@ -219,10 +200,7 @@ func (s *ConfigService) ConfigAggregatorStateRefreshFunc(d *schema.ResourceData, func (s *ConfigService) DescribeConfigAggregateConfigRule(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewConfigClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetAggregateConfigRule" parts, err := ParseResourceId(id, 2) if err != nil { @@ -234,11 +212,9 @@ func (s *ConfigService) DescribeConfigAggregateConfigRule(id string) (object map "AggregatorId": parts[0], "ConfigRuleId": parts[1], } - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -267,10 +243,7 @@ func (s *ConfigService) DescribeConfigAggregateCompliancePack(id string) (object var response map[string]interface{} action := "GetAggregateCompliancePack" - conn, err := s.client.NewConfigClient() - if err != nil { - return object, WrapError(err) - } + client := s.client parts, err := ParseResourceId(id, 2) if err != nil { @@ -282,11 +255,9 @@ func (s *ConfigService) DescribeConfigAggregateCompliancePack(id string) (object "CompliancePackId": parts[1], } - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -338,20 +309,15 @@ func (s *ConfigService) ConfigAggregateCompliancePackStateRefreshFunc(id string, func (s *ConfigService) DescribeConfigCompliancePack(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewConfigClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetCompliancePack" request := map[string]interface{}{ "RegionId": s.client.RegionId, "CompliancePackId": id, } - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -438,19 +404,14 @@ func (s *ConfigService) ConfigRuleStateRefreshFunc(id string, failStates []strin func (s *ConfigService) StopConfigRule(id string) (err error) { var response map[string]interface{} - conn, err := s.client.NewConfigClient() - if err != nil { - return WrapError(err) - } + client := s.client action := "StopConfigRules" request := map[string]interface{}{ "ConfigRuleIds": id, } - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2019-01-08"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2019-01-08", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -468,19 +429,14 @@ func (s *ConfigService) StopConfigRule(id string) (err error) { } func (s *ConfigService) ActiveConfigRule(id string) (err error) { var response map[string]interface{} - conn, err := s.client.NewConfigClient() - if err != nil { - return WrapError(err) - } + client := s.client action := "ActiveConfigRules" request := map[string]interface{}{ "ConfigRuleIds": id, } - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2019-01-08"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2019-01-08", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -499,20 +455,15 @@ func (s *ConfigService) ActiveConfigRule(id string) (err error) { func (s *ConfigService) ActiveAggregateConfigRules(id, aggregatorId string) (err error) { var response map[string]interface{} - conn, err := s.client.NewConfigClient() - if err != nil { - return WrapError(err) - } + client := s.client action := "ActiveAggregateConfigRules" request := map[string]interface{}{ "ConfigRuleIds": id, "AggregatorId": aggregatorId, } - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -531,20 +482,15 @@ func (s *ConfigService) ActiveAggregateConfigRules(id, aggregatorId string) (err func (s *ConfigService) DeactiveAggregateConfigRules(id, aggregatorId string) (err error) { var response map[string]interface{} - conn, err := s.client.NewConfigClient() - if err != nil { - return WrapError(err) - } + client := s.client action := "DeactiveAggregateConfigRules" request := map[string]interface{}{ "ConfigRuleIds": id, "AggregatorId": aggregatorId, } - runtime := util.RuntimeOptions{} - 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), request, nil, &runtime) + response, err = client.RpcGet("Config", "2020-09-07", action, request, nil) if err != nil { if NeedRetry(err) { wait() @@ -563,19 +509,14 @@ func (s *ConfigService) DeactiveAggregateConfigRules(id, aggregatorId string) (e func (s *ConfigService) DescribeConfigDelivery(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewConfigClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetConfigDeliveryChannel" request := map[string]interface{}{ "DeliveryChannelId": id, } - runtime := util.RuntimeOptions{} - 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("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() @@ -603,10 +544,7 @@ func (s *ConfigService) DescribeConfigDelivery(id string) (object map[string]int func (s *ConfigService) DescribeConfigAggregateDelivery(id string) (object map[string]interface{}, err error) { var response map[string]interface{} - conn, err := s.client.NewConfigClient() - if err != nil { - return nil, WrapError(err) - } + client := s.client action := "GetAggregateConfigDeliveryChannel" parts, err := ParseResourceId(id, 2) if err != nil { @@ -617,11 +555,9 @@ func (s *ConfigService) DescribeConfigAggregateDelivery(id string) (object map[s "AggregatorId": parts[0], "DeliveryChannelId": parts[1], } - runtime := util.RuntimeOptions{} - 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("2020-09-07"), StringPointer("AK"), nil, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, nil, request, false) if err != nil { if NeedRetry(err) { wait() diff --git a/alicloud/service_alicloud_config_v2.go b/alicloud/service_alicloud_config_v2.go index 0c282ff4eac6..5fc01b888ee6 100644 --- a/alicloud/service_alicloud_config_v2.go +++ b/alicloud/service_alicloud_config_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" ) @@ -24,10 +23,6 @@ func (s *ConfigServiceV2) DescribeConfigRule(id string) (object map[string]inter var response map[string]interface{} var query map[string]interface{} action := "GetConfigRule" - conn, err := client.NewConfigClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) @@ -35,7 +30,7 @@ func (s *ConfigServiceV2) DescribeConfigRule(id string) (object map[string]inter 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("2020-09-07"), StringPointer("AK"), query, request, &util.RuntimeOptions{}) + response, err = client.RpcPost("Config", "2020-09-07", action, query, request, true) if err != nil { if NeedRetry(err) { @@ -93,10 +88,6 @@ func (s *ConfigServiceV2) DescribeConfigRemediation(id string) (object map[strin var response map[string]interface{} var query map[string]interface{} action := "DescribeRemediation" - conn, err := client.NewConfigClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) @@ -104,7 +95,7 @@ func (s *ConfigServiceV2) DescribeConfigRemediation(id string) (object map[strin 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("GET"), StringPointer("2020-09-07"), StringPointer("AK"), query, request, &util.RuntimeOptions{}) + response, err = client.RpcGet("Config", "2020-09-07", action, query, request) if err != nil { if NeedRetry(err) { @@ -161,19 +152,13 @@ func (s *ConfigServiceV2) DescribeConfigDelivery(id string) (object map[string]i var response map[string]interface{} var query map[string]interface{} action := "GetConfigDeliveryChannel" - conn, err := client.NewConfigClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["DeliveryChannelId"] = id - 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("2020-09-07"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, query, request, true) if err != nil { if NeedRetry(err) { @@ -237,20 +222,14 @@ func (s *ConfigServiceV2) DescribeConfigAggregateDelivery(id string) (object map err = WrapError(fmt.Errorf("invalid Resource Id %s. Expected parts' length %d, got %d", id, 2, len(parts))) } action := "GetAggregateConfigDeliveryChannel" - conn, err := client.NewConfigClient() - if err != nil { - return object, WrapError(err) - } request = make(map[string]interface{}) query = make(map[string]interface{}) query["AggregatorId"] = parts[0] query["DeliveryChannelId"] = parts[1] - 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("2020-09-07"), StringPointer("AK"), query, request, &runtime) + response, err = client.RpcPost("Config", "2020-09-07", action, query, request, true) if err != nil { if NeedRetry(err) { diff --git a/alicloud/service_alicloud_sls_v2.go b/alicloud/service_alicloud_sls_v2.go index 75b6d8279d71..8f69a5aa12ae 100644 --- a/alicloud/service_alicloud_sls_v2.go +++ b/alicloud/service_alicloud_sls_v2.go @@ -312,7 +312,7 @@ func (s *SlsServiceV2) DescribeGetLogStoreMeteringMode(id string) (object map[st runtime := util.RuntimeOptions{} runtime.SetAutoretry(true) wait := incrementalWait(3*time.Second, 5*time.Second) - err = resource.Retry(1*time.Minute, func() *resource.RetryError { + err = resource.Retry(3*time.Minute, func() *resource.RetryError { response, err = conn.Execute(client.GenRoaParam("GetLogStoreMeteringMode", "GET", "2020-12-30", action), &openapi.OpenApiRequest{Query: query, Body: nil, HostMap: hostMap}, &util.RuntimeOptions{}) if err != nil { diff --git a/website/docs/d/config_aggregate_compliance_packs.html.markdown b/website/docs/d/config_aggregate_compliance_packs.html.markdown index 73e91c278685..be6717701c65 100644 --- a/website/docs/d/config_aggregate_compliance_packs.html.markdown +++ b/website/docs/d/config_aggregate_compliance_packs.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Config Aggregate Compliance Packs to the user. --- -# alicloud\_config\_aggregate\_compliance\_packs +# alicloud_config_aggregate_compliance_packs This data source provides the Config Aggregate Compliance Packs of the current Alibaba Cloud user. --> **NOTE:** Available in v1.124.0+. +-> **NOTE:** Available since v1.124.0. ## Example Usage @@ -34,7 +34,7 @@ output "first_config_aggregate_compliance_pack_id" { The following arguments are supported: * `aggregator_id` - (Required, ForceNew) The ID of aggregator. -* `name_regex` - (Optional) A regex string to filter results by Aggregate Compliance Pack name. +* `name_regex` - (Optional, ForceNew) A regex string to filter results by Aggregate Compliance Pack name. * `enable_details` - (Optional) Default to `false`. Set it to `true` can output more details about resource attributes. * `ids` - (Optional, ForceNew, Computed) A list of Aggregate Compliance Pack IDs. * `output_file` - (Optional) File name where to save data source results (after running `terraform plan`). @@ -47,18 +47,18 @@ The following attributes are exported in addition to the arguments listed above: * `names` - A list of Config Aggregate Compliance Pack names. * `packs` - A list of Config Aggregate Compliance Packs. Each element contains the following attributes: - * `account_id` - The Aliyun User Id. - * `aggregator_compliance_pack_id` - The Aggregate Compliance Package Id. - * `aggregate_compliance_pack_name` -The Aggregate Compliance Package Name. - * `compliance_pack_template_id` - The template ID of the Compliance Package. - * `config_rules` - A list of The Aggregate Compliance Package Rules. - * `config_rule_id` - The ID of the rule. - * `config_rule_parameters` - A list of parameter rules. - * `parameter_name` - The Parameter Name. - * `parameter_value` - The Parameter Value. - * `required` - Required. - * `managed_rule_identifier` - Managed Rule Identifier. - * `description` - The description of aggregate compliance pack. - * `id` - The ID of the Aggregate Compliance Pack. - * `risk_level` - The Risk Level. - * `status` - The status of the resource. + * `account_id` - The Aliyun User Id. + * `aggregator_compliance_pack_id` - The Aggregate Compliance Package Id. + * `aggregate_compliance_pack_name` -The Aggregate Compliance Package Name. + * `compliance_pack_template_id` - The template ID of the Compliance Package. + * `config_rules` - A list of The Aggregate Compliance Package Rules. + * `config_rule_id` - The ID of the rule. + * `config_rule_parameters` - A list of parameter rules. + * `parameter_name` - The Parameter Name. + * `parameter_value` - The Parameter Value. + * `required` - Required. + * `managed_rule_identifier` - Managed Rule Identifier. + * `description` - The description of aggregate compliance pack. + * `id` - The ID of the Aggregate Compliance Pack. + * `risk_level` - The Risk Level. + * `status` - The status of the resource. diff --git a/website/docs/d/config_aggregate_config_rules.html.markdown b/website/docs/d/config_aggregate_config_rules.html.markdown index 27be8b5575a1..7ac4fa383aed 100644 --- a/website/docs/d/config_aggregate_config_rules.html.markdown +++ b/website/docs/d/config_aggregate_config_rules.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Config Aggregate Config Rules to the user. --- -# alicloud\_config\_aggregate\_config\_rules +# alicloud_config_aggregate_config_rules This data source provides the Config Aggregate Config Rules of the current Alibaba Cloud user. --> **NOTE:** Available in v1.124.0+. +-> **NOTE:** Available since v1.124.0. ## Example Usage @@ -38,7 +38,7 @@ The following arguments are supported: * `status` - (Optional, ForceNew) The state of the config rule, valid values: `ACTIVE`, `DELETING`, `EVALUATING` and `INACTIVE`. * `enable_details` - (Optional) Default to `false`. Set it to `true` can output more details about resource attributes. * `ids` - (Optional, ForceNew, Computed) A list of Aggregate Config Rule IDs. -* `risk_level` - Optional, ForceNew) The Risk Level. Valid values `1`: critical, `2`: warning, `3`: info. +* `risk_level` - (Optional, ForceNew) The Risk Level. Valid values `1`: critical, `2`: warning, `3`: info. * `name_regex` - (Optional, ForceNew) A regex string to filter results by Aggregate Config Rule name. * `output_file` - (Optional) File name where to save data source results (after running `terraform plan`). @@ -48,28 +48,29 @@ The following attributes are exported in addition to the arguments listed above: * `names` - A list of Aggregate Config Rule names. * `rules` - A list of Config Aggregate Config Rules. Each element contains the following attributes: - * `account_id` - The Aliyun User ID. - * `aggregate_config_rule_name` - The name of the rule. - * `aggregator_id` - The ID of Aggregator. - * `compliance` -The Compliance information. - * `count` - The Count. - * `compliance_type` - The Compliance Type. - * `compliance_pack_id` - The ID of Compliance Package. - * `config_rule_arn` - The config rule arn. - * `config_rule_id` - The ID of the rule. - * `status` - The status of the rule. - * `event_source` - Event source of the Config Rule. - * `description` - The description of the rule. - * `id` - The ID of the Aggregate Config Rule. - * `config_rule_trigger_types` - The trigger types of config rules. - * `exclude_resource_ids_scope` - The id of the resources to be evaluated against the rule. - * `source_identifier`- The identifier of the managed rule or the arn of the custom function. - * `source_owner`- The source owner of the Config Rule. - * `maximum_execution_frequency` - The frequency of the compliance evaluations. - * `region_ids_scope` - The scope of resource region ids. - * `resource_group_ids_scope` - The scope of resource group ids. - * `tag_key_scope` - The scope of tay key. - * `tag_value_scope` - The scope of tay value. - * `input_parameters` - The settings of the input parameters for the rule. - * `modified_timestamp` - The timestamp when the rule was last modified. - * `risk_level` - The risk level of the resources that are not compliant with the rule. Valid values: `1`: critical, `2`: warning, `3`: info. + * `account_id` - The Aliyun User ID. + * `aggregate_config_rule_name` - The name of the rule. + * `aggregator_id` - The ID of Aggregator. + * `resource_types_scope` - The types of resources evaluated by the rule. + * `compliance` -The Compliance information. + * `count` - The Count. + * `compliance_type` - The Compliance Type. + * `compliance_pack_id` - The ID of Compliance Package. + * `config_rule_arn` - The config rule arn. + * `config_rule_id` - The ID of the rule. + * `status` - The status of the rule. + * `event_source` - Event source of the Config Rule. + * `description` - The description of the rule. + * `id` - The ID of the Aggregate Config Rule. + * `config_rule_trigger_types` - The trigger types of config rules. + * `exclude_resource_ids_scope` - The id of the resources to be evaluated against the rule. + * `source_identifier`- The identifier of the managed rule or the arn of the custom function. + * `source_owner`- The source owner of the Config Rule. + * `maximum_execution_frequency` - The frequency of the compliance evaluations. + * `region_ids_scope` - The scope of resource region ids. + * `resource_group_ids_scope` - The scope of resource group ids. + * `tag_key_scope` - The scope of tay key. + * `tag_value_scope` - The scope of tay value. + * `input_parameters` - The settings of the input parameters for the rule. + * `modified_timestamp` - The timestamp when the rule was last modified. + * `risk_level` - The risk level of the resources that are not compliant with the rule. Valid values: `1`: critical, `2`: warning, `3`: info. diff --git a/website/docs/d/config_aggregate_deliveries.html.markdown b/website/docs/d/config_aggregate_deliveries.html.markdown index d27459835628..0568e2ab6a8d 100644 --- a/website/docs/d/config_aggregate_deliveries.html.markdown +++ b/website/docs/d/config_aggregate_deliveries.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Config Aggregate Deliveries to the user. --- -# alicloud\_config\_aggregate\_deliveries +# alicloud_config_aggregate_deliveries This data source provides the Config Aggregate Deliveries of the current Alibaba Cloud user. --> **NOTE:** Available in v1.172.0+. +-> **NOTE:** Available since v1.172.0. ## Example Usage @@ -32,28 +32,29 @@ output "config_aggregate_delivery_id_1" { The following arguments are supported: * `aggregator_id` - (Required, ForceNew) The ID of the Aggregator. -* `delivery_channel_ids` - (Optional, ForceNew) The delivery channel ids. * `ids` - (Optional, ForceNew, Computed) A list of Aggregate Delivery IDs. +* `name_regex` - (Optional, ForceNew) A regex string to filter results by Aggregate Delivery name. * `output_file` - (Optional) File name where to save data source results (after running `terraform plan`). * `status` - (Optional, ForceNew) The status of the delivery method. Valid values: `0`: The delivery method is disabled. `1`: The delivery destination is enabled. -## Argument Reference +## Attributes Reference The following attributes are exported in addition to the arguments listed above: +* `names` - A list of Aggregate Delivery names. * `deliveries` - A list of Config Aggregate Deliveries. Each element contains the following attributes: - * `account_id` - The Aliyun User Id. - * `aggregator_id` - The ID of the Aggregator. - * `configuration_item_change_notification` - Open or close delivery configuration change history. - * `configuration_snapshot` - Open or close timed snapshot of shipping resources. - * `delivery_channel_assume_role_arn` - The Alibaba Cloud Resource Name (ARN) of the role to be assumed by the delivery method. - * `delivery_channel_condition` - The rule attached to the delivery method. - * `delivery_channel_id` - The ID of the delivery method. - * `delivery_channel_name` - The name of the delivery method. - * `delivery_channel_target_arn` - The ARN of the delivery destination. - * `delivery_channel_type` - The type of the delivery method. - * `description` - The description of the delivery method. - * `id` - The ID of the Aggregate Delivery. - * `non_compliant_notification` - Open or close non-compliance events of delivery resources. - * `oversized_data_oss_target_arn` - The oss ARN of the delivery channel when the value data oversized limit. - * `status` - The status of the delivery method. Valid values: `0`: The delivery method is disabled. `1`: The delivery destination is enabled. \ No newline at end of file + * `account_id` - The Aliyun User Id. + * `aggregator_id` - The ID of the Aggregator. + * `configuration_item_change_notification` - Open or close delivery configuration change history. + * `configuration_snapshot` - Open or close timed snapshot of shipping resources. + * `delivery_channel_assume_role_arn` - The Alibaba Cloud Resource Name (ARN) of the role to be assumed by the delivery method. + * `delivery_channel_condition` - The rule attached to the delivery method. + * `delivery_channel_id` - The ID of the delivery method. + * `delivery_channel_name` - The name of the delivery method. + * `delivery_channel_target_arn` - The ARN of the delivery destination. + * `delivery_channel_type` - The type of the delivery method. + * `description` - The description of the delivery method. + * `id` - The ID of the Aggregate Delivery. + * `non_compliant_notification` - Open or close non-compliance events of delivery resources. + * `oversized_data_oss_target_arn` - The oss ARN of the delivery channel when the value data oversized limit. + * `status` - The status of the delivery method. Valid values: `0`: The delivery method is disabled. `1`: The delivery destination is enabled. \ No newline at end of file diff --git a/website/docs/d/config_aggregators.html.markdown b/website/docs/d/config_aggregators.html.markdown index 48a6fda084b7..4901d979c163 100644 --- a/website/docs/d/config_aggregators.html.markdown +++ b/website/docs/d/config_aggregators.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Config Aggregators to the user. --- -# alicloud\_config\_aggregators +# alicloud_config_aggregators This data source provides the Config Aggregators of the current Alibaba Cloud user. --> **NOTE:** Available in v1.124.0+. +-> **NOTE:** Available since v1.124.0. ## Example Usage @@ -44,14 +44,14 @@ The following attributes are exported in addition to the arguments listed above: * `names` - A list of Aggregator names. * `aggregators` - A list of config aggregators. Each element contains the following attributes: - * `account_id` - The Aliyun Uid. - * `aggregator_accounts` - Account information in aggregator. - * `account_id` - Aggregator account uid. - * `account_name` - Aggregator account name. - * `account_type` - Aggregator account source type. - * `aggregator_id` - The id of aggregator. - * `aggregator_name` - The name of aggregator. - * `aggregator_type` - The type of aggregator. - * `description` - The description of aggregator. - * `id` - The id of the aggregator. - * `status` - The status of the resource. + * `account_id` - The Aliyun Uid. + * `aggregator_accounts` - Account information in aggregator. + * `account_id` - Aggregator account uid. + * `account_name` - Aggregator account name. + * `account_type` - Aggregator account source type. + * `aggregator_id` - The id of aggregator. + * `aggregator_name` - The name of aggregator. + * `aggregator_type` - The type of aggregator. + * `description` - The description of aggregator. + * `id` - The id of the aggregator. + * `status` - The status of the resource. diff --git a/website/docs/d/config_compliance_packs.html.markdown b/website/docs/d/config_compliance_packs.html.markdown index c349a569f11b..6769e76fb9a3 100644 --- a/website/docs/d/config_compliance_packs.html.markdown +++ b/website/docs/d/config_compliance_packs.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Config Compliance Packs to the user. --- -# alicloud\_config\_compliance\_packs +# alicloud_config_compliance_packs This data source provides the Config Compliance Packs of the current Alibaba Cloud user. --> **NOTE:** Available in v1.124.0+. +-> **NOTE:** Available since v1.124.0. ## Example Usage @@ -44,18 +44,18 @@ The following attributes are exported in addition to the arguments listed above: * `names` - A list of Compliance Pack names. * `packs` - A list of Config Compliance Packs. Each element contains the following attributes: - * `account_id` - The Aliyun User Id. - * `compliance_pack_id` - The Compliance Package ID. - * `compliance_pack_name` - The Compliance Package Name. - * `compliance_pack_template_id` - The template ID of the Compliance Package. - * `config_rules` - A list of The Compliance Package Rules. - * `config_rule_id` - The ID of the rule. - * `config_rule_parameters` - A list of parameter rules. - * `parameter_name` - The Parameter Name. - * `parameter_value` - The Parameter Value. - * `required` - Required. - * `managed_rule_identifier` - Managed Rule Identifier. - * `description` - The description of compliance pack. - * `id` - The ID of the Compliance Pack. - * `risk_level` - The Ris Level. - * `status` - The status of the resource. + * `account_id` - The Aliyun User Id. + * `compliance_pack_id` - The Compliance Package ID. + * `compliance_pack_name` - The Compliance Package Name. + * `compliance_pack_template_id` - The template ID of the Compliance Package. + * `config_rules` - A list of The Compliance Package Rules. + * `config_rule_id` - The ID of the rule. + * `config_rule_parameters` - A list of parameter rules. + * `parameter_name` - The Parameter Name. + * `parameter_value` - The Parameter Value. + * `required` - Required. + * `managed_rule_identifier` - Managed Rule Identifier. + * `description` - The description of compliance pack. + * `id` - The ID of the Compliance Pack. + * `risk_level` - The Ris Level. + * `status` - The status of the resource. diff --git a/website/docs/d/config_configuration_recorders.html.markdown b/website/docs/d/config_configuration_recorders.html.markdown index 79f8a6ec5a32..a87e57531256 100644 --- a/website/docs/d/config_configuration_recorders.html.markdown +++ b/website/docs/d/config_configuration_recorders.html.markdown @@ -4,16 +4,14 @@ layout: "alicloud" page_title: "Alicloud: alicloud_config_configuration_recorders" sidebar_current: "docs-alicloud-datasource-config-configuration-recorders" description: |- - Provides a list of Config Configuration Recorders to the user. + Provides a list of Config Configuration Recorders to the user. --- -# alicloud\_config\_configuration\_recorders +# alicloud_config_configuration_recorders This data source provides the Config Configuration Recorders of the current Alibaba Cloud user. --> **NOTE:** Available in 1.99.0+. - --> **NOTE:** The Cloud Config region only support `cn-shanghai` and `ap-southeast-1`. +-> **NOTE:** Available since v1.99.0. ## Example Usage @@ -36,9 +34,9 @@ The following arguments are supported: The following attributes are exported in addition to the arguments listed above: * `recorders` - A list of Config Configuration Recorders. Each element contains the following attributes: - * `id` - The ID of the Config Configuration Recorder. Value as the `account_id`. - * `account_id`- The ID of the Alicloud account. - * `organization_enable_status` - Enterprise version configuration audit enabled status. - * `organization_master_id` - The ID of the Enterprise management account. - * `resource_types` - A list of resource types to be monitored. - * `status` - Status of resource monitoring. + * `id` - The ID of the Config Configuration Recorder. Value as the `account_id`. + * `account_id`- The ID of the Alicloud account. + * `organization_enable_status` - Enterprise version configuration audit enabled status. + * `organization_master_id` - The ID of the Enterprise management account. + * `resource_types` - A list of resource types to be monitored. + * `status` - Status of resource monitoring. diff --git a/website/docs/d/config_deliveries.html.markdown b/website/docs/d/config_deliveries.html.markdown index 65cbb9ec999a..f8794ba3b3bf 100644 --- a/website/docs/d/config_deliveries.html.markdown +++ b/website/docs/d/config_deliveries.html.markdown @@ -7,11 +7,11 @@ description: |- Provides a list of Config Deliveries to the user. --- -# alicloud\_config\_deliveries +# alicloud_config_deliveries This data source provides the Config Deliveries of the current Alibaba Cloud user. --> **NOTE:** Available in v1.171.0+. +-> **NOTE:** Available since v1.171.0. ## Example Usage @@ -35,22 +35,23 @@ The following arguments are supported: * `output_file` - (Optional) File name where to save data source results (after running `terraform plan`). * `status` - (Optional, ForceNew) The status of the delivery method. Valid values: `0`: The delivery method is disabled. `1`: The delivery destination is enabled. -## Argument Reference +## Attributes Reference The following attributes are exported in addition to the arguments listed above: +* `names` - A list of Config Delivery names. * `deliveries` - A list of Config Deliveries. Each element contains the following attributes: - * `account_id` - The Aliyun User Id. - * `configuration_item_change_notification` - Open or close delivery configuration change history. - * `configuration_snapshot` - Open or close timed snapshot of shipping resources. - * `delivery_channel_assume_role_arn` - The Alibaba Cloud Resource Name (ARN) of the role to be assumed by the delivery method. - * `delivery_channel_condition` - The rule attached to the delivery method. - * `delivery_channel_id` - The ID of the delivery method. - * `delivery_channel_name` - The name of the delivery method. - * `delivery_channel_target_arn` - The ARN of the delivery destination. - * `delivery_channel_type` - The type of the delivery method. - * `description` - The description of the delivery method. - * `id` - The ID of the Delivery. - * `non_compliant_notification` - Open or close non-compliance events of delivery resources. - * `oversized_data_oss_target_arn` - The oss ARN of the delivery channel when the value data oversized limit. - * `status` - The status of the delivery method. Valid values: `0`: The delivery method is disabled. `1`: The delivery destination is enabled. \ No newline at end of file + * `account_id` - The Aliyun User Id. + * `configuration_item_change_notification` - Open or close delivery configuration change history. + * `configuration_snapshot` - Open or close timed snapshot of shipping resources. + * `delivery_channel_assume_role_arn` - The Alibaba Cloud Resource Name (ARN) of the role to be assumed by the delivery method. + * `delivery_channel_condition` - The rule attached to the delivery method. + * `delivery_channel_id` - The ID of the delivery method. + * `delivery_channel_name` - The name of the delivery method. + * `delivery_channel_target_arn` - The ARN of the delivery destination. + * `delivery_channel_type` - The type of the delivery method. + * `description` - The description of the delivery method. + * `id` - The ID of the Delivery. + * `non_compliant_notification` - Open or close non-compliance events of delivery resources. + * `oversized_data_oss_target_arn` - The oss ARN of the delivery channel when the value data oversized limit. + * `status` - The status of the delivery method. Valid values: `0`: The delivery method is disabled. `1`: The delivery destination is enabled. \ No newline at end of file diff --git a/website/docs/d/config_delivery_channels.html.markdown b/website/docs/d/config_delivery_channels.html.markdown index 7edf71575e83..d2cb6d0894a1 100644 --- a/website/docs/d/config_delivery_channels.html.markdown +++ b/website/docs/d/config_delivery_channels.html.markdown @@ -7,7 +7,7 @@ description: |- Provides a list of Config Delivery Channels to the user. --- -# alicloud\_config\_delivery\_channels +# alicloud_config_delivery_channels -> **DEPRECATED:** This resource is based on Config's old version OpenAPI, and it has been deprecated from version `1.173.0`. Please use new datasource [alicloud_config_deliveries](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/data-sources/config_deliveries) instead. @@ -16,8 +16,6 @@ This data source provides the Config Delivery Channels of the current Alibaba Cl -> **NOTE:** Available in 1.99.0+. --> **NOTE:** The Cloud Config region only support `cn-shanghai` and `ap-southeast-1`. - ## Example Usage ```terraform @@ -47,12 +45,12 @@ The following attributes are exported in addition to the arguments listed above: * `ids` - A list of Config Delivery Channel IDs. * `names` - A list of Config Delivery Channel names. * `channels` - A list of Config Delivery Channels. Each element contains the following attributes: - * `id` - The ID of the Config Delivery Channel. - * `delivery_channel_assume_role_arn` - The Alibaba Cloud Resource Name (ARN) of the role assumed by delivery method. - * `delivery_channel_condition` - The rule attached to the delivery method. This parameter is applicable only to delivery methods of the Message Service (MNS) type. - * `delivery_channel_id` - The ID of the delivery channel. - * `delivery_channel_name` - The name of the delivery channel. - * `delivery_channel_target_arn` - The ARN of the delivery destination. - * `delivery_channel_type` - The type of the delivery channel. - * `description` - The description of the delivery channel. - * `status` - The status of the delivery channel. + * `id` - The ID of the Config Delivery Channel. + * `delivery_channel_assume_role_arn` - The Alibaba Cloud Resource Name (ARN) of the role assumed by delivery method. + * `delivery_channel_condition` - The rule attached to the delivery method. This parameter is applicable only to delivery methods of the Message Service (MNS) type. + * `delivery_channel_id` - The ID of the delivery channel. + * `delivery_channel_name` - The name of the delivery channel. + * `delivery_channel_target_arn` - The ARN of the delivery destination. + * `delivery_channel_type` - The type of the delivery channel. + * `description` - The description of the delivery channel. + * `status` - The status of the delivery channel. diff --git a/website/docs/d/config_rules.html.markdown b/website/docs/d/config_rules.html.markdown index 0c065a8c7099..13e1979e869f 100644 --- a/website/docs/d/config_rules.html.markdown +++ b/website/docs/d/config_rules.html.markdown @@ -4,16 +4,14 @@ layout: "alicloud" page_title: "Alicloud: alicloud_config_rules" sidebar_current: "docs-alicloud-datasource-config-rules" description: |- - Provides a list of Config Rules to the user. + Provides a list of Config Rules to the user. --- -# alicloud\_config\_rules +# alicloud_config_rules This data source provides the Config Rules of the current Alibaba Cloud user. --> **NOTE:** Available in 1.99.0+. - --> **NOTE:** The Cloud Config region only support `cn-shanghai` and `ap-southeast-1`. +-> **NOTE:** Available since v1.99.0. ## Example Usage @@ -33,14 +31,14 @@ output "first_config_rule_id" { The following arguments are supported: * `ids` - (Optional, ForceNew) A list of Config Rule IDs. -* `status` - (Optional, ForceNew, Available in 1.124.1+) The status of the config rule, valid values: `ACTIVE`, `DELETING`, `EVALUATING` and `INACTIVE`. -* `rule_name` - (Optional, ForceNew, Available in 1.124.1+) The name of config rule. -* `multi_account` - (Optional, ForceNew,Removed) Field `multi_account` has been removed from provider version 1.146.0. Please Use the Resource `alicloud_config_aggregate_config_rule`. -* `member_id` - (Optional, ForceNew,Removed) Field `multi_account` has been removed from provider version 1.146.0. Please Use the Resource `alicloud_config_aggregate_config_rule`. +* `status` - (Optional, ForceNew, Available since v1.124.1) The status of the config rule, valid values: `ACTIVE`, `DELETING`, `EVALUATING` and `INACTIVE`. +* `rule_name` - (Optional, ForceNew, Available since v1.124.1) The name of config rule. +* `multi_account` - (Optional, ForceNew, Removed) Field `multi_account` has been removed from provider version 1.146.0. Please Use the Resource `alicloud_config_aggregate_config_rule`. +* `member_id` - (Optional, ForceNew, Removed) Field `multi_account` has been removed from provider version 1.146.0. Please Use the Resource `alicloud_config_aggregate_config_rule`. * `risk_level` - (Optional, ForceNew) The risk level of Config Rule. Valid values: `1`: Critical ,`2`: Warning , `3`: Info. * `enable_details` - (Optional) Default to `false`. Set it to `true` can output more details about resource attributes. * `name_regex` - (Optional, ForceNew) A regex string to filter results by rule name. -* `message_type` - (Optional, ForceNew, Available in v1.104.0+, Remove) Field `message_type` has been removed from provider version 1.124.1. +* `message_type` - (Optional, ForceNew, Available since v1.104.0, Remove) Field `message_type` has been removed from provider version 1.124.1. * `output_file` - (Optional) File name where to save data source results (after running `terraform plan`). * `config_rule_state` - (Optional, ForceNew, Deprecated) Field `config_rule_state` has been deprecated from provider version 1.124.1. New field `status` instead. @@ -51,32 +49,32 @@ The following attributes are exported in addition to the arguments listed above: * `ids` - A list of Config Rule IDs. * `names` - A list of Config Rule names. * `rules` - A list of Config Rules. Each element contains the following attributes: - * `id` - The ID of the Config Rule. - * `account_id`- The ID of the Alicloud account. - * `config_rule_arn`- The ARN of the Config Rule. - * `config_rule_id`- The ID of the Config Rule. - * `config_rule_state`- The state of the Config Rule. - * `description`- The description of the Config Rule. - * `input_parameters`- The input parameters of the Config Rule. - * `modified_timestamp`- the timestamp of the Config Rule modified. - * `risk_level`- The risk level of the Config Rule. - * `rule_name`- The name of the Config Rule. - * `event_source` - Event source of the Config Rule. - * `scope_compliance_resource_id` - (Removed) Field `scope_compliance_resource_id` has been removed from provider version 1.124.1. Please use 'exclude_resource_ids_scope' instead. - * `scope_compliance_resource_types` - The types of the resources to be evaluated against the rule. - * `source_detail_message_type` - Rule trigger mechanism. - * `source_maximum_execution_frequency` - Rule execution cycle. - * `source_identifier`- The identifier of the managed rule or the arn of the custom function. - * `source_owner`- The source owner of the Config Rule. - * `compliance` - The information about the compliance evaluations based on the rule. - * `compliance_type` - The compliance evaluation result of the target resources. - * `count` - The number of resources with the specified compliance evaluation result. - * `config_rule_trigger_types` - (Available in 1.124.1+) A list of trigger types of config rule. - * `exclude_resource_ids_scope` - (Available in 1.124.1+) The scope of exclude of resource ids. - * `maximum_execution_frequency` - (Available in 1.124.1+) The frequency of maximum execution. - * `region_ids_scope` - (Available in 1.124.1+) The scope of region ids. - * `resource_group_ids_scope` - (Available in 1.124.1+) The scope of resource group ids. - * `resource_types_scope` - (Available in 1.124.1+) The scope of resource types. - * `status` - (Available in 1.124.1+) The status of config rule. - * `tag_key_scope` - (Available in 1.124.1+) The scope of tag key. - * `tag_value_scope` - (Available in 1.124.1+) The scope of tag value. + * `id` - The ID of the Config Rule. + * `account_id`- The ID of the Alibaba Cloud account. + * `config_rule_arn`- The ARN of the Config Rule. + * `config_rule_id`- The ID of the Config Rule. + * `compliance_pack_id` - The compliance package ID. + * `config_rule_state`- The state of the Config Rule. + * `description`- The description of the Config Rule. + * `input_parameters`- The input parameters of the Config Rule. + * `modified_timestamp`- the timestamp of the Config Rule modified. + * `risk_level`- The risk level of the Config Rule. + * `rule_name`- The name of the Config Rule. + * `event_source` - Event source of the Config Rule. + * `scope_compliance_resource_types` - The types of the resources to be evaluated against the rule. + * `source_detail_message_type` - Rule trigger mechanism. + * `source_maximum_execution_frequency` - Rule execution cycle. + * `source_identifier`- The identifier of the managed rule or the arn of the custom function. + * `source_owner`- The source owner of the Config Rule. + * `compliance` - The information about the compliance evaluations based on the rule. + * `compliance_type` - The compliance evaluation result of the target resources. + * `count` - The number of resources with the specified compliance evaluation result. + * `config_rule_trigger_types` - (Available since v1.124.1) A list of trigger types of config rule. + * `exclude_resource_ids_scope` - (Available since v1.124.1) The scope of exclude of resource ids. + * `maximum_execution_frequency` - (Available since v1.124.1) The frequency of maximum execution. + * `region_ids_scope` - (Available since v1.124.1) The scope of region ids. + * `resource_group_ids_scope` - (Available since v1.124.1) The scope of resource group ids. + * `resource_types_scope` - (Available since v1.124.1) The scope of resource types. + * `status` - (Available since v1.124.1) The status of config rule. + * `tag_key_scope` - (Available since v1.124.1) The scope of tag key. + * `tag_value_scope` - (Available since v1.124.1) The scope of tag value.