-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
cloudavenue_alb_pool
(#246)
- Loading branch information
Showing
18 changed files
with
1,460 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:new-resource | ||
cloudavenue_alb_pool | ||
``` | ||
|
||
```release-note:new-data-source | ||
cloudavenue_alb_pool | ||
``` |
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,64 @@ | ||
--- | ||
page_title: "cloudavenue_alb_pool Data Source - cloudavenue" | ||
subcategory: "ALB (Advanced Load Balancer)" | ||
description: |- | ||
Provides a data source to manage Advanced Load Balancer Pools. Pools maintain the list of servers assigned to them and perform health monitoring, load balancing, persistence. | ||
--- | ||
|
||
# cloudavenue_alb_pool (Data Source) | ||
|
||
Provides a data source to manage Advanced Load Balancer Pools. Pools maintain the list of servers assigned to them and perform health monitoring, load balancing, persistence. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "cloudavenue_alb_pool" "example" { | ||
edge_gateway_name = "MyEdgeGatewayName" | ||
name = "MyAlbPoolName" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) Name of ALB Pool. | ||
|
||
### Optional | ||
|
||
- `edge_gateway_id` (String) Edge gateway ID in which ALB Pool was created. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. | ||
- `edge_gateway_name` (String) Edge gateway Name in which ALB Pool was created. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. | ||
|
||
### Read-Only | ||
|
||
- `algorithm` (String) Algorithm for choosing pool members. | ||
- `default_port` (Number) Default Port defines destination server port used by the traffic sent to the member. | ||
- `description` (String) Description of ALB Pool. | ||
- `enabled` (Boolean) Define if ALB Pool is enabled or not. | ||
- `graceful_timeout_period` (Number) Maximum time in minutes to gracefully disable pool member. | ||
- `health_monitors` (Set of String) List of health monitors type to activate. | ||
- `id` (String) ID of ALB Pool. | ||
- `members` (Attributes Set) ALB Pool Member(s). (see [below for nested schema](#nestedatt--members)) | ||
- `passive_monitoring_enabled` (Boolean) Monitors if the traffic is accepted by node. | ||
- `persistence_profile` (Attributes) Persistence profile will ensure that the same user sticks to the same server for a desired duration of time. If the persistence profile is unmanaged by Cloud Avenue, updates that leave the values unchanged will continue to use the same unmanaged profile. Any changes made to the persistence profile will cause Cloud Avenue to switch the pool to a profile managed by Cloud Avenue. (see [below for nested schema](#nestedatt--persistence_profile)) | ||
|
||
<a id="nestedatt--members"></a> | ||
### Nested Schema for `members` | ||
|
||
Read-Only: | ||
|
||
- `enabled` (Boolean) Defines if pool member accepts traffic. | ||
- `ip_address` (String) IP address of pool member. | ||
- `port` (Number) Member port. | ||
- `ratio` (Number) Ratio of selecting eligible servers in the pool. | ||
|
||
|
||
<a id="nestedatt--persistence_profile"></a> | ||
### Nested Schema for `persistence_profile` | ||
|
||
Read-Only: | ||
|
||
- `type` (String) Type of persistence strategy. | ||
- `value` (String) Value of attribute based on persistence type. | ||
|
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,121 @@ | ||
--- | ||
page_title: "cloudavenue_alb_pool Resource - cloudavenue" | ||
subcategory: "ALB (Advanced Load Balancer)" | ||
description: |- | ||
Provides a resource to manage Advanced Load Balancer Pools. Pools maintain the list of servers assigned to them and perform health monitoring, load balancing, persistence. A pool may only be used or referenced by only one virtual service at a time. | ||
--- | ||
|
||
# cloudavenue_alb_pool (Resource) | ||
|
||
Provides a resource to manage Advanced Load Balancer Pools. Pools maintain the list of servers assigned to them and perform health monitoring, load balancing, persistence. A pool may only be used or referenced by only one virtual service at a time. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "cloudavenue_tier0_vrfs" "example" {} | ||
resource "cloudavenue_edgegateway" "example" { | ||
owner_name = "MyVDC" | ||
tier0_vrf_name = data.cloudavenue_tier0_vrfs.example.names.0 | ||
owner_type = "vdc" | ||
lb_enabled = true | ||
} | ||
resource "cloudavenue_alb_pool" "example" { | ||
edge_gateway_name = cloudavenue_edgegateway.example.name | ||
name = "Example" | ||
persistence_profile = { | ||
type = "CLIENT_IP" | ||
} | ||
members = [ | ||
{ | ||
ip_address = "192.168.1.1" | ||
port = "80" | ||
}, | ||
{ | ||
ip_address = "192.168.1.2" | ||
port = "80" | ||
}, | ||
{ | ||
ip_address = "192.168.1.3" | ||
port = "80" | ||
} | ||
] | ||
health_monitors = ["UDP", "TCP"] | ||
} | ||
data "cloudavenue_tier0_vrfs" "example" {} | ||
resource "cloudavenue_edgegateway" "example" { | ||
owner_name = "MyVDC" | ||
tier0_vrf_name = data.cloudavenue_tier0_vrfs.example.names.0 | ||
owner_type = "vdc" | ||
lb_enabled = true | ||
} | ||
resource "cloudavenue_alb_pool" "example" { | ||
edge_gateway_name = cloudavenue_edgegateway.example.name | ||
name = "Example" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) Name of ALB Pool. | ||
|
||
### Optional | ||
|
||
- `algorithm` (String) Algorithm for choosing pool members. Value must be one of : `ROUND_ROBIN`, `CONSISTENT_HASH`, `LEAST_CONNECTIONS`. Value defaults to `LEAST_CONNECTIONS`. | ||
- `default_port` (Number) Default Port defines destination server port used by the traffic sent to the member. Value must be between 1 and 65535. Value defaults to `80`. | ||
- `description` (String) Description of ALB Pool. | ||
- `edge_gateway_id` (String) (ForceNew) Edge gateway ID in which ALB Pool should be created. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. | ||
- `edge_gateway_name` (String) (ForceNew) Edge gateway Name in which ALB Pool should be created. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. | ||
- `enabled` (Boolean) Define if ALB Pool is enabled or not. Value defaults to `true`. | ||
- `graceful_timeout_period` (Number) Maximum time in minutes to gracefully disable pool member. Value defaults to `1`. | ||
- `health_monitors` (Set of String) List of health monitors type to activate. Element value must satisfy all validations: value must be one of: ["\"HTTP\"" "\"HTTPS\"" "\"TCP\"" "\"UDP\"" "\"PING\""]. | ||
- `members` (Attributes Set) ALB Pool Member(s). (see [below for nested schema](#nestedatt--members)) | ||
- `passive_monitoring_enabled` (Boolean) Monitors if the traffic is accepted by node. Value defaults to `true`. | ||
- `persistence_profile` (Attributes) Persistence profile will ensure that the same user sticks to the same server for a desired duration of time. If the persistence profile is unmanaged by Cloud Avenue, updates that leave the values unchanged will continue to use the same unmanaged profile. Any changes made to the persistence profile will cause Cloud Avenue to switch the pool to a profile managed by Cloud Avenue. (see [below for nested schema](#nestedatt--persistence_profile)) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) ID of ALB Pool. | ||
|
||
<a id="nestedatt--members"></a> | ||
### Nested Schema for `members` | ||
|
||
Required: | ||
|
||
- `ip_address` (String) IP address of pool member. Must be a valid IP with net.ParseIP. | ||
- `port` (Number) Member port. Value must be between 1 and 65535. | ||
|
||
Optional: | ||
|
||
- `enabled` (Boolean) Defines if pool member accepts traffic. Value defaults to `true`. | ||
- `ratio` (Number) Ratio of selecting eligible servers in the pool. Value must be at least 1. Value defaults to `1`. | ||
|
||
|
||
<a id="nestedatt--persistence_profile"></a> | ||
### Nested Schema for `persistence_profile` | ||
|
||
Required: | ||
|
||
- `type` (String) Type of persistence strategy. Value must be one of : `CLIENT_IP`, `HTTP_COOKIE`. | ||
|
||
Optional: | ||
|
||
- `value` (String) Value of attribute based on persistence type. If "persistence_profile.type" attribute is set and the value is one of `"HTTP_COOKIE"`, this attribute is required. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
```shell | ||
# use the edge_gateway_name.alb_pool_name to import the ALB Pool | ||
terraform import cloudavenue_alb_pool.test edge_gateway_name.alb_pool_name | ||
``` |
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,4 @@ | ||
data "cloudavenue_alb_pool" "example" { | ||
edge_gateway_name = "MyEdgeGatewayName" | ||
name = "MyAlbPoolName" | ||
} |
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,2 @@ | ||
# use the edge_gateway_name.alb_pool_name to import the ALB Pool | ||
terraform import cloudavenue_alb_pool.test edge_gateway_name.alb_pool_name |
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,48 @@ | ||
data "cloudavenue_tier0_vrfs" "example" {} | ||
|
||
resource "cloudavenue_edgegateway" "example" { | ||
owner_name = "MyVDC" | ||
tier0_vrf_name = data.cloudavenue_tier0_vrfs.example.names.0 | ||
owner_type = "vdc" | ||
lb_enabled = true | ||
} | ||
|
||
resource "cloudavenue_alb_pool" "example" { | ||
edge_gateway_name = cloudavenue_edgegateway.example.name | ||
name = "Example" | ||
|
||
persistence_profile = { | ||
type = "CLIENT_IP" | ||
} | ||
|
||
members = [ | ||
{ | ||
ip_address = "192.168.1.1" | ||
port = "80" | ||
}, | ||
{ | ||
ip_address = "192.168.1.2" | ||
port = "80" | ||
}, | ||
{ | ||
ip_address = "192.168.1.3" | ||
port = "80" | ||
} | ||
] | ||
|
||
health_monitors = ["UDP", "TCP"] | ||
} | ||
|
||
data "cloudavenue_tier0_vrfs" "example" {} | ||
|
||
resource "cloudavenue_edgegateway" "example" { | ||
owner_name = "MyVDC" | ||
tier0_vrf_name = data.cloudavenue_tier0_vrfs.example.names.0 | ||
owner_type = "vdc" | ||
lb_enabled = true | ||
} | ||
|
||
resource "cloudavenue_alb_pool" "example" { | ||
edge_gateway_name = cloudavenue_edgegateway.example.name | ||
name = "Example" | ||
} |
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,10 @@ | ||
package alb | ||
|
||
const ( | ||
categoryName = "alb" | ||
) | ||
|
||
type base struct { | ||
id string | ||
name string | ||
} |
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,51 @@ | ||
package alb | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/vmware/go-vcloud-director/v2/govcd" | ||
govcdtypes "github.com/vmware/go-vcloud-director/v2/types/v56" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
|
||
"github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" | ||
) | ||
|
||
var ErrPersistenceProfileIsEmpty = errors.New("persistence profile is empty") | ||
|
||
type albPool interface { | ||
GetID() string | ||
GetName() string | ||
GetAlbPool() (*govcd.NsxtAlbPool, error) | ||
} | ||
|
||
func processMembers(poolMembers []govcdtypes.NsxtAlbPoolMember) (members []member) { | ||
for _, poolMember := range poolMembers { | ||
members = append(members, member{ | ||
Enabled: types.BoolValue(poolMember.Enabled), | ||
IPAddress: types.StringValue(poolMember.IpAddress), | ||
Port: types.Int64Value(int64(poolMember.Port)), | ||
Ratio: types.Int64Value(int64(*poolMember.Ratio)), | ||
}) | ||
} | ||
return | ||
} | ||
|
||
func processHealthMonitors(poolHealthMonitors []govcdtypes.NsxtAlbPoolHealthMonitor) (healthMonitors []string) { | ||
for _, poolHealthMonitor := range poolHealthMonitors { | ||
healthMonitors = append(healthMonitors, poolHealthMonitor.Type) | ||
} | ||
|
||
return | ||
} | ||
|
||
func processPersistenceProfile(poolPersistenceProfile *govcdtypes.NsxtAlbPoolPersistenceProfile) persistenceProfile { | ||
if poolPersistenceProfile == nil { | ||
return persistenceProfile{} | ||
} | ||
|
||
return persistenceProfile{ | ||
Type: types.StringValue(poolPersistenceProfile.Type), | ||
Value: utils.StringValueOrNull(poolPersistenceProfile.Value), | ||
} | ||
} |
Oops, something went wrong.