Skip to content

Instantly share code, notes, and snippets.

#
# do not make any modifications to this file as this resides on github gist
#
# https://taskfile.dev
#
# go install github.com/go-task/task/v3/cmd/task@v3.33.1
# ~/go/bin/task --list-all
#
# 0.1.0
#
@030
030 / vscode-settings.json
Last active February 10, 2024 09:12
vscode-settings
//
// code --list-extensions --show-versions | tr '\n' ' '
//
// esbenp.prettier-vscode@10.1.0 golang.go@0.37.1 ms-python.autopep8@2023.6.0 ms-python.python@2023.18.0 redhat.vscode-yaml@1.14.0 tamasfe.even-better-toml@0.19.2
//
{
// general
"editor.formatOnSave": true,
"window.zoomLevel": -1,
@030
030 / go-build.sh
Last active November 9, 2022 14:03
#!/bin/bash -e
GITHUB_TAG="${GITHUB_TAG:-local}"
SHA512_CMD="${SHA512_CMD:-sha512sum}"
GO_BUILD_DIR="${1}"
GO_BUILD_DELIVERABLE="${2}"
echo "GITHUB_TAG: '${GITHUB_TAG}', SHA512_CMD: '${SHA512_CMD}', GO_BUILD_DIR: ${GO_BUILD_DIR}, GO_BUILD_DELIVERABLE: '${GO_BUILD_DELIVERABLE}'"
cd cmd/${GO_BUILD_DIR}
go build -buildvcs=false -ldflags "-X main.Version=${GITHUB_TAG}" -o "${GO_BUILD_DELIVERABLE}"
@030
030 / dashbord-to-jsonnet.py
Created March 7, 2022 13:49 — forked from tennix/dashbord-to-jsonnet.py
Convert Grafana dashboard json to jsonnet
#!/usr/bin/env python
import json
from jinja2 import Template
# git clone https://github.com/pingcap/tidb-docker-compose
# cd tidb-docker-compose
# git clone https://github.com/tennix/grafonnet-lib -b table
# python dashboard-to-jsonnet.py > pd.jsonnet
# jsonnet -J grafonnet-lib pd.jsonnet > config/dashboards/generated-pd.json
with open('config/dashboards/pd.json', 'r') as f:
data = json.load(f)
@030
030 / print-memory.go
Created February 7, 2022 23:51 — forked from j33ty/print-memory.go
Go print current memory
package main
import (
"runtime"
"fmt"
"time"
)
func main() {
// Print our starting memory usage (should be around 0mb)
@030
030 / script-template.sh
Created April 13, 2021 13:46 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@030
030 / pfx-to-crt-and-key.sh
Created November 6, 2020 07:55 — forked from whereisaaron/pfx-to-crt-and-key.sh
Extract a crt file (PEM), key file, and chain bundle from a PFX file, prompts for password or use PFXPASSWORD environment variable
#!/bin/bash
#------------------
# Extract the key, certficiate, and chain in PEM format from a PFX format file
#
# Must supply the input pfx file
PFX_PATH="$1"
if [ "${PFX_PATH}" == "" ]; then
echo "Must supply pfx file path"
exit 1
#!/bin/bash -e
NEXUS_VERSION="${1:-3.21.1}"
NEXUS_API_VERSION="${2:-v1}"
NEXUS_DOCKER_NAME="${3:-nexus}"
NEXUS_DOCKER_PORT="${4:-9999}"
NEXUS_PW_ON_DISK="${5:-/tmp/nexus-tst-pass}"
NEXUS_HTTP_CONNECTOR_DOCKER_REGISTRY="${6:-8888}"
NEXUS_HTTP_CONNECTOR_DOCKER_REGISTRY_INTERNAL="${7:-8082}"
@030
030 / lambda-vpc-internet-access-cloudformation.yml
Created June 25, 2019 16:36 — forked from romaninsh/lambda-vpc-internet-access-cloudformation.yml
CloudFormation template implementing Private network which can be used by Serverless to deploy Lambda into VPCs an maintaining internet access
# Add the following to your existing VPC CF stack
# create 2 subnets, lambdas like to be in multiple subnets
Private1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 0, !GetAZs ]
CidrBlock: !Ref Private1CIDR

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.