in aws-core-ui/src/Utilities/rotateKeys.tsx [22:56]
export async function requestKeyRotation(
config: Config
): Promise<RotateKeysResult> {
const params = {
connectionId: config.connectionId,
projectId: config.projectId,
};
const response = await post(config.rotateKeyControllerUrl, params);
const result = JSON.parse(response);
if (result.errors && result.errors.length !== 0) {
return { key: '', secret: '', errorMessage: result.errors[0].message };
}
const updatedConnection = await getConfigForConnection(
config.projectId,
config.connectionId
);
if (!updatedConnection) {
return {
key: '',
secret: '',
errorMessage:
'Failed to receive a server response describing the updated connection',
};
}
return {
key: updatedConnection.accessKeyId,
secret: updatedConnection.secretAccessKey,
};
}