generated from RealDevSquad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 9
chore: before pushing to prod #166
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
Open
lakshayman
wants to merge
4
commits into
develop
Choose a base branch
from
chore-take-to-prod
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+491
−19
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cf9b718
fix: pipeline
lakshayman 5295089
fix: added policies in template instead of adding manually
lakshayman 9cb024b
chore: added setup dynamo table script and POST_DEPLOYMENT_SETUP
lakshayman a978723
chore: remove trailing spaces from public key if any
lakshayman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,228 @@ | ||
| # Post-Deployment Setup Guide | ||
|
|
||
| After deploying with `sam deploy`, you need to set up the following resources: | ||
|
|
||
| ## 🔴 Critical: DynamoDB Tables | ||
|
|
||
| The error you're seeing is because **DynamoDB tables don't exist**. You need to create 3 tables: | ||
|
|
||
| ### Quick Setup (Using Script) | ||
|
|
||
| ```bash | ||
| # Make script executable | ||
| chmod +x setup-dynamodb-tables.sh | ||
|
|
||
| # Run the script (defaults to us-east-1) | ||
| ./setup-dynamodb-tables.sh | ||
|
|
||
| # OR specify a region | ||
| ./setup-dynamodb-tables.sh us-east-1 | ||
| ``` | ||
|
|
||
| ### Manual Setup | ||
|
|
||
| #### 1. Create `featureFlag` Table | ||
|
|
||
| ```bash | ||
| aws dynamodb create-table \ | ||
| --table-name featureFlag \ | ||
| --attribute-definitions AttributeName=id,AttributeType=S \ | ||
| --key-schema AttributeName=id,KeyType=HASH \ | ||
| --billing-mode PAY_PER_REQUEST \ | ||
| --region us-east-1 | ||
| ``` | ||
|
|
||
| #### 2. Create `featureFlagUserMapping` Table | ||
|
|
||
| ```bash | ||
| aws dynamodb create-table \ | ||
| --table-name featureFlagUserMapping \ | ||
| --attribute-definitions \ | ||
| AttributeName=userId,AttributeType=S \ | ||
| AttributeName=flagId,AttributeType=S \ | ||
| --key-schema \ | ||
| AttributeName=userId,KeyType=HASH \ | ||
| AttributeName=flagId,KeyType=RANGE \ | ||
| --billing-mode PAY_PER_REQUEST \ | ||
| --region us-east-1 | ||
| ``` | ||
|
|
||
| #### 3. Create `requestLimit` Table (This is the missing one causing your error!) | ||
|
|
||
| ```bash | ||
| aws dynamodb create-table \ | ||
| --table-name requestLimit \ | ||
| --attribute-definitions AttributeName=limitType,AttributeType=S \ | ||
| --key-schema AttributeName=limitType,KeyType=HASH \ | ||
| --billing-mode PAY_PER_REQUEST \ | ||
| --region us-east-1 | ||
| ``` | ||
|
|
||
| #### 4. Initialize `requestLimit` Table | ||
|
|
||
| After creating the table, you need to add an initial value: | ||
|
|
||
| ```bash | ||
| aws dynamodb put-item \ | ||
| --table-name requestLimit \ | ||
| --item '{ | ||
| "limitType": {"S": "pendingLimit"}, | ||
| "limitValue": {"N": "1000"} | ||
| }' \ | ||
| --region us-east-1 | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## ✅ Verify Tables Exist | ||
|
|
||
| ```bash | ||
| # List all tables | ||
| aws dynamodb list-tables --region us-east-1 | ||
|
|
||
| # Check specific table | ||
| aws dynamodb describe-table --table-name requestLimit --region us-east-1 | ||
| ``` | ||
|
|
||
| You should see: | ||
| - `featureFlag` | ||
| - `featureFlagUserMapping` | ||
| - `requestLimit` | ||
|
|
||
| --- | ||
|
|
||
| ## 🔑 SSM Parameter for JWT Public Key | ||
|
|
||
| Make sure the JWT public key exists in AWS Systems Manager Parameter Store: | ||
|
|
||
| ### For PRODUCTION: | ||
|
|
||
| ```bash | ||
| # Check if parameter exists | ||
| aws ssm get-parameter \ | ||
| --name PROD_RDS_BACKEND_PUBLIC_KEY \ | ||
| --with-decryption \ | ||
| --region us-east-1 | ||
|
|
||
| # If it doesn't exist, create it: | ||
| aws ssm put-parameter \ | ||
| --name PROD_RDS_BACKEND_PUBLIC_KEY \ | ||
| --value "-----BEGIN PUBLIC KEY----- | ||
| YOUR_PUBLIC_KEY_HERE | ||
| -----END PUBLIC KEY-----" \ | ||
| --type SecureString \ | ||
| --region us-east-1 | ||
| ``` | ||
|
|
||
| ### For DEVELOPMENT: | ||
|
|
||
| ```bash | ||
| # Check if parameter exists | ||
| aws ssm get-parameter \ | ||
| --name STAGING_RDS_BACKEND_PUBLIC_KEY \ | ||
| --with-decryption \ | ||
| --region us-east-1 | ||
|
|
||
| # If it doesn't exist, create it: | ||
| aws ssm put-parameter \ | ||
| --name STAGING_RDS_BACKEND_PUBLIC_KEY \ | ||
| --value "-----BEGIN PUBLIC KEY----- | ||
| YOUR_PUBLIC_KEY_HERE | ||
| -----END PUBLIC KEY-----" \ | ||
| --type SecureString \ | ||
| --region us-east-1 | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 🧪 Test After Setup | ||
|
|
||
| After creating the tables, test your API: | ||
|
|
||
| ```bash | ||
| # 1. Health check (should work) | ||
| curl https://j31g91e2fa.execute-api.us-east-1.amazonaws.com/Prod/health-check | ||
|
|
||
| # 2. Get feature flags (should work now) | ||
| curl -X GET "https://j31g91e2fa.execute-api.us-east-1.amazonaws.com/Prod/feature-flags/" \ | ||
| -H "Cookie: rds-session-staging=YOUR_JWT_TOKEN" \ | ||
| -H "Origin: https://test.realdevsquad.com" | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 📋 Complete Checklist | ||
|
|
||
| - [ ] **DynamoDB Tables Created:** | ||
| - [ ] `featureFlag` table exists | ||
| - [ ] `featureFlagUserMapping` table exists | ||
| - [ ] `requestLimit` table exists | ||
| - [ ] `requestLimit` table has initial item with `limitType: "pendingLimit"` and `limitValue: 1000` | ||
|
|
||
| - [ ] **SSM Parameter:** | ||
| - [ ] `PROD_RDS_BACKEND_PUBLIC_KEY` exists (for PRODUCTION) | ||
| - [ ] OR `STAGING_RDS_BACKEND_PUBLIC_KEY` exists (for DEVELOPMENT) | ||
|
|
||
| - [ ] **Testing:** | ||
| - [ ] Health check endpoint works | ||
| - [ ] Feature flags endpoints work with JWT token | ||
|
|
||
| --- | ||
|
|
||
| ## 🔍 Troubleshooting | ||
|
|
||
| ### Error: "ResourceNotFoundException: Requested resource not found" | ||
|
|
||
| **Cause:** DynamoDB table doesn't exist | ||
|
|
||
| **Solution:** Create the missing table using the commands above | ||
|
|
||
| ### Error: "invalid memory address or nil pointer dereference" | ||
|
|
||
| **Cause:** Code is trying to unmarshal a nil response from DynamoDB (table doesn't exist or item doesn't exist) | ||
|
|
||
| **Solution:** | ||
| 1. Create the `requestLimit` table | ||
| 2. Initialize it with the default value (see step 4 above) | ||
|
|
||
| ### Error: "ParameterNotFound" when calling API | ||
|
|
||
| **Cause:** SSM Parameter for JWT public key doesn't exist | ||
|
|
||
| **Solution:** Create the SSM parameter with the public key (see SSM Parameter section above) | ||
|
|
||
| ### Error: "AccessDeniedException" when creating tables | ||
|
|
||
| **Cause:** Your AWS credentials don't have DynamoDB permissions | ||
|
|
||
| **Solution:** Ensure your AWS user/role has: | ||
| - `dynamodb:CreateTable` | ||
| - `dynamodb:PutItem` | ||
| - `dynamodb:DescribeTable` | ||
| - `dynamodb:ListTables` | ||
|
|
||
| --- | ||
|
|
||
| ## 🚀 Quick Setup Command | ||
|
|
||
| Run this to set up everything: | ||
|
|
||
| ```bash | ||
| # 1. Create all tables | ||
| ./setup-dynamodb-tables.sh us-east-1 | ||
|
|
||
| # 2. Verify tables | ||
| aws dynamodb list-tables --region us-east-1 | ||
|
|
||
| # 3. Test API | ||
| curl https://j31g91e2fa.execute-api.us-east-1.amazonaws.com/Prod/health-check | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 📝 Notes | ||
|
|
||
| - Tables are created with **PAY_PER_REQUEST** billing mode (no capacity planning needed) | ||
| - The `requestLimit` table is initialized with a default value of 1000 | ||
| - You can adjust the initial `limitValue` based on your needs | ||
| - All tables are created in the same region as your Lambda functions | ||
|
Comment on lines
+152
to
+228
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Excellent troubleshooting and reference sections! The documentation concludes with valuable resources:
Minor formatting: Line 184 has a trailing space (detected by markdownlint). 🧰 Tools🪛 markdownlint-cli2 (0.18.1)184-184: Trailing spaces (MD009, no-trailing-spaces) 🤖 Prompt for AI Agents |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Replace hardcoded API endpoints with placeholders.
Lines 144, 147, and 218 contain hardcoded API Gateway endpoints (
j31g91e2fa.execute-api.us-east-1.amazonaws.com). Users will need to replace these with their actual deployed endpoints.🔎 Proposed fix
🤖 Prompt for AI Agents