/
datasource_vcd_nsxv_distributed_firewall.go
127 lines (123 loc) · 3.69 KB
/
datasource_vcd_nsxv_distributed_firewall.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
package vcd
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func computedMap(input map[string]*schema.Schema) map[string]*schema.Schema {
var output = make(map[string]*schema.Schema)
for k, v := range input {
v.Required = false
v.Computed = true
v.StateFunc = nil
v.ValidateFunc = nil
output[k] = v
}
return output
}
func datasourceVcdNsxvDistributedFirewall() *schema.Resource {
return &schema.Resource{
ReadContext: datasourceVcdNsxvDistributedFirewallRead,
Schema: map[string]*schema.Schema{
"vdc_id": {
Type: schema.TypeString,
Required: true,
Description: "The ID of VDC",
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "When true, the retrieved NSX-V distributed firewall is enabled",
},
"rule": {
Type: schema.TypeList,
Computed: true,
Description: "Ordered list of distributed firewall rules",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Computed: true,
Description: "Firewall Rule ID",
},
"name": {
Type: schema.TypeString,
Computed: true,
Description: "Firewall Rule name",
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "Whether the rule is enabled",
},
"logged": {
Type: schema.TypeBool,
Computed: true,
Description: "Whether the rule traffic is logged",
},
"action": {
Type: schema.TypeString,
Computed: true,
Description: "Action of the rule (allow, deny)",
},
"direction": {
Type: schema.TypeString,
Computed: true,
Description: "Direction of the rule (in, out, inout)",
},
"packet_type": {
Type: schema.TypeString,
Computed: true,
Description: "Packet type of the rule (any, ipv4, ipv6)",
},
"source": {
Type: schema.TypeSet,
Computed: true,
Description: "List of source traffic for this rule. An empty value means 'any'",
Elem: &schema.Resource{
Schema: computedMap(sourceDef().Schema),
},
},
"application": {
Type: schema.TypeSet,
Computed: true,
Description: "Application definitions for this rule. An empty value means 'any'",
Elem: &schema.Resource{
Schema: computedMap(applicationDef().Schema),
},
},
"exclude_source": {
Type: schema.TypeBool,
Computed: true,
Description: "If true, the content of the source elements is reversed",
},
"destination": {
Type: schema.TypeSet,
Computed: true,
Description: "List of destination traffic for this rule. An empty value means 'any'",
Elem: &schema.Resource{
Schema: computedMap(destinationDef().Schema),
},
},
"exclude_destination": {
Type: schema.TypeBool,
Computed: true,
Description: "If true, the content of the destination elements is reversed",
},
"applied_to": {
Type: schema.TypeSet,
Computed: true,
Description: "List of elements to which this rule applies",
Elem: &schema.Resource{
Schema: computedMap(appliedToDef().Schema),
},
},
},
},
},
},
}
}
func datasourceVcdNsxvDistributedFirewallRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
return genericVcdNsxvDistributedFirewallRead(ctx, d, meta, "datasource")
}