diff --git a/src/services/base/enhancers.ts b/src/services/base/enhancers.ts index 336f850f..a9072cc3 100644 --- a/src/services/base/enhancers.ts +++ b/src/services/base/enhancers.ts @@ -105,6 +105,7 @@ export const enrichInstanceWithBillingData = ({ name, mutation, data: natsWithBilling, + rawData: natsWithBilling, }) } } @@ -139,6 +140,7 @@ export const enrichInstanceWithBillingData = ({ name, mutation, data: ec2WithBilling, + rawData: ec2WithBilling, }) } } diff --git a/src/services/index.ts b/src/services/index.ts index 19a75dfe..ca4e0f7b 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -761,6 +761,7 @@ export default class Provider extends CloudGraph.Client { try { const serviceClass = this.getService(serviceData.name) const entities: any[] = [] + const rawEntities: any[] = [] for (const region of Object.keys(serviceData.data)) { await new Promise(resolve => setTimeout(resolve, 10)) // free the main nodejs thread to process other requests const data = serviceData.data[region] @@ -772,6 +773,7 @@ export default class Provider extends CloudGraph.Client { account: serviceData.accountId, }) entities.push(formattedData) + rawEntities.push(service) if (typeof serviceClass.getConnections === 'function') { // We need to loop through all configured regions here because services can be connected to things in another region let serviceConnections = {} @@ -807,23 +809,38 @@ export default class Provider extends CloudGraph.Client { if (existingServiceIdx > -1) { const existingData = result.entities[existingServiceIdx].data for (const currentEntity of entities) { - const exisingEntityIdx = existingData.findIndex( + const existingEntityIdx = existingData.findIndex( ({ id }) => id === currentEntity.id ) - if (exisingEntityIdx > -1) { - const entityToDelete = existingData[exisingEntityIdx] - existingData.splice(exisingEntityIdx, 1) + if (existingEntityIdx > -1) { + const entityToDelete = existingData[existingEntityIdx] + existingData.splice(existingEntityIdx, 1) const entityToMergeIdx = entities.findIndex( ({ id }) => id === currentEntity.id ) entities[entityToMergeIdx] = merge(entityToDelete, currentEntity) } } + const existingRawData = result.entities[existingServiceIdx].rawData + for (const currentRawEntity of rawEntities) { + const existingEntityIdx = existingData.findIndex( + ({ id }) => id === currentRawEntity.id + ) + if (existingEntityIdx > -1) { + const rawEntityToDelete = existingRawData[existingEntityIdx] + existingRawData.splice(existingEntityIdx, 1) + const entityToMergeIdx = rawEntities.findIndex( + ({ id }) => id === currentRawEntity.id + ) + rawEntities[entityToMergeIdx] = merge(rawEntityToDelete, currentRawEntity) + } + } result.entities[existingServiceIdx] = { className: serviceClass.constructor.name, name: serviceData.name, mutation: serviceClass.mutation, data: [...existingData, ...entities], + rawData: [...existingRawData, ...rawEntities], } } else { result.entities.push({ @@ -831,6 +848,7 @@ export default class Provider extends CloudGraph.Client { name: serviceData.name, mutation: serviceClass.mutation, data: entities, + rawData: rawEntities, }) } } catch (error: any) { diff --git a/src/services/s3/data.ts b/src/services/s3/data.ts index 5340a04c..5bedd04c 100644 --- a/src/services/s3/data.ts +++ b/src/services/s3/data.ts @@ -49,6 +49,7 @@ import { initTestEndpoint } from '../../utils' import { gets3BucketId } from '../../utils/ids' import AwsErrorLog from '../../utils/errorLog' import { convertAwsTagsToTagMap } from '../../utils/format' +import { s3BucketArn } from '../../utils/generateArns' const lt = { ...awsLoggerText } const { logger } = CloudGraph @@ -496,6 +497,7 @@ export interface RawAwsS3 { Id: string Name: string region: string + arn: string } export default async ({ @@ -537,6 +539,7 @@ export default async ({ Name: bucket.Name, region, CreationDate: bucket.CreationDate, + arn: s3BucketArn({ name: bucket.Name }), Tags: {}, }) }