Skip to content

Instantly share code, notes, and snippets.

Avatar
🧶

Christian Haller christianhaller3000

🧶
View GitHub Profile
View awsiam.ts
import { IAM } from "aws-sdk";
import { User } from "aws-sdk/clients/iam";
import { formatDistance } from "date-fns";
const getUsers = async (m: string | undefined, iamUsers: User[] = []) => {
const { Users, Marker, IsTruncated } = await new IAM()
.listUsers({
Marker: m,
})
.promise();
View kochwerk-cli.js
const fetch = require("node-fetch");
const fn = async () => {
const token = "11e01fc60358e3d96947ab6d4afaee66";
const today = new Date().toDateString();
const iconMap = {
"10": "Ⓥ",
"11": "🌱",
"12": "🌾",
"13": "🚫🥛",
@christianhaller3000
christianhaller3000 / workflowName.js
Created Dec 11, 2019
get circleci workflow name by api
View workflowName.js
/* eslint-disable import/no-extraneous-dependencies */
const fetch = require("node-fetch");
const log = require("debug")("app:circleci");
module.exports = async ({ circleToken, workflowId }) => {
// wait for https://ideas.circleci.com/ideas/CCI-I-295
const url = `https://circleci.com/api/v2/workflow/${workflowId}?circle-token=${circleToken}`;
// trigger api with node-fetch
const { name } = await (
@christianhaller3000
christianhaller3000 / mock.js
Created Jul 18, 2019
Mock node dns resolver
View mock.js
jest.mock("dns", () => {
return {
promises: {
Resolver: function() {
return {
resolveTxt: () => {
return ["1.1.1.1","2.2.2.2/28"];
}
};
}
View index.js
const { EC2 } = require("aws-sdk");
const region = "eu-central-1";
module.exports = async () => {
const ec2 = new EC2({
region
});
const { Regions } = await ec2.describeRegions().promise();
@christianhaller3000
christianhaller3000 / index.js
Last active Oct 2, 2019
find logs without retention
View index.js
const { CloudWatchLogs, EC2 } = require("aws-sdk");
const region = "eu-central-1";
module.exports = (async () => {
try {
const ec2 = new EC2({
region
});
const { Regions } = await ec2.describeRegions().promise();
View index.js
const { SecretsManager } = require('aws-sdk');
module.exports = async () => {
const secretsManager = new SecretsManager();
const { SecretList } = await secretsManager.listSecrets().promise();
const secrets = SecretList.map(async secret => secretsManager.getSecretValue({
SecretId: secret.Name,
VersionStage: 'AWSCURRENT',
You can’t perform that action at this time.