@cloud-copilot/iam-collect
Version:
Collect IAM information from AWS Accounts
68 lines • 2.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.KinesisDataStreamsSync = void 0;
const client_kinesis_1 = require("@aws-sdk/client-kinesis");
const client_tools_js_1 = require("../../utils/client-tools.js");
const json_js_1 = require("../../utils/json.js");
const typedSync_js_1 = require("../typedSync.js");
exports.KinesisDataStreamsSync = (0, typedSync_js_1.createTypedSyncOperation)('kinesis', 'dataStreams', (0, typedSync_js_1.createResourceSyncType)({
client: client_kinesis_1.KinesisClient,
command: client_kinesis_1.ListStreamsCommand,
key: 'StreamNames',
paginationConfig: {
inputKey: 'NextToken',
outputKey: 'NextToken'
},
arn: (streamName, region, accountId, partition) => streamArn(streamName.name, region, accountId, partition),
resourceTypeParts: (accountId, region) => ({
service: 'kinesis',
resourceType: 'stream',
account: accountId,
region: region
}),
extraFields: {
details: async (client, streamName) => {
const result = await client.send(new client_kinesis_1.DescribeStreamCommand({
StreamName: streamName.name
}));
return result.StreamDescription;
},
policy: async (client, streamName, accountId, region, partition) => {
const streamArnValue = streamArn(streamName.name, region, accountId, partition);
return (0, client_tools_js_1.runAndCatch404)(async () => {
const result = await client.send(new client_kinesis_1.GetResourcePolicyCommand({
ResourceARN: streamArnValue
}));
return (0, json_js_1.parseIfPresent)(result.Policy);
});
},
tags: async (client, streamName) => {
return (0, client_tools_js_1.runAndCatch404)(async () => {
const result = await client.send(new client_kinesis_1.ListTagsForStreamCommand({
StreamName: streamName.name
}));
return result.Tags;
});
}
},
tags: (stream) => stream.extraFields.tags,
results: (stream) => ({
metadata: {
name: stream.name,
encryptionType: stream.extraFields.details?.EncryptionType,
keyId: stream.extraFields.details?.KeyId
},
policy: stream.extraFields.policy
})
}));
/**
* Generate the ARN for a Kinesis data stream.
*
* @param streamName - The name of the Kinesis data stream.
* @param region - The AWS region where the stream is located.
* @param accountId - The AWS account ID that owns the stream.
* @param partition - The AWS partition (e.g., "aws", "aws-cn", "aws-us-gov").
* @returns The ARN of the Kinesis data stream.
*/
const streamArn = (streamName, region, accountId, partition) => `arn:${partition}:kinesis:${region}:${accountId}:stream/${streamName}`;
//# sourceMappingURL=dataStreams.js.map