-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fix startstop lambda has no effect on desire count #35
base: main
Are you sure you want to change the base?
Fix startstop lambda has no effect on desire count #35
Conversation
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Left a couple little comments
@@ -35,7 +35,7 @@ const ec2Client = new EC2Client({ region: REGION }); | |||
/** | |||
* Everything here has the assumption there is only one task. | |||
*/ | |||
const handler: APIGatewayProxyHandler = async (event: APIGatewayEvent, context: Context) => { | |||
export const handler: APIGatewayProxyHandler = async (event: APIGatewayEvent, context: Context) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets specify the return type to clarify the required response values: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/aws-lambda/trigger/api-gateway-proxy.d.ts#L140-L154
console.log("request: " + JSON.stringify(event)); | ||
let responseCode = 400; | ||
let message = "authentication failed"; | ||
export const handler: APIGatewayProxyHandler = async (event: APIGatewayEvent, context: Context) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before, wrt specifying the return type: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/aws-lambda/trigger/api-gateway-proxy.d.ts#L140-L154
|
||
if (event.queryStringParameters && event.queryStringParameters.key) { | ||
let key = event.queryStringParameters.key; | ||
if (key == PASSWORD) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized, this should be ===
Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness
// property to 'true'. | ||
return { | ||
statusCode: responseCode, | ||
headers: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, and the comment above is redundant if the handler response is strongly typed
await client.send(updateCommand).then( | ||
(data) => { | ||
console.log(`OK! ${JSON.stringify(data, null, 2)}`); | ||
}, | ||
(err) => { | ||
console.log(`Error! ${JSON.stringify(err, null, 2)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would refactor this to be pure async/await:
try {
const result = await client.send(updateCommand);
console.log(`OK! ${JSON.stringify(result, null, 2)}`);
} catch (error) {
console.log(`Error! ${JSON.stringify(error, null, 2)}`);
}
This resolves issue #34