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,