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

Add linode_database_mysql_v2 resource #1701

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
echo "LINODE_TOKEN=${{ secrets.LINODE_TOKEN_USER_1 }}" >> $GITHUB_ENV
;;
"USER_2")
echo "TEST_TAGS=firewall,firewalldevice,firewalls,image,images,instancenetworking,instancesharedips,instancetype,instancetypes,ipv6range,ipv6ranges,kernel,kernels,nb,nbconfig,nbconfigs,nbnode,nbs,sshkey,sshkeys,vlan,volume,volumes,vpc,vpcs,vpcsubnets" >> $GITHUB_ENV
echo "TEST_TAGS=databasemysqlv2,firewall,firewalldevice,firewalls,image,images,instancenetworking,instancesharedips,instancetype,instancetypes,ipv6range,ipv6ranges,kernel,kernels,nb,nbconfig,nbconfigs,nbnode,nbs,sshkey,sshkeys,vlan,volume,volumes,vpc,vpcs,vpcsubnets" >> $GITHUB_ENV
echo "LINODE_TOKEN=${{ secrets.LINODE_TOKEN_USER_2 }}" >> $GITHUB_ENV
;;
"USER_3")
Expand Down
164 changes: 164 additions & 0 deletions docs/resources/database_mysql_v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
---
page_title: "Linode: linode_database_mysql_v2"
description: |-
Manages a Linode MySQL Database.
---

# linode\_database\_mysql\_v2

Provides a Linode MySQL Database resource. This can be used to create, modify, and delete Linode MySQL Databases.
For more information, see the [Linode APIv4 docs](https://techdocs.akamai.com/linode-api/reference/post-databases-mysql-instances).

Please keep in mind that Managed Databases can take up to half an hour to provision.

## Example Usage

Creating a simple MySQL database that does not allow connections:

```hcl
resource "linode_database_mysql_v2" "foobar" {
label = "mydatabase"
engine_id = "mysql/8"
region = "us-mia"
type = "g6-nanode-1"
}
```

Creating a simple MySQL database that allows connections from all IPv4 addresses:

```hcl
resource "linode_database_mysql_v2" "foobar" {
label = "mydatabase"
engine_id = "mysql/8"
region = "us-mia"
type = "g6-nanode-1"

allowed_ips = ["0.0.0.0/0"]
}
```

Creating a complex MySQL database:

```hcl
resource "linode_database_mysql_v2" "foobar" {
label = "mydatabase"
engine_id = "mysql/8"
region = "us-mia"
type = "g6-nanode-1"

allow_list = ["10.0.0.3/32"]
cluster_size = 3

updates = {
duration = 4
frequency = "weekly"
hour_of_day = 22
day_of_week = 3
}
}
```

Creating a forked MySQL database:

```hcl
resource "linode_database_mysql_v2" "foobar" {
label = "mydatabase"
engine_id = "mysql/8"
region = "us-mia"
type = "g6-nanode-1"

fork_source = 12345
}
```

## Argument Reference

The following arguments are supported:

* `engine_id` - (Required) The Managed Database engine in engine/version format. (e.g. `mysql`)

* `label` - (Required) A unique, user-defined string referring to the Managed Database.

* `region` - (Required) The region to use for the Managed Database.

* `type` - (Required) The Linode Instance type used for the nodes of the Managed Database.

- - -

* `allow_list` - (Optional) A list of IP addresses that can access the Managed Database. Each item can be a single IP address or a range in CIDR format. Use `linode_database_access_controls` to manage your allow list separately.

* `cluster_size` - (Optional) The number of Linode Instance nodes deployed to the Managed Database. (default `1`)

* `fork_restore_time` - (Optional) The database timestamp from which it was restored.

* `fork_source` - (Optional) The ID of the database that was forked from.

* [`updates`](#updates) - (Optional) Configuration settings for automated patch update maintenance for the Managed Database.

## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `id` - The ID of the Managed Database.

* `ca_cert` - The base64-encoded SSL CA certificate for the Managed Database.

* `created` - When this Managed Database was created.

* `encrypted` - Whether the Managed Databases is encrypted.

* `engine` - The Managed Database engine. (e.g. `mysql`)

* `host_primary` - The primary host for the Managed Database.

* `host_secondary` - The secondary/private host for the managed database.

* `pending_updates` - A set of pending updates.

* `platform` - The back-end platform for relational databases used by the service.

* `port` - The access port for this Managed Database.

* `root_password` - The randomly-generated root password for the Managed Database instance.

* `root_username` - The root username for the Managed Database instance.

* `ssl_connection` - Whether to require SSL credentials to establish a connection to the Managed Database.

* `status` - The operating status of the Managed Database.

* `updated` - When this Managed Database was last updated.

* `version` - The Managed Database engine version. (e.g. `13.2`)

## pending_updates

The following arguments are exposed by each entry in the `pending_updates` attribute:

* `deadline` - The time when a mandatory update needs to be applied.

* `description` - A description of the update.

* `planned_for` - The date and time a maintenance update will be applied.

## updates

The following arguments are supported in the `updates` specification block:

* `day_of_week` - (Required) The day to perform maintenance. (`monday`, `tuesday`, ...)

* `duration` - (Required) The maximum maintenance window time in hours. (`1`..`3`)

* `frequency` - (Required) Whether maintenance occurs on a weekly or monthly basis. (`weekly`, `monthly`)

* `hour_of_day` - (Required) The hour to begin maintenance based in UTC time. (`0`..`23`)

* `week_of_month` - (Optional) The week of the month to perform monthly frequency updates. Required for `monthly` frequency updates. (`1`..`4`)

## Import

Linode MySQL Databases can be imported using the `id`, e.g.

```sh
terraform import linode_database_mysql_v2.foobar 1234567
```
1 change: 0 additions & 1 deletion linode/databaseaccesscontrols/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func init() {
}

func TestAccResourceDatabaseAccessControls_MySQL(t *testing.T) {
acceptance.LongRunningTest(t)
t.Parallel()

resName := "linode_database_access_controls.foobar"
Expand Down
4 changes: 2 additions & 2 deletions linode/databaseaccesscontrols/tmpl/mysql.gotf
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{{ define "database_access_controls_mysql" }}

resource "linode_database_mysql" "foobar" {
resource "linode_database_mysql_v2" "foobar" {
engine_id = "{{.Engine}}"
label = "{{.Label}}"
region = "{{ .Region }}"
type = "g6-nanode-1"
}

resource "linode_database_access_controls" "foobar" {
database_id = linode_database_mysql.foobar.id
database_id = linode_database_mysql_v2.foobar.id
database_type = "mysql"

allow_list = ["{{.AllowedIP}}"]
Expand Down
Loading
Loading