Skip to content

Commit 5f9bf6b

Browse files
author
Eugene Cheung
authored
chore: convert Lambda handlers to vanilla JS (#24)
Partially addresses #18 We don't necessarily need JSII (and therefore TS) to process these.
1 parent f43b4f7 commit 5f9bf6b

File tree

4 files changed

+44
-47
lines changed

4 files changed

+44
-47
lines changed

assets/BitmapWidgetRenderingSupport/index.ts renamed to assets/BitmapWidgetRenderingSupport/index.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
// Ignoring some checks since the function is in pure JS
2-
3-
/* eslint-disable */
41
const aws = require('aws-sdk');
52

63
const DOCS = `
74
## Display a CloudWatch bitmap graph
85
Displays CloudWatch metrics as a bitmap, for faster display of metrics.
9-
6+
107
### Widget parameters
118
Param | Description
129
---|---
1310
**graph** | The graph definition. Use the parameters from the **Source** tab in CloudWatch Console's **Metrics** page.
1411
**useMonitorPortal** (default = true) | Flag indicating whether we want to use MonitorPortal to render the graph. False will switch to CloudWatch API.
15-
12+
1613
### Example parameters
1714
\`\`\` yaml
1815
useMonitorPortal: boolean
@@ -24,11 +21,11 @@ const DOCS = `
2421
\`\`\`
2522
`;
2623

27-
exports.handler = async (event: any) => {
28-
async function renderUsingCloudWatch(graph: any, width: number, height: number) {
24+
exports.handler = async (event) => {
25+
async function renderUsingCloudWatch(graph, width, height) {
2926
const params = {MetricWidget: JSON.stringify(graph)};
3027
const region = graph.region;
31-
const customBackoff = (retryCount: number) => {
28+
const customBackoff = (retryCount) => {
3229
// Keep retrying with a random delay, long enough to overcome throttling from CW
3330
const delay = 300 + Math.floor(Math.random() * 500);
3431
console.log(`retry number ${retryCount} with a delay of ${delay} ms`);

assets/SecretsManagerMetricsPublisher/index.ts renamed to assets/SecretsManagerMetricsPublisher/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import aws = require("aws-sdk");
1+
const aws = require("aws-sdk");
22

33
const region = process.env.AWS_REGION;
44
const millisPerDay = 1000 * 60 * 60 * 24;
@@ -15,13 +15,13 @@ const clientOptions = {
1515
const cloudwatch = new aws.CloudWatch(clientOptions);
1616
const sm = new aws.SecretsManager(clientOptions);
1717

18-
function daysSince(date: any, now = Date.now()) {
18+
function daysSince(date, now = Date.now()) {
1919
const millis = now - date.getTime();
2020
const days = millis / millisPerDay;
2121
return Math.floor(days);
2222
}
2323

24-
exports.handler = async (event: any, context: any) => {
24+
exports.handler = async (event, context) => {
2525
console.debug("event:", JSON.stringify(event));
2626
console.debug("context:", JSON.stringify(context));
2727

test/dashboard/widget/__snapshots__/BitmapWidget.test.ts.snap

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/monitoring/aws-secretsmanager/__snapshots__/SecretsManagerSecretMonitoring.test.ts.snap

Lines changed: 27 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)