Skip to content

Instantly share code, notes, and snippets.

@jmlrt
jmlrt / tf-import-stack.sh
Created March 9, 2018 09:40
import terraform stack resources helper
#!/usr/bin/env bash
# List terraform resources in the current directory and ask their arn to import them into terraform state
RESOURCES_LIST=$(awk -F\" '/^resource "/ {print $2"."$4}' *.tf)
for resource in ${RESOURCES_LIST}
do
read -p "Enter ARN for resource ${resource} (type none to not import it): " arn
if [[ ${arn} != "none" ]]

Keybase proof

I hereby claim:

  • I am jmlrt on github.
  • I am jmlrt (https://keybase.io/jmlrt) on keybase.
  • I have a public key ASDTN1Tul2QgMnw6MCSzixRFfyfZqUlBHBvYf5jt8Q-Fpwo

To claim this, I am signing this object:

@jmlrt
jmlrt / mongodb_update.sh
Created November 16, 2017 11:12
Script to automate mongodb rpm updates steps on ReplicaSet nodes installed on EC2 instances with CentOS7
#!/usr/bin/bash -e
# This script will be use to automate the mongodb rpm updates steps on ReplicaSet nodes installed on EC2 instances with CentOS7
mongo_connect() {
mongo --quiet ${MONGO_DB} -u ${MONGO_USER} -p ${MONGO_PASS}
}
usage() {
cat << EOF
@jmlrt
jmlrt / example.md
Created September 22, 2017 14:24 — forked from kkung/example.md
Getting AWS RDS Log files
$ python get_logs.py rds-db-instance-name rds.log aws-access-key aws-secret-key
$ ./pgbadger -p '%t:%r:%u@%d:[%p]:' ./rds.log

$ open out.html

@jmlrt
jmlrt / proxy.conf
Created September 11, 2017 17:42
nginx minimal https reverse proxy configuration
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://webserver:8080;
}
}
server {
@jmlrt
jmlrt / archive-cloudwatch-logs-to-s3.sh
Created June 27, 2017 13:00
Archives all cloudwatch logs to S3 for the specified environment
#!/bin/bash -x
#
# archive-cloudwatch-logs-to-s3.sh
#
# This script archives all cloudwatch logs to S3 for the specified environment
# Environment (prefix used in all matching cloudwatch log groups - ex: prod-tomcat, prod-apache, prod-mysql, ...)
ENV=$1
# Destination S3 Bucket
S3_LOG_BUCKET="$2"
@jmlrt
jmlrt / k8s_update_deployment_image.sh
Created June 27, 2017 12:53
Update Kubernetes deployment image
#!/bin/bash
#
# Update docker image tag in a kubernetes deployment
# Kubernetes cluster address
K8S_CLUSTER="change.me"
# Kubernetes cluster certificate path
K8S_CERTIFICATE="/change/me"
# Kubernetes cluster token
K8S_USER="CHANGEME"
#!/bin/bash
#
# Download and compress cloudwatch log for the specified group, stream and date
DATE=$1
CLOUDWATCH_LOG_GROUP=$2
CLOUDWATCH_LOG_STREAM=$3
LOG_FILE="${DATE}-${CLOUDWATCH_LOG_GROUP}-${CLOUDWATCH_LOG_STREAM}.log"
echo "Installing awslog tools"
@jmlrt
jmlrt / cf_create.sh
Created June 27, 2017 09:49
Unattend cloudformation creation
#!/bin/bash -ex
export name
export template_url=$2
aws cloudformation create-stack --stack-name ${name} --template-url ${template_url} \
# Check StackStatus
sleep 120
@jmlrt
jmlrt / tf_apply.sh
Created June 27, 2017 09:45
Unattend terraform / terragrunt
#!/bin/bash
ENV=$1
# Install terraform
if [ ! -x terraform ]
then
wget -q https://releases.hashicorp.com/terraform/0.8.8/terraform_0.8.8_linux_amd64.zip
unzip terraform_0.8.8_linux_amd64.zip
chmod +x terraform