Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(postgresql): Update PostgreSQL Resource and Data Source #483

Merged
merged 6 commits into from
Jan 3, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(postgresql): Update PostgreSQL users Resource and Data Source
youngmn committed Nov 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 44a59f270501b9c67624f1ff0f50250bf84c98eb
8 changes: 3 additions & 5 deletions docs/data-sources/postgresql_users.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
subcategory: "PostgresSQL"
subcategory: "PostgreSQL"
---

# Data Source: ncloud_postgresql_users
@@ -29,7 +29,6 @@ output "user_list" {
}
```


Outputs:
```terraform
user_list = {
@@ -41,7 +40,7 @@ user_list = {

The following arguments are required:

* `postgresql_instance_no` - (Required) Postgresql Instance No.
* `id` - (Required) Postgresql Instance No.
* `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
@@ -54,6 +53,5 @@ This data source exports the following attributes in adddition to the argument a

* `postgresql_user_list` - The list of users to add.
* `name` - PostgreSQL User ID.
* `password` - PostgreSQL User Password.
* `client_cidr` - Access Control (CIDR) of the client you want to connect
* `is_replication_role` - Replication Role or not
* `replication_role` - Replication Role or not
47 changes: 22 additions & 25 deletions docs/resources/postgresql_users.md
Original file line number Diff line number Diff line change
@@ -11,30 +11,31 @@ Provides a PostgreSQL User list resource.
## Example Usage

```terraform
resource "ncloud_vpc" "test" {
ipv4_cidr_block = "10.0.0.0/16"
resource "ncloud_vpc" "vpc" {
ipv4_cidr_block = "10.0.0.0/16"
}

resource "ncloud_subnet" "test" {
vpc_no = ncloud_vpc.test.vpc_no
subnet = cidrsubnet(ncloud_vpc.test.ipv4_cidr_block, 8, 1)
resource "ncloud_subnet" "subnet" {
vpc_no = ncloud_vpc.vpc.vpc_no
subnet = cidrsubnet(ncloud_vpc.vpc.ipv4_cidr_block, 8, 1)
zone = "KR-2"
network_acl_no = ncloud_vpc.test.default_network_acl_no
network_acl_no = ncloud_vpc.vpc.default_network_acl_no
subnet_type = "PUBLIC"
}

resource "ncloud_postgresql" "postgresql" {
subnet_no = ncloud_subnet.test.id
service_name = "tf-postgresql"
vpc_no = ncloud_vpc.vpc.vpc_no
subnet_no = ncloud_subnet.subnet.id
service_name = "tf-postgresql"
server_name_prefix = "name-prefix"
user_name = "username"
user_password = "password1!"
client_cidr = "0.0.0.0/0"
database_name = "db_name"
user_name = "username"
user_password = "password1!"
client_cidr = "0.0.0.0/0"
database_name = "db_name"
}

resource "ncloud_postgresql_users" "postgresql_users" {
postgresql_instance_no = ncloud_postgresql.postgresql.postgresql_instance_no
id = ncloud_postgresql.postgresql.id
postgresql_user_list = [
{
name = "test1",
@@ -53,37 +54,33 @@ resource "ncloud_postgresql_users" "postgresql_users" {
```

## Argument Reference

The following arguments are supported:

* `postgresql_instance_no` - (Required) The ID of the associated Postgresql Instance.
* `id` - (Required) The ID of the associated Postgresql Instance.
* `postgresql_user_list` - The list of users to add.
* `name` - (Required) PostgreSQL User ID. Only English alphabets, numbers and special characters ( \ _ , - ) are allowed and must start with an English alphabet. Cannot include User ID. Min: 4, Max: 16
* `password` - (Required) PostgreSQL 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
* `client_cidr` - (Required) Access Control (CIDR) of the client you want to connect to EX) Allow all access: 0.0.0.0/0, Allow specific IP access: 192.168.1.1/32, Allow IP band access: 192.168.1.0/24
* `is_replication_role` - (Required) Replication Role or not (true/false).

## Attribute Reference
In addition to all arguments above, the following attributes are exported

* `id` - Postgresql User List number.(Postgresql Instance number)
* `replication_role` - (Required) Replication Role or not (true/false).

## Import

### `terraform import` command

* PostgreSQL User can be imported using the `id`. For example:
* PostgreSQL User can be imported using the `id`:`name`:`name`:... . For example:

```console
$ terraform import ncloud_postgresql_users.rsc_name 12345
$ terraform import ncloud_postgresql_users.rsc_name 12345:name1:name2
```

### `import` block

* In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import PostgreSQL User using the `id`. For example:
* In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import PostgreSQL User using the `id`:`name`:`name`:... . For example:

```terraform
import {
to = ncloud_postgresql_users.rsc_name
id = "12345"
id = "12345:name1:name2"
}
```
```
Loading