Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0975e0a
Install zappa and initial example configuration
rudransh-shrivastava Oct 16, 2025
aa4eea0
add temporary IaC code for testing
rudransh-shrivastava Oct 17, 2025
18b8adb
Update code
rudransh-shrivastava Oct 17, 2025
6311813
Merge branch 'main' into feature/zappa-migration
rudransh-shrivastava Oct 17, 2025
481b928
Remove IAM and let Zappa manage it
rudransh-shrivastava Oct 18, 2025
ee1edb6
add README
rudransh-shrivastava Oct 18, 2025
90e24e1
add RDS proxy, pre-commit hooks, clean-up code
rudransh-shrivastava Oct 19, 2025
e618808
feat: add ecs tasks
rudransh-shrivastava Oct 23, 2025
6220c24
refactor/clean cache module
rudransh-shrivastava Oct 23, 2025
9495dfd
refactor/clean database module
rudransh-shrivastava Oct 23, 2025
df72c9a
refactor/clean ecs module
rudransh-shrivastava Oct 23, 2025
619400e
refactor/clean networking module
rudransh-shrivastava Oct 23, 2025
b8b49fa
address Sonar Qube bot suggestions
rudransh-shrivastava Oct 23, 2025
8c3569d
keep some Sonar Qube bot suggestions but add #NOSONAR
rudransh-shrivastava Oct 23, 2025
91b12e7
add terraform dictionary
rudransh-shrivastava Oct 23, 2025
92469ac
refactor/clean security module
rudransh-shrivastava Oct 23, 2025
1a66c4f
fix pre-commit hooks and add terraform_validate
rudransh-shrivastava Oct 23, 2025
6994e33
add SHA hash and remove terraform_validate
rudransh-shrivastava Oct 23, 2025
a41221f
refactor/clean storage module
rudransh-shrivastava Oct 23, 2025
1165166
Update docs
rudransh-shrivastava Oct 23, 2025
cc80292
add S3 support for load-data task
rudransh-shrivastava Oct 23, 2025
c694c57
Update README and necessary examples
rudransh-shrivastava Oct 23, 2025
753e234
coderabbit suggestions
rudransh-shrivastava Oct 23, 2025
16445dc
Update code: install awscli before invoking aws in task
rudransh-shrivastava Oct 23, 2025
536e615
update README
rudransh-shrivastava Oct 23, 2025
206e60e
NOSONAR
rudransh-shrivastava Oct 23, 2025
0a8b4ea
Merge branch 'main' into feature/zappa-migration
rudransh-shrivastava Oct 23, 2025
748ed52
update README
rudransh-shrivastava Oct 23, 2025
f71861c
fix spell check
rudransh-shrivastava Oct 23, 2025
e785a42
Update README
rudransh-shrivastava Oct 24, 2025
bc3737e
fix: typo
rudransh-shrivastava Oct 24, 2025
e51d34b
remove immutable tagged images
rudransh-shrivastava Oct 24, 2025
d419073
fix: load-data task fail due to no permissions
rudransh-shrivastava Oct 24, 2025
a347969
fix spell check: add PYTHONPATH
rudransh-shrivastava Oct 24, 2025
88af956
add AWS CLI
rudransh-shrivastava Oct 24, 2025
5be1083
add set -e
rudransh-shrivastava Oct 24, 2025
9650e5e
Update code
arkid15r Oct 26, 2025
d4f7ddd
Merge branch 'feature/nest-zappa-migration' into pr/rudransh-shrivast…
arkid15r Oct 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/run-ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ jobs:
restore-keys: |
pre-commit-${{ runner.os }}-

- name: Setup TFLint
uses: terraform-linters/setup-tflint@v4
with:
tflint_version: v0.59.1

- name: Run pre-commit
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd

Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@ __pycache__
.python_history
.python-version
.ruff_cache
**/.terraform/
*.tfstate
*.tfstate.*
.venv/
.vscode
*.code-workspace
*.key
*.log
*.pdf
*.pem
backend/*nest-backend-dev*.zip
backend/*nest-backend-dev*.tar.gz
backend/*nest-backend-staging*.zip
backend/*nest-backend-staging*.tar.gz
backend/data/backup*
backend/staticfiles
backend/zappa_settings.json
frontend/blob-report/
frontend/coverage
frontend/dist
Expand All @@ -36,6 +44,7 @@ frontend/pnpm-debug.log*
frontend/test-results/
frontend/yarn-debug.log*
frontend/yarn-error.log*
infrastructure/terraform.tfvars
logs
node_modules/
TODO
Expand Down
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ repos:
- --strict
exclude: (.github|pnpm-lock.yaml)

- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.92.0
hooks:
- id: terraform_fmt
files: ^infrastructure/.*\.tf$
- id: terraform_validate
files: ^infrastructure/.*\.tf$
- id: terraform_tflint
files: ^infrastructure/.*\.tf$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.0
hooks:
Expand Down
1,224 changes: 738 additions & 486 deletions backend/poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ strawberry-graphql = { extras = [ "django" ], version = "^0.283.2" }
strawberry-graphql-django = "^0.66.0"
thefuzz = "^0.22.1"
pyparsing = "^3.2.3"
zappa = "^0.60.2"

[tool.poetry.group.dev.dependencies]
djlint = "^1.36.4"
Expand Down
39 changes: 39 additions & 0 deletions backend/zappa_settings.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"staging": {
"app_function": "wsgi.application",
"django_settings": "settings.staging",
"environment_variables": {
"DJANGO_ALGOLIA_APPLICATION_ID": "${DJANGO_ALGOLIA_APPLICATION_ID}",
"DJANGO_ALGOLIA_WRITE_API_KEY": "${DJANGO_ALGOLIA_WRITE_API_KEY}",
"DJANGO_ALLOWED_HOSTS": "${DJANGO_ALLOWED_HOSTS}",
"DJANGO_AWS_ACCESS_KEY_ID": "${DJANGO_AWS_ACCESS_KEY_ID}",
"DJANGO_AWS_SECRET_ACCESS_KEY": "${DJANGO_AWS_SECRET_ACCESS_KEY}",
"DJANGO_CONFIGURATION": "Staging",
"DJANGO_DB_HOST": "${DJANGO_DB_HOST}",
"DJANGO_DB_NAME": "${DJANGO_DB_NAME}",
"DJANGO_DB_USER": "${DJANGO_DB_USER}",
"DJANGO_DB_PORT": "${DJANGO_DB_PORT}",
"DJANGO_DB_PASSWORD": "${DJANGO_DB_PASSWORD}",
"DJANGO_OPEN_AI_SECRET_KEY": "${DJANGO_OPEN_AI_SECRET_KEY}",
"DJANGO_REDIS_HOST": "${DJANGO_REDIS_HOST}",
"DJANGO_REDIS_PASSWORD": "${DJANGO_REDIS_PASSWORD}",
"DJANGO_SECRET_KEY": "${DJANGO_SECRET_KEY}",
"DJANGO_SENTRY_DSN": "${DJANGO_SENTRY_DSN}",
"DJANGO_SLACK_BOT_TOKEN": "${DJANGO_SLACK_BOT_TOKEN}",
"DJANGO_SLACK_SIGNING_SECRET": "${DJANGO_SLACK_SIGNING_SECRET}"
},
"manage_roles": true,
"project_name": "nest-backend",
"runtime": "python3.13",
"s3_bucket": "${ZAPPA_S3_BUCKET}",
"slim_handler": true,
"vpc_config": {
"SecurityGroupIds": ["${AWS_VPC_SECURITY_GROUP}"],
"SubnetIds": [
"${AWS_VPC_SUBNET_A}",
"${AWS_VPC_SUBNET_B}",
"${AWS_VPC_SUBNET_C}"
]
}
}
}
2 changes: 2 additions & 0 deletions cspell/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"python",
"rust",
"software-terms",
"terraform",
"win32"
],
"enabled": true,
Expand All @@ -58,6 +59,7 @@
"@cspell/dict-k8s/cspell-ext.json",
"@cspell/dict-people-names/cspell-ext.json",
"@cspell/dict-software-terms/cspell-ext.json",
"@cspell/dict-terraform/cspell-ext.json",
"@cspell/dict-win32/cspell-ext.json"
],
"useGitignore": true
Expand Down
1 change: 1 addition & 0 deletions cspell/custom-dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ gunicorn
heroui
hsl
igoat
igw
inlinehilite
isanori
jumpstart
Expand Down
1 change: 1 addition & 0 deletions cspell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@cspell/dict-k8s": "^1.0.12",
"@cspell/dict-people-names": "^1.1.14",
"@cspell/dict-software-terms": "^4.2.5",
"@cspell/dict-terraform": "^1.1.3",
"@cspell/dict-win32": "^2.0.9",
"cspell": "^8.19.4"
}
Expand Down
3 changes: 3 additions & 0 deletions cspell/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions infrastructure/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 105 additions & 0 deletions infrastructure/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Infrastructure

This document provides instructions on how to manage the infrastructure for this project using Terraform and Zappa.

## Terraform

### Prerequisites

- Terraform
- An AWS account with credentials configured locally.

### Usage

1. **Initialize Terraform:**

```bash
terraform init
```

2. **Plan the changes:**

```bash
terraform plan
```

3. **Apply the changes:**

```bash
terraform apply
```

### Variables

You can override the default values by creating a `terraform.tfvars` file in the `infrastructure/` directory.

# TODO: Provide an example terraform.tfvars with important vars


### Outputs

Get the output values using the `terraform output` command. These outputs will be used for Zappa configuration.


```bash
terraform output
```

```bash
terraform output -raw db_password redis_auth_token
```

## Zappa Deployment

The Django backend deployment is managed by Zappa, this also includes the API Gateway, IAM roles, and Lambda Function provision.

### Install poetry dependencies

1. **Install dependencies using Poetry:**

```bash
poetry install
```

2. **Activate the virtual environment:**

```bash
eval $(poetry env activate)
```

3. **Create a `zappa_settings.json` file:**

```bash
cp zappa_settings.example.json zappa_settings.json
```

Replace all variables in the copied `zappa_settings.json` with appropriate secrets.
# TODO: explain this step

4. **Deploy staging:**

```bash
zappa deploy staging
```

Once deployed, Zappa will provide you with a URL. You can use this URL to test the API.

### Updating
After making necessary changes, you may run the following command to update the deployment.
```bash
zappa update staging
```

### Cleaning Up

To delete the deployment, you can use the following command:

```bash
zappa undeploy local
```

Then run this command to destroy the terraform infrastructure:

```bash
terraform destroy
```
Loading