Skip to content

Instantly share code, notes, and snippets.

@brianfoody
Last active April 5, 2022 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianfoody/1060e45114e4584fe63b9dd040c26124 to your computer and use it in GitHub Desktop.
Save brianfoody/1060e45114e4584fe63b9dd040c26124 to your computer and use it in GitHub Desktop.
Easy AWS SSO Stuff
const { createAWSClient } = require("easy-aws-utils");
const exec = async () => {
const { aws, access, s3Helper } = await createAWSClient();
// The access details you have configured
console.log(JSON.stringify(access, null, 2));
// The organisations in the left bar
const ssoUrls = access.organisations.map((o) => o.ssoStartUrl);
// List top level buckets for the account
const buckets = await s3Helper.listBuckets({
access: {
accountId: "433121571808",
permissionSet: "AdministratorAccess",
},
});
console.log("buckets");
console.log(buckets);
// List objects under a buckets path
const firstLevelObjects = await s3Helper.listObjects({
access: {
accountId: "433121571808",
permissionSet: "AdministratorAccess",
},
bucket: "wow-this-is-a-great-bucket",
path: "",
});
console.log(firstLevelObjects);
// List objects under another path
const secondLevelObjects = await s3Helper.listObjects({
access: {
accountId: "433121571808",
permissionSet: "AdministratorAccess",
},
bucket: "wow-this-is-a-great-bucket",
path: "whatsinhere",
});
console.log(secondLevelObjects);
// List objects under another path
const levelWithFiles = await s3Helper.listObjects({
access: {
accountId: "433121571808",
permissionSet: "AdministratorAccess",
},
bucket: "wow-this-is-a-great-bucket",
path: "whatsinhere/a-little-further/",
});
console.log(levelWithFiles);
};
exec();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment