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
| #!/bin/bash | |
| # 1) restore connector.env now, 2) tell user the deploy gist is patched. | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| ADMIN_EMAIL="koliadych@gmail.com" | |
| echo "=== Restoring connector.env from Secrets Manager ===" | |
| DB_PWD=$(aws --region "$REGION" secretsmanager get-secret-value --secret-id fintechner/db-password --query SecretString --output text) |
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
| #!/bin/bash | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| CMD_ID=$(aws --region "$REGION" ssm send-command \ | |
| --instance-ids "$INSTANCE_ID" \ | |
| --document-name AWS-RunShellScript \ | |
| --parameters '{"commands":["echo === restart connector ===","sudo systemctl restart fintechner-connector","sleep 10","echo === backfill log lines ===","sudo journalctl -u fintechner-connector --since \"30 sec ago\" --no-pager | grep -iE \"closedtrades|backfill|closed trade|fatal|ERROR\" | head -30","echo === closed_trades count after restart ===","sudo docker exec timescale psql -U fintechner -d fintechner -tA -c \"SELECT COUNT(*) FROM closed_trades;\""]}' \ |
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
| #!/bin/bash | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| SQL_B64=$(base64 -w0 <<'SQL' | |
| SELECT 'closed_trades:'||COUNT(*) FROM closed_trades; | |
| SELECT 'fills by origin:' AS x; | |
| SELECT origin, COUNT(*) FROM fills GROUP BY origin; |
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
| #!/bin/bash | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| echo "=== 1. Enable termination protection (idempotent) ===" | |
| aws --region "$REGION" ec2 modify-instance-attribute \ | |
| --instance-id "$INSTANCE_ID" \ | |
| --disable-api-termination "{\"Value\":true}" |
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
| #!/bin/bash | |
| # fintechner — live inventory of the deployed system. | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| echo "============================================================" | |
| echo " AWS-side" | |
| echo "============================================================" |
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
| #!/bin/bash | |
| # fintechner — gate #7: print all critical secrets to terminal so you can | |
| # write them on paper / save to password manager. NEVER paste output to chat. | |
| # | |
| # If AWS Secrets Manager has a regional outage you cannot re-sign or | |
| # decrypt the credential store. These are your only fallbacks. | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGION=ap-northeast-1 |
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
| #!/bin/bash | |
| # fintechner — readiness gate #6: CloudWatch health alarms + email SNS. | |
| # Catches "EC2 unreachable / instance dead" cases that in-process alerts | |
| # can't surface. ~$0/mo (SNS first 1k notifications free, alarms first 10 free). | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| EMAIL=koliadych@gmail.com |
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
| #!/bin/bash | |
| # fintechner — redeploy (slippage + equity fixes) AND enable termination | |
| # protection in one shot. Idempotent. | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| echo "=== 1. Enable EC2 termination protection ===" |
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
| #!/bin/bash | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| # Bundle the SQL queries into a single shell script, run it via base64 on | |
| # the EC2. Avoids all the JSON-in-SSM-in-bash escape hell. | |
| SCRIPT_B64=$(base64 -w0 <<'INNER' | |
| psql() { sudo docker exec timescale psql -U fintechner -d fintechner -c "$1" 2>&1 | head -15; } |
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
| #!/bin/bash | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| CMD_ID=$(aws --region "$REGION" ssm send-command \ | |
| --instance-ids "$INSTANCE_ID" \ | |
| --document-name AWS-RunShellScript \ | |
| --parameters '{"commands":[ |
NewerOlder