Skip to content

Commit

Permalink
feat: add wallet operatoer permission
Browse files Browse the repository at this point in the history
  • Loading branch information
dadiorchen committed Nov 18, 2023
1 parent 4c84bb5 commit 64a9f32
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 4 deletions.
5 changes: 5 additions & 0 deletions database-grants/terraform/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Prerequisites

- Terraform 1.4.6 , please stick to this version for now, tested 1.6.x, it brings issue with the Dititalocean storage as backend


# How to set up terraform

Find your digitalocean spaces access key and secret key here: https://cloud.digitalocean.com/account/api/spaces?i=d79377
Expand Down
8 changes: 8 additions & 0 deletions database-grants/terraform/dev/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,11 @@ module "keycloak_schema" {
postgresql = postgresql.treetracker
}
}


module "wallet_schema" {
source = "./schemas/wallet"
providers = {
postgresql = postgresql.treetracker
}
}
1 change: 1 addition & 0 deletions database-grants/terraform/dev/other
1 change: 1 addition & 0 deletions database-grants/terraform/dev/schemas/wallet
24 changes: 24 additions & 0 deletions database-grants/terraform/prod/extra/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
resource "postgresql_grant" "wallet-operator-schema" {
database = "treetracker"
role = "wallet_operator"
schema = "wallet"
object_type = "schema"
privileges = ["USAGE", "CREATE"]
}

resource "postgresql_grant" "wallet-operator-table" {
database = "treetracker"
role = "wallet_operator"
schema = "wallet"
object_type = "table"
privileges = ["SELECT", "INSERT", "UPDATE", "DELETE"]
}

resource "postgresql_grant" "wallet-operator-seq" {
database = "treetracker"
role = "wallet_operator"
schema = "wallet"
object_type = "sequence"
privileges = ["USAGE", "SELECT"]

}
8 changes: 8 additions & 0 deletions database-grants/terraform/prod/extra/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
postgresql = {
source = "cyrilgdn/postgresql"
version = "1.11.0"
}
}
}
10 changes: 10 additions & 0 deletions database-grants/terraform/prod/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,13 @@ module "keycloak_schema" {
postgresql = postgresql.treetracker
}
}

module "extra" {
source = "./extra"
providers = {
postgresql = postgresql.treetracker
}
depends_on = [
module.wallet_schema
]
}
4 changes: 2 additions & 2 deletions database-grants/terraform/prod/prod.env.tfvars
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
port = "1111"
host = "localhost"
port = "25060"
host = "treetracker-cluster-do-user-8540031-0.b.db.ondigitalocean.com"
2 changes: 0 additions & 2 deletions database-grants/terraform/prod/schemas/wallet/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ module "microservice_schema" {
source = "./../../modules/microservice_schema"
schema = "wallet"
}


0 comments on commit 64a9f32

Please sign in to comment.