@@ -20,13 +20,15 @@ import { Configuration } from './configuration.js';
20
20
import { AwsCredentials } from './awsCredentials.js' ;
21
21
import { getModuleDirname } from './getDirname.js' ;
22
22
import { Logger } from './logger.js' ;
23
+ import * as crypto from 'crypto' ;
23
24
24
25
let lambdaClient : LambdaClient | undefined ;
25
26
let iamClient : IAMClient | undefined ;
26
27
27
28
const inlinePolicyName = 'LambdaLiveDebuggerPolicy' ;
28
29
const layerName = 'LambdaLiveDebugger' ;
29
30
const lldWrapperPath = '/opt/lld-wrapper' ;
31
+ let layerDescription : string | undefined ;
30
32
31
33
/**
32
34
* Policy document to attach to the Lambda role
@@ -118,7 +120,16 @@ async function findExistingLayerVersion() {
118
120
* @returns
119
121
*/
120
122
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 ;
122
133
}
123
134
124
135
/**
@@ -131,20 +142,8 @@ async function deployLayer() {
131
142
// Check if the layer already exists
132
143
const existingLayer = await findExistingLayerVersion ( ) ;
133
144
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 ;
148
147
}
149
148
150
149
// check the ZIP
0 commit comments