There are use cases where the need to get the AWS Account ID of the Lambda Function during runtime is required. I thought it was easy as getting the AWS Region but it was not. Luckily there is a way to get it, use the step-by-step instructions below.
To get the AWS Account ID where the Lambda Function is running use the code below.
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.
Nowadays, websites can know which version of Windows you are running and would only give you one link to download the installer. Sometimes, it is not that easy like how I installed Visual Studio Code for all Users in Windows which gave me lots of options, Windows, Linux, Mac, 32-bit or 64-bit versions.
It is important to download the correct version of the installer or else it might not work correctly with your system.
To see what architecture your Windows Operating System is running, see the different ways below.
3 ways to check if your Windows Architecture is 64-bit or 32-bit
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?
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.
If you are studying Kubernetes and having a hard time running Minikube on an EC2 Instance, you are not alone. I had a hard time doing it when it was my first time.
Below are the steps (and some comments) that I took to help me run Minikube on my EC2 Instance.
Installation of Minikube on EC2 Ubuntu
1. Run a public EC2 Server with the following setup
Ubuntu Server 18.04 LTS (HVM), SSD Volume Type
t3.micro (2 vCPU, 1GB Memory)
8 GB (gp2)
– Key: Name
– Value: Minikube
Name: Minikube Security Group
– SSH, 0.0.0.0/0 Later we will be editing this.
Create your own keypair. You will need this to SSH to your EC2 Instance
Update: I changed the Instance Type from t2.micro (1 vCPU) to t3.micro (2 vCPU). An update to Minikube required a minimum of 2 vCPUs. The error when running with t2.micro was Requested cpu count 1 is less than the minimum allowed of 2.
t3.micro is no longer in the Free Tier, make sure to stop or terminate the instance after you are done testing to avoid a huge AWS bill.
Thank you to everyone in the comments section who pointed this change.
2. SSH into your created EC2 Instance using your keypair.
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 like if the date is before or after a certain date.
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 <strong><span style="color:#e53b51" class="tadv-color">2019-09-18T07:34:34.000Z</span></strong>. To convert this we need to use the strptime function from the datetime.datetime library.