Skip to content

Commit

Permalink
feat: Add InMemoryDB resources and data sources (#564)
Browse files Browse the repository at this point in the history
* add client

* doc: remove Required/Optional datasource

* doc: required location

* test: Add tests for replica set resource

* feat: Add data source for Snapshots, add documentation, fix version in user agent

* test: Fix 500 error for tests, use constant for time layout

* refactor: Use the recently released SDK

* doc: Add docs references in 'summary.md'

* refactor: Resolve linter errors

---------

Co-authored-by: Alexandru Claudius Virtopeanu <[email protected]>
  • Loading branch information
adeatcu-ionos and avirtopeanu-ionos authored Aug 1, 2024
1 parent f36ad00 commit 35ebe52
Show file tree
Hide file tree
Showing 69 changed files with 15,781 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Add new attributes `central_logging` and `logging_format` to `application_loadbalancer` resource and data source
- Add support for Event Streams for Apache Kafka
- Add support for Certificate Manager providers and auto-certificates
- Add support for In-Memory DB
- Add support for API Gateway
- Add support for VPN Gateway

Expand Down
73 changes: 73 additions & 0 deletions docs/data-sources/dbaas_inmemorydb_replica_set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
subcategory: "Database as a Service - InMemoryDB"
layout: "ionoscloud"
page_title: "IonosCloud: ionoscloud_inmemorydb_replicaset"
sidebar_current: "docs-datasource-inmemorydb_replicaset"
description: |-
Gets information about an existing InMemoryDB Replica Set.
---

# ionoscloud_inmemorydb_replicaset

The `ionoscloud_inmemorydb_replicaset` data source can be used to retrieve information about an existing InMemoryDB Replica Set.

## Example Usage

### By id
```hcl
data "ionoscloud_inmemorydb_replicaset" "example" {
id = "example-id"
location = "es/vit"
}
```

### By display_name
```hcl
data "ionoscloud_inmemorydb_replicaset" "example" {
display_name = "example-id"
location = "us/las"
}
```

## Argument Reference

* `id` - (Optional) The ID of the InMemoryDB Replica Set.
* `display_name` - (Optional) The display name of the InMemoryDB Replica Set.
* `location` - (Required) The location of the InMemoryDB Replica Set.

> **Note:** Either `id` or `display_name` must be provided. If none, or both are provided, the datasource will return an error.
## Attributes Reference

The following attributes are returned by the datasource:

* `dns_name` - [string] The DNS name pointing to your replica set. Will be used to connect to the active/standalone instance.
* `connections` - [object] The network connection for your replica set. Only one connection is allowed. It includes:
* `cidr` - [string] The IP and subnet for your instance. Note the following unavailable IP ranges: 10.233.64.0/18, 10.233.0.0/18, 10.233.114.0/24.
* `datacenter_id` - [string] The datacenter to connect your instance to.
* `lan_id` - [string] The numeric LAN ID to connect your instance to.
* `credentials` - [object] Credentials for the InMemoryDB replicaset, only one type of password can be used since they are mutually exclusive. It includes:
* `username` - [string] The username for the initial InMemoryDB user. Some system usernames are restricted (e.g. 'admin', 'standby').
* `eviction_policy` - [string] The eviction policy for the replica set, possible values are:
* `noeviction` - No eviction policy is used. InMemoryDB will never remove any data. If the memory limit is reached, an error will be returned on write operations.
* `allkeys-lru` - The least recently used keys will be removed first.
* `allkeys-lfu` - The least frequently used keys will be removed first.
* `allkeys-random` - Random keys will be removed.
* `volatile-lru` - The least recently used keys will be removed first, but only among keys with the `expire` field set to `true`.
* `volatile-lfu` - The least frequently used keys will be removed first, but only among keys with the `expire` field set to `true`.
* `volatile-random` - Random keys will be removed, but only among keys with the `expire` field set to `true`.
* `volatile-ttl` - The key with the nearest time to live will be removed first, but only among keys with the `expire` field set to `true`.
* `maintenance_window` - A weekly 4 hour-long window, during which maintenance might occur. It includes:
* `time` - [string] Start of the maintenance window in UTC time.
* `day_of_the_week` - [string] The name of the week day.
* `persistence_mode` - [string] Specifies How and If data is persisted, possible values are:
* `None` - Data is inMemory only and will not be persisted. Useful for cache only applications.
* `AOF` - (Append Only File) AOF persistence logs every write operation received by the server. These operations can then be replayed again at server startup, reconstructing the original dataset. Commands are logged using the same format as the InMemoryDB protocol itself.
* `RDB` - RDB persistence performs snapshots of the current in memory state.
* `RDB_AOF` - Both, RDB and AOF persistence are enabled.
* `version` - [string] The InMemoryDB version of your replica set.
* `replicas` - [int] The total number of replicas in the replica set (one active and n-1 passive). In case of a standalone instance, the value is 1. In all other cases, the value is > 1. The replicas will not be available as read replicas, they are only standby for a failure of the active instance.
* `resources` - [object] The resources of the individual replicas. It includes:
* `cores` - [int] The number of CPU cores per instance.
* `ram` - [int] The amount of memory per instance in gigabytes (GB).
* `storage` - [int] The size of the storage in GB. The size is derived from the amount of RAM and the persistence mode and is not configurable.
35 changes: 35 additions & 0 deletions docs/data-sources/dbaas_inmemorydb_snapshot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
subcategory: "Database as a Service - InMemoryDB"
layout: "ionoscloud"
page_title: "IonosCloud: ionoscloud_inmemorydb_snapshot"
sidebar_current: "docs-datasource-inmemorydb_snapshot"
description: |-
Gets information about an existing InMemoryDB Snapshot.
---

# ionoscloud_inmemorydb_snapshot

The `ionoscloud_inmemorydb_snapshot` data source can be used to retrieve information about an existing InMemoryDB Snapshot.

## Example Usage

```hcl
data "ionoscloud_inmemorydb_snapshot" "example" {
id = "snapshot-id"
location = "de/txl"
}
```

## Argument Reference

* `id` - (Required) The ID of the InMemoryDB Snapshot.
* `location` - (Required) The location of the InMemoryDB Snapshot.

## Attributes Reference

* `metadata` - Metadata of the snapshot.
* `created_date` - The ISO 8601 creation timestamp.
* `datacenter_id` - The ID of the datacenter in which the snapshot is located.
* `last_modified_date` - The ISO 8601 modified timestamp.
* `replica_set_id` - The ID of the replica set from which the snapshot was created.
* `snapshot_time` - The time at which the snapshot was taken.
128 changes: 128 additions & 0 deletions docs/resources/dbaas_inmemorydb_replica_set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
subcategory: "Database as a Service - InMemoryDB"
layout: "ionoscloud"
page_title: "IonosCloud: ionoscloud_inmemorydb_replicaset"
sidebar_current: "docs-resource-inmemorydb_replicaset"
description: |-
Creates and manages DBaaS InMemoryDB Replica Set objects.
---

# ionoscloud_inmemorydb_replicaset

Manages a **DBaaS InMemoryDB Replica Set**.

## Example Usage

```hcl
resource "ionoscloud_datacenter" "example" {
name = "example"
location = "de/txl"
description = "Datacenter for DBaaS InMemoryDB replica sets"
}
resource "ionoscloud_lan" "example" {
datacenter_id = ionoscloud_datacenter.example.id
public = false
name = "example"
}
resource "ionoscloud_server" "example" {
name = "example"
datacenter_id = ionoscloud_datacenter.example.id
cores = 2
ram = 2048
availability_zone = "ZONE_1"
cpu_family = "INTEL_SKYLAKE"
image_name = "rockylinux-8-GenericCloud-20230518"
image_password = "password"
volume {
name = "example"
size = 6
disk_type = "SSD Standard"
}
nic {
lan = ionoscloud_lan.example.id
name = "example"
dhcp = true
}
}
locals {
prefix = format("%s/%s", ionoscloud_server.example.nic[0].ips[0], "24")
database_ip = cidrhost(local.prefix, 1)
database_ip_cidr = format("%s/%s", local.database_ip, "24")
}
resource "ionoscloud_inmemorydb_replicaset" "example" {
location = ionoscloud_datacenter.example.location
display_name = "ExampleReplicaSet"
version = "7.2"
replicas = 4
resources {
cores = 1
ram = 6
}
persistence_mode = "RDB"
eviction_policy = "noeviction"
connections {
datacenter_id = ionoscloud_datacenter.example.id
lan_id = ionoscloud_lan.example.id
cidr = local.database_ip_cidr
}
maintenance_window {
day_of_the_week = "Monday"
time = "10:00:00"
}
credentials {
username = "myuser"
plain_text_password = "testpassword"
}
}
```

## Argument Reference
* `display_name` - (Required)[string] The human readable name of your replica set.
* `location` - (Required)[string] The location of your replica set. Updates to the value of the field force the replica set to be re-created.
* `version` - (Required)[string] The InMemoryDB version of your replica set.
* `replicas` - (Required)[int] The total number of replicas in the replica set (one active and n-1 passive). In case of a standalone instance, the value is 1. In all other cases, the value is > 1. The replicas will not be available as read replicas, they are only standby for a failure of the active instance.
* `resources` - (Required)[object] The resources of the individual replicas.
* `cores` - (Required)[int] The number of CPU cores per instance.
* `ram` - (Required)[int] The amount of memory per instance in gigabytes (GB).
* `storage` - (Computed)[int] The size of the storage in GB. The size is derived from the amount of RAM and the persistence mode and is not configurable.
* `persistence_mode` - (Required)[string] Specifies How and If data is persisted, possible values are:
* `None` - Data is inMemory only and will not be persisted. Useful for cache only applications.
* `AOF` - (Append Only File) AOF persistence logs every write operation received by the server. These operations can then be replayed again at server startup, reconstructing the original dataset. Commands are logged using the same format as the InMemoryDB protocol itself.
* `RDB` - RDB persistence performs snapshots of the current in memory state.
* `RDB_AOF` - Booth, RDB and AOF persistence are enabled.
* `eviction_policy` - (Required)[string] The eviction policy for the replica set, possible values are:
* `noeviction` - No eviction policy is used. InMemoryDB will never remove any data. If the memory limit is reached, an error will be returned on write operations.
* `allkeys-lru` - The least recently used keys will be removed first.
* `allkeys-lfu` - The least frequently used keys will be removed first.
* `allkeys-random` - Random keys will be removed.
* `volatile-lru` - The least recently used keys will be removed first, but only among keys with the `expire` field set to `true`.
* `volatile-lfu` - The least frequently used keys will be removed first, but only among keys with the `expire` field set to `true`.
* `volatile-random` - Random keys will be removed, but only among keys with the `expire` field set to `true`.
* `volatile-ttl` - The key with the nearest time to live will be removed first, but only among keys with the `expire` field set to `true`.
* `connections` - (Required)[object] The network connection for your replica set. Only one connection is allowed.
* `datacenter_id` - (Required)[string] The datacenter to connect your instance to.
* `lan_id` - (Required)[string] The numeric LAN ID to connect your instance to.
* `cidr` - (Required)[string] The IP and subnet for your instance. Note the following unavailable IP ranges: 10.233.64.0/18, 10.233.0.0/18, 10.233.114.0/24.
* `credentials` - (Required)[object] Credentials for the InMemoryDB replicaset, only one type of password can be used since they are mutually exclusive
* `username` - (Required)[string] The username for the initial InMemoryDB user. Some system usernames are restricted (e.g. 'admin', 'standby').
* `plain_text_password` - (Optional)[string] The password for a InMemoryDB user, this is a field that is marked as `Sensitive`.
* `hashed_password` - (Optional)[object] The hashed password for a InMemoryDB user.
* `algorithm` - (Required)[string] The value can be only: "SHA-256".
* `hash` - (Required)[string] The hashed password.
* `maintenance_window` - (Optional)(Computed) A weekly 4 hour-long window, during which maintenance might occur.
* `time` - (Required)[string] Start of the maintenance window in UTC time.
* `day_of_the_week` - (Required)[string] The name of the week day.
* `initial_snapshot_id` - (Optional)[string] The ID of a snapshot to restore the replica set from. If set, the replica set will be created from the snapshot.
* `dns_name` - (Computed)[string] The DNS name pointing to your replica set. Will be used to connect to the active/standalone instance.

## Import

Resource DBaaS InMemoryDB Replica Set can be imported using the `replicaset_id` and the `location`, separated by `:`, e.g:

```shell
terraform import ionoscloud_inmemorydb_replicaset.example {location}:{replicaSet UUID}
```
7 changes: 7 additions & 0 deletions gitbook_docs/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@
* [DBaaS MongoDB Cluster](../docs/data-sources/dbaas_mariadb_cluster.md)
* [DBaaS MongoDB Backups](../docs/data-sources/dbaas_mariadb_backups.md)

* Database as a Service - InMemory-DB
* Resources
* [DBaaS InMemoryDB ReplicaSet](../docs/resources/dbaas_inmemorydb_replica_set.md)
* Data sources
* [DBaaS InMemoryDB ReplicaSet](../docs/data-sources/dbaas_inmemorydb_replica_set.md)
* [DBaaS InMemoryDB Snapshot](../docs/data-sources/dbaas_inmemorydb_snapshot.md)

* Application Load Balancer
* Resources
* [Application Load Balancer](../docs/resources/application_loadbalancer.md)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/ionos-cloud/sdk-go-cert-manager v1.1.0
github.com/ionos-cloud/sdk-go-container-registry v1.2.0
github.com/ionos-cloud/sdk-go-dataplatform v1.0.3
github.com/ionos-cloud/sdk-go-dbaas-in-memory-db v1.0.1
github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.0.1
github.com/ionos-cloud/sdk-go-dbaas-mongo v1.3.1
github.com/ionos-cloud/sdk-go-dbaas-postgres v1.1.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ github.com/ionos-cloud/sdk-go-container-registry v1.2.0 h1:C5r2XleKLbSFw9kmb4N8I
github.com/ionos-cloud/sdk-go-container-registry v1.2.0/go.mod h1:woBP1+A4N0KXiRj9jG4y/hEXgrVjJv0CUlAvc24mCeo=
github.com/ionos-cloud/sdk-go-dataplatform v1.0.3 h1:eaZITgPaLHbK4d/nVaImvP19a5yAumI5hprjM/B1qSE=
github.com/ionos-cloud/sdk-go-dataplatform v1.0.3/go.mod h1:LXJGnUwLLiJhKgApv7TIPGy7WOuGbYIzBPFxGpNfqN0=
github.com/ionos-cloud/sdk-go-dbaas-in-memory-db v1.0.1 h1:vd3SCqZ1OI5l7Tzql7NDb5Zlpna8e2SsfEYZRGHOkOo=
github.com/ionos-cloud/sdk-go-dbaas-in-memory-db v1.0.1/go.mod h1:JLbyt5wj7+f/njy7pnWD6K+cCfe32p8VrjmKks055+w=
github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.0.1 h1:EBsHfY/Bt7CcSsP7W7ohVsnhFAtMEcil3Aa/Q5MBq/Y=
github.com/ionos-cloud/sdk-go-dbaas-mariadb v1.0.1/go.mod h1:627dsH56YGQD7x0g2FGdVsxNtBySvQ3QU0uG+d6/Evk=
github.com/ionos-cloud/sdk-go-dbaas-mongo v1.3.1 h1:+tDoZ8IEPxYwJd6fDIpWksNJs9Zzw7Pu5A39jTew058=
Expand Down
Loading

0 comments on commit 35ebe52

Please sign in to comment.