Automate creation of Performance Monitor Data Collector on an EC2 instance or a WorkSpace

Do you sometimes notice high CPU or memory usage on your EC2 instances or WorkSpaces? Do you know what’s causing it? For how long and how frequently?

It’s easy to find a rogue process in Task Manager and stop it, but is it a part of the pattern?

Enter a century-old tool -> Performance Monitor.

Sometimes, the rogue process is an application or a service which spikes at random times for random intervals. In such cases, we need to set up a Data Collector in the Performance Monitor and use it to track resource usage over a period of time. Logs are then replayed and root cause identified.

Continue Reading

OpsWorks for Puppet Enterprise IAM role for nodes

“To allow your Puppet nodes to connect to your server, you have to create an AWS Identity and Access Management (IAM) role to use as your EC2 instance profile.”
That’s what the Puppet Enterprise Starter Kit manual says.

Step 1 of the guide says: “Here’s the policy. Create IAM role to use it. For information about how to create an IAM role, see our docs.”

I think we can do better than that. And automate it.

Continue Reading

How to get my EC2 instance password?

I have issues with default EC2 passwords for Windows Server 2016.

Don’t get me wrong, I like that they are 32-character ones. But they are not my 32-character ones. These are really random which makes it pointless to try and type.

Now, if you were like me and actually care about security, your passwords are also long but they make sense. Like “IreallyREALLYlikeUNICORNS!BUTonlyPINKones#”.

Awesome password, am I right? *high five*

So we need a nice way to grab the default admin password. And yet again, let’s keep away from the AWS console. I did say “a nice way”, after all.

How to get my EC2 instance password?

Continue Reading

Get OS of the instance. Or, Gods forbid, SQL version…

I’ve thought about this long and hard. More ‘longer’ than ‘harder’, but still 🙂

The conclusion was that the blog won’t have much sense if I keep updating it once every few months. So I’ll minimize, or completely drop, the teaching tone from my posts.

Time taken to dissect every line of code isn’t worth it, really. If you’d like to go deeper into something that interests you, drop me a line and we can have a chat about it. Much better use of time than laying it all out initially… for nobody to read 🙂

So there you have it. This is about to become a soulless code dump place… But at least I’ve created a GitHub account! Yay! 🙂

First thing on the menu is my today’s puzzle. “How to find out which of my instances are running Windows and which run Linux?”

Continue Reading

Remove EC2 instance snapshots older than X days

Guess who was lazy and didn’t post anything for months? 🙂

Let’s fix that!

Newest challenge: “I’m spamming New-EC2Snapshot every minute because I need my instance to be super protected against hacker ninjas! (Or was it pirates?) But now I have 6.022×1023 snapshots I have no idea what to do with!”

How to get rid of all snapshots older than 3, 7, 30 days?

Continue Reading

I terminated my EC2 instance!

Congratulations! Your rite of passage is now complete, and you are officially an adult! 🙂

As far as rites of passage go, this one, too, sucks and was just about as exciting and useful as any other one. So let’s celebrate by preventing this from happening ever again.

Does your account contain production instances? Do you love right-clicking them in the console instead of selecting and going to Action button? Do you frequently run test instances in your prod account and then remove them (plus other collateral stuff) without thinking twice?

If answer to any of this is ‘Yes’, you need protection. Not armed forces-type of protection, and certainly not Durex. You need protection from your very self.

Continue Reading