-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from volcengine/feat/volc
Feat/volc
- Loading branch information
Showing
32 changed files
with
3,461 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "volcengine_cloud_monitor_contact" "default" { | ||
name = "tf-acc" | ||
email = "192*****72@****.com" | ||
phone = "180****27812" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "volcengine_cloud_monitor_contact_group" "foo" { | ||
name = "tfgroup" | ||
description = "tftest" | ||
contacts_id_list = ["1737376113733353472", "1737375997680111616"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
resource "volcengine_cloud_monitor_event_rule" "foo" { | ||
status = "enable" | ||
contact_methods = ["Phone", "TLS", "MQ"] | ||
event_source = "ecs" | ||
level = "notice" | ||
rule_name = "tftest1" | ||
effective_time { | ||
start_time = "01:00" | ||
end_time = "22:00" | ||
} | ||
event_type = ["ecs:Disk:DiskError.Redeploy.Canceled"] | ||
contact_group_ids = ["1737941730782699520", "1737940985502777344"] | ||
filter_pattern { | ||
type = ["ecs:Disk:DiskError.Redeploy.Canceled"] | ||
source = "ecs" | ||
} | ||
message_queue { | ||
instance_id = "kafka-cnoe4rfrsqfb1d64" | ||
vpc_id = "vpc-2d68hz41j7qio58ozfd6jxgtb" | ||
type = "kafka" | ||
region = "*****" | ||
topic = "tftest" | ||
} | ||
tls_target { | ||
project_name = "tf-test" | ||
region_name_cn = "*****" | ||
region_name_en = "*****" | ||
project_id = "17ba378d-de43-495e-8906-03ae6567b376" | ||
topic_id = "7ce12237-6670-44a7-9d79-2e36961586e6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
resource "volcengine_cloud_monitor_rule" "foo" { | ||
rule_name = "acc-test-rule" | ||
description = "acc-test" | ||
namespace = "VCM_ECS" | ||
sub_namespace = "Storage" | ||
level = "warning" | ||
enable_state = "disable" | ||
evaluation_count = 5 | ||
effect_start_at = "00:15" | ||
effect_end_at = "22:55" | ||
silence_time = 5 | ||
alert_methods = ["Email", "Webhook"] | ||
web_hook = "http://alert.volc.com/callback" | ||
contact_group_ids = ["174284616403161****"] | ||
multiple_conditions = true | ||
condition_operator = "||" | ||
regions = ["cn-beijing"] | ||
original_dimensions { | ||
key = "ResourceID" | ||
value = ["*"] | ||
} | ||
original_dimensions { | ||
key = "DiskName" | ||
value = ["vda", "vda1"] | ||
} | ||
conditions { | ||
metric_name = "DiskUsageAvail" | ||
metric_unit = "Megabytes" | ||
statistics = "avg" | ||
comparison_operator = ">" | ||
threshold = "100" | ||
} | ||
conditions { | ||
metric_name = "DiskUsageUtilization" | ||
metric_unit = "Percent" | ||
statistics = "avg" | ||
comparison_operator = ">" | ||
threshold = "90" | ||
} | ||
recovery_notify { | ||
enable = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "volcengine_cloud_monitor_contact_groups" "foo"{ | ||
name = "tftest" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "volcengine_cloud_monitor_contacts" "foo" { | ||
ids = ["17******516", "1712**********0"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "volcengine_cloud_monitor_event_rules" "foo"{ | ||
rule_name = "tftest" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "volcengine_cloud_monitor_rules" "foo" { | ||
ids = ["174402785374661****"] | ||
} |
67 changes: 67 additions & 0 deletions
67
...gine/cloud_monitor/cloud_monitor_contact/data_source_volcengine_cloud_monitor_contacts.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package cloud_monitor_contact | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
ve "github.com/volcengine/terraform-provider-volcengine/common" | ||
) | ||
|
||
func DataSourceVolcengineCloudMonitorContacts() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceVolcengineCloudMonitorContactsRead, | ||
Schema: map[string]*schema.Schema{ | ||
"ids": { | ||
Type: schema.TypeSet, | ||
Required: true, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
}, | ||
Set: schema.HashString, | ||
Description: "A list of Contact IDs.", | ||
}, | ||
"output_file": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "File name where to save data source results.", | ||
}, | ||
"total_count": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "The total count of query.", | ||
}, | ||
"contacts": { | ||
Description: "The collection of query.", | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The ID of contact.", | ||
}, | ||
"name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The name of contact.", | ||
}, | ||
"phone": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The phone of contact.", | ||
}, | ||
"email": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The email of contact.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceVolcengineCloudMonitorContactsRead(d *schema.ResourceData, meta interface{}) error { | ||
service := NewService(meta.(*ve.SdkClient)) | ||
return ve.DefaultDispatcher().Data(service, d, DataSourceVolcengineCloudMonitorContacts()) | ||
} |
89 changes: 89 additions & 0 deletions
89
volcengine/cloud_monitor/cloud_monitor_contact/resource_volcengine_cloud_monitor_contact.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package cloud_monitor_contact | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
ve "github.com/volcengine/terraform-provider-volcengine/common" | ||
) | ||
|
||
/* | ||
Import | ||
CloudMonitor Contact can be imported using the id, e.g. | ||
``` | ||
$ terraform import volcengine_cloud_monitor_contact.default 145258255725730**** | ||
``` | ||
*/ | ||
|
||
func ResourceVolcengineCloudMonitorContact() *schema.Resource { | ||
return &schema.Resource{ | ||
Create: resourceVolcengineCloudMonitorContactCreate, | ||
Read: resourceVolcengineCloudMonitorContactRead, | ||
Update: resourceVolcengineCloudMonitorContactUpdate, | ||
Delete: resourceVolcengineCloudMonitorContactDelete, | ||
Importer: &schema.ResourceImporter{ | ||
State: schema.ImportStatePassthrough, | ||
}, | ||
Timeouts: &schema.ResourceTimeout{ | ||
Create: schema.DefaultTimeout(30 * time.Minute), | ||
Update: schema.DefaultTimeout(30 * time.Minute), | ||
Delete: schema.DefaultTimeout(30 * time.Minute), | ||
}, | ||
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The name of contact.", | ||
}, | ||
"email": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The email of contact.", | ||
}, | ||
"phone": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The phone of contact.", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func resourceVolcengineCloudMonitorContactCreate(d *schema.ResourceData, meta interface{}) (err error) { | ||
service := NewService(meta.(*ve.SdkClient)) | ||
err = ve.DefaultDispatcher().Create(service, d, ResourceVolcengineCloudMonitorContact()) | ||
if err != nil { | ||
return fmt.Errorf("error on creating Contact %q, %w", d.Id(), err) | ||
} | ||
return resourceVolcengineCloudMonitorContactRead(d, meta) | ||
} | ||
|
||
func resourceVolcengineCloudMonitorContactRead(d *schema.ResourceData, meta interface{}) (err error) { | ||
service := NewService(meta.(*ve.SdkClient)) | ||
err = ve.DefaultDispatcher().Read(service, d, ResourceVolcengineCloudMonitorContact()) | ||
if err != nil { | ||
return fmt.Errorf("error on reading Contact %q, %w", d.Id(), err) | ||
} | ||
return err | ||
} | ||
|
||
func resourceVolcengineCloudMonitorContactUpdate(d *schema.ResourceData, meta interface{}) (err error) { | ||
service := NewService(meta.(*ve.SdkClient)) | ||
err = ve.DefaultDispatcher().Update(service, d, ResourceVolcengineCloudMonitorContact()) | ||
if err != nil { | ||
return fmt.Errorf("error on updating Contact %q, %w", d.Id(), err) | ||
} | ||
return resourceVolcengineCloudMonitorContactRead(d, meta) | ||
} | ||
|
||
func resourceVolcengineCloudMonitorContactDelete(d *schema.ResourceData, meta interface{}) (err error) { | ||
service := NewService(meta.(*ve.SdkClient)) | ||
err = ve.DefaultDispatcher().Delete(service, d, ResourceVolcengineCloudMonitorContact()) | ||
if err != nil { | ||
return fmt.Errorf("error on deleting Contact %q, %w", d.Id(), err) | ||
} | ||
return err | ||
} |
Oops, something went wrong.