diff --git a/README.md b/README.md index d552532..a555645 100644 --- a/README.md +++ b/README.md @@ -72,11 +72,17 @@ scenario. The reason behind every resources and data sources are stated as below ### Data Sources -- **st-alicloud_antiddos_coo_domain** +- **st-alicloud_ddoscoo_domain_resources** Official AliCloud Terraform provider does not support querying the CNAME of AntiDDoS domain resources through - [*alicloud_antiddos_coo_domain_resources*](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/data-sources/ddoscoo_domain_resources). + [*alicloud_ddoscoo_domain_resources*](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/data-sources/ddoscoo_domain_resources). + +- **st-alicloud_ddoscoo_instances** + + Official AliCloud Terraform provider does not support querying the EIP of + AntiDDoS instance resources through + [*alicloud_ddoscoo_instances*](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/data-sources/ddoscoo_instances). - **st-alicloud_cdn_domain** diff --git a/alicloud/data_source_antiddos_coo_domain.go b/alicloud/data_source_ddoscoo_domain_resources.go similarity index 73% rename from alicloud/data_source_antiddos_coo_domain.go rename to alicloud/data_source_ddoscoo_domain_resources.go index 97c5036..7b725fd 100644 --- a/alicloud/data_source_antiddos_coo_domain.go +++ b/alicloud/data_source_ddoscoo_domain_resources.go @@ -14,28 +14,28 @@ import ( ) var ( - _ datasource.DataSource = &antiddosCooDataSource{} - _ datasource.DataSourceWithConfigure = &antiddosCooDataSource{} + _ datasource.DataSource = &ddoscooDomainResourcesDataSource{} + _ datasource.DataSourceWithConfigure = &ddoscooDomainResourcesDataSource{} ) -func NewAntiddosCooDataSource() datasource.DataSource { - return &antiddosCooDataSource{} +func NewDdosCooDomainResourcesDataSource() datasource.DataSource { + return &ddoscooDomainResourcesDataSource{} } -type antiddosCooDataSource struct { +type ddoscooDomainResourcesDataSource struct { client *alicloudAntiddosClient.Client } -type antiddosCooDataSourceModel struct { +type ddoscooDomainResourcesDataSourceModel struct { DomainName types.String `tfsdk:"domain_name"` DomainCName types.String `tfsdk:"domain_cname"` } -func (d *antiddosCooDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_antiddos_coo_domain" +func (d *ddoscooDomainResourcesDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_ddoscoo_domain_resources" } -func (d *antiddosCooDataSource) Schema(_ context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (d *ddoscooDomainResourcesDataSource) Schema(_ context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ Description: "This data source provides the AntiDDoS domain resources of the current AliCloud user.", Attributes: map[string]schema.Attribute{ @@ -51,7 +51,7 @@ func (d *antiddosCooDataSource) Schema(_ context.Context, req datasource.SchemaR } } -func (d *antiddosCooDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { +func (d *ddoscooDomainResourcesDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return } @@ -59,8 +59,8 @@ func (d *antiddosCooDataSource) Configure(_ context.Context, req datasource.Conf d.client = req.ProviderData.(alicloudClients).antiddosClient } -func (d *antiddosCooDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var plan, state antiddosCooDataSourceModel +func (d *ddoscooDomainResourcesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var plan, state ddoscooDomainResourcesDataSourceModel diags := req.Config.Get(ctx, &plan) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { diff --git a/alicloud/data_source_ddoscoo_instances.go b/alicloud/data_source_ddoscoo_instances.go new file mode 100644 index 0000000..82abeef --- /dev/null +++ b/alicloud/data_source_ddoscoo_instances.go @@ -0,0 +1,354 @@ +package alicloud + +import ( + "context" + "regexp" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + + alicloudAntiddosClient "github.com/alibabacloud-go/ddoscoo-20200101/v2/client" + util "github.com/alibabacloud-go/tea-utils/v2/service" + "github.com/alibabacloud-go/tea/tea" +) + +var ( + _ datasource.DataSource = &ddoscooInstancesDataSource{} + _ datasource.DataSourceWithConfigure = &ddoscooInstancesDataSource{} +) + +func NewDdosCooInstancesDataSource() datasource.DataSource { + return &ddoscooInstancesDataSource{} +} + +type ddoscooInstancesDataSource struct { + client *alicloudAntiddosClient.Client +} + +type ddoscooInstancesDataSourceModel struct { + Remark types.String `tfsdk:"remark_regex"` + IDs types.List `tfsdk:"ids"` + Instances []*antiddosCooInstance `tfsdk:"instances"` +} + +type antiddosCooInstance struct { + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + BaseBandwidth types.Int64 `tfsdk:"base_bandwidth"` + Bandwidth types.Int64 `tfsdk:"bandwidth"` + ServiceBandwidth types.Int64 `tfsdk:"service_bandwidth"` + PortCount types.Int64 `tfsdk:"port_count"` + DomainCount types.Int64 `tfsdk:"domain_count"` + Remark types.String `tfsdk:"remark"` + IpMode types.String `tfsdk:"ip_mode"` + DebtStatus types.Int64 `tfsdk:"debt_status"` + Edition types.Int64 `tfsdk:"edition"` + IpVersion types.String `tfsdk:"ip_version"` + Status types.Int64 `tfsdk:"status"` + Enabled types.Int64 `tfsdk:"enabled"` + ExpireTime types.Int64 `tfsdk:"expire_time"` + CreateTime types.Int64 `tfsdk:"create_time"` + Eip types.List `tfsdk:"eip"` +} + +func (d *ddoscooInstancesDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_ddoscoo_instances" +} + +func (d *ddoscooInstancesDataSource) Schema(_ context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "This data source provides the AntiDDoS domain resources of the current AliCloud user.", + Attributes: map[string]schema.Attribute{ + "remark_regex": schema.StringAttribute{ + Description: "Remark of AntiDDoS instances.", + Optional: true, + }, + "ids": schema.ListAttribute{ + Description: "List of IDs of AntiDDoS instance.", + Optional: true, + ElementType: types.StringType, + }, + "instances": schema.ListNestedAttribute{ + Description: "A list of Anti-DDoS instances", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Description: "ID of AntiDDoS instance.", + Computed: true, + }, + "name": schema.StringAttribute{ + Description: "Name of AntiDDoS instance.", + Computed: true, + }, + "base_bandwidth": schema.Int64Attribute{ + Description: "Base bandwidth of AntiDDoS instance.", + Computed: true, + }, + "bandwidth": schema.Int64Attribute{ + Description: "Bandwidth of AntiDDoS instacne.", + Computed: true, + }, + "service_bandwidth": schema.Int64Attribute{ + Description: "Service bandwidth of AntiDDoS instance.", + Computed: true, + }, + "port_count": schema.Int64Attribute{ + Description: "Port count of AntiDDoS instance.", + Computed: true, + }, + "domain_count": schema.Int64Attribute{ + Description: "Domain count of AntiDDoS instance.", + Computed: true, + }, + "remark": schema.StringAttribute{ + Description: "Remark of AntiDDoS instance.", + Computed: true, + }, + "ip_mode": schema.StringAttribute{ + Description: "IP Mode of AntiDDoS instance.", + Computed: true, + }, + "debt_status": schema.Int64Attribute{ + Description: "Debt status of AntiDDoS instance.", + Computed: true, + }, + "edition": schema.Int64Attribute{ + Description: "Edition of AntiDDoS instance.", + Computed: true, + }, + "ip_version": schema.StringAttribute{ + Description: "IP version of AntiDDoS instance.", + Computed: true, + }, + "status": schema.Int64Attribute{ + Description: "Status of AntiDDoS instance.", + Computed: true, + }, + "enabled": schema.Int64Attribute{ + Description: "If the AntiDDoS instance is enabled", + Computed: true, + }, + "expire_time": schema.Int64Attribute{ + Description: "Expire time of AntiDDoS instance.", + Computed: true, + }, + "create_time": schema.Int64Attribute{ + Description: "Create time of AntiDDoS instance.", + Computed: true, + }, + "eip": schema.ListAttribute{ + Description: "EIP of AntiDDoS instance.", + Computed: true, + ElementType: types.StringType, + }, + }, + }, + }, + }, + } +} + +func (d *ddoscooInstancesDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + d.client = req.ProviderData.(alicloudClients).antiddosClient +} + +func (d *ddoscooInstancesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var plan, state ddoscooInstancesDataSourceModel + diags := req.Config.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + state.IDs = plan.IDs + state.Remark = plan.Remark + state.Instances = []*antiddosCooInstance{} + + var antiddosInstances *alicloudAntiddosClient.DescribeInstancesResponse + var antiddosInstanceSpecs *alicloudAntiddosClient.DescribeInstanceSpecsResponse + var antiddosInstanceDetails *alicloudAntiddosClient.DescribeInstanceDetailsResponse + + describeInstancesRequest := &alicloudAntiddosClient.DescribeInstancesRequest{ + PageNumber: tea.String("1"), + PageSize: tea.String("20"), + } + describeInstanceSpecsRequest := &alicloudAntiddosClient.DescribeInstanceSpecsRequest{} + describeInstanceDetailsRequest := &alicloudAntiddosClient.DescribeInstanceDetailsRequest{} + + var nameRegex *regexp.Regexp + + runtime := &util.RuntimeOptions{} + + if !(plan.IDs.IsNull() || plan.IDs.IsUnknown()) { + // Plan ID List to List of String + var planIdsList []string + for _, x := range plan.IDs.Elements() { + planIdsList = append(planIdsList, trimStringQuotes(x.String())) + } + + describeInstancesRequest.InstanceIds = tea.StringSlice(planIdsList) + } + + if !(plan.Remark.IsNull() || plan.Remark.IsUnknown()) { + // Convert Remark Input to Regex + v := plan.Remark.ValueString() + if r, err := regexp.Compile(v); err != nil { + resp.Diagnostics.AddError( + "[API ERROR] Failed to Convert Remark Input to Regex", + err.Error(), + ) + return + } else { + nameRegex = r + } + } + + // Describe Instances + if descInstancesErr := func() (_e error) { + defer func() { + if r := tea.Recover(recover()); r != nil { + _e = r + } + }() + + var err error + if antiddosInstances, err = d.client.DescribeInstancesWithOptions(describeInstancesRequest, runtime); err != nil { + return err + } + return nil + }(); descInstancesErr != nil { + var error = &tea.SDKError{} + if _t, ok := descInstancesErr.(*tea.SDKError); ok { + error = _t + } else { + error.Message = tea.String(descInstancesErr.Error()) + } + + if _, err := util.AssertAsString(error.Message); err != nil { + resp.Diagnostics.AddError( + "[API ERROR] Failed to Describe AntiDDoS Instances", + err.Error(), + ) + return + } + } + + var antiddosInstancesList []string + if antiddosInstances.String() != "{}" && *antiddosInstances.Body.TotalCount > int64(0) { + + for _, instances := range antiddosInstances.Body.Instances { + // Regex Filter + if nameRegex != nil && !(nameRegex.MatchString(*instances.Remark)) { + continue + } + antiddosInstancesList = append(antiddosInstancesList, *instances.InstanceId) + } + + // Describe Instance Specs + describeInstanceSpecsRequest.InstanceIds = tea.StringSlice(antiddosInstancesList) + if descSpecsErr := func() (_e error) { + defer func() { + if r := tea.Recover(recover()); r != nil { + _e = r + } + }() + + var err error + if antiddosInstanceSpecs, err = d.client.DescribeInstanceSpecsWithOptions(describeInstanceSpecsRequest, runtime); + err != nil { + return err + } + return nil + }(); descSpecsErr != nil { + var error = &tea.SDKError{} + if _t, ok := descSpecsErr.(*tea.SDKError); ok { + error = _t + } else { + error.Message = tea.String(descSpecsErr.Error()) + } + + if _, err := util.AssertAsString(error.Message); err != nil { + resp.Diagnostics.AddError( + "[API ERROR] Failed to Describe AntiDDoS Instance Specs", + err.Error(), + ) + return + } + } + + // Describe Instance Details + describeInstanceDetailsRequest.InstanceIds = tea.StringSlice(antiddosInstancesList) + if descDetailsErr := func() (_e error) { + defer func() { + if r := tea.Recover(recover()); r != nil { + _e = r + } + }() + + var err error + if antiddosInstanceDetails, err = d.client.DescribeInstanceDetailsWithOptions(describeInstanceDetailsRequest, runtime); + err != nil { + return err + } + return nil + }(); descDetailsErr != nil { + var error = &tea.SDKError{} + if _t, ok := descDetailsErr.(*tea.SDKError); ok { + error = _t + } else { + error.Message = tea.String(descDetailsErr.Error()) + } + + if _, err := util.AssertAsString(error.Message); err != nil { + resp.Diagnostics.AddError( + "[API ERROR] Failed to Describe AntiDDoS Instance Details", + err.Error(), + ) + return + } + } + + // Assign all values into instances + for i := 0; i < len(antiddosInstancesList); i++ { + + var instanceEipList []attr.Value + for _, instanceDetailsEip := range antiddosInstanceDetails.Body.InstanceDetails[i].EipInfos { + instanceEipList = append(instanceEipList, types.StringValue(*instanceDetailsEip.Eip)) + } + + instanceDetail := &antiddosCooInstance{ + ID: types.StringValue(antiddosInstancesList[i]), + Name: types.StringValue(*antiddosInstances.Body.Instances[i].Remark), + BaseBandwidth: types.Int64Value(int64(*antiddosInstanceSpecs.Body.InstanceSpecs[i].BaseBandwidth)), + Bandwidth: types.Int64Value(int64(*antiddosInstanceSpecs.Body.InstanceSpecs[i].ElasticBandwidth)), + ServiceBandwidth: types.Int64Value(int64(*antiddosInstanceSpecs.Body.InstanceSpecs[i].BandwidthMbps)), + PortCount: types.Int64Value(int64(*antiddosInstanceSpecs.Body.InstanceSpecs[i].PortLimit)), + DomainCount: types.Int64Value(int64(*antiddosInstanceSpecs.Body.InstanceSpecs[i].DomainLimit)), + Remark: types.StringValue(*antiddosInstances.Body.Instances[i].Remark), + IpMode: types.StringValue(*antiddosInstances.Body.Instances[i].IpMode), + DebtStatus: types.Int64Value(int64(*antiddosInstances.Body.Instances[i].DebtStatus)), + Edition: types.Int64Value(int64(*antiddosInstances.Body.Instances[i].Edition)), + IpVersion: types.StringValue(*antiddosInstances.Body.Instances[i].IpVersion), + Status: types.Int64Value(int64(*antiddosInstances.Body.Instances[i].Status)), + Enabled: types.Int64Value(int64(*antiddosInstances.Body.Instances[i].Enabled)), + ExpireTime: types.Int64Value(*antiddosInstances.Body.Instances[i].ExpireTime), + CreateTime: types.Int64Value(*antiddosInstances.Body.Instances[i].CreateTime), + Eip: types.ListValueMust(types.StringType, instanceEipList), + } + state.Instances = append(state.Instances, instanceDetail) + } + } + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} diff --git a/alicloud/provider.go b/alicloud/provider.go index bc91571..9511566 100644 --- a/alicloud/provider.go +++ b/alicloud/provider.go @@ -249,9 +249,9 @@ func (p *alicloudProvider) Configure(ctx context.Context, req provider.Configure } // AliCloud SLB Client - slbCliientConfig := clientCredentialsConfig - slbCliientConfig.Endpoint = tea.String("slb.aliyuncs.com") - slbClient, err := alicloudSlbClient.NewClient(slbCliientConfig) + slbClientConfig := clientCredentialsConfig + slbClientConfig.Endpoint = tea.String("slb.aliyuncs.com") + slbClient, err := alicloudSlbClient.NewClient(slbClientConfig) if err != nil { resp.Diagnostics.AddError( @@ -295,7 +295,8 @@ func (p *alicloudProvider) Configure(ctx context.Context, req provider.Configure func (p *alicloudProvider) DataSources(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ NewCdnDomainDataSource, - NewAntiddosCooDataSource, + NewDdosCooInstancesDataSource, + NewDdosCooDomainResourcesDataSource, NewSlbLoadBalancersDataSource, } } diff --git a/alicloud/resource_alidns_record_weight.go b/alicloud/resource_alidns_record_weight.go index 79202a6..6ad987a 100644 --- a/alicloud/resource_alidns_record_weight.go +++ b/alicloud/resource_alidns_record_weight.go @@ -276,16 +276,7 @@ func (r *aliDnsRecordWeightResource) ImportState(ctx context.Context, req resour func (r *aliDnsRecordWeightResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { // If the entire plan is null, the resource is planned for destruction. - if req.Plan.Raw.IsNull() { - // Return an example warning diagnostic to practitioners. - resp.Diagnostics.AddWarning( - "Resource Destruction Considerations", - "Applying this resource destruction will only remove the resource from the Terraform state "+ - "and will not call the deletion API due to API limitations. Manually use the web "+ - "interface to fully destroy this resource.", - ) - - } else { + if !(req.Plan.Raw.IsNull()) { var plan *aliDnsRecordWeightResourceModel getPlanDiags := req.Plan.Get(ctx, &plan) resp.Diagnostics.Append(getPlanDiags...) diff --git a/docs/data-sources/antiddos_coo_domain.md b/docs/data-sources/ddoscoo_domain_resources.md similarity index 74% rename from docs/data-sources/antiddos_coo_domain.md rename to docs/data-sources/ddoscoo_domain_resources.md index 823895a..99bccdc 100644 --- a/docs/data-sources/antiddos_coo_domain.md +++ b/docs/data-sources/ddoscoo_domain_resources.md @@ -1,19 +1,19 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "st-alicloud_antiddos_coo_domain Data Source - st-alicloud" +page_title: "st-alicloud_ddoscoo_domain_resources Data Source - st-alicloud" subcategory: "" description: |- This data source provides the AntiDDoS domain resources of the current AliCloud user. --- -# st-alicloud_antiddos_coo_domain (Data Source) +# st-alicloud_ddoscoo_domain_resources (Data Source) This data source provides the AntiDDoS domain resources of the current AliCloud user. ## Example Usage ```terraform -data "st-alicloud_antiddos_coo_domain" "def" { +data "st-alicloud_ddoscoo_domain_resources" "def" { domain_name = "test.example.com" } ``` diff --git a/docs/data-sources/ddoscoo_instances.md b/docs/data-sources/ddoscoo_instances.md new file mode 100644 index 0000000..fd38771 --- /dev/null +++ b/docs/data-sources/ddoscoo_instances.md @@ -0,0 +1,67 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "st-alicloud_ddoscoo_instances Data Source - st-alicloud" +subcategory: "" +description: |- + This data source provides the AntiDDoS domain resources of the current AliCloud user. +--- + +# st-alicloud_ddoscoo_instances (Data Source) + +This data source provides the AntiDDoS domain resources of the current AliCloud user. + +## Example Usage + +```terraform +provider "st-alicloud" { + alias = "antiddos-instance" + region = "ap-southeast-1" +} + +data "st-alicloud_ddoscoo_instances" "ins" { + provider = st-alicloud.antiddos-instance + ids = ["id1", "id2"] + remark_regex = "^example-remark" +} + +output "alicloud_ddoscoo_instances" { + value = data.st-alicloud_ddoscoo_instances.ins +} +``` + + +## Schema + +### Optional + +- `ids` (List of String) List of IDs of AntiDDoS instance. +- `remark_regex` (String) Remark of AntiDDoS instances. + +### Read-Only + +- `instances` (Attributes List) A list of Anti-DDoS instances (see [below for nested schema](#nestedatt--instances)) + + +### Nested Schema for `instances` + +Read-Only: + +- `bandwidth` (Number) Bandwidth of AntiDDoS instacne. +- `base_bandwidth` (Number) Base bandwidth of AntiDDoS instance. +- `create_time` (Number) Create time of AntiDDoS instance. +- `debt_status` (Number) Debt status of AntiDDoS instance. +- `domain_count` (Number) Domain count of AntiDDoS instance. +- `edition` (Number) Edition of AntiDDoS instance. +- `eip` (List of String) EIP of AntiDDoS instance. +- `enabled` (Number) If the AntiDDoS instance is enabled +- `expire_time` (Number) Expire time of AntiDDoS instance. +- `id` (String) ID of AntiDDoS instance. +- `ip_mode` (String) IP Mode of AntiDDoS instance. +- `ip_version` (String) IP version of AntiDDoS instance. +- `name` (String) Name of AntiDDoS instance. +- `port_count` (Number) Port count of AntiDDoS instance. +- `remark` (String) Remark of AntiDDoS instance. +- `service_bandwidth` (Number) Service bandwidth of AntiDDoS instance. +- `status` (Number) Status of AntiDDoS instance. + + diff --git a/examples/data-sources/st-alicloud_antiddos_coo_domain/data-source.tf b/examples/data-sources/st-alicloud_antiddos_coo_domain/data-source.tf deleted file mode 100644 index b872112..0000000 --- a/examples/data-sources/st-alicloud_antiddos_coo_domain/data-source.tf +++ /dev/null @@ -1,3 +0,0 @@ -data "st-alicloud_antiddos_coo_domain" "def" { - domain_name = "test.example.com" -} diff --git a/examples/data-sources/st-alicloud_ddoscoo_domain_resources/data-source.tf b/examples/data-sources/st-alicloud_ddoscoo_domain_resources/data-source.tf new file mode 100644 index 0000000..92fae17 --- /dev/null +++ b/examples/data-sources/st-alicloud_ddoscoo_domain_resources/data-source.tf @@ -0,0 +1,3 @@ +data "st-alicloud_ddoscoo_domain_resources" "def" { + domain_name = "test.example.com" +} diff --git a/examples/data-sources/st-alicloud_ddoscoo_instances/data-source.tf b/examples/data-sources/st-alicloud_ddoscoo_instances/data-source.tf new file mode 100644 index 0000000..90bc652 --- /dev/null +++ b/examples/data-sources/st-alicloud_ddoscoo_instances/data-source.tf @@ -0,0 +1,14 @@ +provider "st-alicloud" { + alias = "antiddos-instance" + region = "ap-southeast-1" +} + +data "st-alicloud_ddoscoo_instances" "ins" { + provider = st-alicloud.antiddos-instance + ids = ["id1", "id2"] + remark_regex = "^example-remark" +} + +output "alicloud_ddoscoo_instances" { + value = data.st-alicloud_ddoscoo_instances.ins +} diff --git a/go.mod b/go.mod index 9a87acd..da905c3 100644 --- a/go.mod +++ b/go.mod @@ -45,6 +45,7 @@ require ( github.com/russross/blackfriday v1.6.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect + github.com/stretchr/testify v1.8.1 // indirect github.com/zclconf/go-cty v1.13.0 // indirect golang.org/x/crypto v0.5.0 // indirect golang.org/x/mod v0.7.0 // indirect diff --git a/go.sum b/go.sum index 109ee34..87fc667 100644 --- a/go.sum +++ b/go.sum @@ -265,14 +265,19 @@ github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w= github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho= github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=