Skip to content
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

Week4 #18

Open
wants to merge 66 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
b05d2bc
week0
papicool Mar 3, 2023
ddbaf01
qdd budget files
papicool Mar 3, 2023
df03cac
cli commands for billing and budget alarm
papicool Mar 4, 2023
752fecc
add screenshot folder
papicool Mar 4, 2023
5c15f56
Delete file
papicool Mar 4, 2023
5e7a2f4
add changes
papicool Mar 4, 2023
0ce1485
Merge branch 'main' of https://github.com/papicool/aws-bootcamp-crudd…
papicool Mar 4, 2023
4d9ff4c
Add files via upload
papicool Mar 4, 2023
1fca794
Delete week0.md
papicool Mar 4, 2023
0179694
Update week0.md
papicool Mar 4, 2023
00b4d95
Update week0.md
papicool Mar 4, 2023
a9bc699
Update week0.md
papicool Mar 4, 2023
4170a8a
Update week0.md
papicool Mar 4, 2023
86c6bf2
Add files via upload
papicool Mar 4, 2023
62ee26d
add dockerfile
papicool Mar 6, 2023
165a709
update dockerfile
papicool Mar 6, 2023
e422be8
week1
papicool Mar 6, 2023
7b99af3
Update week1.md
papicool Mar 6, 2023
8177728
Update week1.md
papicool Mar 6, 2023
18bbf75
Update week1.md
papicool Mar 6, 2023
e0f7cf2
Update week1.md
papicool Mar 6, 2023
c82fc12
Add files via upload
papicool Mar 6, 2023
8cfc00f
Update week1.md
papicool Mar 6, 2023
b193877
updated
papicool Mar 6, 2023
bbe3037
update the open api file to add notifications
papicool Mar 7, 2023
812652c
create a new notifications backend endpoint
papicool Mar 7, 2023
32fd0db
implement frontend notifications page
papicool Mar 7, 2023
017d09a
install postgres and docker
papicool Mar 7, 2023
8ff822b
instrument HoneyComb
papicool Mar 8, 2023
a98c143
implement Honeycomb and add tracer, attributes
papicool Mar 8, 2023
46de277
Update week2.md
papicool Mar 13, 2023
da820ed
install xray
papicool Mar 13, 2023
1e658a6
instrument xray
papicool Mar 13, 2023
cb387db
instument xray updates
papicool Mar 13, 2023
e9757b1
updates instrument AWS XRAY
papicool Mar 15, 2023
9aea920
updates intrument AWS Xray
papicool Mar 15, 2023
e7196ea
comment implementation cloudwatch logs and xray implementation
papicool Mar 15, 2023
e0d88f5
instrument rollbar
papicool Mar 15, 2023
6f50dc1
finish implementing rollbar
papicool Mar 15, 2023
bff798c
Update README.md
papicool Mar 15, 2023
44935eb
Update week3.md
papicool Mar 15, 2023
bdac5ea
integrate AWS Cognito
papicool Mar 15, 2023
982c09a
update amplify configuration
papicool Mar 15, 2023
8d13cb5
Setup Cognito User Pool and Implement Custom Signin Page
papicool Mar 15, 2023
e1b8cc1
Implement Custom Signin, Signup and Confirmation Pages
papicool Mar 16, 2023
6cd8eae
update Recovery Page and add logs
papicool Mar 16, 2023
815306f
implement and Verify backend JWT token server side
papicool Mar 18, 2023
f92aee3
Update README.md
papicool Mar 18, 2023
cb90005
Update week4.md
papicool Mar 18, 2023
f30bdad
add devcontainer json file
papicool Mar 18, 2023
69a53c8
Update devcontainer.json
papicool Mar 18, 2023
24627c0
add dark theme
papicool Mar 18, 2023
2c16c8a
codespace config setup
papicool Mar 20, 2023
8ab9863
add env vars to devcontainer
papicool Mar 20, 2023
ecf606b
bash commands for psql
papicool Mar 20, 2023
ffb2640
bash commands for psql
papicool Mar 20, 2023
c7be3ac
add postgres lib and requirements
papicool Mar 21, 2023
670a293
implement home queries working
papicool Mar 21, 2023
d7d8fbb
implement inbound rule and connect to prod db
papicool Mar 21, 2023
2cb5456
update bin scripts files
papicool Mar 21, 2023
d45338c
post confirmation lambda
papicool Mar 22, 2023
6844720
refector db calls
papicool Mar 23, 2023
62c7a4d
bascule to gitpod
papicool Mar 27, 2023
294d00a
create activities and update display_name
papicool Mar 29, 2023
6d11348
create activities
papicool Mar 30, 2023
5d21553
Update README.md
papicool Apr 3, 2023
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
37 changes: 37 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "Cruddur Configuration",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/aws-cli:1": {}
},
"remoteEnv": {
"AWS_CLI_AUTO_PROMPT": "on-partial"
},
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"ms-python.python",
"dracula-theme.theme-dracula"
],
"settings": {
"workbench.colorThe": "Default Dark+ Experimental"
}
}
}

// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],


// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
39 changes: 37 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@

tasks:
- name: aws-cli
env:
AWS_CLI_AUTO_PROMPT: on-partial
init: |
cd /workspace
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
cd $THEIA_WORKSPACE_ROOT
- name: postgres
init: |
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt update
sudo apt install -y postgresql-client-13 libpq-dev
command: |
export GITPOD_IP=$(curl ifconfig.me)
source "$THEIA_WORKSPACE_ROOT/backend-flask/bin/db-update-sg-rule"
- name: react-js
command: |
cd frontend-react-js
npm i
vscode:
extensions:
- 42Crunch.vscode-openapi
- 42Crunch.vscode-openapi
- cweijan.vscode-postgresql-client2

ports:
- name: frontend
port: 3000
onOpen: open-browser
visibility: public
- name: backend
port: 4567
visibility: public
- name: xray-daemon
port: 2000
visibility: public
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ At the start of the bootcamp you need to create a new Github Repository from thi

The `/journal` directory contains

- [ ] [Week 0](journal/week0.md)
- [ ] [Week 1](journal/week1.md)
- [ ] [Week 2](journal/week2.md)
- [ ] [Week 3](journal/week3.md)
- [ ] [Week 4](journal/week4.md)
- [X] [Week 0](journal/week0.md)
- [X] [Week 1](journal/week1.md)
- [X] [Week 2](journal/week2.md)
- [X] [Week 3](journal/week3.md)
- [X] [Week 4](journal/week4.md)
- [ ] [Week 5](journal/week5.md)
- [ ] [Week 6](journal/week6.md)
- [ ] [Week 7](journal/week7.md)
Expand All @@ -30,4 +30,4 @@ The `/journal` directory contains
- [ ] [Week 10](journal/week10.md)
- [ ] [Week 11](journal/week11.md)
- [ ] [Week 12](journal/week12.md)
- [ ] [Week 13](journal/week13.md)
- [ ] [Week 13](journal/week13.md)
35 changes: 35 additions & 0 deletions aws/json/alarm_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"AlarmName": "DailyEstimatedCharges",
"AlarmDescription": "This alarm would be triggered if the daily estimated charges exceeds 1$",
"ActionsEnabled": true,
"AlarmActions": [
"arn:aws:sns:us-east-1:730331264766:billing-alarm"
],
"EvaluationPeriods": 1,
"DatapointsToAlarm": 1,
"Threshold": 1,
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"TreatMissingData": "breaching",
"Metrics": [{
"Id": "m1",
"MetricStat": {
"Metric": {
"Namespace": "AWS/Billing",
"MetricName": "EstimatedCharges",
"Dimensions": [{
"Name": "Currency",
"Value": "USD"
}]
},
"Period": 86400,
"Stat": "Maximum"
},
"ReturnData": false
},
{
"Id": "e1",
"Expression": "IF(RATE(m1)>0,RATE(m1)*86400,0)",
"Label": "DailyEstimatedCharges",
"ReturnData": true
}]
}
16 changes: 16 additions & 0 deletions aws/json/budget-notifications-with-subscribers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"Notification": {
"ComparisonOperator": "GREATER_THAN",
"NotificationType": "ACTUAL",
"Threshold": 50,
"ThresholdType": "PERCENTAGE"
},
"Subscribers": [
{
"Address": "[email protected]",
"SubscriptionType": "EMAIL"
}
]
}
]
31 changes: 31 additions & 0 deletions aws/json/budget.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"BudgetLimit": {
"Amount": "10",
"Unit": "USD"
},
"BudgetName": "Example Tag Budget",
"BudgetType": "COST",
"CostFilters": {
"TagKeyValue": [
"user:Key$value1",
"user:Key$value2"
]
},
"CostTypes": {
"IncludeCredit": true,
"IncludeDiscount": true,
"IncludeOtherSubscription": true,
"IncludeRecurring": true,
"IncludeRefund": true,
"IncludeSubscription": true,
"IncludeSupport": true,
"IncludeTax": true,
"IncludeUpfront": true,
"UseBlended": false
},
"TimePeriod": {
"Start": 1477958399,
"End": 3706473600
},
"TimeUnit": "MONTHLY"
}
53 changes: 53 additions & 0 deletions aws/json/lambdas/cruddur-post-confirmation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import json
import psycopg2
import os

def lambda_handler(event, context):
user = event['request']['userAttributes']

print('UserAttributes')
print(user)

user_display_name=user['name']
user_email=user['email']
user_handle=user['preferred_username']
user_cognito_id=user['sub']
try:
conn = psycopg2.connect(os.getenv('CONNECTION_URL'))
cur = conn.cursor()


sql = f"""
INSERT INTO public.users (
display_name,
email,
handle,
cognito_user_id
)
VALUES(
%s,
%s,
%s,
%s
)
"""
#cur.execute("INSERT INTO users (display_name, handle, cognito_user_id) VALUES(%s, %s, %s)", (user['name'], user['email'], user['sub']))
params = [
user_display_name,
user_email,
user_handle,
user_cognito_id
]
cur.execute(sql,*params)
conn.commit()

except (Exception, psycopg2.DatabaseError) as error:
print(error)

finally:
if conn is not None:
cur.close()
conn.close()
print('Database connection closed.')

return event
15 changes: 15 additions & 0 deletions aws/json/xray.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"SamplingRule": {
"RuleName": "Cruddur",
"ResourceARN": "*",
"Priority": 9000,
"FixedRate": 0.1,
"ReservoirSize": 5,
"ServiceName": "Cruddur",
"ServiceType": "*",
"Host": "*",
"HTTPMethod": "*",
"URLPath": "*",
"Version": 1
}
}
32 changes: 32 additions & 0 deletions backend-flask/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM python:3.10-slim-buster
## Step 1:
# inside container
# Create a working directory
WORKDIR /backend-flask

## Step 2:
# Outside -> inside container
# Copy source code to working directory
COPY requirements.txt requirements.txt
## Step 3:
# inside the container
# Install packages from requirements.txt
RUN pip3 install -r requirements.txt

# Outside -> inside container
# first (.) mean /backend-flask Outside container
# second (.) mean /backend-flask Inside container
#
COPY . .

# set env variable inside container
ENV FLASK_ENV=development

## Step 4:
# Expose port 80
EXPOSE ${PORT}

## Step 5:
# Run app at container launch
# python3 -m flask run --host=0.0.0.0 --port 4567
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0", "--port=4567"]
Loading