Fixed secret access + return state

This commit is contained in:
Elizabeth Cray 2024-10-04 19:41:54 -04:00
parent 92c8ecb5d7
commit 0da438d46b

View File

@ -14,6 +14,8 @@ export const handler = async (event) => {
keyResponse = await keyClient.send(new GetSecretValueCommand({ keyResponse = await keyClient.send(new GetSecretValueCommand({
SecretId: process.env.TRIGGER_SECRET SecretId: process.env.TRIGGER_SECRET
})); }));
keyResponse = JSON.parse(keyResponse.SecretString);
keyResponse = keyResponse["carbon-key"].replaceAll(" ", "\n");
} catch (err) { } catch (err) {
console.warn(err); console.warn(err);
result = err; result = err;
@ -32,6 +34,14 @@ export const handler = async (event) => {
stream.on('close', (code, signal) => { stream.on('close', (code, signal) => {
// COMPLETE // COMPLETE
console.info("Trigger completed", code, signal) console.info("Trigger completed", code, signal)
result = code;
const response = {
statusCode: 200,
body: {
result
},
};
return response;
}).stderr.on('data', (data) => { }).stderr.on('data', (data) => {
// STDERR // STDERR
console.warn(data); console.warn(data);
@ -41,15 +51,16 @@ export const handler = async (event) => {
host: process.env.TRIGGER_HOST, host: process.env.TRIGGER_HOST,
port: 22, port: 22,
username: process.env.TRIGGER_USERNAME, 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;
}; };