quick setup and usage guide for SSH access over SSM to private AWS EC2 instances
- python3
- awscli
- session-manager-plugin
git clone https://github.com/elpy1/ssm-tool.git
#!/usr/bin/env python | |
import math | |
import sys | |
from moviepy.editor import AudioClip, VideoFileClip, concatenate_videoclips | |
# Get average RGB of part of a frame. Frame is H * W * 3 (rgb) | |
# Assumes x1 < x2, y1 < y2 |
terraform { | |
required_providers { | |
http = "~> 1.2" | |
} | |
required_version = "~> 0.12.29" | |
} | |
data "http" "terraform_cloud_ip_ranges" { | |
url = "https://app.terraform.io/api/meta/ip-ranges" |
PROFILE=test | |
echo "Please, provide MFA code:" | |
read MFA_CODE | |
ASSUMED_ROLE=$(aws sts assume-role --role-arn="$(aws configure get role_arn --profile $PROFILE)" --role-session-name=session --token-code=$MFA_CODE --serial-number="$(aws configure get mfa_serial --profile $PROFILE)" --output text) | |
ASSUMED_ROLE_ARRAY=( $ASSUMED_ROLE ) | |
if [ -z "$ASSUMED_ROLE_ARRAY" ] | |
then |
quick setup and usage guide for SSH access over SSM to private AWS EC2 instances
git clone https://github.com/elpy1/ssm-tool.git
package main | |
import ( | |
"fmt" | |
"log" | |
"log/syslog" | |
"strings" | |
"github.com/shirou/gopsutil/process" | |
) |
package main | |
// put this executable as .git/hooks/prepare-commit-msg | |
import ( | |
"io/ioutil" | |
"log" | |
"os" | |
"strings" | |
) |
sudo apt install s3fs | |
echo "<redacted>" > ~/.passwd-s3fs | |
sudo nano /etc/systemd/system/s3fs.service | |
chmod 600 /home/ubuntu/.passwd-s3fs | |
sudo systemctl daemon-reload | |
sudo systemctl enable s3fs |
data "aws_caller_identity" "current" {} | |
resource "aws_s3_bucket" "terraform_state" { | |
bucket = "${data.aws_caller_identity.current.account_id}-tfstate" | |
versioning { | |
enabled = true | |
} | |
policy = <<POLICY | |
{ | |
"Version": "2012-10-17", |
// kotlin.collections | |
inline fun <T> Array<out T>.takeWhileInclusive( | |
predicate: (T) -> Boolean | |
): List<T> { | |
var shouldContinue = true | |
return takeWhile { | |
val result = shouldContinue | |
shouldContinue = predicate(it) | |
result |
""" | |
Craft a web request to the AWS rest API and hit an endpoint that actually works but isn't supported in the CLI or in Boto3. | |
Based on this: https://github.com/aws/aws-cli/issues/2268#issuecomment-373803942 | |
""" | |
import boto3 | |
import os | |
import sys, os, base64, datetime, hashlib, hmac, urllib | |
import requests |