- boto3 initializes a session using the specified profile, for which it assumes a role as configured in your
~/.aws/config
- Python script with above session initialization prints out shell-compatible environment variables of the temporary credentials
- Wrapper script sets these a la eval
- By the time Ansible runs, the
AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
andAWS_SECURITY_TOKEN
(for boto2) /AWS_SESSION_TOKEN
(for boto3) are all set, and are consumed by boto2 in the inventory script and other boto2-based modules
# This hosts file is brought to you by Dan Pollock and can be found at | |
# http://someonewhocares.org/hosts/ | |
# You are free to copy and distribute this file for non-commercial uses, | |
# as long the original URL and attribution is included. | |
#<localhost> | |
127.0.0.1 localhost | |
127.0.0.1 localhost.localdomain | |
255.255.255.255 broadcasthost | |
::1 localhost |
sub vcl_hit { | |
if (obj.ttl >= 0s) { | |
# normal hit | |
return (deliver); | |
} | |
# We have no fresh fish. Lets look at the stale ones. | |
if (std.healthy(req.backend_hint)) { | |
# Backend is healthy. Limit age to 10s. | |
if (obj.ttl + 10s > 0s) { | |
set req.http.grace = "normal(limited)"; |
global | |
log /dev/log local0 | |
log /dev/log local1 notice | |
chroot /var/lib/haproxy | |
stats socket /run/haproxy/admin.sock mode 660 level admin | |
stats timeout 30s | |
user haproxy | |
group haproxy | |
daemon | |
maxconn 2048 |
#list metrics | |
aws --profile dev --region us-east-1 cloudwatch list-metrics --namespace "AWS/Billing" | |
# Estimated charges | |
aws --region us-east-1 cloudwatch get-metric-statistics --namespace "AWS/Billing" --metric-name "EstimatedCharges" --dimension "Name=Currency,Value=USD" --start-time $(gdate +"%Y-%m-%dT%H:%M:00" --date="-12 hours") --end-time $(gdate +"%Y-%m-%dT%H:%M:00") --statistic Maximum --period 60 --output text | sort -r -k 3 | head -n 1 | cut -f 2 | |
# Marketplace Charges | |
aws --profile dev --region us-east-1 cloudwatch get-metric-statistics --namespace "AWS/Billing" --metric-name "EstimatedCharges" --dimensions Name=ServiceName,Value=AWSMarketplace Name=Currency,Value=USD --start-time $(gdate +"%Y-%m-%dT%H:%M:00" --date="-12 hours") --end-time $(gdate +"%Y-%m-%dT%H:%M:00") --statistic Maximum --period 60 --output text | |
# Redshift |
How to Completely Remove Android Studio | |
Execute these commands from the terminal | |
rm -Rf /Applications/Android\ Studio.app | |
rm -Rf ~/Library/Preferences/AndroidStudio* | |
rm ~/Library/Preferences/com.google.android.studio.plist | |
rm -Rf ~/Library/Application\ Support/AndroidStudio* | |
rm -Rf ~/Library/Logs/AndroidStudio* |
Bash is the JavaScript of systems programming. Although in some cases it's better to use a systems language like C or Go, Bash is an ideal systems language for smaller POSIX-oriented or command line tasks. Here's three quick reasons why:
- It's everywhere. Like JavaScript for the web, Bash is already there ready for systems programming.
- It's neutral. Unlike Ruby, Python, JavaScript, or PHP, Bash offends equally across all communities. ;)
- It's made to be glue. Write complex parts in C or Go (or whatever!), and glue them together with Bash.
This document is how I write Bash and how I'd like collaborators to write Bash with me in my open source projects. It's based on a lot of experience and time collecting best practices. Most of them come from these two articles, but here integrated, slightly modified, and focusing on the most bang for buck items. Plus some ne
I've been playing with jq, and I've been having a hard time finding examples of how it works with output from a service like AWS (which I use a lot).
Here is one I use a lot with vagrant-ec2.
When we're launching and killing a lot of instances, the AWS API is the only way to track down which instances are live, ready, dead, etc.
To find instances that are tagged with e.g. {"Key" = "Name", "Value" = "Web-00'} in the middle of a vagrant dev cycle, or a prod launch/replace cycle, you can do something like this:
#!/usr/bin/env python | |
# | |
# Copyright (C) 2015 Alexander Taler | |
# | |
# This is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This is distributed in the hope that it will be useful, |