Skip to content

Commit d1d0331

Browse files
Add linode_database_mysql_v2 resource (#1701)
* Implement linode_database_mysql_v2 resource * Correct example * Reorder updates field handling in creation
1 parent 618a842 commit d1d0331

File tree

14 files changed

+1816
-4
lines changed

14 files changed

+1816
-4
lines changed

.github/workflows/integration_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
echo "LINODE_TOKEN=${{ secrets.LINODE_TOKEN_USER_1 }}" >> $GITHUB_ENV
4747
;;
4848
"USER_2")
49-
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
49+
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
5050
echo "LINODE_TOKEN=${{ secrets.LINODE_TOKEN_USER_2 }}" >> $GITHUB_ENV
5151
;;
5252
"USER_3")
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
page_title: "Linode: linode_database_mysql_v2"
3+
description: |-
4+
Manages a Linode MySQL Database.
5+
---
6+
7+
# linode\_database\_mysql\_v2
8+
9+
Provides a Linode MySQL Database resource. This can be used to create, modify, and delete Linode MySQL Databases.
10+
For more information, see the [Linode APIv4 docs](https://techdocs.akamai.com/linode-api/reference/post-databases-mysql-instances).
11+
12+
Please keep in mind that Managed Databases can take up to half an hour to provision.
13+
14+
## Example Usage
15+
16+
Creating a simple MySQL database that does not allow connections:
17+
18+
```hcl
19+
resource "linode_database_mysql_v2" "foobar" {
20+
label = "mydatabase"
21+
engine_id = "mysql/8"
22+
region = "us-mia"
23+
type = "g6-nanode-1"
24+
}
25+
```
26+
27+
Creating a simple MySQL database that allows connections from all IPv4 addresses:
28+
29+
```hcl
30+
resource "linode_database_mysql_v2" "foobar" {
31+
label = "mydatabase"
32+
engine_id = "mysql/8"
33+
region = "us-mia"
34+
type = "g6-nanode-1"
35+
36+
allowed_ips = ["0.0.0.0/0"]
37+
}
38+
```
39+
40+
Creating a complex MySQL database:
41+
42+
```hcl
43+
resource "linode_database_mysql_v2" "foobar" {
44+
label = "mydatabase"
45+
engine_id = "mysql/8"
46+
region = "us-mia"
47+
type = "g6-nanode-1"
48+
49+
allow_list = ["10.0.0.3/32"]
50+
cluster_size = 3
51+
52+
updates = {
53+
duration = 4
54+
frequency = "weekly"
55+
hour_of_day = 22
56+
day_of_week = 3
57+
}
58+
}
59+
```
60+
61+
Creating a forked MySQL database:
62+
63+
```hcl
64+
resource "linode_database_mysql_v2" "foobar" {
65+
label = "mydatabase"
66+
engine_id = "mysql/8"
67+
region = "us-mia"
68+
type = "g6-nanode-1"
69+
70+
fork_source = 12345
71+
}
72+
```
73+
74+
## Argument Reference
75+
76+
The following arguments are supported:
77+
78+
* `engine_id` - (Required) The Managed Database engine in engine/version format. (e.g. `mysql`)
79+
80+
* `label` - (Required) A unique, user-defined string referring to the Managed Database.
81+
82+
* `region` - (Required) The region to use for the Managed Database.
83+
84+
* `type` - (Required) The Linode Instance type used for the nodes of the Managed Database.
85+
86+
- - -
87+
88+
* `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.
89+
90+
* `cluster_size` - (Optional) The number of Linode Instance nodes deployed to the Managed Database. (default `1`)
91+
92+
* `fork_restore_time` - (Optional) The database timestamp from which it was restored.
93+
94+
* `fork_source` - (Optional) The ID of the database that was forked from.
95+
96+
* [`updates`](#updates) - (Optional) Configuration settings for automated patch update maintenance for the Managed Database.
97+
98+
## Attributes Reference
99+
100+
In addition to all arguments above, the following attributes are exported:
101+
102+
* `id` - The ID of the Managed Database.
103+
104+
* `ca_cert` - The base64-encoded SSL CA certificate for the Managed Database.
105+
106+
* `created` - When this Managed Database was created.
107+
108+
* `encrypted` - Whether the Managed Databases is encrypted.
109+
110+
* `engine` - The Managed Database engine. (e.g. `mysql`)
111+
112+
* `host_primary` - The primary host for the Managed Database.
113+
114+
* `host_secondary` - The secondary/private host for the managed database.
115+
116+
* `pending_updates` - A set of pending updates.
117+
118+
* `platform` - The back-end platform for relational databases used by the service.
119+
120+
* `port` - The access port for this Managed Database.
121+
122+
* `root_password` - The randomly-generated root password for the Managed Database instance.
123+
124+
* `root_username` - The root username for the Managed Database instance.
125+
126+
* `ssl_connection` - Whether to require SSL credentials to establish a connection to the Managed Database.
127+
128+
* `status` - The operating status of the Managed Database.
129+
130+
* `updated` - When this Managed Database was last updated.
131+
132+
* `version` - The Managed Database engine version. (e.g. `13.2`)
133+
134+
## pending_updates
135+
136+
The following arguments are exposed by each entry in the `pending_updates` attribute:
137+
138+
* `deadline` - The time when a mandatory update needs to be applied.
139+
140+
* `description` - A description of the update.
141+
142+
* `planned_for` - The date and time a maintenance update will be applied.
143+
144+
## updates
145+
146+
The following arguments are supported in the `updates` specification block:
147+
148+
* `day_of_week` - (Required) The day to perform maintenance. (`monday`, `tuesday`, ...)
149+
150+
* `duration` - (Required) The maximum maintenance window time in hours. (`1`..`3`)
151+
152+
* `frequency` - (Required) Whether maintenance occurs on a weekly or monthly basis. (`weekly`, `monthly`)
153+
154+
* `hour_of_day` - (Required) The hour to begin maintenance based in UTC time. (`0`..`23`)
155+
156+
* `week_of_month` - (Optional) The week of the month to perform monthly frequency updates. Required for `monthly` frequency updates. (`1`..`4`)
157+
158+
## Import
159+
160+
Linode MySQL Databases can be imported using the `id`, e.g.
161+
162+
```sh
163+
terraform import linode_database_mysql_v2.foobar 1234567
164+
```

linode/databaseaccesscontrols/resource_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ func init() {
5353
}
5454

5555
func TestAccResourceDatabaseAccessControls_MySQL(t *testing.T) {
56-
acceptance.LongRunningTest(t)
5756
t.Parallel()
5857

5958
resName := "linode_database_access_controls.foobar"

linode/databaseaccesscontrols/tmpl/mysql.gotf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{{ define "database_access_controls_mysql" }}
22

3-
resource "linode_database_mysql" "foobar" {
3+
resource "linode_database_mysql_v2" "foobar" {
44
engine_id = "{{.Engine}}"
55
label = "{{.Label}}"
66
region = "{{ .Region }}"
77
type = "g6-nanode-1"
88
}
99

1010
resource "linode_database_access_controls" "foobar" {
11-
database_id = linode_database_mysql.foobar.id
11+
database_id = linode_database_mysql_v2.foobar.id
1212
database_type = "mysql"
1313

1414
allow_list = ["{{.AllowedIP}}"]

0 commit comments

Comments
 (0)