@cloud-copilot/iam-collect
Version:
Collect IAM information from AWS Accounts
89 lines • 3.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AwsConfigEfsClient = void 0;
const client_efs_1 = require("@aws-sdk/client-efs");
const AbstractClient_js_1 = require("../../customClients/AbstractClient.js");
const json_js_1 = require("../../utils/json.js");
const AwsConfigClientContext_js_1 = require("../AwsConfigClientContext.js");
const awsConfigUtils_js_1 = require("../awsConfigUtils.js");
/**
* AWS Config-based EFS client implementation
*/
class AwsConfigEfsClient extends AbstractClient_js_1.AbstractClient {
static clientName = client_efs_1.EFSClient.name;
constructor(options, customContext) {
super(options, customContext);
}
/**
* Register all EFS command implementations
*/
registerCommands() {
this.registerCommand(AwsConfigDescribeFileSystemsCommand);
this.registerCommand(AwsConfigDescribeFileSystemPolicyCommand);
}
}
exports.AwsConfigEfsClient = AwsConfigEfsClient;
/**
* Config-based implementation of EFS DescribeFileSystemPolicyCommand
* Uses configuration.FileSystemPolicy from AWS Config
*/
const AwsConfigDescribeFileSystemPolicyCommand = (0, AwsConfigClientContext_js_1.awsConfigCommand)({
command: client_efs_1.DescribeFileSystemPolicyCommand,
execute: async (input, context) => {
const configuration = context.getCache(input.FileSystemId, 'configuration');
return {
FileSystemId: input.FileSystemId,
Policy: (0, json_js_1.stringifyIfPresent)(configuration?.FileSystemPolicy)
};
}
});
/**
* Config-based implementation of EFS DescribeFileSystemsCommand
* Retrieves file system information from AWS Config with minimal required fields
*/
const AwsConfigDescribeFileSystemsCommand = (0, AwsConfigClientContext_js_1.awsConfigCommand)({
command: client_efs_1.DescribeFileSystemsCommand,
execute: async (input, context) => {
let query = `
SELECT
resourceId,
arn,
configuration.Name,
configuration.AvailabilityZoneId,
configuration.KmsKeyId,
configuration.Encrypted,
configuration.CreationTime,
configuration.FileSystemPolicy,
tags
WHERE
resourceType = 'AWS::EFS::FileSystem'
AND awsRegion = '${context.region}'
AND accountId = '${context.accountId}'
AND ${awsConfigUtils_js_1.resourceStatusWhereClause}
`;
// Add specific file system ID filter if provided
if (input.FileSystemId) {
query += ` AND resourceId = '${input.FileSystemId}'`;
}
const results = await (0, awsConfigUtils_js_1.executeConfigQuery)(query, context);
// Transform Config results to match AWS SDK format with minimal required fields
const fileSystems = results.map((resultString) => {
const { configItem, configuration, tags } = (0, awsConfigUtils_js_1.parseConfigItem)(resultString);
// Cache data that will be needed by other commands
context.putCache(configItem.resourceId, 'configuration', configuration);
return {
FileSystemId: configItem.resourceId,
FileSystemArn: configItem.arn,
Name: configuration.Name,
Encrypted: configuration.Encrypted || false,
KmsKeyId: configuration.KmsKeyId,
AvailabilityZoneId: configuration.AvailabilityZoneId,
Tags: tags
};
});
return {
FileSystems: fileSystems
};
}
});
//# sourceMappingURL=AwsConfigEfsClient.js.map