Skip to content

Instantly share code, notes, and snippets.

View WillianTomaz's full-sized avatar
🎯
Focusing

Willian T. WillianTomaz

🎯
Focusing
View GitHub Profile
@felipelima94
felipelima94 / create-temp-pod.md
Created December 6, 2022 14:55
Criar pod temporario dentro do kubernetes
kubectl run [pod-name] -i --tty -n [namespace] --image [image] --image-pull-policy='IfNotPresent' --restart='Never' --rm -- [commands]
kubectl run "$USER-ubuntu" -i --tty -n [namespace] --image=ubuntu:latest --image-pull-policy='IfNotPresent' --restart='Never' --rm -- bash -c 'apt update;/bin/bash'

Comando para criar pod $USER-ubuntu pega o nome de usuário do seu sistema e concatena com ubuntu

import json
import boto3
ec2 = boto3.resource('ec2', region_name='us-east-1')
def lambda_handler(event, context):
instances = ec2.instances.filter(Filters=[
{
'Name': 'instance-state-name',
'Values': ['running']
},
{
import json
import boto3
ec2 = boto3.resource('ec2', region_name='us-east-1')
def lambda_handler(event, context):
instances = ec2.instances.filter(Filters=[
{
'Name': 'instance-state-name',
'Values': ['stopped']
},
{
@mehdihasan
mehdihasan / install-oc-client-ubuntu.md
Last active August 27, 2024 20:10
Install OC client in Ubuntu/Debian
@lukeplausin
lukeplausin / bash_aws_jq_cheatsheet.sh
Last active August 29, 2024 20:27
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
@lukechilds
lukechilds / get_latest_release.sh
Created August 9, 2016 19:43
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4