Fixed secret access + return state
This commit is contained in:
parent
92c8ecb5d7
commit
0da438d46b
27
index.mjs
27
index.mjs
@ -14,6 +14,8 @@ export const handler = async (event) => {
|
||||
keyResponse = await keyClient.send(new GetSecretValueCommand({
|
||||
SecretId: process.env.TRIGGER_SECRET
|
||||
}));
|
||||
keyResponse = JSON.parse(keyResponse.SecretString);
|
||||
keyResponse = keyResponse["carbon-key"].replaceAll(" ", "\n");
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
result = err;
|
||||
@ -32,6 +34,14 @@ export const handler = async (event) => {
|
||||
stream.on('close', (code, signal) => {
|
||||
// COMPLETE
|
||||
console.info("Trigger completed", code, signal)
|
||||
result = code;
|
||||
const response = {
|
||||
statusCode: 200,
|
||||
body: {
|
||||
result
|
||||
},
|
||||
};
|
||||
return response;
|
||||
}).stderr.on('data', (data) => {
|
||||
// STDERR
|
||||
console.warn(data);
|
||||
@ -41,15 +51,16 @@ export const handler = async (event) => {
|
||||
host: process.env.TRIGGER_HOST,
|
||||
port: 22,
|
||||
username: process.env.TRIGGER_USERNAME,
|
||||
privateKey: keyResponse.SecretString
|
||||
privateKey: keyResponse.SecretStrin,
|
||||
});
|
||||
}else{
|
||||
const response = {
|
||||
statusCode: 200,
|
||||
body: {
|
||||
result
|
||||
},
|
||||
};
|
||||
return response;
|
||||
}
|
||||
const response = {
|
||||
statusCode: 200,
|
||||
body: {
|
||||
result
|
||||
},
|
||||
};
|
||||
return response;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user