|
| 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 | +``` |
0 commit comments