lambdachecks 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lambdachecks-0.1.0/PKG-INFO +31 -0
- lambdachecks-0.1.0/README.md +10 -0
- lambdachecks-0.1.0/lambdachecks/__init__.py +7 -0
- lambdachecks-0.1.0/lambdachecks/server/__init__.py +4 -0
- lambdachecks-0.1.0/lambdachecks/server/lambda_function.py +287 -0
- lambdachecks-0.1.0/lambdachecks/server/local_settings.py +40 -0
- lambdachecks-0.1.0/lambdachecks/server/requirements.txt +3 -0
- lambdachecks-0.1.0/lambdachecks.egg-info/PKG-INFO +31 -0
- lambdachecks-0.1.0/lambdachecks.egg-info/SOURCES.txt +11 -0
- lambdachecks-0.1.0/lambdachecks.egg-info/dependency_links.txt +1 -0
- lambdachecks-0.1.0/lambdachecks.egg-info/top_level.txt +1 -0
- lambdachecks-0.1.0/pyproject.toml +35 -0
- lambdachecks-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lambdachecks
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Healthchecks (cron / scheduled-job monitoring) on AWS Lambda, unchanged, with its database on s3rds: ≈ $0 when idle. The package carries the Lambda code a deployment runs.
|
|
5
|
+
Author: Frank Zhang
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/cloudformer/lambdachecks
|
|
8
|
+
Project-URL: IdleFree, https://cloudformer.github.io/
|
|
9
|
+
Project-URL: Repository, https://github.com/cloudformer/lambdachecks
|
|
10
|
+
Project-URL: Deploy, https://github.com/cloudformer/lambdachecks#quick-start
|
|
11
|
+
Project-URL: Changelog, https://github.com/cloudformer/lambdachecks/blob/main/CHANGELOG.md
|
|
12
|
+
Project-URL: Issues, https://github.com/cloudformer/lambdachecks/issues
|
|
13
|
+
Keywords: serverless,aws,lambda,healthchecks,cron,monitoring,s3rds,sqlite,s3
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: System :: Monitoring
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# lambdachecks
|
|
23
|
+
|
|
24
|
+
**[Healthchecks](https://github.com/healthchecks/healthchecks) (cron / scheduled-job monitoring) on AWS Lambda,
|
|
25
|
+
unchanged, with its database on [s3rds](https://github.com/cloudformer/s3rds) (SQLite on S3): ≈ $0 when idle.**
|
|
26
|
+
Part of [IdleFree](https://cloudformer.github.io/).
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
This package carries the Lambda code a deployment runs (`lambdachecks.server`); there is nothing to import in your
|
|
31
|
+
own code. Deploy it with Terraform: see the [main repository](https://github.com/cloudformer/lambdachecks).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# lambdachecks
|
|
2
|
+
|
|
3
|
+
**[Healthchecks](https://github.com/healthchecks/healthchecks) (cron / scheduled-job monitoring) on AWS Lambda,
|
|
4
|
+
unchanged, with its database on [s3rds](https://github.com/cloudformer/s3rds) (SQLite on S3): ≈ $0 when idle.**
|
|
5
|
+
Part of [IdleFree](https://cloudformer.github.io/).
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
This package carries the Lambda code a deployment runs (`lambdachecks.server`); there is nothing to import in your
|
|
10
|
+
own code. Deploy it with Terraform: see the [main repository](https://github.com/cloudformer/lambdachecks).
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"""The Lambda code: lambda_function.lambda_handler (Function URL: Healthchecks' WSGI app, the setup page) and
|
|
2
|
+
lambda_function.manage_handler (manage.py). Deployed from this package: lambda_function.py at the zip root next to
|
|
3
|
+
Healthchecks' release, local_settings.py as hc/local_settings.py; requirements.txt is installed next to Healthchecks'
|
|
4
|
+
own requirements.txt."""
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"""lambdachecks server: Healthchecks, unchanged, in one Lambda behind a Function URL.
|
|
2
|
+
|
|
3
|
+
lambda_handler Function URL event (payload 2.0) -> WSGI environ -> hc.wsgi.application -> response
|
|
4
|
+
until the first account exists: the setup page instead (migrate, then createsuperuser)
|
|
5
|
+
manage_handler {"manage": ["migrate", "--noinput"]} -> manage.py migrate --noinput, output returned
|
|
6
|
+
(the manage function: no URL, 15 minutes; the setup page starts migrate there)
|
|
7
|
+
|
|
8
|
+
The package (the build: Terraform's modules/lambdachecks/build.py, scripts/build_server.py for this checkout) puts
|
|
9
|
+
Healthchecks' release at the root next to this file, so `hc` imports as it does in Healthchecks' own checkout; its
|
|
10
|
+
settings hook hc/local_settings.py is local_settings.py from this directory.
|
|
11
|
+
"""
|
|
12
|
+
import base64
|
|
13
|
+
import hmac
|
|
14
|
+
import html
|
|
15
|
+
import io
|
|
16
|
+
import json
|
|
17
|
+
import os
|
|
18
|
+
import sys
|
|
19
|
+
import time
|
|
20
|
+
from contextlib import redirect_stderr, redirect_stdout
|
|
21
|
+
from urllib.parse import parse_qs, unquote_to_bytes
|
|
22
|
+
|
|
23
|
+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hc.settings")
|
|
24
|
+
|
|
25
|
+
_app = None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _retry_throttled():
|
|
29
|
+
"""s3rds runs one writer (its Lambda's reserved concurrency is 1): a request that arrives while another runs is
|
|
30
|
+
refused by Lambda with HTTP 429 before the function starts, so it provably did not execute and is safe to send
|
|
31
|
+
again. s3rds 0.2.1's client raises it at once; this retries it with backoff (about 10 s in all).
|
|
32
|
+
Remove once the s3rds client does it itself."""
|
|
33
|
+
from s3rds import sqlite
|
|
34
|
+
if getattr(sqlite.Connection._send, "retries_429", False):
|
|
35
|
+
return
|
|
36
|
+
send = sqlite.Connection._send
|
|
37
|
+
|
|
38
|
+
def _send(self, path, body):
|
|
39
|
+
for delay in (0.05, 0.1, 0.2, 0.4, 0.8, 1.2, 1.6, 2.0, 2.0, 2.0):
|
|
40
|
+
try:
|
|
41
|
+
return send(self, path, body)
|
|
42
|
+
except sqlite.Error as e:
|
|
43
|
+
if e.status != 429:
|
|
44
|
+
raise
|
|
45
|
+
time.sleep(delay)
|
|
46
|
+
return send(self, path, body)
|
|
47
|
+
|
|
48
|
+
_send.retries_429 = True
|
|
49
|
+
sqlite.Connection._send = _send
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _application(domain):
|
|
53
|
+
"""Healthchecks' WSGI app, loaded on the first request. Healthchecks derives ALLOWED_HOSTS, the ping URL
|
|
54
|
+
and its links from SITE_ROOT; the Function URL cannot be passed in as an environment variable (it does not
|
|
55
|
+
exist before the function), so it comes from the first request. AWS sets domainName, not the caller."""
|
|
56
|
+
global _app
|
|
57
|
+
if _app is None:
|
|
58
|
+
_retry_throttled()
|
|
59
|
+
os.environ.setdefault("SITE_ROOT", "https://" + domain)
|
|
60
|
+
from django.core.wsgi import get_wsgi_application
|
|
61
|
+
_app = get_wsgi_application()
|
|
62
|
+
return _app
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _environ(event):
|
|
66
|
+
ctx = event["requestContext"]
|
|
67
|
+
http = ctx["http"]
|
|
68
|
+
headers = event.get("headers") or {}
|
|
69
|
+
body = event.get("body") or ""
|
|
70
|
+
body = base64.b64decode(body) if event.get("isBase64Encoded") else body.encode()
|
|
71
|
+
environ = {
|
|
72
|
+
"REQUEST_METHOD": http["method"],
|
|
73
|
+
"SCRIPT_NAME": "",
|
|
74
|
+
"PATH_INFO": unquote_to_bytes(event.get("rawPath", "/")).decode("latin-1"), # WSGI: decoded, latin-1
|
|
75
|
+
"QUERY_STRING": event.get("rawQueryString", ""),
|
|
76
|
+
"CONTENT_TYPE": headers.get("content-type", ""),
|
|
77
|
+
"CONTENT_LENGTH": str(len(body)),
|
|
78
|
+
"SERVER_NAME": ctx.get("domainName", "localhost"),
|
|
79
|
+
"SERVER_PORT": "443",
|
|
80
|
+
"SERVER_PROTOCOL": http.get("protocol", "HTTP/1.1"),
|
|
81
|
+
"REMOTE_ADDR": http.get("sourceIp", ""),
|
|
82
|
+
"wsgi.version": (1, 0),
|
|
83
|
+
"wsgi.url_scheme": headers.get("x-forwarded-proto", "https"), # Django's CSRF origin check needs https
|
|
84
|
+
"wsgi.input": io.BytesIO(body),
|
|
85
|
+
"wsgi.errors": sys.stderr,
|
|
86
|
+
"wsgi.multithread": False,
|
|
87
|
+
"wsgi.multiprocess": True,
|
|
88
|
+
"wsgi.run_once": False,
|
|
89
|
+
}
|
|
90
|
+
for name, value in headers.items():
|
|
91
|
+
key = name.upper().replace("-", "_")
|
|
92
|
+
if key not in ("CONTENT_TYPE", "CONTENT_LENGTH"):
|
|
93
|
+
environ["HTTP_" + key] = value
|
|
94
|
+
if event.get("cookies"): # payload 2.0 moves Cookie out of the headers
|
|
95
|
+
environ["HTTP_COOKIE"] = "; ".join(event["cookies"])
|
|
96
|
+
return environ
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _call(app, environ):
|
|
100
|
+
"""Run the WSGI app; the response in the Function URL's shape (body always base64: fonts, gzip)."""
|
|
101
|
+
started = {}
|
|
102
|
+
|
|
103
|
+
def start_response(status, response_headers, exc_info=None):
|
|
104
|
+
started["status"], started["headers"] = status, response_headers
|
|
105
|
+
|
|
106
|
+
result = app(environ, start_response)
|
|
107
|
+
try:
|
|
108
|
+
body = b"".join(result)
|
|
109
|
+
finally:
|
|
110
|
+
if hasattr(result, "close"):
|
|
111
|
+
result.close()
|
|
112
|
+
headers, cookies = {}, []
|
|
113
|
+
for name, value in started["headers"]:
|
|
114
|
+
if name.lower() == "set-cookie":
|
|
115
|
+
cookies.append(value)
|
|
116
|
+
else:
|
|
117
|
+
key = name.lower()
|
|
118
|
+
headers[key] = f"{headers[key]},{value}" if key in headers else value
|
|
119
|
+
return {"statusCode": int(started["status"].split(None, 1)[0]), "headers": headers, "cookies": cookies,
|
|
120
|
+
"body": base64.b64encode(body).decode(), "isBase64Encoded": True}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def lambda_handler(event, context):
|
|
124
|
+
app = _application(event["requestContext"].get("domainName", "localhost"))
|
|
125
|
+
if not _set_up():
|
|
126
|
+
return _setup(event)
|
|
127
|
+
return _call(app, _environ(event))
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# ---------------- first run, in the browser: migrate, then the first account ----------------
|
|
131
|
+
# Until a superuser exists every page is the setup page. Each step needs the setup key (the deployment's
|
|
132
|
+
# SECRET_KEY, from the Terraform variable file), so nobody else can claim a fresh deployment.
|
|
133
|
+
|
|
134
|
+
_ready = False # once true, never checked again in this container
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _query(sql):
|
|
138
|
+
"""One query outside Django's request cycle, on a fresh connection (a failed one is not reused)."""
|
|
139
|
+
from django.db import connection
|
|
140
|
+
connection.close()
|
|
141
|
+
try:
|
|
142
|
+
with connection.cursor() as c:
|
|
143
|
+
c.execute(sql)
|
|
144
|
+
return c.fetchone()
|
|
145
|
+
finally:
|
|
146
|
+
connection.close()
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def _set_up():
|
|
150
|
+
global _ready
|
|
151
|
+
if not _ready:
|
|
152
|
+
try:
|
|
153
|
+
_ready = _query("SELECT 1 FROM auth_user WHERE is_superuser = 1 LIMIT 1") is not None
|
|
154
|
+
except Exception: # noqa: BLE001 - no database / no tables yet: not set up
|
|
155
|
+
pass
|
|
156
|
+
return _ready
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _progress():
|
|
160
|
+
"""(applied, total) migrations."""
|
|
161
|
+
from django.db.migrations.loader import MigrationLoader
|
|
162
|
+
total = len(MigrationLoader(None, ignore_no_migrations=True).disk_migrations)
|
|
163
|
+
try:
|
|
164
|
+
applied = _query("SELECT COUNT(*) FROM django_migrations")[0]
|
|
165
|
+
except Exception: # noqa: BLE001 - the table comes with the first migration
|
|
166
|
+
applied = 0
|
|
167
|
+
return applied, total
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _key_ok(key):
|
|
171
|
+
secret = os.environ.get("SECRET_KEY", "")
|
|
172
|
+
return bool(secret) and hmac.compare_digest(key.encode(), secret.encode())
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _setup(event):
|
|
176
|
+
method, path = event["requestContext"]["http"]["method"], event.get("rawPath", "/")
|
|
177
|
+
message, refresh = "", False
|
|
178
|
+
if method == "POST":
|
|
179
|
+
body = event.get("body") or ""
|
|
180
|
+
body = base64.b64decode(body).decode() if event.get("isBase64Encoded") else body
|
|
181
|
+
form = {k: v[0] for k, v in parse_qs(body).items()}
|
|
182
|
+
if not _key_ok(form.get("key", "")):
|
|
183
|
+
message = "Wrong setup key: it is secret_key in your Terraform variable file."
|
|
184
|
+
elif path == "/setup/migrate":
|
|
185
|
+
import boto3
|
|
186
|
+
boto3.client("lambda").invoke(FunctionName=os.environ["MANAGE_FUNCTION"], InvocationType="Event",
|
|
187
|
+
Payload=json.dumps({"manage": ["migrate", "--noinput"]}).encode())
|
|
188
|
+
message, refresh = "Migrations started; this page refreshes every 10 seconds.", True
|
|
189
|
+
elif path == "/setup/user":
|
|
190
|
+
applied, total = _progress()
|
|
191
|
+
if applied < total:
|
|
192
|
+
message = "Run the migrations first."
|
|
193
|
+
else:
|
|
194
|
+
code, output = _manage(["createsuperuser", "--email", form.get("email", ""),
|
|
195
|
+
"--password", form.get("password", "")])
|
|
196
|
+
if code == 0 and _set_up():
|
|
197
|
+
return {"statusCode": 303, "headers": {"location": "/accounts/login/"}, "body": ""}
|
|
198
|
+
message = output.strip() or f"createsuperuser failed (exit {code})"
|
|
199
|
+
applied, total = _progress()
|
|
200
|
+
refresh = refresh or 0 < applied < total
|
|
201
|
+
return {"statusCode": 200, "headers": {"content-type": "text/html; charset=utf-8"},
|
|
202
|
+
"body": SETUP_HTML.format(
|
|
203
|
+
refresh='<meta http-equiv="refresh" content="10;url=/">' if refresh else "",
|
|
204
|
+
message=f'<p class="msg">{html.escape(message)}</p>' if message else "",
|
|
205
|
+
applied=applied, total=total, done="done" if applied >= total else "",
|
|
206
|
+
user_disabled="" if applied >= total else "disabled")}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
SETUP_HTML = """<!doctype html>
|
|
210
|
+
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">{refresh}
|
|
211
|
+
<title>lambdachecks setup</title>
|
|
212
|
+
<style>
|
|
213
|
+
body {{ font: 15px/1.5 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; max-width: 34em;
|
|
214
|
+
margin: 3em auto; padding: 0 16px; color: #0f172a; background: #fff; }}
|
|
215
|
+
h1 {{ font-size: 1.4em; }} h2 {{ font-size: 1.1em; margin-top: 2em; }}
|
|
216
|
+
input {{ display: block; width: 100%; box-sizing: border-box; margin: .3em 0 .8em; padding: .5em; font: inherit; }}
|
|
217
|
+
button {{ padding: .5em 1.2em; font: inherit; }}
|
|
218
|
+
.msg {{ background: #fef3c7; padding: .6em .8em; white-space: pre-wrap; }}
|
|
219
|
+
.done {{ color: #15803d; font-weight: 600; }} .muted {{ color: #64748b; }}
|
|
220
|
+
</style></head><body>
|
|
221
|
+
<h1>lambdachecks setup</h1>
|
|
222
|
+
<p class="muted">Healthchecks is deployed; its database is empty. Two steps, once. The setup key is
|
|
223
|
+
<code>secret_key</code> in your Terraform variable file.</p>
|
|
224
|
+
{message}
|
|
225
|
+
<h2>1. Database</h2>
|
|
226
|
+
<p class="{done}">{applied} / {total} migrations applied</p>
|
|
227
|
+
<form method="post" action="/setup/migrate">
|
|
228
|
+
<input type="password" name="key" placeholder="setup key" required>
|
|
229
|
+
<button>Run migrations</button>
|
|
230
|
+
<span class="muted">a few minutes; safe to run again, it continues where it stopped</span>
|
|
231
|
+
</form>
|
|
232
|
+
<h2>2. First account</h2>
|
|
233
|
+
<form method="post" action="/setup/user">
|
|
234
|
+
<input type="email" name="email" placeholder="email" required {user_disabled}>
|
|
235
|
+
<input type="password" name="password" placeholder="password" required {user_disabled}>
|
|
236
|
+
<input type="password" name="key" placeholder="setup key" required {user_disabled}>
|
|
237
|
+
<button {user_disabled}>Create the account</button>
|
|
238
|
+
</form>
|
|
239
|
+
</body></html>
|
|
240
|
+
"""
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _create_database():
|
|
244
|
+
"""lambdachecks' database in s3rds, created through s3rds' own client (an existing one is left alone),
|
|
245
|
+
so nothing has to be set up on the s3rds side first."""
|
|
246
|
+
from s3rds import sqlite
|
|
247
|
+
db = sqlite.connect(os.environ["DB_HOST"], os.environ["DB_USER"], os.environ["DB_PASSWORD"],
|
|
248
|
+
os.environ.get("DB_NAME", "healthchecks"))
|
|
249
|
+
try:
|
|
250
|
+
db.create_database()
|
|
251
|
+
finally:
|
|
252
|
+
db.close()
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def manage_handler(event, context):
|
|
256
|
+
"""One manage.py command, e.g. {"manage": ["createsuperuser", "--email", "me@x.org", "--password", "..."]}.
|
|
257
|
+
Returns {"exit": 0, "output": "..."}; stdin is not a terminal, so nothing prompts."""
|
|
258
|
+
args = event.get("manage")
|
|
259
|
+
if not isinstance(args, list) or not args or not all(isinstance(a, str) for a in args):
|
|
260
|
+
return {"exit": 2, "output": 'expected {"manage": ["<command>", "<arg>", ...]}'}
|
|
261
|
+
_retry_throttled()
|
|
262
|
+
_create_database()
|
|
263
|
+
code, output = _manage(args)
|
|
264
|
+
print(output) # CloudWatch keeps it too
|
|
265
|
+
return {"exit": code, "output": output[-20000:]}
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def _manage(args):
|
|
269
|
+
"""manage.py <args> in this process: (exit code, output). A warm container keeps Django's connection between
|
|
270
|
+
invocations; a command that failed mid-transaction would leave it broken for the next one, so each command
|
|
271
|
+
starts and ends with a fresh one."""
|
|
272
|
+
from django.core.management import execute_from_command_line
|
|
273
|
+
from django.db import connections
|
|
274
|
+
out, code = io.StringIO(), 0
|
|
275
|
+
with redirect_stdout(out), redirect_stderr(out):
|
|
276
|
+
try:
|
|
277
|
+
connections.close_all()
|
|
278
|
+
execute_from_command_line(["manage.py", *args])
|
|
279
|
+
except SystemExit as e:
|
|
280
|
+
code = e.code if isinstance(e.code, int) else 1
|
|
281
|
+
except Exception: # noqa: BLE001 - a failed command is reported, not raised
|
|
282
|
+
import traceback
|
|
283
|
+
traceback.print_exc()
|
|
284
|
+
code = 1
|
|
285
|
+
finally:
|
|
286
|
+
connections.close_all()
|
|
287
|
+
return code, out.getvalue()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""What lambdachecks changes in Healthchecks: its own settings hook (hc/settings.py imports hc/local_settings.py
|
|
2
|
+
last). The build copies this file there; Healthchecks' code is not touched.
|
|
3
|
+
|
|
4
|
+
Everything else stays Healthchecks' (SECRET_KEY, SITE_ROOT, ... from the environment, set by the Terraform module).
|
|
5
|
+
Nothing here needs AWS at import time: collectstatic and compress run with it at build time.
|
|
6
|
+
"""
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
DEBUG = os.getenv("DEBUG", "False") == "True" # Healthchecks defaults to True
|
|
10
|
+
REGISTRATION_OPEN = os.getenv("REGISTRATION_OPEN", "False") == "True" # Healthchecks defaults to True
|
|
11
|
+
|
|
12
|
+
# the database: a database in an existing s3rds deployment (github.com/cloudformer/s3rds), Django's SQLite
|
|
13
|
+
# backend over HTTPS. Healthchecks' own variable names; DB_HOST = the s3rds Function URL host.
|
|
14
|
+
DATABASES = {
|
|
15
|
+
"default": {
|
|
16
|
+
"ENGINE": "s3rds.sqlite",
|
|
17
|
+
"NAME": os.getenv("DB_NAME", "healthchecks"),
|
|
18
|
+
"HOST": os.getenv("DB_HOST", ""),
|
|
19
|
+
"USER": os.getenv("DB_USER", ""),
|
|
20
|
+
"PASSWORD": os.getenv("DB_PASSWORD", ""),
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# the Function URL is HTTPS only
|
|
25
|
+
SESSION_COOKIE_SECURE = True
|
|
26
|
+
CSRF_COOKIE_SECURE = True
|
|
27
|
+
|
|
28
|
+
# Healthchecks' logging, plus errors to stderr (CloudWatch): with DEBUG off Django prints nothing otherwise
|
|
29
|
+
LOGGING = {
|
|
30
|
+
"version": 1,
|
|
31
|
+
"disable_existing_loggers": False,
|
|
32
|
+
"handlers": {
|
|
33
|
+
"db": {"level": "DEBUG", "class": "hc.logs.Handler"},
|
|
34
|
+
"console": {"level": "ERROR", "class": "logging.StreamHandler"},
|
|
35
|
+
},
|
|
36
|
+
"loggers": {
|
|
37
|
+
"django.request": {"level": "ERROR", "handlers": ["db", "console"]},
|
|
38
|
+
"hc": {"level": "DEBUG", "handlers": ["db", "console"]},
|
|
39
|
+
},
|
|
40
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lambdachecks
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Healthchecks (cron / scheduled-job monitoring) on AWS Lambda, unchanged, with its database on s3rds: ≈ $0 when idle. The package carries the Lambda code a deployment runs.
|
|
5
|
+
Author: Frank Zhang
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/cloudformer/lambdachecks
|
|
8
|
+
Project-URL: IdleFree, https://cloudformer.github.io/
|
|
9
|
+
Project-URL: Repository, https://github.com/cloudformer/lambdachecks
|
|
10
|
+
Project-URL: Deploy, https://github.com/cloudformer/lambdachecks#quick-start
|
|
11
|
+
Project-URL: Changelog, https://github.com/cloudformer/lambdachecks/blob/main/CHANGELOG.md
|
|
12
|
+
Project-URL: Issues, https://github.com/cloudformer/lambdachecks/issues
|
|
13
|
+
Keywords: serverless,aws,lambda,healthchecks,cron,monitoring,s3rds,sqlite,s3
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: System :: Monitoring
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# lambdachecks
|
|
23
|
+
|
|
24
|
+
**[Healthchecks](https://github.com/healthchecks/healthchecks) (cron / scheduled-job monitoring) on AWS Lambda,
|
|
25
|
+
unchanged, with its database on [s3rds](https://github.com/cloudformer/s3rds) (SQLite on S3): ≈ $0 when idle.**
|
|
26
|
+
Part of [IdleFree](https://cloudformer.github.io/).
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
This package carries the Lambda code a deployment runs (`lambdachecks.server`); there is nothing to import in your
|
|
31
|
+
own code. Deploy it with Terraform: see the [main repository](https://github.com/cloudformer/lambdachecks).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
lambdachecks/__init__.py
|
|
4
|
+
lambdachecks.egg-info/PKG-INFO
|
|
5
|
+
lambdachecks.egg-info/SOURCES.txt
|
|
6
|
+
lambdachecks.egg-info/dependency_links.txt
|
|
7
|
+
lambdachecks.egg-info/top_level.txt
|
|
8
|
+
lambdachecks/server/__init__.py
|
|
9
|
+
lambdachecks/server/lambda_function.py
|
|
10
|
+
lambdachecks/server/local_settings.py
|
|
11
|
+
lambdachecks/server/requirements.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lambdachecks
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "lambdachecks"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Healthchecks (cron / scheduled-job monitoring) on AWS Lambda, unchanged, with its database on s3rds: ≈ $0 when idle. The package carries the Lambda code a deployment runs."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Frank Zhang" }]
|
|
13
|
+
keywords = ["serverless", "aws", "lambda", "healthchecks", "cron", "monitoring", "s3rds", "sqlite", "s3"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Topic :: System :: Monitoring",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [] # the Lambda's dependencies are installed by the deployment (server/requirements.txt + Healthchecks')
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://github.com/cloudformer/lambdachecks"
|
|
25
|
+
IdleFree = "https://cloudformer.github.io/"
|
|
26
|
+
Repository = "https://github.com/cloudformer/lambdachecks"
|
|
27
|
+
Deploy = "https://github.com/cloudformer/lambdachecks#quick-start"
|
|
28
|
+
Changelog = "https://github.com/cloudformer/lambdachecks/blob/main/CHANGELOG.md"
|
|
29
|
+
Issues = "https://github.com/cloudformer/lambdachecks/issues"
|
|
30
|
+
|
|
31
|
+
[tool.setuptools]
|
|
32
|
+
packages = ["lambdachecks", "lambdachecks.server"] # lambdachecks.server = the Lambda code (next to Healthchecks' release in the zip, handler lambda_function.lambda_handler)
|
|
33
|
+
|
|
34
|
+
[tool.setuptools.package-data]
|
|
35
|
+
"lambdachecks.server" = ["requirements.txt"] # the server's pins, installed next to Healthchecks' own requirements.txt
|