Skip to content

Commit

Permalink
provider/mysql: user and grant resources (#7656)
Browse files Browse the repository at this point in the history
* provider/mysql: User Resource

This commit introduces a mysql_user resource. It includes basic
functionality of adding a user@host along with a password.

* provider/mysql: Grant Resource

This commit introduces a mysql_grant resource. It can grant a set
of privileges to a user against a whole database.

* provider/mysql: Adding documentation for user and grant resources
  • Loading branch information
jtopjian authored and stack72 committed Jul 26, 2016
1 parent df813d4 commit 9a6cb36
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
52 changes: 52 additions & 0 deletions r/grant.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
layout: "mysql"
page_title: "MySQL: mysql_grant"
sidebar_current: "docs-mysql-resource-grant"
description: |-
Creates and manages privileges given to a user on a MySQL server
---

# mysql\_grant

The ``mysql_grant`` resource creates and manages privileges given to
a user on a MySQL server.

## Example Usage

```
resource "mysql_user" "jdoe" {
user = "jdoe"
host = "example.com"
password = "password"
}
resource "mysql_grant" "jdoe" {
user = "${mysql_user.jdoe.user}"
host = "${mysql_user.jdoe.host}"
database = "app"
privileges = ["SELECT", "UPDATE"]
}
```

## Argument Reference

The following arguments are supported:

* `user` - (Required) The name of the user.

* `host` - (Optional) The source host of the user. Defaults to "localhost".

* `database` - (Required) The database to grant privileges on. At this time,
privileges are given to all tables on the database (`mydb.*`).

* `privileges` - (Required) A list of privileges to grant to the user. Refer
to a list of privileges (such as
[here](https://dev.mysql.com/doc/refman/5.5/en/grant.html)) for applicable
privileges.

* `grant` - (Optional) Whether to also give the user privileges to grant
the same privileges to other users.

## Attributes Reference

No further attributes are exported.
37 changes: 37 additions & 0 deletions r/user.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
layout: "mysql"
page_title: "MySQL: mysql_user"
sidebar_current: "docs-mysql-resource-user"
description: |-
Creates and manages a user on a MySQL server.
---

# mysql\_user

The ``mysql_user`` resource creates and manages a user on a MySQL
server.

## Example Usage

```
resource "mysql_user" "jdoe" {
user = "jdoe"
host = "example.com"
password = "password"
}
```

## Argument Reference

The following arguments are supported:

* `user` - (Required) The name of the user.

* `host` - (Optional) The source host of the user. Defaults to "localhost".

* `password` - (Optional) The password of the user. The value of this
argument is plain-text so make sure to secure where this is defined.

## Attributes Reference

No further attributes are exported.

0 comments on commit 9a6cb36

Please sign in to comment.