@@ -21,7 +21,8 @@ Follow these steps to set up the infrastructure:
2121 ``` bash
2222 cd infrastructure/backend/
2323 ```
24- * Note:* Optionally change the region: set ` aws_region ` in a ` .tfvars ` file.
24+
25+ ** Note:** Optionally change the region: set ` aws_region ` in a ` .tfvars ` file.
2526
2627- Initialize Terraform if needed:
2728 ``` bash
@@ -33,6 +34,10 @@ Follow these steps to set up the infrastructure:
3334 terraform apply
3435 ```
3536
37+ ** Note:** Copy the state bucket name from the output.
38+
39+ ** Note:** It is recommended to not destroy the backend resources unless absolutely necessary.
40+
36412 . ** Setup Main Infrastructure (staging)** :
3742
3843- Navigate to the main infrastructure directory. If you are in ` infrastructure/backend ` , you can use:
@@ -50,13 +55,23 @@ Follow these steps to set up the infrastructure:
5055 cat terraform.tfvars.example > terraform.tfvars
5156 ```
5257
53- - * Note:* Optionally change the region:
54- - set ` aws_region ` in a ` .tfvars ` file.
55- - set ` region ` in a ` .tfbackend ` file and provide it using ` terraform init -backend-config=<file> ` .
58+ - Create a local backend configuration file:
59+ ``` bash
60+ touch terraform.tfbackend
61+ ```
62+
63+ - Copy the contents from the example file:
64+ ``` bash
65+ cat terraform.tfbackend.example > terraform.tfbackend
66+ ```
67+
68+ * Note:* Update the state bucket name in ` terraform.tfbackend ` with the name of the state bucket created in the previous step.
69+
70+ * Note:* Update defaults (e.g. ` region ` ) as needed.
5671
5772- Initialize Terraform with the backend configuration:
5873 ``` bash
59- terraform init
74+ terraform init -backend-config=terraform.tfbackend
6075 ```
6176
6277- Apply the changes to create the main infrastructure using the command:
@@ -114,13 +129,15 @@ The Django backend deployment is managed by Zappa. This includes the API Gateway
114129
1151305. ** Deploy** :
116131
117- - * Note* : Make sure to populate all ` DJANGO_* ` secrets that are set as ` to-be-set-in-aws-console`
132+ - ** Note* * : Make sure to populate all ` DJANGO_* ` secrets that are set as ` to-be-set-in-aws-console`
118133 in the Parameter Store. The deployment might fail with no logs if secrets such as
119134 ` DJANGO_SLACK_BOT_TOKEN` are invalid.
120135
121136 ` ` ` bash
122137 zappa deploy staging
123138 ` ` `
139+ - ** Note** : If the deployment is successful but returns a ` 5xx` error, resolve the issues
140+ and use ` zappa undeploy staging` & ` zappa deploy staging` . The command ` zappa update staging` may not work.
124141
125142Once deployed, use the URL provided by Zappa to test the API.
126143
@@ -163,7 +180,7 @@ Migrate and load data into the new database.
163180 - Upload the fixture present in ` backend/data` to ` nest-fixtures` bucket using the following command:
164181
165182 ` ` ` bash
166- aws s3 cp data/nest.json.gz s3://nest-fixtures/
183+ aws s3 cp data/nest.json.gz s3://owasp- nest-fixtures- < id > /
167184 ` ` `
168185
1691863. ** Run ECS Tasks** :
@@ -188,6 +205,9 @@ Migrate and load data into the new database.
188205 zappa undeploy staging
189206 ` ` `
190207
208+ - Ensure all buckets and ECR repositories are empty.
209+
210+ ** Note:** Some resources have ` prevent_destroy` set to ` true` . Please set it to ` false` before destruction.
191211- To destroy Terraform infrastructure:
192212
193213 ` ` ` bash
0 commit comments