Skip to content

Instantly share code, notes, and snippets.

View embano1's full-sized avatar

Michael Gasch embano1

View GitHub Profile
@embano1
embano1 / README.md
Last active June 23, 2023 14:49
EventBridge CloudEvents Input Transformer

About

Transform EventBridge Events to CloudEvents using Input Transformer, incl. projecting AWS Region and Account ID from the EventBridge event to CloudEvent extended attributes.

Note
You can test whether the transformed CloudEvent is valid using this simple CloudEvent validator utility.

Example Event

@embano1
embano1 / README.MD
Last active February 6, 2023 16:29
Global Endpoints IAM Example

Trust Relationship

Assume a role named EventBridgeGlobalEndpoints which is important for the "iam:PassRole" part.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
@embano1
embano1 / handler.ts
Created October 3, 2022 11:31
CloudEvents TypeScript AWS Lambda SQS Example
import {SQSEvent, SQSHandler} from 'aws-lambda';
import {CloudEvent} from 'cloudevents';
export const handler: SQSHandler = async (events: SQSEvent) => {
events.Records.forEach(e => {
const ce: CloudEvent<string> = new CloudEvent<string>(JSON.parse(e.body));
console.log(ce);
});
};
@embano1
embano1 / README.md
Created September 23, 2022 09:29
Build and run AWS Lambda Containers locally with Go and ko on M1 Mac

download Lambda RUI for M1

mkdir -p ~/.aws-lambda-rie && curl -Lo ~/.aws-lambda-rie/aws-lambda-rie \
https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie-arm64 \
&& chmod +x ~/.aws-lambda-rie/aws-lambda-rie

login

@embano1
embano1 / README.md
Created April 6, 2022 08:58
Retrieve StorageIOAllocation property of a virtual disk
$ ./govc object.collect -json /vcqaDC/vm/vm-with-disk config.hardware.device \
  | jq '.[0].Val.VirtualDevice[]|select(.Key==2000)|.StorageIOAllocation'
{
  "Limit": -1,
  "Shares": {
    "Shares": 1000,
    "Level": "normal"
  },
 "Reservation": 0
@embano1
embano1 / RESULT.md
Last active April 22, 2022 09:01
go 1.18 assert.Equal benchmark
go test -v -bench=. -gcflags '-l -N' -cpu=1,2,4 -benchmem
goos: darwin
goarch: amd64
pkg: github.com/embano1/assertbench
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
BenchmarkEqualGeneric
BenchmarkEqualGeneric           462083778                2.392 ns/op           0 B/op          0 allocs/op
BenchmarkEqualGeneric-2         504194739                2.391 ns/op           0 B/op          0 allocs/op
BenchmarkEqualGeneric-4 513227227 2.470 ns/op 0 B/op 0 allocs/op
@embano1
embano1 / workflow.yaml
Created March 11, 2022 12:15
Github Actions ko cosign Example
name: image
on:
push:
branches: ['main']
workflow_dispatch:
permissions:
contents: read
packages: write
@embano1
embano1 / create.sh
Last active September 9, 2021 08:34
HTTP CloudEvents function always returning 500 (for failure tests, retries, etc.)
export KIND_CLUSTER_NAME=knative-0.24
export KO_DOCKER_REPO=kind.local
ko apply -f .
@embano1
embano1 / README.md
Created July 26, 2021 20:47
VMware Horizon Events API

Authenticate

Note: Access token is valid for 8min.

TOKEN=$(echo -n '{"domain":"corp","username":"administrator","password":"VMware1!"}'| curl -s -d@- -H "content-type: application/json" -k https://10.153.252.17:15443/rest/login | jq -r '.access_token')

Filter to URL-encoded

@embano1
embano1 / README.md
Last active November 23, 2021 09:30
End-to-End Installation of VMware Event Router with kind

End-to-End Installation of VMware Event Router with kind

The following steps describe the installation of the VMware Event Router (also part of the VEBA project) in a local Kubernetes and Knative environment.

The steps assume a Mac OSX environment but the links provide resources to install the components for other platforms.