-
Notifications
You must be signed in to change notification settings - Fork 2
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
New upgrade process in mgmt-lambda #163
New upgrade process in mgmt-lambda #163
Conversation
Coverage report
Show new covered files 🐣
Test suite run success102 tests passing in 18 suites. Report generated by 🧪jest coverage report action from d816e8f Show full coverage report
|
8442eb5
to
e220693
Compare
e220693
to
f991634
Compare
c35ccbd
to
4139b8c
Compare
}, | ||
if (path.startsWith('/update') && method === 'POST') { | ||
return handleUpdate(lambdaClient, cloudFrontClient, deploymentSettings) | ||
} else if (path.startsWith('/status') && method === 'GET') { |
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.
we can remove else
here to make to more readable
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.
yes
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.
could you do it?
return handleUpdate(lambdaClient, cloudFrontClient, deploymentSettings) | ||
} else if (path.startsWith('/status') && method === 'GET') { | ||
return handleStatus(lambdaClient, deploymentSettings) | ||
} else { |
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.
we can remove else
here to make to more readable
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.
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.
could you do it?
mgmt-lambda/app.ts
Outdated
function loadDeploymentSettings(): DeploymentSettings { | ||
const cfDistributionId = process.env.CFDistributionId | ||
if (!cfDistributionId) { | ||
throw new Error('No CloudFront distribution Id') |
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'd suggest to have more clear error message, for instance load failed: env variable CFDistributionId not found
.
mgmt-lambda/app.ts
Outdated
return Promise.resolve(undefined) | ||
const lambdaFunctionName = process.env.LambdaFunctionArn | ||
if (!lambdaFunctionName) { | ||
throw new Error('No lambda function name') |
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'd suggest to have more clear error message, for instance load failed: env variable LambdaFunctionArn not found
.
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.
This seems to be duplicated. Did you mean something like process.env.LambdaFunctionName
?
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.
This part is reworked and test added
Also, I will have validation for values given in env vars as a part of POST /update
test
mgmt-lambda/app.ts
Outdated
defaultsMode: 'standard', | ||
const lambdaFunctionArn = process.env.LambdaFunctionArn | ||
if (!lambdaFunctionArn) { | ||
throw new Error('No lambda function ARN') |
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'd suggest to have more clear error message, for instance load failed: env variable LambdaFunctionArn not found
.
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.
fixed
mgmt-lambda/auth.ts
Outdated
export async function getAuthSettings(secretManagerClient: SecretsManagerClient): Promise<AuthSettings> { | ||
const secretName = process.env.SettingsSecretName | ||
if (!secretName) { | ||
throw new Error('Unable to retrieve secret. Error: unable to get secret name') |
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'd suggest to have more clear error message, for instance getAuthSettings failed: env variable SettingsSecretName not found
.
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.
fixed
mgmt-lambda/auth.ts
Outdated
|
||
if (response.SecretBinary) { | ||
return JSON.parse(Buffer.from(response.SecretBinary).toString('utf8')) | ||
} else if (response.SecretString) { |
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.
Let's remove else
here to make code more readable
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.
fixed
mgmt-lambda/auth.ts
Outdated
return JSON.parse(Buffer.from(response.SecretBinary).toString('utf8')) | ||
} else if (response.SecretString) { | ||
return JSON.parse(response.SecretString) | ||
} else { |
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.
Let's remove else
here to make code more readable
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.
fixed
try { | ||
const authSettings = await getAuthSettings(secretManagerClient) | ||
const authorization = event.headers['authorization'] | ||
if (authorization !== authSettings.token) { |
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.
Will authorization
header be directly the token, no scheme? This header needs a scheme by standard, such as Basic
or something, no?
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.
In general, I supposed that we have a single option for authorization
header so I didn't add any scheme.
Basic
is supposed to be base64 encoded username+password.
We can introduce some specific scheme name, let's say token
or mgmt-token
.
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.
So what will we do about this in this PR?
24dcbe2
to
741dab9
Compare
This PR will create a minor release 🚀1.5.0 (2023-12-19)Features
Bug Fixes |
/status
and/update