Skip to content

Commit 20f1872

Browse files
author
Weyder Santos
committed
Adicionando modulo do MySQL
1 parent c84a90f commit 20f1872

File tree

10 files changed

+128
-0
lines changed

10 files changed

+128
-0
lines changed

mysql/databases/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resource "mysql_database" "mdb" {
2+
name = var.name
3+
default_character_set = var.default_character_set
4+
default_collation = var.default_collation
5+
6+
lifecycle {
7+
prevent_destroy = true
8+
}
9+
}

mysql/databases/outputs.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
output "name" {
2+
value = mysql_database.mdb.name
3+
}
4+
5+
output "id" {
6+
value = mysql_database.mdb.id
7+
}
8+
9+
output "default_character_set" {
10+
value = mysql_database.mdb.default_character_set
11+
}
12+
13+
output "default_collation" {
14+
value = mysql_database.mdb.default_collation
15+
}

mysql/databases/vars.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
variable name {
2+
type = string
3+
description = "(Required) The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running."
4+
}
5+
6+
variable default_character_set {
7+
type = string
8+
default = "utf8"
9+
description = "(Optional) The default character set to use when a table is created without specifying an explicit character set."
10+
}
11+
12+
variable default_collation {
13+
type = string
14+
default = "utf8_general_ci"
15+
description = "(Optional) The default collation to use when a table is created without specifying an explicit collation."
16+
}

mysql/grants/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "mysql_grant" "mg" {
2+
user = var.user
3+
host = var.host
4+
database = var.database
5+
table = var.table
6+
privileges = var.privileges
7+
grant = var.grant
8+
}

mysql/grants/vars.tf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
variable user {
2+
type = string
3+
description = "(Optional) The name of the user. Conflicts with role."
4+
}
5+
6+
variable host {
7+
type = string
8+
default = "localhost"
9+
description = "(Optional) The source host of the user. Conflicts with role."
10+
}
11+
12+
variable database {
13+
type = string
14+
description = "(Required) The database to grant privileges on."
15+
}
16+
17+
variable table {
18+
type = string
19+
default = "*"
20+
description = "(Optional) Which table to grant privileges on. Defaults to *, which is all tables."
21+
}
22+
23+
variable privileges {
24+
type = list
25+
default = []
26+
description = "(Optional) A list of privileges to grant to the user."
27+
}
28+
29+
variable grant {
30+
type = bool
31+
default = false
32+
description = "(Optional) Whether to also give the user privileges to grant the same privileges to other users."
33+
}

mysql/roles/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resource "mysql_role" "mr" {
2+
name = var.name
3+
}

mysql/roles/vars.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
variable name {
2+
type = string
3+
description = "(Required) The name of the role."
4+
}

mysql/users/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resource "mysql_user" "mu" {
2+
user = var.name
3+
host = var.host
4+
plaintext_password = var.password
5+
6+
lifecycle {
7+
prevent_destroy = true
8+
}
9+
}

mysql/users/outputs.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
output "user" {
2+
value = mysql_user.mu.user
3+
}
4+
5+
output "password" {
6+
value = mysql_user.mu.password
7+
sensitive = true
8+
}
9+
10+
output "id" {
11+
value = mysql_user.mu.id
12+
}
13+
14+
output "host" {
15+
value = mysql_user.mu.host
16+
}

mysql/users/vars.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
variable name {
2+
type = string
3+
description = "(Required) THe name of the user."
4+
}
5+
6+
variable host {
7+
type = string
8+
default = "localhost"
9+
description = "(Optional) The source host of the user. Defaults to localhost."
10+
}
11+
12+
variable password {
13+
type = string
14+
description = "(Optional) The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin."
15+
}

0 commit comments

Comments
 (0)