Skip to content

Instantly share code, notes, and snippets.

host i-*
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
ServerAliveInterval 120
User ec2-user
ProxyCommand sh -c "aws ec2 start-instances --instance-ids %h ; aws ec2 wait instance-running --instance-ids %h ; aws ec2-instance-connect send-ssh-public-key --instance-id %h --instance-os-user %r --ssh-public-key 'file://~/.ssh/id_rsa.pub' --availability-zone $(aws ec2 describe-instances --instance-ids %h --query 'Reservations[0].Instances[0].Placement.AvailabilityZone') ; aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
@nicornk
nicornk / tail.py
Last active July 7, 2022 07:43 — forked from alanyee/tail.py
Boto3 Tail AWS Cloudwatch Logs
"""Using boto3, instead of awscli, to tail logs.
Based on https://github.com/aws/aws-cli/blob/v2/awscli/customizations/logs/tail.py
and
https://gist.github.com/alanyee/601f995bfd6acfd4c3c16ee7e9115ab5
"""
from collections import defaultdict
import time
import re
from botocore.utils import parse_timestamp, datetime2timestamp