-
Notifications
You must be signed in to change notification settings - Fork 9
/
data_source_volcengine_security_group_rules.go
129 lines (126 loc) · 3.9 KB
/
data_source_volcengine_security_group_rules.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package security_group_rule
import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
ve "github.com/volcengine/terraform-provider-volcengine/common"
)
func DataSourceVolcengineSecurityGroupRules() *schema.Resource {
return &schema.Resource{
Read: dataSourceVolcengineSecurityGroupRulesRead,
Schema: map[string]*schema.Schema{
"security_group_id": {
Type: schema.TypeString,
Required: true,
Description: "SecurityGroup ID.",
},
"direction": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"ingress",
"egress",
}, false),
Description: "Direction of rule, ingress (inbound) or egress (outbound).",
},
"cidr_ip": {
Type: schema.TypeString,
Optional: true,
Description: "Cidr ip of egress/ingress Rule.",
},
"protocol": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"tcp",
"udp",
"icmp",
"all",
}, false),
Description: "Protocol of the SecurityGroup, the value can be `tcp` or `udp` or `icmp` or `all`.",
},
"source_group_id": {
Type: schema.TypeString,
Optional: true,
Description: "ID of the source security group whose access permission you want to set.",
},
"output_file": {
Type: schema.TypeString,
Optional: true,
Description: "File name where to save data source results.",
},
"security_group_rules": {
Description: "The collection of SecurityGroup query.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"direction": {
Type: schema.TypeString,
Computed: true,
Description: "Direction of rule, ingress (inbound) or egress (outbound).",
},
"protocol": {
Type: schema.TypeString,
Computed: true,
Description: "Protocol of the SecurityGroup, the value can be `tcp` or `udp` or `icmp` or `all`.",
},
"security_group_id": {
Type: schema.TypeString,
Computed: true,
Description: "Id of SecurityGroup.",
},
"port_start": {
Type: schema.TypeInt,
Computed: true,
Description: "Port start of egress/ingress Rule.",
},
"port_end": {
Type: schema.TypeInt,
Computed: true,
Description: "Port end of egress/ingress Rule.",
},
"cidr_ip": {
Type: schema.TypeString,
Computed: true,
Description: "Cidr ip of egress/ingress Rule.",
},
"source_group_id": {
Type: schema.TypeString,
Computed: true,
Description: "ID of the source security group whose access permission you want to set.",
},
"policy": {
Type: schema.TypeString,
Computed: true,
Description: "Access strategy.",
},
"priority": {
Type: schema.TypeInt,
Computed: true,
Description: "Priority of a security group rule.",
},
"description": {
Type: schema.TypeString,
Computed: true,
Description: "description of a group rule.",
},
"creation_time": {
Type: schema.TypeString,
Computed: true,
Description: "The creation time of security group rule.",
},
"update_time": {
Type: schema.TypeString,
Computed: true,
Description: "The update time of security group rule.",
},
},
},
},
},
}
}
func dataSourceVolcengineSecurityGroupRulesRead(d *schema.ResourceData, meta interface{}) error {
securityGroupService := NewSecurityGroupRuleService(meta.(*ve.SdkClient))
return ve.DefaultDispatcher().Data(securityGroupService, d, DataSourceVolcengineSecurityGroupRules())
}