-
-
Couldn't load subscription status.
- Fork 248
Migrate OWASP Nest to Zappa for serverless deployment #2431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 17 commits
0975e0a
aa4eea0
18b8adb
6311813
481b928
ee1edb6
90e24e1
e618808
6220c24
9495dfd
df72c9a
619400e
b8b49fa
8c3569d
91b12e7
92469ac
1a66c4f
6994e33
a41221f
1165166
cc80292
c694c57
753e234
16445dc
536e615
206e60e
0a8b4ea
748ed52
f71861c
e785a42
bc3737e
e51d34b
d419073
a347969
88af956
5be1083
9650e5e
d4f7ddd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| 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", | ||
rudransh-shrivastava marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "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}" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,7 @@ gunicorn | |
| heroui | ||
| hsl | ||
| igoat | ||
| igw | ||
| inlinehilite | ||
| isanori | ||
| jumpstart | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| 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 | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| ### 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 | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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 | ||
| ``` | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Cleaning Up | ||
|
|
||
| To delete the deployment, you can use the following command: | ||
|
|
||
| ```bash | ||
| zappa undeploy local | ||
rudransh-shrivastava marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| Then run this command to destroy the terraform infrastructure: | ||
|
|
||
| ```bash | ||
| terraform destroy | ||
| ``` | ||
Uh oh!
There was an error while loading. Please reload this page.