Skip to content

Commit affbf65

Browse files
SEANDOUGHTYoleg-render
authored andcommitted
Initial commit
0 parents  commit affbf65

31 files changed

+2096
-0
lines changed

.github/workflows/go-tests.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Go Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
name: Run Tests
11+
runs-on: ubuntu-latest-m
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '1.25.0'
21+
22+
- name: Download dependencies
23+
run: go mod download
24+
25+
- name: Run tests
26+
run: go test -v -race ./...

.github/workflows/pre-commit.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
name: pre-commit
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
workflow_dispatch:
10+
11+
env:
12+
GIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
13+
14+
concurrency:
15+
group: pre-commit-${{ github.event.pull_request.number || github.sha }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
run-pre-commit:
20+
runs-on: ubuntu-latest-m
21+
steps:
22+
- name: checkout
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
with:
25+
ref: ${{ env.GIT_SHA }}
26+
27+
- name: get PR base commit
28+
if: ${{ github.event_name == 'pull_request' }}
29+
run: |
30+
set -euxo pipefail
31+
git fetch origin ${{ github.event.pull_request.base.sha }} --depth 1 --no-tags --prune
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
35+
with:
36+
python-version: '3.x'
37+
38+
- name: Install pre-commit
39+
run: pip install pre-commit
40+
41+
- name: Cache pre-commit
42+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
43+
with:
44+
path: |
45+
~/.cache/pre-commit
46+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
47+
48+
- name: Run pre-commit
49+
run: |
50+
set -euxo pipefail
51+
if [ "${{ github.event_name }}" = "pull_request" ]; then
52+
# For PRs, only run on changed files
53+
pre-commit run --from-ref ${{ github.event.pull_request.base.sha }} --to-ref HEAD --show-diff-on-failure --hook-stage manual
54+
else
55+
# For pushes to master, run on all files
56+
pre-commit run --all-files --show-diff-on-failure --hook-stage manual
57+
fi

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.DS_Store
2+
.env
3+
panther-logs-render/
4+
5+
# Terraform files
6+
**/.terraform/
7+
**/.terraform.lock.hcl
8+
*.tfstate
9+
*.tfstate.*
10+
*.tfstate.backup
11+
**/*.tfvars
12+
crash.log
13+
crash.*.log
14+
override.tf
15+
override.tf.json
16+
*_override.tf
17+
*_override.tf.json

.pre-commit-config.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
default_stages: [pre-commit, manual]
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v5.0.0
7+
hooks:
8+
- id: check-added-large-files
9+
- id: check-case-conflict
10+
- id: check-merge-conflict
11+
- id: check-symlinks
12+
- id: check-vcs-permalinks
13+
- id: detect-private-key
14+
- id: end-of-file-fixer
15+
- id: trailing-whitespace
16+
- id: check-yaml
17+
- id: check-json
18+
19+
- repo: local
20+
hooks:
21+
- id: goimports
22+
name: goimports
23+
description: Runs goimports
24+
entry: go run golang.org/x/tools/cmd/goimports@latest -local github.com/renderinc -w
25+
language: system
26+
files: '\.go$'
27+
pass_filenames: true
28+
29+
- id: go-mod-tidy
30+
name: go mod tidy
31+
description: Runs go mod tidy
32+
entry: go mod tidy
33+
language: system
34+
pass_filenames: false
35+
files: '\.(go|mod|sum)$'
36+
37+
- id: go-vet
38+
name: go vet
39+
description: Runs go vet for static analysis
40+
entry: go vet ./...
41+
language: system
42+
types: [go]
43+
pass_filenames: false
44+
45+
- id: go-test
46+
name: go test
47+
description: Runs go test
48+
entry: go test -v ./...
49+
language: system
50+
types: [go]
51+
pass_filenames: false
52+
stages: [pre-push, manual]

LICENSE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2019, Render Developers
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# render-auditlogs
2+
3+
Export [Render](https://render.com) audit logs to an AWS S3 bucket.
4+
5+
## Overview
6+
7+
This project provides:
8+
- A Go application that fetches audit logs from the Render API and uploads them to S3
9+
- Terraform modules to deploy the infrastructure on both AWS and Render
10+
- Automatic scheduling via a Render Cron Job that runs every 15 minutes by default
11+
12+
Supports both workspace-level and organization-level (Enterprise) audit logs.
13+
14+
## Prerequisites
15+
16+
- Render workspace on Organization or Enterprise plan
17+
- [Render API Key](https://dashboard.render.com/u/settings) (create from Account Settings)
18+
- Render Owner ID (`tea-xxx`) — workspace where the Cron Job will be deployed
19+
- [Terraform](https://www.terraform.io/downloads) >= 1.0
20+
- AWS account with permissions to create S3 buckets and IAM users
21+
22+
## Quick Start
23+
24+
### 1. Clone the repository
25+
26+
```bash
27+
git clone https://github.com/renderinc/render-auditlogs.git
28+
cd render-auditlogs/terraform
29+
```
30+
31+
### 2. Configure authentication
32+
33+
Set up authentication for both providers:
34+
35+
```bash
36+
# AWS - use one of these methods:
37+
export AWS_PROFILE=your-profile
38+
# or
39+
export AWS_ACCESS_KEY_ID=...
40+
export AWS_SECRET_ACCESS_KEY=...
41+
42+
# Render - both are required for the Terraform provider
43+
export RENDER_API_KEY=your-render-api-key
44+
export RENDER_OWNER_ID=tea-xxxxx
45+
```
46+
47+
### 3. Deploy with Terraform
48+
49+
```bash
50+
terraform init
51+
terraform apply \
52+
-var="aws_s3_bucket_name=your-audit-logs-bucket" \
53+
-var="render_api_key=${RENDER_API_KEY}" \
54+
-var='render_workspace_ids=["tea-xxxxx", "tea-yyyyy"]'
55+
```
56+
57+
For Enterprise customers with organization-level audit logs:
58+
59+
```bash
60+
terraform apply \
61+
-var="aws_s3_bucket_name=your-audit-logs-bucket" \
62+
-var="render_api_key=${RENDER_API_KEY}" \
63+
-var="render_organization_id=org-xxxxx" \
64+
-var='render_workspace_ids=["tea-xxxxx", "tea-yyyyy"]'
65+
```
66+
67+
## Terraform Variables
68+
69+
| Variable | Required | Default | Description |
70+
|----------|----------|---------|-------------|
71+
| `aws_s3_bucket_name` | Yes | - | Name of the S3 bucket to create for storing audit logs |
72+
| `render_api_key` | Yes | - | Render API key for accessing audit logs |
73+
| `render_workspace_ids` | No | `[]` | List of workspace IDs to fetch audit logs from |
74+
| `render_organization_id` | No | `""` | Organization ID for Enterprise audit logs |
75+
| `aws_iam_user_name` | No | `render-audit-log-processor` | Name of the IAM user created for S3 access |
76+
| `render_cronjob_name` | No | `render-auditlogs` | Name of the Render Cron Job |
77+
| `render_cronjob_schedule` | No | `1/15 * * * *` | Cron schedule (default: every 15 minutes) |
78+
| `render_cronjob_plan` | No | `starter` | Render plan for the Cron Job |
79+
| `render_cronjob_region` | No | `oregon` | Region to deploy the Cron Job |
80+
| `render_project_name` | No | `audit-logs` | Name of the Render project |
81+
82+
## Architecture
83+
84+
The Terraform configuration creates:
85+
86+
**AWS Resources:**
87+
- S3 bucket (versioned, encrypted, public access blocked)
88+
- IAM user with S3 write permissions
89+
90+
**Render Resources:**
91+
- Project
92+
- Cron Job (builds from this repo)
93+
94+
## Local Development
95+
96+
To run the application locally:
97+
98+
1. Create a `.env` file:
99+
100+
```bash
101+
WORKSPACE_IDS=tea-xxxxx,tea-yyyyy
102+
ORGANIZATION_ID=org-xxxxx # Optional, for Enterprise
103+
S3_BUCKET=your-bucket-name
104+
RENDER_API_KEY=your-api-key
105+
AWS_ACCESS_KEY_ID=your-aws-key
106+
AWS_SECRET_ACCESS_KEY=your-aws-secret
107+
AWS_REGION=us-west-2
108+
```
109+
110+
2. Run the application:
111+
112+
```bash
113+
go run main.go
114+
```
115+
116+
## S3 Object Structure
117+
118+
Path format (Hive-style partitioning, gzip compressed):
119+
120+
```
121+
s3://your-bucket/
122+
├── workspace=tea-xxxxx/
123+
│ └── year=2024/
124+
│ └── month=1/
125+
│ └── day=15/
126+
│ └── audit-logs-2024-01-15_10-30-00.json.gz
127+
└── organization=org-xxxxx/
128+
└── year=2024/
129+
└── month=1/
130+
└── day=15/
131+
└── audit-logs-2024-01-15_10-30-00.json.gz
132+
```
133+
134+
## Integration with Panther SIEM
135+
136+
1. Create a custom log type in Panther with the schema below
137+
2. Add an S3 log source pointing to your audit-logs bucket
138+
3. Configure S3 event notifications to send object-create events to Panther
139+
140+
Panther schema:
141+
142+
```yaml
143+
fields:
144+
- name: auditLog
145+
required: true
146+
type: object
147+
fields:
148+
- name: actor
149+
type: object
150+
fields:
151+
- name: email
152+
type: string
153+
indicators:
154+
- email
155+
- name: id
156+
type: string
157+
- name: type
158+
type: string
159+
- name: event
160+
type: string
161+
- name: id
162+
type: string
163+
- name: metadata
164+
type: json
165+
- name: status
166+
type: string
167+
- name: timestamp
168+
type: timestamp
169+
isEventTime: true
170+
timeFormats:
171+
- rfc3339
172+
- name: cursor
173+
required: true
174+
type: string
175+
```
176+
177+
## Contributing
178+
179+
1. Fork the repository
180+
2. Create a feature branch (`git checkout -b feature/my-feature`)
181+
3. Commit your changes (`git commit -am 'Add my feature'`)
182+
4. Push to the branch (`git push origin feature/my-feature`)
183+
5. Open a Pull Request
184+
185+
Tests run automatically on PRs via GitHub Actions.
186+
187+
## Security
188+
189+
To report a security vulnerability, email [email protected]. Do not open a public issue.
190+
191+
## License
192+
193+
See [LICENSE](LICENSE) for details.

go.mod

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module github.com/renderinc/render-auditlogs
2+
3+
go 1.25.0
4+
5+
require (
6+
github.com/aws/aws-sdk-go-v2 v1.39.6
7+
github.com/aws/aws-sdk-go-v2/config v1.31.20
8+
github.com/aws/aws-sdk-go-v2/service/s3 v1.90.2
9+
github.com/google/uuid v1.6.0
10+
github.com/joho/godotenv v1.5.1
11+
github.com/kelseyhightower/envconfig v1.4.0
12+
github.com/stretchr/testify v1.11.1
13+
)
14+
15+
require (
16+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.3 // indirect
17+
github.com/aws/aws-sdk-go-v2/credentials v1.18.24 // indirect
18+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.13 // indirect
19+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.13 // indirect
20+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.13 // indirect
21+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 // indirect
22+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.13 // indirect
23+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.3 // indirect
24+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.4 // indirect
25+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.13 // indirect
26+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.13 // indirect
27+
github.com/aws/aws-sdk-go-v2/service/sso v1.30.3 // indirect
28+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.7 // indirect
29+
github.com/aws/aws-sdk-go-v2/service/sts v1.40.2 // indirect
30+
github.com/aws/smithy-go v1.23.2 // indirect
31+
github.com/davecgh/go-spew v1.1.1 // indirect
32+
github.com/pmezard/go-difflib v1.0.0 // indirect
33+
gopkg.in/yaml.v3 v3.0.1 // indirect
34+
)

0 commit comments

Comments
 (0)