-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp.ps1
More file actions
232 lines (218 loc) · 12.8 KB
/
Copy pathhelp.ps1
File metadata and controls
232 lines (218 loc) · 12.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<#
.SYNOPSIS
Shows an overview of all useful commands for the AWS Automation Projects.
Simply run: .\help.ps1
#>
Write-Host ""
Write-Host " =============================================" -ForegroundColor DarkCyan
Write-Host " AWS Automation Projects - Command Reference " -ForegroundColor White
Write-Host " =============================================" -ForegroundColor DarkCyan
# --- INITIAL SETUP ---
Write-Host ""
Write-Host " INITIAL SETUP" -ForegroundColor Cyan
Write-Host " ----------------" -ForegroundColor DarkGray
Write-Host ""
Write-Host " Verify prerequisites (AWS CLI, Terraform, Python, credentials):" -ForegroundColor Gray
Write-Host " aws --version" -ForegroundColor Yellow
Write-Host " terraform -version" -ForegroundColor Yellow
Write-Host " python --version" -ForegroundColor Yellow
Write-Host " aws sts get-caller-identity" -ForegroundColor Yellow
Write-Host ""
Write-Host " Configure AWS credentials:" -ForegroundColor Gray
Write-Host " aws configure" -ForegroundColor Yellow
Write-Host ""
Write-Host " Create the variables file from the template:" -ForegroundColor Gray
Write-Host " cd terraform" -ForegroundColor Yellow
Write-Host " Copy-Item terraform.tfvars.example terraform.tfvars" -ForegroundColor Yellow
Write-Host " # Then open terraform.tfvars and enter your emails" -ForegroundColor DarkGray
# --- DEPLOY ---
Write-Host ""
Write-Host " DEPLOY (ALL PROJECTS AT ONCE)" -ForegroundColor Cyan
Write-Host " --------------------------------" -ForegroundColor DarkGray
Write-Host ""
Write-Host " Full deploy (packages Lambdas + terraform apply):" -ForegroundColor Gray
Write-Host " .\deploy.ps1" -ForegroundColor Yellow
Write-Host ""
# --- TERRAFORM ---
Write-Host " TERRAFORM - INFRASTRUCTURE" -ForegroundColor Cyan
Write-Host " ----------------------------" -ForegroundColor DarkGray
Write-Host ""
Write-Host " Initialize Terraform (downloads providers, run once):" -ForegroundColor Gray
Write-Host " cd terraform" -ForegroundColor Yellow
Write-Host " terraform init" -ForegroundColor Yellow
Write-Host ""
Write-Host " Preview the resources to be created (no changes made):" -ForegroundColor Gray
Write-Host " terraform plan" -ForegroundColor Yellow
Write-Host ""
Write-Host " Create/update all resources on AWS:" -ForegroundColor Gray
Write-Host " terraform apply" -ForegroundColor Yellow
Write-Host ""
Write-Host " Show output values (resource names, ARNs, etc.):" -ForegroundColor Gray
Write-Host " terraform output" -ForegroundColor Yellow
Write-Host ""
Write-Host " Show currently managed resources:" -ForegroundColor Gray
Write-Host " terraform state list" -ForegroundColor Yellow
Write-Host ""
Write-Host " Inspect a specific resource in the state:" -ForegroundColor Gray
Write-Host " terraform state show module.youtube_summarizer.aws_lambda_function.youtube_summarizer" -ForegroundColor Yellow
Write-Host ""
Write-Host " Delete ALL resources from AWS:" -ForegroundColor Gray
Write-Host " terraform destroy" -ForegroundColor Yellow -NoNewline
Write-Host " # asks for confirmation" -ForegroundColor DarkGray
# ===========================================================================
# MODULE 1: REAL ESTATE SCRAPER
# ===========================================================================
Write-Host ""
Write-Host " =============================================" -ForegroundColor DarkCyan
Write-Host " Module 1: Real Estate Scraper " -ForegroundColor White
Write-Host " =============================================" -ForegroundColor DarkCyan
# --- SCRAPER LAMBDA ---
Write-Host ""
Write-Host " SCRAPER - INVOKE & LOGS" -ForegroundColor Cyan
Write-Host " -------------------------" -ForegroundColor DarkGray
Write-Host ""
Write-Host " Invoke the scraper manually:" -ForegroundColor Gray
Write-Host " aws lambda invoke --function-name scraper-function ``" -ForegroundColor Yellow
Write-Host " --payload '{}' --cli-binary-format raw-in-base64-out response.json" -ForegroundColor Yellow
Write-Host " Get-Content response.json" -ForegroundColor Yellow
Write-Host ""
Write-Host " Show the most recent logs (last hour):" -ForegroundColor Gray
Write-Host " aws logs tail /aws/lambda/scraper-function --since 1h" -ForegroundColor Yellow
Write-Host ""
Write-Host " Follow logs in real time (CTRL+C to exit):" -ForegroundColor Gray
Write-Host " aws logs tail /aws/lambda/scraper-function --follow" -ForegroundColor Yellow
# --- DYNAMODB ---
Write-Host ""
Write-Host " DYNAMODB - DATABASE" -ForegroundColor Cyan
Write-Host " ---------------------" -ForegroundColor DarkGray
Write-Host ""
Write-Host " Show all saved listings:" -ForegroundColor Gray
Write-Host " aws dynamodb scan --table-name scraper-listings ``" -ForegroundColor Yellow
Write-Host " --query ""Items[].{ID:listing_id.S, Title:title.S, URL:url.S}"" ``" -ForegroundColor Yellow
Write-Host " --output table" -ForegroundColor Yellow
Write-Host ""
Write-Host " Count how many listings are saved:" -ForegroundColor Gray
Write-Host " aws dynamodb scan --table-name scraper-listings ``" -ForegroundColor Yellow
Write-Host " --select COUNT --output json" -ForegroundColor Yellow
Write-Host ""
Write-Host " Delete a single listing by ID:" -ForegroundColor Gray
Write-Host " aws dynamodb delete-item --table-name scraper-listings ``" -ForegroundColor Yellow
Write-Host " --key '{""listing_id"": {""S"": ""ID_TO_DELETE""}}'" -ForegroundColor Yellow
# --- SNS ---
Write-Host ""
Write-Host " SNS - NOTIFICATIONS" -ForegroundColor Cyan
Write-Host " -----------------" -ForegroundColor DarkGray
Write-Host ""
Write-Host " Check the email subscription status:" -ForegroundColor Gray
Write-Host " aws sns list-subscriptions-by-topic ``" -ForegroundColor Yellow
Write-Host " --topic-arn (terraform output -raw scraper_sns_topic_arn)" -ForegroundColor Yellow
Write-Host ""
Write-Host " Send a test message to the topic:" -ForegroundColor Gray
Write-Host " aws sns publish ``" -ForegroundColor Yellow
Write-Host " --topic-arn (terraform output -raw scraper_sns_topic_arn) ``" -ForegroundColor Yellow
Write-Host " --subject ""Test"" --message ""Test notification""" -ForegroundColor Yellow
# ===========================================================================
# MODULE 2: YOUTUBE SUMMARIZER
# ===========================================================================
Write-Host ""
Write-Host " =============================================" -ForegroundColor DarkCyan
Write-Host " Module 2: YouTube Summarizer " -ForegroundColor White
Write-Host " =============================================" -ForegroundColor DarkCyan
# --- YOUTUBE SUMMARIZER LAMBDA ---
Write-Host ""
Write-Host " YOUTUBE SUMMARIZER - INVOKE" -ForegroundColor Cyan
Write-Host " -----------------------------" -ForegroundColor DarkGray
Write-Host ""
Write-Host " Summarize a YouTube video (invoke from CLI):" -ForegroundColor Gray
Write-Host " aws lambda invoke --function-name scraper-youtube-summarizer-v2 ``" -ForegroundColor Yellow
Write-Host " --payload '{""youtube_url"": ""https://www.youtube.com/watch?v=VIDEO_ID""}' ``" -ForegroundColor Yellow
Write-Host " --cli-binary-format raw-in-base64-out response.json" -ForegroundColor Yellow
Write-Host " Get-Content response.json" -ForegroundColor Yellow
Write-Host ""
Write-Host " Show the most recent logs (last hour):" -ForegroundColor Gray
Write-Host " aws logs tail /aws/lambda/scraper-youtube-summarizer-v2 --since 1h" -ForegroundColor Yellow
Write-Host ""
Write-Host " Follow logs in real time:" -ForegroundColor Gray
Write-Host " aws logs tail /aws/lambda/scraper-youtube-summarizer-v2 --follow" -ForegroundColor Yellow
# --- SSM PARAMETER STORE (API KEYS) ---
Write-Host ""
Write-Host " SSM PARAMETER STORE - API KEYS" -ForegroundColor Cyan
Write-Host " ---------------------------------" -ForegroundColor DarkGray
Write-Host ""
Write-Host " Set or update your Gemini API key:" -ForegroundColor Gray
Write-Host " aws ssm put-parameter ``" -ForegroundColor Yellow
Write-Host " --name ""/scraper/youtube_summarizer/gemini_api_key"" ``" -ForegroundColor Yellow
Write-Host " --value ""YOUR_GEMINI_KEY"" --type ""SecureString"" --overwrite" -ForegroundColor Yellow
Write-Host ""
Write-Host " Set or update your OpenAI API key (fallback provider):" -ForegroundColor Gray
Write-Host " aws ssm put-parameter ``" -ForegroundColor Yellow
Write-Host " --name ""/scraper/youtube_summarizer/openai_api_key"" ``" -ForegroundColor Yellow
Write-Host " --value ""YOUR_OPENAI_KEY"" --type ""SecureString"" --overwrite" -ForegroundColor Yellow
Write-Host ""
Write-Host " Check which keys are stored (shows metadata, NOT the value):" -ForegroundColor Gray
Write-Host " aws ssm describe-parameters --filters ""Key=Path,Values=/scraper/youtube_summarizer""" -ForegroundColor Yellow
Write-Host ""
Write-Host " Read the current value of a key (decrypted):" -ForegroundColor Gray
Write-Host " aws ssm get-parameter ``" -ForegroundColor Yellow
Write-Host " --name ""/scraper/youtube_summarizer/gemini_api_key"" ``" -ForegroundColor Yellow
Write-Host " --with-decryption --query ""Parameter.Value"" --output text" -ForegroundColor Yellow
# --- SES ---
Write-Host ""
Write-Host " SES - EMAIL SERVICE" -ForegroundColor Cyan
Write-Host " ---------------------" -ForegroundColor DarkGray
Write-Host ""
Write-Host " Verify a new email identity (required in sandbox mode):" -ForegroundColor Gray
Write-Host " aws ses verify-email-identity --email-address ""your@email.com""" -ForegroundColor Yellow
Write-Host ""
Write-Host " List verified email identities:" -ForegroundColor Gray
Write-Host " aws ses list-identities --identity-type EmailAddress" -ForegroundColor Yellow
Write-Host ""
Write-Host " Check SES sending quota and limits:" -ForegroundColor Gray
Write-Host " aws ses get-send-quota" -ForegroundColor Yellow
# --- EVENTBRIDGE (SCHEDULING) ---
Write-Host ""
Write-Host " EVENTBRIDGE - SCHEDULING" -ForegroundColor Cyan
Write-Host " --------------------------" -ForegroundColor DarkGray
Write-Host ""
Write-Host " The scraper is already scheduled via Terraform (rate/cron in terraform.tfvars)." -ForegroundColor Gray
Write-Host " To change the schedule, edit terraform.tfvars:" -ForegroundColor Gray
Write-Host " schedule_expression = ""rate(1 hour)""" -ForegroundColor Yellow -NoNewline
Write-Host " # every hour" -ForegroundColor DarkGray
Write-Host " schedule_expression = ""rate(30 minutes)""" -ForegroundColor Yellow -NoNewline
Write-Host " # every 30 min" -ForegroundColor DarkGray
Write-Host " schedule_expression = ""cron(0 9 * * ? *)""" -ForegroundColor Yellow -NoNewline
Write-Host " # daily at 9 AM UTC" -ForegroundColor DarkGray
Write-Host " schedule_expression = ""cron(0 9,18 * * ? *)""" -ForegroundColor Yellow -NoNewline
Write-Host " # daily at 9 AM and 6 PM UTC" -ForegroundColor DarkGray
Write-Host ""
Write-Host " Then apply:" -ForegroundColor Gray
Write-Host " cd terraform; terraform apply" -ForegroundColor Yellow
Write-Host ""
Write-Host " Check the current EventBridge rule:" -ForegroundColor Gray
Write-Host " aws events describe-rule --name scraper-schedule" -ForegroundColor Yellow
Write-Host ""
Write-Host " Temporarily disable the schedule (without destroying):" -ForegroundColor Gray
Write-Host " aws events disable-rule --name scraper-schedule" -ForegroundColor Yellow
Write-Host ""
Write-Host " Re-enable the schedule:" -ForegroundColor Gray
Write-Host " aws events enable-rule --name scraper-schedule" -ForegroundColor Yellow
# --- TYPICAL FLOW ---
Write-Host ""
Write-Host " =============================================" -ForegroundColor DarkCyan
Write-Host " Typical flow for the first deployment " -ForegroundColor White
Write-Host " =============================================" -ForegroundColor DarkCyan
Write-Host ""
Write-Host " 1. aws configure" -ForegroundColor White -NoNewline
Write-Host " # configure credentials" -ForegroundColor DarkGray
Write-Host " 2. Copy-Item terraform\terraform.tfvars.example terraform\terraform.tfvars" -ForegroundColor White
Write-Host " " -NoNewline
Write-Host "# open the file and fill in your emails" -ForegroundColor DarkGray
Write-Host " 3. .\deploy.ps1" -ForegroundColor White -NoNewline
Write-Host " # build + deploy everything" -ForegroundColor DarkGray
Write-Host " 4. " -NoNewline -ForegroundColor White
Write-Host "# confirm SNS email + verify SES email identity" -ForegroundColor DarkGray
Write-Host " 5. aws ssm put-parameter ..." -ForegroundColor White -NoNewline
Write-Host " # store Gemini API key" -ForegroundColor DarkGray
Write-Host " 6. aws lambda invoke ..." -ForegroundColor White -NoNewline
Write-Host " # test the YouTube summarizer" -ForegroundColor DarkGray
Write-Host ""