Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ress/data elb_virtual_service #985

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changelog/973.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:new-resource
`resource/cloudavenue_elb_virtual_service` - Add new resource `cloudavenue_elb_virtual_service` to manage edgegateway load balancer virtual services. A virtual service advertises an IP address and ports to the external world and listens for client traffic.
```

```release-note:new-data-source
`datasource/cloudavenue_elb_virtual_service` - Add new datasource `cloudavenue_elb_virtual_service` to read details of an existing edgegateway load balancer virtual service.
```
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"remoteUser": "vscode",
"updateRemoteUserUID": true,
"features": {
"github-cli": "latest",
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/terraform:1": {},
"ghcr.io/guiyomh/features/golangci-lint:0": {},
"ghcr.io/meaningful-ooo/devcontainer-features/fish": {},
Expand All @@ -59,4 +59,4 @@
},
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind",
"workspaceFolder": "/workspace"
}
}
53 changes: 53 additions & 0 deletions docs/data-sources/elb_virtual_service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
page_title: "cloudavenue_elb_virtual_service Data Source - cloudavenue"
subcategory: "ELB (EdgeGateway Load Balancer)"
description: |-
Provides a data source to read ELB Virtual services for particular Gateway. A virtual service advertises an IP address and ports to the external world and listens for client traffic. When a virtual service receives traffic, it directs it to members in ELB Pool.
---

# cloudavenue_elb_virtual_service (Data Source)

Provides a data source to read ELB Virtual services for particular Gateway. A virtual service advertises an IP address and ports to the external world and listens for client traffic. When a virtual service receives traffic, it directs it to members in ELB Pool.

## Example Usage

```terraform
data "cloudavenue_elb_virtual_service" "example" {
name = "example"
edge_gateway_id = data.cloudavenue_edgegateway.example.id
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name of the ELB Virtual Service.

### Optional

- `edge_gateway_id` (String) The ID of the edge gateway on which the ELB Virtual Service is to be created. Ensure that one and only one attribute from this collection is set : `edge_gateway_name`, `edge_gateway_id`.
- `edge_gateway_name` (String) The name of the edge gateway on which the ELB Virtual Service is to be created. Ensure that one and only one attribute from this collection is set : `edge_gateway_name`, `edge_gateway_id`.

### Read-Only

- `certificate_id` (String) The ID of the certificate. The certificate must be uploaded to your certificate library before it can be used. The certificate MUSTN'T be expired.
- `description` (String) The description of the ELB Virtual Service.
- `enabled` (Boolean) Defines if the ELB Virtual Service is enabled.
- `id` (String) The ID of the ELB virtual service.
- `pool_id` (String) The ID of the ELB Server Pool associated.
- `pool_name` (String) The name of the ELB Server Pool associated.
- `service_engine_group_name` (String) The name of the service Engine Group (Take the first one if not specified).
- `service_ports` (Attributes List) The service port of the ELB Virtual Service. The service port is the port on which the virtual service listens for client traffic. (see [below for nested schema](#nestedatt--service_ports))
- `service_type` (String) The type of the service. The different modes that the ELB supports for handling TCP traffic and various parameters that can be tuned for optimization of the TCP traffic are also detailed here.
- `virtual_ip` (String) The virtual IP address of the ELB Virtual Service.

<a id="nestedatt--service_ports"></a>
### Nested Schema for `service_ports`

Read-Only:

- `end` (Number) The end port of the service port range. If not specified, only the `start` value is used.
- `start` (Number) The start port of the service port range or exact port number if `end` is not set.

146 changes: 146 additions & 0 deletions docs/resources/elb_virtual_service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
page_title: "cloudavenue_elb_virtual_service Resource - cloudavenue"
subcategory: "ELB (EdgeGateway Load Balancer)"
description: |-
Provides a resource to manage ELB Virtual services for particular Gateway. A virtual service advertises an IP address and ports to the external world and listens for client traffic. When a virtual service receives traffic, it directs it to members in ELB Pool.
---

# cloudavenue_elb_virtual_service (Resource)

Provides a resource to manage ELB Virtual services for particular Gateway. A virtual service advertises an IP address and ports to the external world and listens for client traffic. When a virtual service receives traffic, it directs it to members in ELB Pool.

## Example Usage

```terraform
resource "cloudavenue_elb_virtual_service" "example" {
name = "example"
enabled = true

virtual_ip = "192.168.0.1"

pool_id = cloudavenue_elb_pool.example.id
edge_gateway_id = cloudavenue_edgegateway.example.id

service_type = "HTTP"
service_ports = [
{
start = 80
}
]
}
```
-> More examples can be found at the [Advanced Usage](#advanced-usage) section.


<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name of the ELB Virtual Service.
- `service_ports` (Attributes List) The service port of the ELB Virtual Service. The service port is the port on which the virtual service listens for client traffic. (see [below for nested schema](#nestedatt--service_ports))
- `service_type` (String) The type of the service. The different modes that the ELB supports for handling TCP traffic and various parameters that can be tuned for optimization of the TCP traffic are also detailed here. Value must be one of : `HTTP`, `HTTPS`, `L4_TCP`, `L4_UDP`, `L4_TLS`.
- `virtual_ip` (String) The virtual IP address of the ELB Virtual Service.

-> The `virtual_ip` accept a private IP in your network range or a public IP (Warning: the public IP must be reserved and not used by any other service). The value must be a valid IPV4 address (`192.168.0.1`).

### Optional

- `certificate_id` (String) The ID of the certificate. The certificate must be uploaded to your certificate library before it can be used. The certificate MUSTN'T be expired. If the value of [`<.service_type`](#<.service_type) attribute is one of `L4_TLS` or `HTTPS` this attribute is **REQUIRED**. If the value of [`<.service_type`](#<.service_type) attribute is one of `HTTP`, `L4_TCP` or `L4_UDP` this attribute is **NULL**. This value must start with `urn:vcloud:certificateLibraryItem:`.
- `description` (String) The description of the ELB Virtual Service.
- `edge_gateway_id` (String) (ForceNew) The ID of the edge gateway on which the ELB Virtual Service is to be created. Ensure that one and only one attribute from this collection is set : `edge_gateway_name`, `edge_gateway_id`.
- `edge_gateway_name` (String) (ForceNew) The name of the edge gateway on which the ELB Virtual Service is to be created. Ensure that one and only one attribute from this collection is set : `edge_gateway_name`, `edge_gateway_id`.
- `enabled` (Boolean) Defines if the ELB Virtual Service is enabled. Value defaults to `true`.
- `pool_id` (String) The ID of the ELB Server Pool associated. Ensure that one and only one attribute from this collection is set : `pool_name`, `pool_id`.
- `pool_name` (String) The name of the ELB Server Pool associated. Ensure that one and only one attribute from this collection is set : `pool_name`, `pool_id`.
- `service_engine_group_name` (String) The name of the service Engine Group (Take the first one if not specified).

### Read-Only

- `id` (String) The ID of the ELB virtual service.

<a id="nestedatt--service_ports"></a>
### Nested Schema for `service_ports`

Required:

- `start` (Number) The start port of the service port range or exact port number if `end` is not set. Value must be between 1 and 65535.

Optional:

- `end` (Number) The end port of the service port range. If not specified, only the `start` value is used. Value must be between 1 and 65535.

## Advanced Usage

### Expose TLS service

Use the resource `cloudavenue_org_certificate_library` to reference the certificate used for the HTTPS service.
This example exposes a HTTPS service on the virtual IP `192.168.0.1` on port `443`.

```hcl
resource "cloudavenue_elb_virtual_service" "example_https" {
name = "example"
enabled = true

edge_gateway_id = cloudavenue_edgegateway.example.id
pool_id = cloudavenue_elb_pool.example.id
certificate_id = cloudavenue_org_certificate_library.example.id

virtual_ip = "192.168.0.1"

service_type = "HTTPS" // Use HTTPS or L4_TLS
service_ports = [
{
start = 443
}
]
}
```

### Expose L4 service

This example exposes a L4 TCP service on the virtual IP `192.168.0.1` on port `443`.

```hcl
resource "cloudavenue_elb_virtual_service" "example_https" {
name = "example"
enabled = true

edge_gateway_id = cloudavenue_edgegateway.example.id
pool_id = cloudavenue_elb_pool.example.id

virtual_ip = "192.168.0.1"

service_type = "L4_TCP" // Use L4_TCP or L4_UDP
service_ports = [
{
start = 443
}
]
}
```

### Expose service with public IP

The ELB virtual service require a **dedicated public IP** to expose the service.
If another resource use the same public IP, the ELB virtual service will fail to create.

```hcl
resource "cloudavenue_elb_virtual_service" "example_https" {
name = "example"
enabled = true

edge_gateway_id = cloudavenue_edgegateway.example.id
pool_id = cloudavenue_elb_pool.example.id
virtual_ip = cloudavenue_public_ip.example.public_ip

[...]
}
```

## Import

Import is supported using the following syntax:
```shell
terraform import cloudavenue_elb_virtual_service.example edgeGatewayNameOrID.virtualServiceIDOrName
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data "cloudavenue_elb_virtual_service" "example" {
name = "example"
edge_gateway_id = data.cloudavenue_edgegateway.example.id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import cloudavenue_elb_virtual_service.example edgeGatewayNameOrID.virtualServiceIDOrName
16 changes: 16 additions & 0 deletions examples/resources/cloudavenue_elb_virtual_service/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "cloudavenue_elb_virtual_service" "example" {
name = "example"
enabled = true

virtual_ip = "192.168.0.1"

pool_id = cloudavenue_elb_pool.example.id
edge_gateway_id = cloudavenue_edgegateway.example.id

service_type = "HTTP"
service_ports = [
{
start = 80
}
]
}
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ toolchain go1.23.3
require (
github.com/FrangipaneTeam/terraform-analytic-tool v0.0.12
github.com/aws/aws-sdk-go v1.55.6
github.com/cilium/fake v0.7.0
github.com/drhodes/golorem v0.0.0-20220328165741-da82e5b29246
github.com/google/uuid v1.6.0
github.com/hashicorp/aws-sdk-go-base v1.1.0
Expand All @@ -17,10 +18,10 @@ require (
github.com/hashicorp/terraform-plugin-framework-validators v0.16.0
github.com/hashicorp/terraform-plugin-go v0.26.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.36.0
github.com/iancoleman/strcase v0.3.0
github.com/madflojo/testcerts v1.4.0
github.com/orange-cloudavenue/cloudavenue-sdk-go v0.21.4-0.20250207103134-f809a9e41443
github.com/orange-cloudavenue/cloudavenue-sdk-go v0.22.0
github.com/orange-cloudavenue/common-go/print v0.0.0-20250109171729-2be550d5d3ac
github.com/orange-cloudavenue/common-go/utils v0.0.0-20240119163616-66b473d92339
github.com/orange-cloudavenue/terraform-plugin-framework-planmodifiers v1.4.0
Expand All @@ -41,7 +42,7 @@ require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
github.com/ProtonMail/go-crypto v1.1.3 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
Expand Down Expand Up @@ -78,11 +79,11 @@ require (
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hc-install v0.9.0 // indirect
github.com/hashicorp/hcl/v2 v2.22.0 // indirect
github.com/hashicorp/hc-install v0.9.1 // indirect
github.com/hashicorp/hcl/v2 v2.23.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.23.0 // indirect
github.com/hashicorp/terraform-exec v0.22.0 // indirect
github.com/hashicorp/terraform-json v0.24.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.4 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
Expand Down Expand Up @@ -116,7 +117,7 @@ require (
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/yuin/goldmark v1.7.7 // indirect
github.com/yuin/goldmark-meta v1.1.0 // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
github.com/zclconf/go-cty v1.16.2 // indirect
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/mod v0.22.0 // indirect
Expand All @@ -128,7 +129,6 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/grpc v1.69.4 // indirect
google.golang.org/protobuf v1.36.3 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading
Loading