You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
289 lines
5.8 KiB
289 lines
5.8 KiB
package secgroup
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
|
)
|
|
|
|
func resourceSecurityGroupSchemaMake() map[string]*schema.Schema {
|
|
res := map[string]*schema.Schema{
|
|
"account_id": {
|
|
Type: schema.TypeInt,
|
|
Required: true,
|
|
},
|
|
"name": {
|
|
Type: schema.TypeString,
|
|
Required: true,
|
|
},
|
|
"description": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
},
|
|
"rules": {
|
|
Type: schema.TypeSet,
|
|
Optional: true,
|
|
Elem: &schema.Resource{
|
|
Schema: map[string]*schema.Schema{
|
|
"direction": {
|
|
Type: schema.TypeString,
|
|
Required: true,
|
|
ValidateFunc: validation.StringInSlice([]string{"inbound", "outbound"}, true),
|
|
},
|
|
"ethertype": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
Default: "IPv4",
|
|
ValidateFunc: validation.StringInSlice([]string{"IPv4", "IPv6"}, true),
|
|
},
|
|
"protocol": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
ValidateFunc: validation.StringInSlice([]string{"icmp", "tcp", "udp"}, true),
|
|
},
|
|
"port_range_min": {
|
|
Type: schema.TypeInt,
|
|
Optional: true,
|
|
},
|
|
"port_range_max": {
|
|
Type: schema.TypeInt,
|
|
Optional: true,
|
|
},
|
|
"remote_ip_prefix": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
},
|
|
"id": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
"security_group_id": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"created_at": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"updated_at": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"created_by": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"updated_by": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
}
|
|
return res
|
|
}
|
|
|
|
func dataSourceSecurityGroupSchemaMake() map[string]*schema.Schema {
|
|
res := map[string]*schema.Schema{
|
|
"security_group_id": {
|
|
Type: schema.TypeInt,
|
|
Required: true,
|
|
},
|
|
"account_id": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"name": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"description": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"rules": {
|
|
Type: schema.TypeList,
|
|
Computed: true,
|
|
Elem: &schema.Resource{
|
|
Schema: map[string]*schema.Schema{
|
|
"id": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"direction": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"ethertype": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"protocol": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"port_range_min": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"port_range_max": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"remote_ip_prefix": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
"created_at": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"updated_at": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"created_by": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"updated_by": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
}
|
|
return res
|
|
}
|
|
|
|
func dataSourceSecurityGroupListSchemaMake() map[string]*schema.Schema {
|
|
res := map[string]*schema.Schema{
|
|
"page": {
|
|
Type: schema.TypeInt,
|
|
Optional: true,
|
|
},
|
|
"size": {
|
|
Type: schema.TypeInt,
|
|
Optional: true,
|
|
},
|
|
"by_id": {
|
|
Type: schema.TypeInt,
|
|
Optional: true,
|
|
},
|
|
"account_id": {
|
|
Type: schema.TypeInt,
|
|
Optional: true,
|
|
},
|
|
"name": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
},
|
|
"desc": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
},
|
|
"sort_by": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
},
|
|
"created_min": {
|
|
Type: schema.TypeInt,
|
|
Optional: true,
|
|
},
|
|
"created_max": {
|
|
Type: schema.TypeInt,
|
|
Optional: true,
|
|
},
|
|
"updated_min": {
|
|
Type: schema.TypeInt,
|
|
Optional: true,
|
|
},
|
|
"updated_max": {
|
|
Type: schema.TypeInt,
|
|
Optional: true,
|
|
},
|
|
"items": {
|
|
Type: schema.TypeList,
|
|
Computed: true,
|
|
Elem: &schema.Resource{
|
|
Schema: map[string]*schema.Schema{
|
|
"security_group_id": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"account_id": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"name": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"description": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"rules": {
|
|
Type: schema.TypeList,
|
|
Computed: true,
|
|
Elem: &schema.Resource{
|
|
Schema: map[string]*schema.Schema{
|
|
"id": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"direction": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"ethertype": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"protocol": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"port_range_min": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"port_range_max": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"remote_ip_prefix": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
"created_at": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"updated_at": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"created_by": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"updated_by": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
"entry_count": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
}
|
|
return res
|
|
}
|