UNPKG

@csermet/multiprovider

Version:

cloud-graph provider plugin for AWS used to fetch AWS cloud data.

37 lines (36 loc) 1.25 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const isEmpty_1 = __importDefault(require("lodash/isEmpty")); const services_1 = __importDefault(require("../../enums/services")); /** * EBS Snapshot */ exports.default = ({ service: snapshot, data, region, account, }) => { const connections = []; const { SnapshotId: id, KmsKeyId: kmsKeyId, } = snapshot; /** * Find KMS * related to the cloudTrail */ const kmsKeys = data.find(({ name }) => name === services_1.default.kms); if (kmsKeys?.data?.[region]) { const kmsKeyInRegion = kmsKeys.data[region].filter(kmsKey => kmsKey.Arn === kmsKeyId); if (!isEmpty_1.default(kmsKeyInRegion)) { for (const kms of kmsKeyInRegion) { connections.push({ id: kms.KeyId, resourceType: services_1.default.kms, relation: 'child', field: 'kms', }); } } } const snapshotResult = { [id]: connections, }; return snapshotResult; };