Skip to content

Instantly share code, notes, and snippets.

@cloudfiles-me
cloudfiles-me / awscli_jq.txt
Last active June 13, 2018 16:39
aws cli + jq snippet
Get some values from all instances
aws ec2 describe-instances \
| jq '.Reservations[].Instances[] \
| {PublicDnsName, InstanceId, SecurityGroups}'
Get instance screenshoot
aws ec2 get-console-screenshot --instance-id instance_id \
| jq -r '.ImageData' | base64 --decode | open -f -a /Applications/Preview.app
# Example de select by tag name
# Using configuration file in kubectl
kubectl --kubeconfig kubectl.config cluster-info
# kubectl.config file example
current-context: default-context
apiVersion: v1
clusters:
- cluster:
api-version: v1
server: https://172.31.53.107:443/
@cloudfiles-me
cloudfiles-me / aws_metadata.txt
Last active March 9, 2018 20:12
Some aws metadata usage
curl -s -w "\n" http://169.254.169.254/latest/meta-data/placement/availability-zone
REGION=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region)
aws ec2 describe-tags --filters "Name=resource-id,Values=$INSTANCE_ID" "Name=key,Values=$KEY" --region=$REGION --output=json | jq -r .Tags[0].Value
@cloudfiles-me
cloudfiles-me / other_stuffs.txt
Last active May 19, 2018 16:45
user_data_in_terraform.txt
user_data = <<-EOF
#!/bin/bash
sudo service apache2 start
EOF
@cloudfiles-me
cloudfiles-me / csshx.sh
Created March 9, 2018 22:11
Cluster SSH
csshX --host hostfile.txt -l username --ssh_args " -i path/to/ssh_keys/key.pem"
@cloudfiles-me
cloudfiles-me / commands.txt
Created March 19, 2018 20:49
git clone without credentials in CodeCommit
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
#!/bin/bash
START=$(date +%s)
this_instance=`aws ec2 run-instances --image-id $ami-id --key-name $key_name --instance-type t2.micro --security-groups $SG-Name --count 1 | jq -r '.Instances[] | ."InstanceId"'`
while true
do
# save the output of the line starting with INSTANCE, 6th field, to "status"
status=`aws ec2 describe-instance-status --instance-ids $this_instance| jq -r '.InstanceStatuses[].InstanceState.Name'`
@cloudfiles-me
cloudfiles-me / install_python3_6_on_C9.md
Last active June 1, 2018 23:13 — forked from espozbob/install_python3_6_on_C9.md
Install Python3.6 on the C9
$ wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz

$ tar xvf Python-3.6.3.tgz

$ cd Python-3.6.3

$ ./configure --enable-optimizations

$ make -j8
@cloudfiles-me
cloudfiles-me / aws-cfn-bootstrap-ubuntu.txt
Created June 4, 2018 21:53
Install aws-cfn-bootstrap on Ubuntu
sudo apt-get install python-pip
sudo pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz