DEV Community

Cover image for Gifted my wife an AWS EC2 Automation Script
NaveenKumar Namachivayam ⚡ for AWS Community Builders

Posted on • Originally published at


Gifted my wife an AWS EC2 Automation Script

For this new year, I gifted my wife an AWS EC2 automation script. Read on to know more about this in this blog about our problem statement and its simple solution.

Problem Statement

We have one of the national bank accounts in India to do financial transactions every month. Recently, we couldn't log in to the account as it is blocking foreign IPs. I tried it from a couple of VPNs to access it, but no luck.


Then, I spun an EC2 instance Windows instance in the ap-south-1 region. It worked. For every month, I manually log in into my AWS console to spin up an instance, then I provide her with the credentials. This has continued for the last couple of months.

Better Solution

Got bored with the manual steps. Enter automation. I could have done this with Terraform or Ansible, but it would be too techie for my wife. Hence, the bash.


The following are the prerequisites to implement this simple solution. Initially, I had to set this up on her laptop.

  • AWS Account
  • IAM Role to create, describe, and terminate EC2
  • PEM file to decrypt password

As I mentioned above, you would need to have an AWS account with the right IAM role and the key pair. Also, you need to have AWS CLI configured with the right API Access Key and Secret.

How to?

Once the setup is done, follow the steps below to create an EC2 instance.

  • Clone this repo git clone
  • cd aws-ec2-windows
  • Run the below commands
chmod +x
  • To spin up an EC2 instance
  • After a while, it will display the credentials as shown below

Gifted my wife an AWS EC2 Automation Script
Gifted my wife an AWS EC2 Automation Script

To terminate this spanned instance, run the below command.

Terminate EC2
Terminate EC2

GitHub Repo

<!-- /wp:button -->


Once the repo is cloned, you can configure the below parameters in

Importantly, change the name, pem_location, key_name, security_group, image_id, and region parameters. Running with the default parameters will fail to create an instance.

region="ap-south-1" #mumbai

While creating the instance, the script will display random love quotes from

If you want to disable this, comment out the function get_random_quote

Final Thoughts

My wife loves this and makes it easy for her so that she is not dependent on me. The above script can be improved further by installing dependencies on its own. But I do not want to overcomplicate things. Hope this helps someone. If you have any comments, please let me know.

Top comments (1)

lakincoder profile image
Lakin Mohapatra

Superb man

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.