Posts

Showing posts from September, 2024

Does Target Group Updates Instances Dynamically?

Image
  We all know what is a target group, it is a pool of EC2 instances. It sits between the load balancer and ASG. When you add EC2 instances to the target group manually which is registering and deregistering EC2 instance. But in real time, we don't register/deregister manually. For this we need to create an EMPTY TARGET GROUP and attach the load balancer and refer that load balancer to the ASG. I created an empty target group. Attached this a load balancer and associated the load balancer to the ASG. Now we have an EC2 instance created and it gets registered automatically with the target group. Let’s terminate the instance and ASG will replace the instance. This should also update the target group dynamically. Now, we can see a new instance created in ASG. i-06f8b560ea0a3bbaa  Instance ID should be updated in target group. We can see the new instance updated dynamically. 

AWS - SQS Demo Python

Image
  Short demo on how to use Python to create a AWS SQS producer and consumer . All we need is a SQS queue and keep the SQS URL ready. I am using boto3 library to call SQS. # SQS producer code # Code generates random greeting message # We will feed random generates messages to SQS # Message will generated for every 10sec import random; import boto3; import time; from Sitecheck import response # Initialize boto3 SQS client sqs = boto3.client( 'sqs' ); # URL for the SQS queue = 'https://sqs.us-east-1.amazonaws.com/851725408580/demo-sqs'; # Producer Code def generate_welcome_message (): greetings = [ "Hello" , "Hi" , "Welcome" , "Howdy" , "Greetings" ] compliments = [ "nice to see you" , "great to have you here" , "welcome aboard" ] greeting = random.choice( greetings ) compliment = random.choice( compliments ) message_to_send = ( greeting + " " + compliment ); d...