File tree Expand file tree Collapse file tree 5 files changed +54
-4
lines changed Expand file tree Collapse file tree 5 files changed +54
-4
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ No modules.
39
39
| Name | Type |
40
40
| ------| ------|
41
41
| [ random_password.this] ( https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password ) | resource |
42
+ | [ scaleway_rdb_acl.this] ( https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/resources/rdb_acl ) | resource |
42
43
| [ scaleway_rdb_database.this] ( https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/resources/rdb_database ) | resource |
43
44
| [ scaleway_rdb_instance.this] ( https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/resources/rdb_instance ) | resource |
44
45
| [ scaleway_rdb_user.this] ( https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/resources/rdb_user ) | resource |
Original file line number Diff line number Diff line change
1
+ resource "scaleway_rdb_acl" "this" {
2
+ for_each = local. databases
3
+
4
+ instance_id = scaleway_rdb_instance. this [each . key ]. id
5
+
6
+ dynamic "acl_rules" {
7
+ for_each = each. value . acls
8
+
9
+ content {
10
+ ip = acl_rules. value [" ip" ]
11
+ description = acl_rules. value [" description" ]
12
+ }
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ module "rdb" {
2
+ source = " ../../"
3
+
4
+ databases = {
5
+ main = {
6
+ name = " test-simple-db"
7
+ node_type = " DB-DEV-S"
8
+ engine = " PostgreSQL-11"
9
+ acls = [
10
+ {
11
+ ip = " 1.2.3.4/32"
12
+ description = " Specific ACL 1"
13
+ },
14
+ {
15
+ ip = " 192.168.1.20/28"
16
+ description = " Specific ACL 2"
17
+ }
18
+ ]
19
+ }
20
+ }
21
+ }
22
+
23
+ output "rdb" {
24
+ value = module. rdb . this
25
+ sensitive = true
26
+ }
Original file line number Diff line number Diff line change @@ -7,14 +7,22 @@ locals {
7
7
}
8
8
]
9
9
])
10
+ acl_configs = flatten ([
11
+ for database , config in local . databases : [
12
+ for acl in config . acls : {
13
+ database = database
14
+ rule = acl
15
+ }
16
+ ]
17
+ ])
18
+ acls_by_database = {
19
+ for index , config in local . acl_configs :
20
+ " ${config.database}_${index}" => config
21
+ }
10
22
user_by_database = {
11
23
for config in local . user_configs :
12
24
" ${config.database}_${config.user.username}" => config
13
25
}
14
- user_computed = {
15
- for identifier , config in local . user_by_database :
16
- config.database = > config...
17
- }
18
26
default_database = {
19
27
name = " default"
20
28
node_type = " DB-DEV-S"
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ output "this" {
3
3
for name in keys (var. databases ) : name => {
4
4
" instance" = scaleway_rdb_instance.this[name],
5
5
" database" = scaleway_rdb_database.this[name],
6
+ " acls" = scaleway_rdb_acl.this[name],
6
7
" users" = [
7
8
for identifier , config in local . user_by_database : {
8
9
" username" : config.user.username,
You can’t perform that action at this time.
0 commit comments