To get the AWS Region where your Lambda Function is running we need to access the Environment Variable AWS_REGION
.
To access the environment variable AWS_REGION
using Node.js Lambda Function we can use process.env.AWS_REGION
.
To get the AWS Region where your Lambda Function is running we need to access the Environment Variable AWS_REGION
.
To access the environment variable AWS_REGION
using Node.js Lambda Function we can use process.env.AWS_REGION
.
To get the AWS Account ID of the currently running Lambda Function using Node.js use the code below.
exports.handler = async (event, context) => {
const awsAccountId = context.invokedFunctionArn.split(':')[4]
console.log(awsAccountId)
};
Continue reading How to get the AWS Account ID in Lambda Node.js AWS Lambda Environment Variables are a useful way to input configuration values to your AWS Lambda runtime. Especially, when there are configurations that are different in your Development environment compared to your Production environment. Like name of DynamoDB tables or MySQL databases.
Below we discuss how we can retrieve the values of Environment Variables in AWS Lambda using Ruby.
The code for accessing Environment Variables on AWS Lambda is just the same code for accessing environment variables in your local computer or server.
Here is the code to access environment variables using Ruby.
env_var = ENV['ENVIRONMENT_VARIABLE']
If we want to get the value of an environment variable with the key of DB_HOST
then we will use the code below.
If you want to get the AWS Account ID of your Lambda Function while it is running then you can use the code below. The code below is written in Ruby.
Continue reading How to get AWS Account ID in Lambda using RubyIf you need to get the Region of your running Lambda Function then you should look for the AWS_REGION
in the Environment Variables.
Below is the code on how to access the AWS_REGION
Environment Variable using Ruby.
aws_region = ENV['AWS_REGION']
Continue reading How to get the Region of a Running AWS Lambda Function using Ruby To get the remaining time of a running AWS Lambda Function using Python you should check the context
object and its get_remaining_time_in_millis
function.
To get the remaining time of a running Lambda Function using Node.js, we will use the context
object’s getRemainingTimeInMillis()
function. This returns the number of milliseconds that the Lambda Function can still run before it times out.
Below is a simple code that fetches the remaining time inside a Lambda Function. I have set the timeout to be only 3 seconds, that is why the output is 2,999 milliseconds or approximately 3 seconds.
Continue reading How to get the remaining time of a running AWS Lambda Function using Node.jsBelow are commands that you can use to connect and check the status of your WiFi connection using nmcli.
I usually use this when connecting my Rock Pi running Ubuntu to the WiFi Network. But commands below will also work as long as you have the nmcli in your Linux System.
Turn On WiFi
# Turn on WiFi
nmcli r wifi on
Scan WiFi Networks
# Scan WiFi Networks
nmcli dev wifi
Continue reading How to connect to WiFi using nmcli I have been using Terraform for a while to launch my infrastructure in AWS, Google Cloud, and Azure and I am loving it since I do not need to learn different sets of languages or syntax for different Cloud Providers.
My only challenge when it comes to Terraform is that the installation instruction in the terraform site is not as detailed as I want it to be.
So here’s a tutorial on how to install Terraform in Windows 11 and make it work in Command Prompt, Powershell, and Git Bash with instructions and screenshots you can follow.
Note: You can also follow these steps for Windows 10.
terraform
CommandGo to terraform.io/downloads.html, then scroll down and look for the Windows section. Click on 64-bit.
This will start the download of the zip file that contains the terraform.exe
binary.
I have experienced that when I did the normal steps in installing terraform, the Command Prompt, PowerShell, and Git Bash still did not recognize the terraform
command in Windows 11. Even when I already added the terraform.exe location in the Path Environment Variable.
It is just annoying when this happens, luckily I was able to resolve this issue.
Note: The instructions are for Windows 11, but these steps will also work in Windows 10.
Continue reading Fix Terraform not running even when added to Path Environment Variable in Windows 11