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

Restart feedback API when rotating db password #1152

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lambda-db-password-rotation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async function restartMainDbECSServices(ecsClient = new ECSClient(), overridenDe
await dependencies.restartECSService(ecsClient, process.env.CMS_ADMIN_ECS_SERVICE_NAME)
await dependencies.restartECSService(ecsClient, process.env.PRIVATE_API_ECS_SERVICE_NAME)
await dependencies.restartECSService(ecsClient, process.env.PUBLIC_API_ECS_SERVICE_NAME)
await dependencies.restartECSService(ecsClient, process.env.FEEDBACK_API_ECS_SERVICE_NAME)
console.log(`All required ECS tasks have been restarted for main DB`);
};

Expand Down
5 changes: 3 additions & 2 deletions src/lambda-db-password-rotation/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ describe('restartMainDbECSServices', () => {
const fakeCMSAdminECSServiceName = 'fake-cms-admin-ecs-service-name'
const fakePrivateAPIECSServiceName = 'fake-private-api-ecs-service-name'
const fakePublicAPIECSServiceName = 'fake-public-api-ecs-service-name'
const fakeFeedbackAPIECSServiceName = 'fake-feedback-api-ecs-service-name'

const mockedEnvVar = sinon.stub(process, 'env').value(
{
CMS_ADMIN_ECS_SERVICE_NAME: fakeCMSAdminECSServiceName,
PRIVATE_API_ECS_SERVICE_NAME: fakePrivateAPIECSServiceName,
PUBLIC_API_ECS_SERVICE_NAME: fakePublicAPIECSServiceName,
FEEDBACK_API_ECS_SERVICE_NAME: fakeFeedbackAPIECSServiceName,
}
);

Expand All @@ -78,12 +80,11 @@ describe('restartMainDbECSServices', () => {
await restartMainDbECSServices(mockedECSClient, spyDependencies);

// Then
// The function should have been called 3 times, 1 for each ECS service
expect(restartECSServiceSpy.calledThrice).toBeTruthy();
// The function should have been called with each ECS service name
expect(restartECSServiceSpy.firstCall.lastArg).toEqual(fakeCMSAdminECSServiceName)
expect(restartECSServiceSpy.secondCall.lastArg).toEqual(fakePrivateAPIECSServiceName)
expect(restartECSServiceSpy.thirdCall.lastArg).toEqual(fakePublicAPIECSServiceName)
expect(restartECSServiceSpy.lastCall.lastArg).toEqual(fakeFeedbackAPIECSServiceName)

// Restore the environment variable
mockedEnvVar.restore();
Expand Down
3 changes: 3 additions & 0 deletions terraform/20-app/lambda.db-password-rotation.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module "lambda_db_password_rotation" {
CMS_ADMIN_ECS_SERVICE_NAME = module.ecs_service_cms_admin.name
PRIVATE_API_ECS_SERVICE_NAME = module.ecs_service_private_api.name
PUBLIC_API_ECS_SERVICE_NAME = module.ecs_service_public_api.name
FEEDBACK_API_ECS_SERVICE_NAME = module.ecs_service_feedback_api.name
FEATURE_FLAGS_ECS_SERVICE_NAME = module.ecs_service_feature_flags.name
}

Expand All @@ -31,7 +32,9 @@ module "lambda_db_password_rotation" {
module.ecs_service_private_api.id,
module.ecs_service_public_api.id,
module.ecs_service_cms_admin.id,
module.ecs_service_feedback_api.id,
module.ecs_service_feature_flags.id,

]
}
}
Expand Down
Loading