Skip to content

Commit

Permalink
Add st-alicloud_cms_composite_group_metric_rule resource.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruokei authored Jul 12, 2023
1 parent 55bf3c8 commit c385a28
Show file tree
Hide file tree
Showing 7 changed files with 497 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ scenario. The reason behind every resources and data sources are stated as below
This resource is designed to handle policy content that exceeds the limit of 6144 characters.
It provides functionality to create policies by splitting the content into smaller segments that fit within the limit,
enabling the management and combination of these segments to form the complete policy. Finally, the policy will be attached to the relevant user.
- **st-alicloud_cms_alarm_rule**
The official AliCloud Terraform provider's resource
[*alicloud_cms_group_metric_rule*](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/cms_group_metric_rule)
does not support adding alarm rules into application groups based on expression-based creation.
For namespaces and metric inputs, please refer to: [*Alicloud Alarm Metric List*](https://cms.console.aliyun.com/metric-meta)
### Data Sources
Expand Down
19 changes: 19 additions & 0 deletions alicloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
alicloudDnsClient "github.com/alibabacloud-go/alidns-20150109/v4/client"
alicloudBaseClient "github.com/alibabacloud-go/bssopenapi-20171214/v3/client"
alicloudCdnClient "github.com/alibabacloud-go/cdn-20180510/v2/client"
alicloudCmsClient "github.com/alibabacloud-go/cms-20190101/v8/client"
alicloudOpenapiClient "github.com/alibabacloud-go/darabonba-openapi/v2/client"
alicloudAntiddosClient "github.com/alibabacloud-go/ddoscoo-20200101/v2/client"
alicloudRamClient "github.com/alibabacloud-go/ram-20150501/v2/client"
Expand All @@ -30,6 +31,7 @@ type alicloudClients struct {
dnsClient *alicloudDnsClient.Client
slbClient *alicloudSlbClient.Client
ramClient *alicloudRamClient.Client
cmsClient *alicloudCmsClient.Client
}

// Ensure the implementation satisfies the expected interfaces
Expand Down Expand Up @@ -278,6 +280,21 @@ func (p *alicloudProvider) Configure(ctx context.Context, req provider.Configure
return
}

// AliCloud CMS Client
cmsClientConfig := clientCredentialsConfig
cmsClientConfig.Endpoint = tea.String(fmt.Sprintf("metrics.%s.aliyuncs.com", region))
cmsClient, err := alicloudCmsClient.NewClient(cmsClientConfig)

if err != nil {
resp.Diagnostics.AddError(
"Unable to Create AliCloud CMS API Client",
"An unexpected error occurred when creating the AliCloud CMS API client. "+
"If the error is not clear, please contact the provider developers.\n\n"+
"AliCloud CMS Client Error: "+err.Error(),
)
return
}

// AliCloud clients wrapper
alicloudClients := alicloudClients{
baseClient: baseClient,
Expand All @@ -286,6 +303,7 @@ func (p *alicloudProvider) Configure(ctx context.Context, req provider.Configure
dnsClient: dnsClient,
slbClient: slbClient,
ramClient: ramClient,
cmsClient: cmsClient,
}

resp.DataSourceData = alicloudClients
Expand All @@ -307,5 +325,6 @@ func (p *alicloudProvider) Resources(_ context.Context) []func() resource.Resour
NewAliDnsGtmInstanceResource,
NewRamUserGroupAttachmentResource,
NewRamPolicyResource,
NewCmsAlarmRuleResource,
}
}
Loading

0 comments on commit c385a28

Please sign in to comment.