Skip to content

Instantly share code, notes, and snippets.

View jonathanhle's full-sized avatar

Jonathan Le jonathanhle

View GitHub Profile
@jonathanhle
jonathanhle / get_instance_tag_with_instance_id.py
Created April 9, 2020 03:35 — forked from sidja/get_instance_tag_with_instance_id.py
Using Python and Boto3 to get Instance Tag information with instance id
import boto3
def get_instance_name(fid):
"""
When given an instance ID as str e.g. 'i-1234567', return the instance 'Name' from the name tag.
:param fid:
:return:
"""
ec2 = boto3.resource('ec2')
ec2instance = ec2.Instance(fid)
@jonathanhle
jonathanhle / Devops Definition of Done Thoughts
Last active March 6, 2020 01:56
Devops Definition of Done Thoughts
• Releases Managed
• You have to have some type of deployable software object before you can do anything.
• The object here is the AMI, container, deb, zip, something
• Deployments are Automated
• Now that you have a deployable software object, you have to automate the deployment.
• APIs for Observability
• Both before and after the object is deployed, you're going to have spend some time instrumenting/researching what characteristics need to be exposed for monitoring at runtime.
• What should be measured so we can do whatever is needed to ensure the systems keep working optimally
• Monitoring & Alerting
• Using the APIs, logs, whatever from above, implement monitoring and alerting on KPIs
@jonathanhle
jonathanhle / gh-dl-release
Created December 14, 2019 00:30 — forked from maxim/gh-dl-release
Download assets from private Github releases
#!/usr/bin/env bash
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#
@jonathanhle
jonathanhle / cheaply dump ec2 info to csv
Last active December 9, 2019 18:47
cheaply dump ec2 info to csv
import boto3
import csv
# define header row and start a row_list with the header present
header_row = ["account_id", "aws_region", "environment", "instance_id", "instance_name", "security_groups"]
row_list = [header_row]
regions = ["us-east-1", "us-west-2"]
# ---------------------------------------------------------------------------------------------------------------------
@jonathanhle
jonathanhle / gist:6835a15bbb60fe90ded2cf4bf9884753
Created October 16, 2019 18:23
AWS Step Functions Example for Sub Minute Scheduled Lambdas
{
"Comment": "Invoke Lambda every 10 seconds",
"StartAt": "ConfigureCount",
"States": {
"ConfigureCount": {
"Type": "Pass",
"Result": {
"index": 0,
"count": 6
},
@jonathanhle
jonathanhle / gist:9f38a671d72dd9fdac745ddce1211567
Created July 22, 2019 23:01
tfh-helper cancel pending and current runs
# Cancel Pending Runs
export project_env="nonprod"
export project_prefix="project-prefix-yada-foo-bar"
export working_workspaces=$(tfh workspace list | grep ${project_prefix} | grep ${project_env})
for wrkspace in ${working_workspaces}:
do
echo $wrkspace
pending_run=`tfh run list -name ${wrkspace} | grep "pending" | awk '{print $1}' | head -n 1`
@jonathanhle
jonathanhle / lambda-function-xray-enablement.tf
Created July 9, 2019 20:11 — forked from mdlavin/lambda-function-xray-enablement.tf
Terraform configuration to enable X-Ray for a Lambda function
resource "aws_lambda_function" "service" {
# Your usual aws_lambda_function configuration settings here
tracing_config {
mode = "Active"
}
}

Keybase proof

I hereby claim:

  • I am jonathanhle on github.
  • I am jonathanhle (https://keybase.io/jonathanhle) on keybase.
  • I have a public key ASBc9Jif9zaS6tJIibA947uteCd8_WfgcY560sBj5XzsBgo

To claim this, I am signing this object:

import boto3
import hvac
import ssl
#ssl._create_default_https_context = ssl._create_unverified_context
session = boto3.Session()
credentials = session.get_credentials()
client = hvac.Client(verify=False)
client.auth_aws_iam(credentials.access_key, credentials.secret_key, credentials.token, role='example-role', header_value='vault.service.consul')
@jonathanhle
jonathanhle / README.md
Created June 25, 2019 20:22 — forked from joelthompson/README.md
Vault Auth