UNPKG

@infrascan/aws-cloudfront-scanner

Version:

Infrascan scanner definition for AWS Cloudfront

47 lines (46 loc) 1.23 kB
// src/generated/getters.ts import { CloudFrontServiceException, ListDistributionsCommand } from "@aws-sdk/client-cloudfront"; import debug from "debug"; async function ListDistributions(client, stateConnector, context) { const getterDebug = debug("cloudfront:ListDistributions"); const state = []; getterDebug("ListDistributions"); const preparedParams = {}; try { const cmd = new ListDistributionsCommand(preparedParams); const result = await client.send(cmd); state.push({ _metadata: { account: context.account, region: context.region, timestamp: Date.now() }, _parameters: preparedParams, _result: result }); } catch (err) { if (err instanceof CloudFrontServiceException) { if (err?.$retryable) { console.log("Encountered retryable error", err); } else { console.log("Encountered unretryable error", err); } } else { console.log("Encountered unexpected error", err); } } getterDebug("Recording state"); await stateConnector.onServiceScanCompleteCallback( context.account, context.region, "CloudFront", "ListDistributions", state ); } export { ListDistributions };