From 97a885fd98c66ad8233fa1e6d83a8ef88a62c494 Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Wed, 18 Nov 2020 13:26:48 -0700 Subject: [PATCH] moving check inside getCloudMetadata --- .../infra/server/routes/inventory_metadata/index.ts | 13 ------------- .../inventory_metadata/lib/get_cloud_metadata.ts | 8 ++++++++ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/infra/server/routes/inventory_metadata/index.ts b/x-pack/plugins/infra/server/routes/inventory_metadata/index.ts index c2ca93baa26511..637cb8a864d0b8 100644 --- a/x-pack/plugins/infra/server/routes/inventory_metadata/index.ts +++ b/x-pack/plugins/infra/server/routes/inventory_metadata/index.ts @@ -39,19 +39,6 @@ export const initInventoryMetaRoute = (libs: InfraBackendLibs) => { fold(throwErrors(Boom.badRequest), identity) ); - const model = findInventoryModel(nodeType); - - // Only run this for AWS modules, eventually we might have more. - if (model.requiredModule !== 'aws') { - return response.ok({ - body: { - accounts: [], - projects: [], - regions: [], - }, - }); - } - const { configuration } = await libs.sources.getSourceConfiguration( requestContext.core.savedObjects.client, sourceId diff --git a/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts b/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts index 7e8b26de75e8bc..af9e9c5f57c5b7 100644 --- a/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts +++ b/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts @@ -29,6 +29,14 @@ export const getCloudMetadata = async ( currentTime: number ): Promise => { const model = findInventoryModel(nodeType); + // Only run this for AWS modules, eventually we might have more. + if (model.requiredModule !== 'aws') { + return { + accounts: [], + projects: [], + regions: [], + }; + } const metricQuery = { allowNoIndices: true,