Skip to content

Add lambda layers #230

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

Merged
merged 4 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 43 additions & 0 deletions src/components/lambdaLayersTable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const contrib = require("blessed-contrib");

class LambdaLayersTable {
constructor(parent) {
this.parent = parent;
this.table = this.generateTable();
}

generateTable() {
const table = contrib.table({
fg: "white",
interactive: false,
label: "Lambda Layers",
columnWidth: [20, 30],
padding: { top: 1 },
});
this.parent.append(table);
return table;
}

static extractLayerInfo(lambdaFuncInfo) {
if (lambdaFuncInfo.Layers) {
return lambdaFuncInfo.Layers.map((layer) => {
const s = layer.Arn.split(":");
const layerName = s[s.length - 2];
const layerVersion = s[s.length - 1];
return [layerName, layerVersion];
});
}
return [["-", "-"]];
}

updateData(lambdaFuncInfo) {
this.table.setData({
headers: ["Name", "Version"],
data: LambdaLayersTable.extractLayerInfo(lambdaFuncInfo),
});
}
}

module.exports = {
LambdaLayersTable,
};
10 changes: 7 additions & 3 deletions src/components/resourceTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class ResourceTable {
this.getCurrentlyOnHoverFullLambdaName(),
this.cloudwatchLogs,
this.cloudwatch,
this.lambda
this.lambda,
this.lambdaFunctions[this.getCurrentlyOnHoverFullLambdaName()]
);
}
return 0;
Expand Down Expand Up @@ -173,7 +174,7 @@ class ResourceTable {
fg: "green",
label: "<- Lambda Functions ->",
columnSpacing: 1,
columnWidth: [30, 30, 10, 10, 20],
columnWidth: [30, 30, 10, 10, 20, 10],
style: {
border: {
fg: "yellow",
Expand Down Expand Up @@ -263,10 +264,12 @@ class ResourceTable {
let timeout = "?";
let memory = "?";
let funcRuntime = "?";
let layersPresent = "?";
if (func) {
funcRuntime = func.Runtime;
timeout = func.Timeout.toString();
memory = func.MemorySize.toString();
layersPresent = func.Layers ? "Y" : "N";
}
// Max timout is 900 seconds, align values with whitespace
timeout = padString(timeout, 3);
Expand All @@ -278,6 +281,7 @@ class ResourceTable {
`${memory} MB`,
`${timeout} secs`,
funcRuntime,
`${layersPresent}`,
];
});
this.updateLambdaTableRows();
Expand Down Expand Up @@ -377,7 +381,7 @@ class ResourceTable {
}

this.table.setData({
headers: ["logical", "updated", "memory", "timeout", "runtime"],
headers: ["logical", "updated", "memory", "timeout", "runtime", "layers"],
data: lambdaFunctionsWithDeploymentIndicator,
});

Expand Down
11 changes: 9 additions & 2 deletions src/modals/lambdaStatisticsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ import { ModalLayout } from "../components/modalLayout";
import { getLambdaMetrics } from "../services/lambdaMetrics";
import { InvocationCountLCD } from "../components/invocationCountLCD";
import { LambdaDeploymentsTable } from "../components/lambdaDeploymentsTable";
import { LambdaLayersTable } from "../components/lambdaLayersTable";

const lambdaStatisticsModal = async (
screen,
application,
lambdaName,
cloudwatchLogs,
cloudwatch,
lambda
lambda,
lambdaFuncInfo
) => {
const lambdaStatisticsLayout = new ModalLayout(screen, 112, 39, false);
const lambdaStatisticsLayout = new ModalLayout(screen, 112, 50, false);
new Box(lambdaStatisticsLayout, 110, 3, `Lambda Statistics - ${lambdaName}`);
const durationChartBox = new Box(lambdaStatisticsLayout, 55, 17);
const errorChartBox = new Box(lambdaStatisticsLayout, 55, 17);
const invocationCountBox = new Box(lambdaStatisticsLayout, 55, 17);
const lambdaDeploymentsTableBox = new Box(lambdaStatisticsLayout, 55, 17);
const lambdaLayersBox = new Box(lambdaStatisticsLayout, 55, 11);
const durationChart = new DurationBarChart(
application,
cloudwatchLogs,
Expand All @@ -36,11 +39,15 @@ const lambdaStatisticsModal = async (
lambdaDeploymentsTableBox,
lambda
);

const lambdaLayersTable = new LambdaLayersTable(lambdaLayersBox);

const metrics = await getLambdaMetrics(application, lambdaName, cloudwatch);
invocationCount.updateData(metrics);
errorChart.updateData(metrics);
durationChart.updateData(lambdaName);
lambdaDeploymentsTable.updateData(lambdaName);
lambdaLayersTable.updateData(lambdaFuncInfo);
lambdaStatisticsLayout.focus();
lambdaStatisticsLayout.key(["escape"], () => {
application.setIsModalOpen(false);
Expand Down