Skip to content

Commit

Permalink
fix: nfs nitpicks (#642)
Browse files Browse the repository at this point in the history
* doc nitpicks

* remove additional minversion check

* make fmt

* add basic example

* add basic setup for share example
  • Loading branch information
glimberea authored Aug 26, 2024
1 parent 7aabd4f commit f105b5a
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 8 deletions.
49 changes: 45 additions & 4 deletions docs/resources/nfs_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,41 @@ Create clusters of Network File Storage (NFS) on IonosCloud.
## Example Usage

```hcl
# Basic example
resource "ionoscloud_datacenter" "nfs_dc" {
name = "NFS Datacenter"
location = "de/txl"
description = "Datacenter Description"
sec_auth_protection = false
}
resource "ionoscloud_lan" "nfs_lan" {
datacenter_id = ionoscloud_datacenter.nfs_dc.id
public = false
name = "Lan for NFS"
}
resource "ionoscloud_nfs_cluster" "example" {
name = "test"
location = "de/txl"
size = 2
nfs {
min_version = "4.2"
}
connections {
datacenter_id = ionoscloud_datacenter.nfs_dc.id
ip_address = "192.168.100.10/24"
lan = ionoscloud_lan.nfs_lan.id
}
}
```

```hcl
# Complete example
resource "ionoscloud_datacenter" "nfs_dc" {
name = "NFS Datacenter"
location = "de/txl"
Expand Down Expand Up @@ -62,6 +97,12 @@ resource "ionoscloud_server" "nfs_server" {
}
}
locals {
nfs_server_cidr = format("%s/24", ionoscloud_server.nfs_server.nic[0].ips[0])
nfs_cluster_ip = cidrhost(local.nfs_server_cidr, 10)
nfs_cluster_cidr = format("%s/24", local.nfs_cluster_ip)
}
resource "ionoscloud_nfs_cluster" "example" {
name = "test"
location = "de/txl"
Expand All @@ -73,7 +114,7 @@ resource "ionoscloud_nfs_cluster" "example" {
connections {
datacenter_id = ionoscloud_datacenter.nfs_dc.id
ip_address = format("%s/24", ionoscloud_server.nfs_server.nic[0].ips[0])
ip_address = local.nfs_cluster_cidr
lan = ionoscloud_lan.nfs_lan.id
}
}
Expand All @@ -89,8 +130,8 @@ The following arguments are supported:
- `de/txl` - Berlin
- `size` - (Required) The size of the Network File Storage cluster in TiB. Note that the cluster size cannot be reduced after provisioning. This value determines the billing fees. Default is `2`. The minimum value is `2` and the maximum value is `42`.
- `nfs` - (Optional) The NFS configuration for the Network File Storage cluster. Each NFS configuration supports the following:
- `min_version` - (Optional) The minimum supported version of the NFS cluster. Default is `4.2`
- `connections` - (Required) A list of connections for the Network File Storage cluster. You can specify only one connection. Each connection supports the following:
- `min_version` - (Optional) The minimum supported version of the NFS cluster. Supported values: `4.2`. Default is `4.2`.
- `connections` - (Required) A list of connections for the Network File Storage cluster. You can specify only one connection. Connections are **immutable**. Each connection supports the following:
- `datacenter_id` - (Required) The ID of the datacenter where the Network File Storage cluster is located.
- `ip_address` - (Required) The IP address and prefix of the Network File Storage cluster. The IP address can be either IPv4 or IPv6. The IP address has to be given with CIDR notation.
- `lan` - (Required) The Private LAN to which the Network File Storage cluster must be connected.
Expand All @@ -101,4 +142,4 @@ A Network File Storage Cluster resource can be imported using its `location` and

```shell
terraform import ionoscloud_nfs_cluster.name {location}:{uuid}
```
```
35 changes: 33 additions & 2 deletions docs/resources/nfs_share.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,39 @@ Creates and manages Network File Storage (NFS) Share objects on IonosCloud.
## Example Usage

```hcl
# Basic example
resource "ionoscloud_datacenter" "nfs_dc" {
name = "NFS Datacenter"
location = "de/txl"
description = "Datacenter Description"
sec_auth_protection = false
}
resource "ionoscloud_lan" "nfs_lan" {
datacenter_id = ionoscloud_datacenter.nfs_dc.id
public = false
name = "Lan for NFS"
}
resource "ionoscloud_nfs_cluster" "example" {
name = "test"
location = "de/txl"
size = 2
nfs {
min_version = "4.2"
}
connections {
datacenter_id = ionoscloud_datacenter.nfs_dc.id
ip_address = "192.168.100.10/24"
lan = ionoscloud_lan.nfs_lan.id
}
}
resource "ionoscloud_nfs_share" "example" {
location = ionoscloud_nfs_cluster.example.location
location = "de/txl"
cluster_id = ionoscloud_nfs_cluster.example.id
name = "example-share"
Expand Down Expand Up @@ -62,4 +93,4 @@ A Network File Storage Share resource can be imported using its `location`, `clu

```shell
terraform import ionoscloud_nfs_share.name location:cluster_id:resource_id
```
```
6 changes: 4 additions & 2 deletions ionoscloud/resource_nfs_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ func resourceNFSCluster() *schema.Resource {
Schema: map[string]*schema.Schema{
"location": {
Type: schema.TypeString,
Description: fmt.Sprintf("The location of the Network File Storage Cluster. "+
"Available locations: '%s'", strings.Join(nfs.ValidNFSLocations, ", '")),
Description: fmt.Sprintf(
"The location of the Network File Storage Cluster. "+
"Available locations: '%s'", strings.Join(nfs.ValidNFSLocations, ", '"),
),
Required: true,
ForceNew: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(nfs.ValidNFSLocations, false)),
Expand Down

0 comments on commit f105b5a

Please sign in to comment.