Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @mhoc/aws-cred-report with all npm packages installed. Try it out:

var awsCredReport = require("@mhoc/aws-cred-report")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@mhoc/aws-cred-report v0.1.0

helper library for generating aws credential reports

AWSCredReport

npm docs

This is a small TS library which wraps the aws-sdk to assist in generating AWS Credential Reports.

What's Wrong With the AWS-SDK?

Nothing; but it could be made easier to work with.

First, the SDK includes two methods to create credential reports: GenerateCredentialReport and GetCredentialReport. Its an asynchronous operation, and while the time between generation and retrieval isn't usually too long, its still something callers need to think about.

Moreover, there's no method provided to determine the "status" of a "credential report generation" operation; so, if you were to call Generate, followed by Get, and there's no credential report ready, you'd need to retry. This library handles the retrying for you.

Finally, you're given it back as a CSV-encoded buffer. This library fixes that for you; it'll parse the CSV, and return back a useful data structure.

Usage

import { AWSCredReportClient } from "@mhoc/aws-cred-report";

const main = async () => {
  const client = new AWSCredReportClient();
  const report = await client.generateCredentialReport();
  for (const user of report.users) {
    console.log(`${user.username} mfa status: ${user.mfaActive}`);
    if (user.isRoot && !user.mfaActive) {
      console.log("root account has no mfa active!")
    }
  }
}

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free