I am software industry veteran with 18 years of experience working as an Architect. Worked with high profile client like Apple Inc (California) and Hewlett Packard. Worked in the USA for 8+ years.
Hello Sir I have followed the video exactly but when I try switch user to root. It gives authentication failure as I am passing the password as "postgres". How can I resolve it please help?
I guess by terminate you mean delete, right ? No please dont delete the default vpc, as the name says. - it is "default" and it is required for creating your EC2 instances. In case you have deleted the default vpc, then go to the "Your VPCs" section on left side, then "Actions" -> "Create default VPC"
I need your one more help can you please help me out: Q. How can I getcustomised email notifications when someone creates an EC2 instance that’s not nano, micro, small or medium? can you please help me out...
Please refer to this video - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-XGkm2BwNpyI.html For your requireement, the flow will be - EC2 Service -> listen to EC2 create instance events in Eventbridge --> Trigger lambda --> Send email to an group or whoever you want.
No you cannot do it without a compute instance. you need a way to run some code which will trigger the shutdown command to the correct set of instances and thats where lambda's come in. They are on demand and you only pay for the time it is running, so it actually very cost effective.
yeah, you can do it without using a lambda... no compute, just use event bridge for EC2 stop (not lambda), obviously you need IAM Role for your Scheduler (trusted policy for scheduler and IAM policy for actions on ec2) .... and you have a EC2 scheduler without lambda now guy :)
Hi Gaurav, As you mentioned, In Amazon SNS (Simple Notification Service/SES), the confirmation process for email subscriptions typically occurs only in sandbox and not in production environments. So if i deploy my code in producation environement there is no need of email subscription, as we can directly send an email to particular email?. 2. How can i bypass email subscription process while i am implementing in my local?
If you know the list of ec2 instance id's then you can run the following aws command - aws ec2 start-instances --instance-ids i-INSTANCE_ID1 i-INSTANCE_ID2 i-INSTANCE_ID3
@@AWSTrainingByGauravAgrawal Sure I can use that, however, I would like a script like you mentioned Python script, for example, to shut down the instance and I would use multiple instance IDs to auto-start the instance. Is it possible to get a complete Python script to auto-start the instance? it will be very helpful for me
@@that_epics use the below python lambda code import boto3 def lambda_handler(event, context): # Create a Boto3 EC2 client ec2 = boto3.client('ec2') # Describe all instances in your account instances = ec2.describe_instances() # Extract instance IDs from the response instance_ids = [] for reservation in instances['Reservations']: for instance in reservation['Instances']: instance_ids.append(instance['InstanceId']) # Start all instances if instance_ids: ec2.start_instances(InstanceIds=instance_ids) return f'Starting instances: {instance_ids}' else: return 'No instances to start' # Note: Make sure that your Lambda function has the appropriate IAM permissions to describe and start EC2 instances.
@@AWSTrainingByGauravAgrawalSorry I am bothering you but where is the name of the tag like start=true and where I can mention only two or three examples of the ID is only.
Amazon S3 does not provide a built-in feature to automatically move an object back to its previous storage class. However you can manually edit the object and changed the storage class to the desired class. Also the lifecycle transitions happens from higher cost storage class to the lower cost storage class and not vice versa
No problem with that. The RDS service also stores data on the EFS volume. Volume is the only way to store data. All the other services like EFS, S3 also store their data on EB S volumes.@@crazy_gamers_0079
Thank you Gaurav, I liked this video, and subscribed your channel, am sure you will upload more informative video for AWS services. I have an query about EventBridge rule, you just created a t2. micro instance and that also got deleted by this rule, but t2.micro is free tier, so I'm little bit confused, I want delete instance those are above t2.large, can you please help for this?
Thanks Sahab. I have keep the lambda code simple to reduce the complexity. The lambda code as of now is deleting any instance that got created. We can modify this code to ignore certain instance types. Let me know if you are looking for a modified lambda. I can provide you the same.
@@sahabsinghlathwal5956 - this is the code that you can try (not tested, please test it out) import boto3 def lambda_handler(event, context): # Initialize the EC2 client for the N. Virginia region (us-east-1) ec2_client = boto3.client('ec2', region_name='us-east-1') # Get a list of all EC2 instances in the N. Virginia region instances = ec2_client.describe_instances() # Define a list of instance types that are eligible for the AWS Free Tier in us-east-1 free_tier_instance_types = ["t2.micro", "t3.micro", "t3.nano"] for reservation in instances['Reservations']: for instance in reservation['Instances']: # Check if the instance is in a running state if instance['State']['Name'] == 'running': instance_type = instance['InstanceType'] instance_id = instance['InstanceId'] # Check if the instance type is not in the free tier list if instance_type not in free_tier_instance_types: print(f"Terminating instance: {instance_id} (Instance Type: {instance_type})") ec2_client.terminate_instances(InstanceIds=[instance_id]) else: print(f"Skipping instance in Free Tier: {instance_id} (Instance Type: {instance_type})")
@@AWSTrainingByGauravAgrawal I tried to execute this code, but getting below error - { "errorMessage": "An error occurred (UnauthorizedOperation) when calling the DescribeInstances operation: You are not authorized to perform this operation.", "errorType": "ClientError", "requestId": "d3493d54-903d-4852-bd0c-fc1164cc1acc", "stackTrace": [ " File \"/var/task/lambda_function.py\", line 8, in lambda_handler instances = ec2_client.describe_instances() ", " File \"/var/lang/lib/python3.11/site-packages/botocore/client.py\", line 534, in _api_call return self._make_api_call(operation_name, kwargs) ", " File \"/var/lang/lib/python3.11/site-packages/botocore/client.py\", line 976, in _make_api_call raise error_class(parsed_response, operation_name) " ] } Function Logs START RequestId: d3493d54-903d-4852-bd0c-fc1164cc1acc Version: $LATEST [ERROR] ClientError: An error occurred (UnauthorizedOperation) when calling the DescribeInstances operation: You are not authorized to perform this operation. Traceback (most recent call last): File "/var/task/lambda_function.py", line 8, in lambda_handler instances = ec2_client.describe_instances() File "/var/lang/lib/python3.11/site-packages/botocore/client.py", line 534, in _api_call return self._make_api_call(operation_name, kwargs) File "/var/lang/lib/python3.11/site-packages/botocore/client.py", line 976, in _make_api_call raise error_class(parsed_response, operation_name)END RequestId: d3493d54-903d-4852-bd0c-fc1164cc1acc REPORT RequestId: d3493d54-903d-4852-bd0c-fc1164cc1acc Duration: 449.11 ms Billed Duration: 450 ms Memory Size: 128 MB Max Memory Used: 88 MB Request ID d3493d54-903d-4852-bd0c-fc1164cc1acc
Thank you for the detailed hands on video. I've been learning AWS recently and had trouble finding hands on guide on AWS EventBridge. This video have been really helpful to me