-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add mysql users service (#444)
* feat: add mysql users service * docs: correct name size * refactor: remove annotation * docs: add data source output * feat: add update and remove reverse * fix: change check 5001017 func * chore: remove print
- Loading branch information
1 parent
be36e0c
commit 82109ad
Showing
8 changed files
with
1,136 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
subcategory: "MySQL" | ||
--- | ||
|
||
# Data Source: ncloud_mysql_users | ||
|
||
Get a list of MySQL users. | ||
|
||
~> **NOTE:** This only supports VPC environments. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "ncloud_mysql_users" "all" { | ||
id = 12345 | ||
filter { | ||
name = "name" | ||
values = ["test-user1"] | ||
} | ||
output_file = "users.json" | ||
} | ||
output "user_list" { | ||
values = { | ||
for user in data.ncloud_mysql_users.all.mysql_user_list: | ||
user.name => user.host_ip | ||
} | ||
} | ||
``` | ||
|
||
Outputs: | ||
```terraform | ||
user_list = { | ||
"test-user1": "192.168.0.1" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are required: | ||
|
||
* `id` - (Required) Mysql Users number. Either `id` or `mysql_instance_no` must be provided. | ||
* `mysql_instance_no` - (Required) Mysql Instance No, either `id` or `mysql_instance_no` must be provided. | ||
* `output_file` - (Optional) The name of file that can save data source after running `terraform plan`. | ||
* `filter` - (Optional) Custom filter block as described below. | ||
* `name` - (Required) The name of the field to filter by | ||
* `vlaues` - (Required) Set of values that are accepted for the given field. | ||
* `regex` - (Optional) is `values` treated as a regular expression. | ||
|
||
## Attributes Reference | ||
|
||
This data source exports the following attributes in addition to the argument above: | ||
|
||
* `mysql_user_list` - The list of users to add . | ||
* `name` - MySQL User ID. | ||
* `password` - MySQL User Password. | ||
* `host_ip` - MySQL user host. | ||
* `authority` - MySQL User Authority. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
subcategory: "MySQL" | ||
--- | ||
|
||
# Resource: ncloud_mysql_users | ||
|
||
Provides a MySQL User list resource. | ||
|
||
~> **NOTE:** This resource only supports VPC environment. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "ncloud_vpc" "test_vpc" { | ||
ipv4_cidr_block = "10.5.0.0/16" | ||
} | ||
resource "ncloud_subnet" "test_subnet" { | ||
vpc_no = ncloud_vpc.test_vpc.vpc_no | ||
subnet = "10.5.0.0/24" | ||
zone = "KR-2" | ||
network_acl_no = ncloud_vpc.test_vpc.default_network_acl_no | ||
subnet_type = "PUBLIC" | ||
} | ||
resource "ncloud_mysql" "mysql" { | ||
subnet_no = ncloud_subnet.test_subnet.id | ||
service_name = "tf-mysql" | ||
server_name_prefix = "testprefix" | ||
user_name = "testusername" | ||
user_password = "t123456789!a" | ||
host_ip = "192.168.0.1" | ||
database_name = "test_db" | ||
} | ||
resource "ncloud_mysql_users" "mysql_users" { | ||
mysql_instance_no = ncloud_mysql.mysql.id | ||
mysql_user_list = [ | ||
{ | ||
name = "test1", | ||
password = "t123456789!", | ||
host_ip = "%%", | ||
authority = "READ" | ||
}, | ||
{ | ||
name = "test2", | ||
password = "t123456789!", | ||
host_ip = "%%", | ||
authority = "DDL" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
The following arguments are supported: | ||
|
||
* `mysql_instance_no` - (Required) The ID of the associated Mysql Instance. | ||
* `mysql_user_list` - The list of users to add . | ||
* `name` - (Required) MySQL User ID. Only English alphabets, numbers and special characters ( \ _ , - ) are allowed and must start with an English alphabet. Min: 4, Max: 16 | ||
* `password` - (Required) MySQL User Password. At least one English alphabet, number and special character must be included. Certain special characters ( ` & + \ " ' / space ) cannot be used. Min: 8, Max: 20 | ||
* `host_ip` - (Required) MySQL user host. ex) Overall connection permitted: %, Connection by specific IPs permitted: 1.1.1.1, IP band connection permitted: 1.1.1.% | ||
* `authority` - (Required) MySQL User Authority. You can select `READ|CRUD|DDL`. | ||
|
||
## Attribute Reference | ||
In addition to all arguments above, the following attributes are exported | ||
|
||
* `id` - Mysql User List number.(Mysql Instance number) | ||
|
||
## Import | ||
|
||
### `terraform import` command | ||
|
||
* MySQL User can be imported using the `id`. For example: | ||
|
||
```console | ||
$ terraform import ncloud_mysql_users.rsc_name 12345 | ||
``` | ||
|
||
### `import` block | ||
|
||
* In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import MySQL User using the `id`. For example: | ||
|
||
```terraform | ||
import { | ||
to = ncloud_mysql_users.rsc_name | ||
id = "12345" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.