Skip to content

Commit

Permalink
docs: add docs for PCG IPAM pool and the data resource (#514)
Browse files Browse the repository at this point in the history
* docs: add docs for PCG IPAM pool and the data resource

* chore: minor example touch up.

* chore: issued go fmt
  • Loading branch information
karl-cardenas-coding authored Sep 13, 2024
1 parent f67d5c0 commit 308d1da
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 37 deletions.
15 changes: 12 additions & 3 deletions docs/data-sources/private_cloud_gateway.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "spectrocloud_private_cloud_gateway Data Source - terraform-provider-spectrocloud"
subcategory: ""
description: |-
A data resource to get the ID or name of Private Cloud Gateway.
---

# spectrocloud_private_cloud_gateway (Data Source)

A data resource to get the ID or name of Private Cloud Gateway.

To learn more about Private Cloud Gateways, review the [Private Cloud Gateway](https://docs.spectrocloud.com/clusters/pcg/) documentation.

## Example Usage


```hcl
data "spectrocloud_private_cloud_gateway" "pcg" {
name = "wst-1-pcg"
}
```

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

### Optional

- `id` (String) The ID of Private Cloud Gateway.
- `name` (String) The Name of Private Cloud Gateway.
- `name` (String) The name of Private Cloud Gateway.
67 changes: 53 additions & 14 deletions docs/resources/privatecloudgateway_ippool.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,76 @@
page_title: "spectrocloud_privatecloudgateway_ippool Resource - terraform-provider-spectrocloud"
subcategory: ""
description: |-
A Resource to manage IP pools for Private Cloud Gateway.
---

# spectrocloud_privatecloudgateway_ippool (Resource)


A Resource to manage IP pools for Private Cloud Gateway.

## Example Usage
You can learn more about Private Cloud Gateways IP Pools by revewing the [Create and Manage IPAM Node Pools](https://docs.spectrocloud.com/clusters/pcg/manage-pcg/create-manage-node-pool/) guide.

## Example Usage

An example of creating an IP Pool for a Private Cloud Gateway using a range of IP addresses and restricting the IP Pool to a single cluster.

```hcl
data "spectrocloud_private_cloud_gateway" "pcg" {
name = "wst-1-pcg"
}
resource "spectrocloud_privatecloudgateway_ippool" "ippool" {
gateway = "192.168.1.1"
name = "primary-compute-pool-1"
network_type = "range"
prefix = "24"
private_cloud_gateway_id = data.spectrocloud_private_cloud_gateway.pcg.id
ip_start_range = "192.168.1.10"
ip_end_range = "192.168.1.100"
nameserver_addresses = "192.168.1.8"
restrict_to_single_cluster = true
}
```


An example of creating an IP Pool for a Private Cloud Gateway using a subnet of IP addresses.

```hcl
data "spectrocloud_private_cloud_gateway" "pcg" {
name = "east-3-pcg"
}
resource "spectrocloud_privatecloudgateway_ippool" "ippool" {
gateway = "10.10.192.1"
name = "backup-compute-pool"
network_type = "subnet"
prefix = "24"
subnet_cidr = "10.10.100.0/24"
private_cloud_gateway_id = data.spectrocloud_private_cloud_gateway.pcg.id
nameserver_addresses = "192.168.1.8"
}
```


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

### Required

- `gateway` (String)
- `name` (String)
- `network_type` (String)
- `prefix` (Number)
- `private_cloud_gateway_id` (String)
- `gateway` (String) The network gateway IP address for the IP pool. Typically, this is the default network gateway for the subnet.
- `name` (String) The name of the IP pool.
- `network_type` (String) The type of network for the IP pool. Allowed values are: `range` and `subnet`.
- `prefix` (Number) The prefix of the IP pool provided network range or subnet. For example `24` for a `/24` subnet or a range that falls inside a `24` subnet.
- `private_cloud_gateway_id` (String) The ID of the Private Cloud Gateway.

### Optional

- `ip_end_range` (String)
- `ip_start_range` (String)
- `nameserver_addresses` (Set of String)
- `nameserver_search_suffix` (Set of String)
- `restrict_to_single_cluster` (Boolean)
- `subnet_cidr` (String)
- `ip_end_range` (String) The end IP address of the IP pool. Required if `network_type` is `range`.
- `ip_start_range` (String) The start IP address of the IP pool. Required if `network_type` is `range`.
- `nameserver_addresses` (Set of String) The list of nameserver IP addresses for the IP pool.
- `nameserver_search_suffix` (Set of String) The list of nameserver search suffixes for the IP pool. For example, `example.org`.
- `restrict_to_single_cluster` (Boolean) Restrict the IP pool to a single cluster. If set to `true`, the IP pool is restricted to a single cluster. We recommend setting this to `true` for production environments and creating separate IP pools for each cluster.
- `subnet_cidr` (String) The subnet CIDR of the IP pool. Required if `network_type` is `subnet`.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/data_source_private_cloud_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
func dataSourcePCG() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourcePCGRead,
Description: "A data resource to get the ID or name of Private Cloud Gateway.",

Schema: map[string]*schema.Schema{
"id": {
Expand All @@ -23,7 +24,7 @@ func dataSourcePCG() *schema.Resource {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: "The Name of Private Cloud Gateway.",
Description: "The name of Private Cloud Gateway.",
},
},
}
Expand Down
50 changes: 31 additions & 19 deletions spectrocloud/resource_pcg_ippool.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func resourcePrivateCloudGatewayIpPool() *schema.Resource {
ReadContext: resourceIpPoolRead,
UpdateContext: resourceIpPoolUpdate,
DeleteContext: resourceIpPoolDelete,
Description: "A Resource to manage IP pools for Private Cloud Gateway.",

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Expand All @@ -28,39 +29,47 @@ func resourcePrivateCloudGatewayIpPool() *schema.Resource {
SchemaVersion: 2,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The name of the IP pool.",
},
"private_cloud_gateway_id": {
Type: schema.TypeString,
ForceNew: true,
Required: true,
Type: schema.TypeString,
ForceNew: true,
Required: true,
Description: "The ID of the Private Cloud Gateway.",
},
"network_type": {
Type: schema.TypeString,
Required: true,
ValidateDiagFunc: validateNetworkType,
Description: "The type of network for the IP pool. Allowed values are: `range` and `subnet`.",
},
"ip_start_range": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
Description: "The start IP address of the IP pool. Required if `network_type` is `range`.",
},
"ip_end_range": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
Description: "The end IP address of the IP pool. Required if `network_type` is `range`.",
},
"subnet_cidr": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
Description: "The subnet CIDR of the IP pool. Required if `network_type` is `subnet`.",
},
"prefix": {
Type: schema.TypeInt,
Required: true,
Type: schema.TypeInt,
Required: true,
Description: "The prefix of the IP pool provided network range or subnet. For example `24` for a `/24` subnet or a range that falls inside a `24` subnet.",
},
"gateway": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
Description: "The network gateway IP address for the IP pool. Typically, this is the default network gateway for the subnet.",
},
"nameserver_addresses": {
Type: schema.TypeSet,
Expand All @@ -69,6 +78,7 @@ func resourcePrivateCloudGatewayIpPool() *schema.Resource {
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "The list of nameserver IP addresses for the IP pool.",
},
"nameserver_search_suffix": {
Type: schema.TypeSet,
Expand All @@ -77,11 +87,13 @@ func resourcePrivateCloudGatewayIpPool() *schema.Resource {
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "The list of nameserver search suffixes for the IP pool. For example, `example.org`.",
},
"restrict_to_single_cluster": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Restrict the IP pool to a single cluster. If set to `true`, the IP pool is restricted to a single cluster. We recommend setting this to `true` for production environments and creating separate IP pools for each cluster.",
},
},
}
Expand Down
24 changes: 24 additions & 0 deletions templates/data-sources/private_cloud_gateway.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}"
subcategory: ""
description: |-
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
---

# {{.Name}} ({{.Type}})

{{ .Description | plainmarkdown | trimspace | prefixlines " " }}

To learn more about Private Cloud Gateways, review the [Private Cloud Gateway](https://docs.spectrocloud.com/clusters/pcg/) documentation.

## Example Usage


```hcl
data "spectrocloud_private_cloud_gateway" "pcg" {
name = "wst-1-pcg"
}

```

{{ .SchemaMarkdown | trimspace }}
39 changes: 39 additions & 0 deletions templates/resources/privatecloudgateway_ippool.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,48 @@ description: |-

{{ .Description | plainmarkdown | trimspace | prefixlines " " }}

You can learn more about Private Cloud Gateways IP Pools by revewing the [Create and Manage IPAM Node Pools](https://docs.spectrocloud.com/clusters/pcg/manage-pcg/create-manage-node-pool/) guide.

## Example Usage

An example of creating an IP Pool for a Private Cloud Gateway using a range of IP addresses and restricting the IP Pool to a single cluster.

```hcl
data "spectrocloud_private_cloud_gateway" "pcg" {
name = "wst-1-pcg"
}

resource "spectrocloud_privatecloudgateway_ippool" "ippool" {
gateway = "192.168.1.1"
name = "primary-compute-pool-1"
network_type = "range"
prefix = "24"
private_cloud_gateway_id = data.spectrocloud_private_cloud_gateway.pcg.id
ip_start_range = "192.168.1.10"
ip_end_range = "192.168.1.100"
nameserver_addresses = "192.168.1.8"
restrict_to_single_cluster = true
}
```


An example of creating an IP Pool for a Private Cloud Gateway using a subnet of IP addresses.

```hcl
data "spectrocloud_private_cloud_gateway" "pcg" {
name = "east-3-pcg"
}

resource "spectrocloud_privatecloudgateway_ippool" "ippool" {
gateway = "10.10.192.1"
name = "backup-compute-pool"
network_type = "subnet"
prefix = "24"
subnet_cidr = "10.10.100.0/24"
private_cloud_gateway_id = data.spectrocloud_private_cloud_gateway.pcg.id
nameserver_addresses = "192.168.1.8"
}
```


{{ .SchemaMarkdown | trimspace }}

0 comments on commit 308d1da

Please sign in to comment.