Where 1.1.1.1 is the current IP address where the cert we are testing is located.
JSON & friends
CFN EBS volume tagging
If you want to tag EC2 instance root volume based on the EC2 instance tag, you can use something like this.
Note:
This is script that runs post-stack creation.
Stack creates a single instance
We are using CFN Outputs to get the InstanceID
Fine grained CloudTrail parsing with custom output
Parse large amounts of CT logs:
Note: I did the above for both months in parallel as CPU (core) was the bottleneck. Doing it for the larger month alone (984MB) took almost 12 minutes.
After this, I parsed individual out.txt files in a few different ways until I was happy with outputting only PutRolePolicy or DeleteRolePolicy, and formatted the output a little bit, in a way it was presentable to the customer:
Similar to above, but in one step and using a jq argument (import shell variable). Use case: “Who removed rules from “sg-xxxxxxxx”:
Adding values via JQ
Script that parses a JSON, structures it im key: value structure where value is integer.
A friend needed to put a sum at the bottom. My last line in this JQ is what did what he wanted:
Filter then catenate all CloudTrail gzip logs into one text file with output time sorted
Finding highest offenders
Again, in this example, we try to do as much as possible on each iteration of .gz files to avoid crashing the desktop
Recursively search json structure for a value of desired keyname
For example, we might have keys “volumeId” in different places throughout our input JSON. If we want to grab all such entries, we can do something like this (CloudTrail parse example):
Note: This is an expensive operation (~4-5 x more time than when directly checking for a value on a specific key location)
Database stuff
MySQL Basics
Useful MySQL commands
When creating MySQL users, make sure that your .mysql_history file does not log anything. There are two ways:
Permanently: ln -s /dev/null $HOME/.mysql_history
Temporarily: MYSQL_HISTFILE=/dev/null && mysql <your parameters here>
And now for some general tips:
SSL for MySQL (RDS example)
MySQL workbench also supports SSL. When creating a connection go to the Advanced tab and just fill in the CA field. Relevant RDS doc