Skip to content

Commit 75b5eaf

Browse files
feat(INT-58): create module - add tests and examples.
feat(INT-58): first pass at setting up repo
2 parents 27d507e + 3d14754 commit 75b5eaf

19 files changed

+1067
-100
lines changed

.github/workflows/notion-sync.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/test.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: TF Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
actions: read
11+
checks: write
12+
contents: read
13+
id-token: write
14+
pull-requests: read
15+
16+
jobs:
17+
tf-test:
18+
name: ${{ matrix.tf }} Test
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
tf: [tofu, terraform]
23+
steps:
24+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
26+
- name: Aqua Cache
27+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
28+
if: ${{ !github.event.act }} # Don't enable the cache step if we're using act for testing
29+
with:
30+
path: ~/.local/share/aquaproj-aqua
31+
key: v1-aqua-installer-${{runner.os}}-${{runner.arch}}-${{hashFiles('aqua.yaml')}}
32+
restore-keys: |
33+
v1-aqua-installer-${{runner.os}}-${{runner.arch}}-
34+
35+
- name: Install Aqua
36+
uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.2.1
37+
with:
38+
aqua_version: v2.48.1
39+
40+
- name: Aqua Install
41+
shell: bash
42+
run: aqua install --tags ${{ matrix.tf }}
43+
44+
- run: ${{ matrix.tf }} init
45+
- run: ${{ matrix.tf }} test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
# Local .terraform directories
1010
**/.terraform/*
1111

12+
# Terraform lock file
13+
.terraform.lock.hcl
14+
1215
# IDE/Editor settings
1316
**/.idea
1417
**/*.iml

.terraform-docs.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
version: 0.19.0
1+
version: 0.20.0
22
formatter: markdown table
33

44
recursive:
5-
enabled: true
6-
include-main: false
5+
enabled: false
76

87
settings:
98
lockfile: false
9+
path: .
1010

1111
output:
1212
file: README.md

CHANGELOG.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1 @@
11
# Changelog
2-
3-
## [0.4.0](https://github.com/masterpointio/terraform-module-template/compare/v0.3.0...v0.4.0) (2025-04-16)
4-
5-
6-
### Features
7-
8-
* setup connection to notion db ([#21](https://github.com/masterpointio/terraform-module-template/issues/21)) ([857df50](https://github.com/masterpointio/terraform-module-template/commit/857df5042fbde3d3e9ffbfc964eae9f7a7927cb0))
9-
10-
## [0.3.0](https://github.com/masterpointio/terraform-module-template/compare/v0.2.0...v0.3.0) (2025-04-10)
11-
12-
13-
### Features
14-
15-
* actualize README template ([#15](https://github.com/masterpointio/terraform-module-template/issues/15)) ([5d8de5f](https://github.com/masterpointio/terraform-module-template/commit/5d8de5fcf98b255ed65201b1ab2036ebf92ca138))
16-
* **renovate:** enables renovate terraform manager ([#18](https://github.com/masterpointio/terraform-module-template/issues/18)) ([e45f5ac](https://github.com/masterpointio/terraform-module-template/commit/e45f5acf08195f45ac9d4fe23447c600230ba4b4))
17-
18-
19-
### Bug Fixes
20-
21-
* **renovate:** schedule update ([#20](https://github.com/masterpointio/terraform-module-template/issues/20)) ([62d7e24](https://github.com/masterpointio/terraform-module-template/commit/62d7e24aa39312565c894525ef5c0ebb1053eb74))
22-
23-
## [0.2.0](https://github.com/masterpointio/terraform-module-template/compare/v0.1.1...v0.2.0) (2024-11-14)
24-
25-
26-
### Features
27-
28-
* adds GH + CRabbit configs ([d86d463](https://github.com/masterpointio/terraform-module-template/commit/d86d463385d501db5465b02de13d60c925b5815d))
29-
30-
## [0.1.1](https://github.com/masterpointio/terraform-module-template/compare/0.1.0...v0.1.1) (2024-08-15)
31-
32-
33-
### Bug Fixes
34-
35-
* remove markdown trailing whitespace ([d609646](https://github.com/masterpointio/terraform-module-template/commit/d6096463b916eb536603d4ca3b2f3315e3fec9f2))
36-
* removes redundant editorconfig settings ([bbe0050](https://github.com/masterpointio/terraform-module-template/commit/bbe0050450cece8074f3d9ff5c3bd72ff01d8a1b))

README.md

Lines changed: 194 additions & 17 deletions
Large diffs are not rendered by default.

aqua.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ registries:
1010
- type: standard
1111
ref: v4.210.0 # renovate: depName=aquaproj/aqua-registry
1212
packages:
13-
- name: terraform-docs/terraform-docs@v0.19.0
13+
- name: terraform-docs/terraform-docs@v0.20.0
1414
- name: hashicorp/terraform@v1.9.3
1515
- name: opentofu/opentofu@v1.8.0

examples/complete/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Example: Complete Setup
2+
3+
This example demonstrates how to set up the Terraform Postgres Automation.
4+
5+
It includes configurations for both an application role and a read-only role.
6+
7+
## Prerequisites
8+
9+
- Terraform installed on your local machine.
10+
- Access to a PostgreSQL instance where you can apply these configurations.
11+
12+
## Usage
13+
14+
1. Clone the repository and navigate to the `examples/complete` directory.
15+
2. Review and update the `fixtures.tfvars` file with your specific configuration details.
16+
3. Run the following Terraform commands to apply the configuration:
17+
18+
```bash
19+
terraform init
20+
terraform plan -var-file="fixtures.tfvars"
21+
terraform apply -var-file="fixtures.tfvars"
22+
```
23+
24+
## Roles and Permissions
25+
26+
The `fixtures.tfvars` file defines two roles:
27+
28+
- **system_user**: This role is intended for application use with the following permissions:
29+
30+
- Can log in and is not a superuser.
31+
- Has all privileges on tables and sequences in the `app` database.
32+
- Can use and create within the `public` schema.
33+
34+
- **readonly_user**: This role is intended for read-only access with the following permissions:
35+
- Can log in and is not a superuser.
36+
- Has `SELECT` privileges on tables and `USAGE`, `SELECT` on sequences in the `app` database.

examples/complete/fixtures.tfvars

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# complete/fixtures.tfvars
2+
3+
# postgres shell command to create this user:
4+
# CREATE ROLE admin_user LOGIN CREATEDB PASSWORD 'insecure-pass-for-demo-admin-user';
5+
db_username = "admin_user"
6+
7+
db_password = "insecure-pass-for-demo-admin-user"
8+
db_scheme = "postgres"
9+
db_hostname = "localhost"
10+
db_port = 5432
11+
db_superuser = false
12+
db_sslmode = "disable"
13+
14+
databases = [
15+
{
16+
name = "app"
17+
connection_limit = 10
18+
}
19+
]
20+
21+
roles = [
22+
{
23+
role = {
24+
name = "system_user"
25+
login = true
26+
superuser = false
27+
password = "insecure-pass-for-demo-system-user"
28+
}
29+
30+
table_grants = {
31+
role = "system_user"
32+
database = "app"
33+
schema = "public"
34+
object_type = "table"
35+
objects = [] # empty list to grant all tables
36+
privileges = ["ALL"]
37+
}
38+
39+
schema_grants = {
40+
role = "system_user"
41+
database = "app"
42+
schema = "public"
43+
object_type = "schema"
44+
privileges = ["USAGE", "CREATE"]
45+
}
46+
47+
sequence_grants = {
48+
role = "system_user"
49+
database = "app"
50+
schema = "public"
51+
object_type = "sequence"
52+
objects = [] # empty list to grant all sequences
53+
privileges = ["ALL"]
54+
}
55+
},
56+
{
57+
role = {
58+
name = "readonly_user"
59+
login = true
60+
password = "insecure-pass-for-demo-readonly-user"
61+
superuser = false
62+
}
63+
64+
table_grants = {
65+
role = "readonly_user"
66+
database = "app"
67+
schema = "public"
68+
object_type = "table"
69+
objects = [] # empty list to grant all tables
70+
privileges = ["SELECT"]
71+
}
72+
73+
sequence_grants = {
74+
role = "readonly_user"
75+
database = "app"
76+
schema = "public"
77+
object_type = "sequence"
78+
objects = [] # empty list to grant all sequences
79+
privileges = ["USAGE", "SELECT"]
80+
}
81+
82+
default_privileges = [
83+
{
84+
role = "readonly_user"
85+
database = "app"
86+
schema = "public"
87+
owner = "system_user"
88+
object_type = "table"
89+
objects = [] # empty list to grant all tables
90+
privileges = ["SELECT"]
91+
},
92+
{
93+
role = "readonly_user"
94+
database = "app"
95+
schema = "public"
96+
owner = "system_user"
97+
object_type = "sequence"
98+
objects = [] # empty list to grant all sequences
99+
privileges = ["USAGE", "SELECT"]
100+
},
101+
]
102+
}
103+
]

examples/complete/main.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
# complete.tf
1+
# complete/main.tf
2+
3+
module "postgres_automation" {
4+
source = "../../"
5+
6+
databases = var.databases
7+
roles = var.roles
8+
}

0 commit comments

Comments
 (0)