Skip to content

Instantly share code, notes, and snippets.

function stop_ecs_service_tasks () {
local cluster_name=$1
local service_name=$2
local wait_time=${3:-10}
local tasks
local task
# Get tasks
tasks=$(aws --output json \
ecs list-tasks \
function get_ecs_service_instances () {
local cluster_name=$1
local service_name=$2
local tasks
local container_arns
local ec2_instance_ids
echo "Cluster: ${cluster_name}"
echo "Service: ${service_name}"
echo "EC2 instances:"
@mlf4aiur
mlf4aiur / cleanup_ecr_untagged_images.sh
Last active November 18, 2016 02:13
Cleanup AWS ECR untagged images
#!/bin/bash
function delete_image () {
local repo_name=$1
local image_digest=$2
echo "${image_digest}"
aws --out=json \
ecr \
batch-delete-image \
--repository-name="${repo_name}" \
function update_ecs_agent () {
local cluster_name=$1
local container_arns
local container_arn
# Get container instances
container_arns=$(aws --output json \
ecs list-container-instances \
--cluster "${cluster_name}" | \
jq '.containerInstanceArns[]' | tr -d '"' | tr "\n" " ")
for container_arn in ${container_arns}; do
@mlf4aiur
mlf4aiur / get_ecs_cluster_instance_ips.sh
Last active July 12, 2018 23:14
Get AWS ECS cluster instance IPs
function get_ecs_cluster_instance_ips () {
local cluster_name=$1
local container_arns
local ec2_instance_ids
# Get container instances
container_arns=$(aws --output json \
ecs list-container-instances \
--cluster "${cluster_name}" | \
jq '.containerInstanceArns[]' | tr -d '"' | tr "\n" " ")
@mlf4aiur
mlf4aiur / get_ecs_service_instance_ips.sh
Last active December 2, 2016 09:43
Get AWS ECS service instance IPs
function get_ecs_service_instance_ips () {
local cluster_name=$1
local service_name=$2
local tasks
local container_arns
local ec2_instance_ids
# Get tasks
tasks=$(aws --output json \
ecs list-tasks \
@mlf4aiur
mlf4aiur / Grafana-cAdvisor-Templated.json
Last active February 16, 2016 15:30
Grafana cAdvisor Templated dashboard
{
"id": 3,
"title": "cAdvisor Templated",
"originalTitle": "cAdvisor Templated",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"sharedCrosshair": false,
@mlf4aiur
mlf4aiur / setup_docker_on_osx.md
Last active August 29, 2015 14:18
Setup Docker on OSX

Setup Docker on OSX

Install Homebrew on your laptop

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install some packages you like

brew update

@mlf4aiur
mlf4aiur / Grafana Templated Graphs.json
Created June 15, 2014 02:09
Grafana-Templated Graphs
{
"title": "Templated Graphs",
"services": {
"filter": {
"list": [
{
"type": "filter",
"name": "host",
"query": "sensu.*",
"includeAll": true,
@mlf4aiur
mlf4aiur / convert_unixtimestamp.sh
Created March 26, 2014 06:16
Convert unix timestamp
utime(){ date -d @$1; }
utime(){ date -d "1970-01-01 GMT $1 seconds"; }
utime(){ awk -v d=$1 'BEGIN{print strftime("%a %b %d %H:%M:%S %Y", d)}'; }
utime(){ perl -e "print localtime($1).\"\n\""; }
utime(){ python -c "import time; print(time.strftime('%a %b %d %H:%M:%S %Y', time.localtime($1)))"; }
[root@test test]# utime(){ date -d @$1; }
[root@test test]# utime 1273817956
Fri May 14 14:19:16 CST 2010