Skip to content

Instantly share code, notes, and snippets.

@Bharathkumarraju
Bharathkumarraju / bash_aws_jq_cheatsheet.sh
Created March 7, 2023 03:33 — forked from lukeplausin/bash_aws_jq_cheatsheet.sh
AWS, JQ and bash command cheat sheet. How to query, cut and munge things in JSON generally.
# Count total EBS based storage in AWS
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add"
# Count total EBS storage with a tag filter
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add"
# Describe instances concisely
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]'
# Wait until $instance_id is running and then immediately stop it again
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id
# Get 10th instance in the account
variable "firebase_admin_token" {
description = "The token to use to deploy firebase resources."
type = string
}
variable "project" {
description = "The project id to create the app for."
type = string
}
import json
import boto3
def lambda_handler(event, context):
ses = boto3.client('ses')
body = """
Hello and welcome to the SES Lambda Python Demo.
--- # apache_balancer_manager_role do.yml
- name: member_host
debug:
msg: "member_host {{ member_host }}"
- name: "Get the balancer_manager content"
uri:
url: "{{ apache.balancer.url }}"
follow_redirects: yes
return_content: yes
@Bharathkumarraju
Bharathkumarraju / __main__.py
Created July 12, 2021 23:37 — forked from 1oglop1/__main__.py
Pulumi component resources
import pulumi
from pulumi_aws import s3
from pulumi import Output, Input, ResourceOptions, ComponentResource, set, get
import time
import json
from pydantic import BaseModel
async def w2():
"""Awaitable simulating output"""
@Bharathkumarraju
Bharathkumarraju / private-k8s.md
Created June 18, 2021 00:31 — forked from pydevops/private-k8s.md
how to set up kubectl on laptop for private GKE cluster and on prem private cluster

HTTP tunnel

On prem k8s cluster set up with bastion vm

  1. Run the bastion vm in your data center or in cloud with connectivity set up (usually vpn) to the on prem data center.
  2. Install tinyproxy on the bastion vm and pick a random port as it would be too easy for spam bot with default 8888, set up as systemd service according to https://nxnjz.net/2019/10/how-to-setup-a-simple-proxy-server-with-tinyproxy-debian-10-buster/. Make sure it works by validating with curl --proxy http://127.0.0.1:<tinyproxy-port> https://httpbin.org/ip. And I don't use any user authentication for proxy, so I locked down the firewall rules with my laptop IP/32.
  3. Download the kubeconfig file for the k8s cluster to your laptop
  4. From your laptop, run
HTTPS_PROXY=<bastion-external-ip>:<tinyproxy-port> KUBECONFIG=my-kubeconfig kubectl get nodes
jobs:
should_run:
name: should run the next job
runs-on: ubuntu-latest
steps:
- name: check if vb is the commiter
if: github.event.pusher.name != 'vibou'
run: exit 1 # the job fails if not vibou
perform_action:
name: should run the next job
@Bharathkumarraju
Bharathkumarraju / networking.tf
Created October 1, 2019 03:52 — forked from duduribeiro/networking.tf
Terraform staging - networking.tf
module "networking" {
source = "../modules/networking"
environment = "${var.environment}"
vpc_cidr = "${var.vpc_cidr}"
public_subnet_cidr = "${var.public_subnet_cidr}"
private_subnet_cidr = "${var.private_subnet_cidr}"
region = "${var.region}"
availability_zone = "${var.availability_zone}"
key_name = "${var.key_name}"
}
@Bharathkumarraju
Bharathkumarraju / Dockerfile
Created October 1, 2019 03:51 — forked from duduribeiro/Dockerfile
Dockerfile 2
# dump build stage
FROM postgres:11-alpine as dumper
COPY test_dump.sql /docker-entrypoint-initdb.d/
RUN ["sed", "-i", "s/exec \"$@\"/echo \"skipping...\"/", "/usr/local/bin/docker-entrypoint.sh"]
ENV PG_USER=postgres
ENV PGDATA=/data