diff --git a/database-grants/terraform/README.md b/database-grants/terraform/README.md index 7f4e2a6..bd1bd05 100644 --- a/database-grants/terraform/README.md +++ b/database-grants/terraform/README.md @@ -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 diff --git a/database-grants/terraform/dev/main.tf b/database-grants/terraform/dev/main.tf index de732df..5e55477 100644 --- a/database-grants/terraform/dev/main.tf +++ b/database-grants/terraform/dev/main.tf @@ -81,3 +81,11 @@ module "keycloak_schema" { postgresql = postgresql.treetracker } } + + +module "wallet_schema" { + source = "./schemas/wallet" + providers = { + postgresql = postgresql.treetracker + } +} diff --git a/database-grants/terraform/dev/other b/database-grants/terraform/dev/other new file mode 120000 index 0000000..b492abe --- /dev/null +++ b/database-grants/terraform/dev/other @@ -0,0 +1 @@ +../prod/other \ No newline at end of file diff --git a/database-grants/terraform/dev/schemas/wallet b/database-grants/terraform/dev/schemas/wallet new file mode 120000 index 0000000..7918131 --- /dev/null +++ b/database-grants/terraform/dev/schemas/wallet @@ -0,0 +1 @@ +../../prod/schemas/wallet/ \ No newline at end of file diff --git a/database-grants/terraform/prod/extra/main.tf b/database-grants/terraform/prod/extra/main.tf new file mode 100644 index 0000000..3ee78b2 --- /dev/null +++ b/database-grants/terraform/prod/extra/main.tf @@ -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"] + +} diff --git a/database-grants/terraform/prod/extra/provider.tf b/database-grants/terraform/prod/extra/provider.tf new file mode 100644 index 0000000..7c80654 --- /dev/null +++ b/database-grants/terraform/prod/extra/provider.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + postgresql = { + source = "cyrilgdn/postgresql" + version = "1.11.0" + } + } +} diff --git a/database-grants/terraform/prod/main.tf b/database-grants/terraform/prod/main.tf index 55c15a3..46ea5ed 100644 --- a/database-grants/terraform/prod/main.tf +++ b/database-grants/terraform/prod/main.tf @@ -90,3 +90,13 @@ module "keycloak_schema" { postgresql = postgresql.treetracker } } + +module "extra" { + source = "./extra" + providers = { + postgresql = postgresql.treetracker + } + depends_on = [ + module.wallet_schema + ] +} diff --git a/database-grants/terraform/prod/prod.env.tfvars b/database-grants/terraform/prod/prod.env.tfvars index fc6f324..daff614 100644 --- a/database-grants/terraform/prod/prod.env.tfvars +++ b/database-grants/terraform/prod/prod.env.tfvars @@ -1,2 +1,2 @@ -port = "1111" -host = "localhost" +port = "25060" +host = "treetracker-cluster-do-user-8540031-0.b.db.ondigitalocean.com" diff --git a/database-grants/terraform/prod/schemas/wallet/main.tf b/database-grants/terraform/prod/schemas/wallet/main.tf index b2a0855..30dcb6c 100644 --- a/database-grants/terraform/prod/schemas/wallet/main.tf +++ b/database-grants/terraform/prod/schemas/wallet/main.tf @@ -3,5 +3,3 @@ module "microservice_schema" { source = "./../../modules/microservice_schema" schema = "wallet" } - -