diff --git a/.gitignore b/.gitignore index 69f4a99..2cdf400 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ terraform.tfvars .terraform* *.swp password_file* -.vscode \ No newline at end of file +.vscode +*.tfstate +*.backup diff --git a/database-grants/terraform/dev/provider.tf b/database-grants/terraform/dev/provider.tf index 3ddbcc6..52a5eb9 100644 --- a/database-grants/terraform/dev/provider.tf +++ b/database-grants/terraform/dev/provider.tf @@ -13,7 +13,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/dev/schemas/messaging/provider.tf b/database-grants/terraform/dev/schemas/messaging/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/dev/schemas/messaging/provider.tf +++ b/database-grants/terraform/dev/schemas/messaging/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/dev/schemas/queue/main.tf b/database-grants/terraform/dev/schemas/queue/main.tf new file mode 100644 index 0000000..c2ebb1b --- /dev/null +++ b/database-grants/terraform/dev/schemas/queue/main.tf @@ -0,0 +1,44 @@ +module "microservice_schema" { + source = "./../../modules/microservice_schema" + schema = "queue" + service_user_table_grants = ["SELECT", "INSERT", "UPDATE", "DELETE"] +} + +resource "random_password" "s_password" { + length = 16 + special = true + override_special = "_%@" +} + +resource "postgresql_role" "service_user" { + name = "s_queue" + login = true + password = random_password.s_password.result + search_path = ["queue"] +} + + +resource "postgresql_grant" "service-user-usage" { + database = "treetracker" + role = "s_queue" + schema = "queue" + object_type = "schema" + privileges = ["USAGE", "CREATE"] +} + +resource "postgresql_grant" "table-service-user" { + database = "treetracker" + role = "s_queue" + schema = "queue" + object_type = "table" + privileges = ["SELECT", "INSERT", "UPDATE", "DELETE"] +} + +resource "postgresql_grant" "sequence-service-user" { + database = "treetracker" + role = "s_queue" + schema = "queue" + object_type = "sequence" + privileges = ["USAGE", "SELECT"] + +} \ No newline at end of file diff --git a/database-grants/terraform/dev/schemas/queue/provider.tf b/database-grants/terraform/dev/schemas/queue/provider.tf new file mode 100644 index 0000000..77f71fb --- /dev/null +++ b/database-grants/terraform/dev/schemas/queue/provider.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + postgresql = { + source = "cyrilgdn/postgresql" + version = "1.22.0" + } + } +} \ No newline at end of file diff --git a/database-grants/terraform/prod/extra/provider.tf b/database-grants/terraform/prod/extra/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/extra/provider.tf +++ b/database-grants/terraform/prod/extra/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/modules/microservice_schema/provider.tf b/database-grants/terraform/prod/modules/microservice_schema/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/modules/microservice_schema/provider.tf +++ b/database-grants/terraform/prod/modules/microservice_schema/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/provider.tf b/database-grants/terraform/prod/provider.tf index d484d35..7f1040f 100644 --- a/database-grants/terraform/prod/provider.tf +++ b/database-grants/terraform/prod/provider.tf @@ -14,7 +14,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/airflow/provider.tf b/database-grants/terraform/prod/schemas/airflow/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/airflow/provider.tf +++ b/database-grants/terraform/prod/schemas/airflow/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/contracts/provider.tf b/database-grants/terraform/prod/schemas/contracts/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/contracts/provider.tf +++ b/database-grants/terraform/prod/schemas/contracts/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/denormalized/provider.tf b/database-grants/terraform/prod/schemas/denormalized/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/denormalized/provider.tf +++ b/database-grants/terraform/prod/schemas/denormalized/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/earnings/provider.tf b/database-grants/terraform/prod/schemas/earnings/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/earnings/provider.tf +++ b/database-grants/terraform/prod/schemas/earnings/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/field_data/provider.tf b/database-grants/terraform/prod/schemas/field_data/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/field_data/provider.tf +++ b/database-grants/terraform/prod/schemas/field_data/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/keycloak/provider.tf b/database-grants/terraform/prod/schemas/keycloak/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/keycloak/provider.tf +++ b/database-grants/terraform/prod/schemas/keycloak/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/messaging/provider.tf b/database-grants/terraform/prod/schemas/messaging/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/messaging/provider.tf +++ b/database-grants/terraform/prod/schemas/messaging/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/query/provider.tf b/database-grants/terraform/prod/schemas/query/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/query/provider.tf +++ b/database-grants/terraform/prod/schemas/query/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/regions/provider.tf b/database-grants/terraform/prod/schemas/regions/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/regions/provider.tf +++ b/database-grants/terraform/prod/schemas/regions/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/reporting/provider.tf b/database-grants/terraform/prod/schemas/reporting/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/reporting/provider.tf +++ b/database-grants/terraform/prod/schemas/reporting/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/stakeholder/provider.tf b/database-grants/terraform/prod/schemas/stakeholder/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/stakeholder/provider.tf +++ b/database-grants/terraform/prod/schemas/stakeholder/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/treetracker/provider.tf b/database-grants/terraform/prod/schemas/treetracker/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/treetracker/provider.tf +++ b/database-grants/terraform/prod/schemas/treetracker/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/wallet/provider.tf b/database-grants/terraform/prod/schemas/wallet/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/wallet/provider.tf +++ b/database-grants/terraform/prod/schemas/wallet/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } } diff --git a/database-grants/terraform/prod/schemas/webmap/provider.tf b/database-grants/terraform/prod/schemas/webmap/provider.tf index 7c80654..5b9d227 100644 --- a/database-grants/terraform/prod/schemas/webmap/provider.tf +++ b/database-grants/terraform/prod/schemas/webmap/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { postgresql = { source = "cyrilgdn/postgresql" - version = "1.11.0" + version = "1.22.0" } } }