Skip to content

Instantly share code, notes, and snippets.

View andreif's full-sized avatar
👾
invading spaces

Andrei Fokau andreif

👾
invading spaces
View GitHub Profile

Example of Go AWS Lambda using stdlib only

Source

Create a main.go file:

package main

import (
import { Construct } from 'constructs';
import { CfnOutput, Stack } from 'aws-cdk-lib';
import * as cdk from 'aws-cdk-lib';
export function output(scope: Construct, name: string, value: string) {
return new CfnOutput(scope, name, {
value,
exportName: `${Stack.of(scope).stackName}:${name}`,
});
}
@andreif
andreif / Makefile
Created February 21, 2024 09:56
.npmrc
# $(call secret,region,account,secret_id)
define secret
$(shell aws secretsmanager get-secret-value \
--region $(1) --secret-id arn:aws:secretsmanager:$(1):$(2):secret:$(3) \
--output text --query SecretString)
endef
.npmrc: NPM_TOKEN ?= $(call secret,eu-west-1,1234567890,npm-readonly-token)
.npmrc:
@test -n "${NPM_TOKEN}" || (>&2 echo "Error: NPM_TOKEN is missing"; exit 1)
@andreif
andreif / sso-oidc.py
Last active February 19, 2024 09:29
AWS auth via SSO OIDC
import os
from time import sleep
import boto3
from utils import dump as _print, list_all
import cache
FORCE = False
ROLE_NAME = os.environ['ROLE_NAME']
@andreif
andreif / AWS-list-accounts.sh
Last active February 14, 2024 09:29
List AWS accounts and format in Markdown
aws organizations list-accounts --query Accounts \
| jq -r 'sort_by(.Name) | .[] | [.Id,.Name] | @csv' \
| sed 's/"//g' \
| sed -E 's/^([0-9]+),/- [ ] `\1` /g'
import http.server
class Handler(http.server.BaseHTTPRequestHandler):
def __getattr__(self, item):
if item.startswith('do_'):
return self.default
return getattr(super(), item)
def default(self):
@andreif
andreif / Cloud Build and Cloud Run example.md
Last active January 6, 2024 21:42
Cloud Build and Cloud Run example

Cloud Build and Cloud Run example

PROJECT=my-project-123456  make setup build-and-deploy
@andreif
andreif / App Engine.md
Last active January 6, 2024 21:13
App Engine

App Engine

@andreif
andreif / jaml.py
Last active July 16, 2023 08:56
Convert JSON to YAML in Python without any dependency.
"""
Convert JSON to colorful YAML.
Example:
$ alias jaml="python .../jaml.py"
$ curl https://api.thecatapi.com/v1/images/search -s | jaml
License: MIT
"""
function reveal_url() {
for (let el of document.getElementsByClassName("reveal-url")) {
let x = el.innerText.split("").reverse().join("");
el.setAttribute("href", el.getAttribute("href") + x.replaceAll(" ", ""));
el.innerText = x;
}
}