Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rjaduthie
Copy link
Contributor

This resolves issue #34

@sonarcloud
Copy link

sonarcloud bot commented Jan 22, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

@giantcow giantcow left a 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) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log("request: " + JSON.stringify(event));
let responseCode = 400;
let message = "authentication failed";
export const handler: APIGatewayProxyHandler = async (event: APIGatewayEvent, context: Context) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if (event.queryStringParameters && event.queryStringParameters.key) {
let key = event.queryStringParameters.key;
if (key == PASSWORD) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// property to 'true'.
return {
statusCode: responseCode,
headers: {},
Copy link
Contributor

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

Comment on lines +57 to +62
await client.send(updateCommand).then(
(data) => {
console.log(`OK! ${JSON.stringify(data, null, 2)}`);
},
(err) => {
console.log(`Error! ${JSON.stringify(err, null, 2)}`);
Copy link
Contributor

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)}`);
      }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants