When retrieving the AMI Creation Date from boto3 it returns a string data type. Visually, this is okay but it is challenging to do operations and comparisons to the AMI Creation Date in this format.
To solve the issue we need to convert the AMI Creation Date from type string to datetime before we could do some operations.
The AMI Creation Date string looks like 2019-09-18T07:34:34.000Z. To convert this we need to use the strptime function from the datetime.datetime library.
Creating an EC2 Instance with an IAM Role is easy when you do it via the AWS Console but doing this with CloudFormation is not as direct. You will need an Instance Profile to connect an EC2 with an IAM Role.
For production systems we should specify the specific version of ChefDK or else this will install the version. To do this we need to add the -v option in the end of the command.
Below is an example where we install ChefDK version 4.7.73.
If you need Active Directory Users and Computers on your Windows Server, you need to install Active Directory Administration Tools.
The walk through below will also install other AD Administration Tools like DNS configuration and optional if you want to install Group Policy Management.
Tutorial below have been tested in Windows Server 2016, Windows Server 2019 and Amazon Workspaces Windows 10.
I learned the steps below when I was configuring Amazon Workspaces Windows 10 to do Active Directory Administration. I was avoiding to RDP to the AD Domain Controller to lessen the impact when I make adjustments that is why I needed the Active Directory Management Tools inside my Amazon Workspace.
Note: It is best if your Windows Server is already joined to an Active Directory Domain.
Step-by-step Instruction to Install Active Directory Administration Tools
Grafana is an open source software to create visualization of time-series data. This can graph AWS CloudWatch Metrics too.
As a security best practice when using Grafana on an EC2 Instance it is recommended to use an IAM Role. Using a credentials file may expose access to your AWS Account if ever other people gain access to your Grafana Server.
Follow the step-by-step instructions below on how to attach an IAM Role to your Grafana EC2 Instance and set Grafana to access CloudWatch.
I have an existing key pair that was generated via AWS Console. Since I do not want to create another set of Key Pair for the other regions, I would like to use the same Key Pair. Is it possible to copy the Key Pair to another Region? How can I do this?
Dany
Hi Dany, the short answer to your question is yes, it is possible to copy your existing AWS generated Key Pair to another region and even copy this to another AWS account.
Generating the Key Pairs via AWS Console is easy, it gives you the Private Key and you can launch EC2 instances and associate it with your instance by adjusting the settings during EC2 Instance Launch. Then you can SSH to your EC2 Instance via the Private Key.
The issue here is the Public Key. AWS does not provide the Public Key during creation or any time after that.
Do not worry, we can still get the Public Key. It is not easy as clicking on the console then selecting copy to other region, but it is still doable.
See the steps below.
Step-by-step guide on copying a Key Pair to another region.
For this tutorial, I have created an AWS Key Pair in N. Virginia Region (us-east-1) – radishlogic_key.
The goal is to copy the Key Pair to Oregon Region (us-west-2).
Here are screenshots of my Key Pair.
1. Retrieving the Private Key in N. Virginia Region (us-east-1)
Launch a temporary Linux EC2 Instance in where the Key Pair is located (us-east-1). Any Linux Image will do.
When I create Windows Instances in AWS EC2, I usually forget to add a drive or two. With this step-by-step tutorial, I will walk you through how to create a new Volume for EC2 Instances, then make Windows use the new Volume without a reboot.
Initial Setup
Creating and Attaching the Volume in AWS EC2 Console
Adding the new Volume to Windows System
Initial Setup
I launched a EC2 Windows 2016 Server with only 1 Block Device (/dev/sda1), which is also my Root Device.
Note the Availability Zone where your instance is located, you will need this later. Mine is in us-east-1a.
Looking inside Windows it only has 1 volume.
Creating and Attaching the Volume in AWS EC2 Console
Now we need to attach a new Volume for our Windows Server.
Go to AWS EC2 Console, on the left sidebar click on <strong>Volumes</strong>.
Problem: You are running a critical Windows Server on AWS EC2 and the C: drive is almost full (storage volume) but it should zero downtime (No Restart, No Stop then Start). Is this possible on AWS EC2?