@cloud-copilot/iam-collect
Version:
Collect IAM information from AWS Accounts
56 lines • 1.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VpcEndpointsSync = void 0;
const client_ec2_1 = require("@aws-sdk/client-ec2");
const json_js_1 = require("../../utils/json.js");
const typedSync_js_1 = require("../typedSync.js");
exports.VpcEndpointsSync = (0, typedSync_js_1.createTypedSyncOperation)('ec2', 'vpcEndpoints', (0, typedSync_js_1.createResourceSyncType)({
client: client_ec2_1.EC2Client,
command: client_ec2_1.DescribeVpcEndpointsCommand,
key: 'VpcEndpoints',
paginationConfig: {
inputKey: 'NextToken',
outputKey: 'NextToken'
},
arguments: (accountId, region) => ({
Filters: [{ Name: 'vpc-endpoint-state', Values: ['available'] }]
}),
arn: (resource, region, accountId, partition) => {
return `arn:${partition}:ec2:${region}:${accountId}:vpc-endpoint/${resource.VpcEndpointId}`;
},
resourceTypeParts: (account, region) => ({
service: 'ec2',
resourceType: 'vpc-endpoint',
account,
region
}),
extraFields: {
vpcArn: async (client, resource, accountId, region, partition) => {
return vpcArn(accountId, region, partition, resource.VpcId);
}
},
tags: (resource) => resource.Tags,
results: (resource) => ({
metadata: {
id: resource.VpcEndpointId,
vpc: resource.extraFields.vpcArn,
type: resource.VpcEndpointType,
serviceName: resource.ServiceName
},
policy: undefined,
'endpoint-policy': (0, json_js_1.parseIfPresent)(resource.PolicyDocument)
})
}));
/**
* Make a VPC ARN from the account ID, region, partition, and VPC ID.
*
* @param accountId
* @param region
* @param partition
* @param vpcId
* @returns
*/
function vpcArn(accountId, region, partition, vpcId) {
return `arn:${partition}:ec2:${region}:${accountId}:vpc/${vpcId}`;
}
//# sourceMappingURL=vpcEndpoints.js.map