Skip to content

Commit c62b182

Browse files
fix: Development layer deployment (#108)
1 parent aeb430d commit c62b182

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/infraDeploy.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ import { Configuration } from './configuration.js';
2020
import { AwsCredentials } from './awsCredentials.js';
2121
import { getModuleDirname } from './getDirname.js';
2222
import { Logger } from './logger.js';
23+
import * as crypto from 'crypto';
2324

2425
let lambdaClient: LambdaClient | undefined;
2526
let iamClient: IAMClient | undefined;
2627

2728
const inlinePolicyName = 'LambdaLiveDebuggerPolicy';
2829
const layerName = 'LambdaLiveDebugger';
2930
const lldWrapperPath = '/opt/lld-wrapper';
31+
let layerDescription: string | undefined;
3032

3133
/**
3234
* Policy document to attach to the Lambda role
@@ -118,7 +120,16 @@ async function findExistingLayerVersion() {
118120
* @returns
119121
*/
120122
async function getLayerDescription() {
121-
return `Lambda Live Debugger Layer version ${await getVersion()}`;
123+
if (!layerDescription) {
124+
layerDescription = `Lambda Live Debugger Layer version ${await getVersion()}`;
125+
}
126+
127+
if ((await getVersion()) === '0.0.1') {
128+
// add a random string to the description to make it unique
129+
layerDescription = `Lambda Live Debugger Layer - development ${crypto.randomUUID()}`;
130+
}
131+
132+
return layerDescription;
122133
}
123134

124135
/**
@@ -131,20 +142,8 @@ async function deployLayer() {
131142
// Check if the layer already exists
132143
const existingLayer = await findExistingLayerVersion();
133144
if (existingLayer && existingLayer.LayerVersionArn) {
134-
// delete existing layer when developing
135-
if ((await getVersion()) === '0.0.1') {
136-
Logger.verbose(
137-
'Deleting existing layer version, because it is a development mode.',
138-
);
139-
const deleteLayerVersionCommand = new DeleteLayerVersionCommand({
140-
LayerName: layerName,
141-
VersionNumber: existingLayer.Version,
142-
});
143-
await getLambdaClient().send(deleteLayerVersionCommand);
144-
} else {
145-
Logger.verbose(`${layerDescription} already deployed.`);
146-
return existingLayer.LayerVersionArn;
147-
}
145+
Logger.verbose(`${layerDescription} already deployed.`);
146+
return existingLayer.LayerVersionArn;
148147
}
149148

150149
// check the ZIP

0 commit comments

Comments
 (0)