amazon-ec2

AWS Python CDK – define the launch template for Batch Compute Environment

AWS Python CDK – define the launch template for Batch Compute Environment Question: In my Python CDK Stack, I’m trying to configure an AWS Batch Compute Environment to be able to use a Launch Template I’m creating in the same stack. Example: launch_template = ec2.CfnLaunchTemplate( scope=self, id=f"{stack_id}-EC2LaunchTemplate", launch_template_name=f"{stack_id}-EC2LaunchTemplate", launch_template_data=ec2.CfnLaunchTemplate.LaunchTemplateDataProperty( image_id="ami-xxxxxxxxxxx", instance_type="xxxxxxxxxx", ebs_optimized=True, user_data=Fn.base64(…) ) ) …

Total answers: 1

Create EC2 instance, start instance and run Linux command using Boto3

Create EC2 instance, start instance and run Linux command using Boto3 Question: I am trying to create an AWS EC2 instance, start it, execute a simple Linux command and print the output. However, I keep getting: botocore.errorfactory.InvalidInstanceId: An error occurred (InvalidInstanceId) when calling the SendCommand operation: Instances [[the_instance_id]] not in a valid state for account …

Total answers: 1

OSError: [Errno 24] Too many open files: '/home/ec2-user/car/1016780737.jpg'

OSError: [Errno 24] Too many open files: '/home/ec2-user/car/1016780737.jpg' Question: I am doing predictions on 100K images using following yolov8 code: model = YOLO(self.weightpath) src_dir = self.src_Dir src_dir = src_dir+ ‘*’ img_list = glob.glob(src_dir) results = model(img_list, max_det = 1) I am getting following error: Traceback (most recent call last): File "/home/ec2-user/Deployment/main/Quality_check.py", line 63, in <module> …

Total answers: 1

AccessDenied when calling Boto3 assume_role from EC2 even with service principal

AccessDenied when calling Boto3 assume_role from EC2 even with service principal Question: I’m running into an issue when trying to have a Python script running on an EC2 instance assume a role to perform S3 tasks. Here’s what I have done. Created a IAM role with AmazonS3FullAccess permissions and got the following ARN: arn:aws:iam::<account_number>:role/<role_name> The …

Total answers: 1

Clone private github repo to launched EC2 instance

Clone private github repo to launched EC2 instance Question: I’m building a scrip that launches and connects to an EC2 instance. After all setup of the instance I have to copy my private repo to it, and then run it. The code works fine for public repo. Also if I manually launch an instance, connect …

Total answers: 1

torch hub error for yolov5 in ubuntu aws ec2 instance

torch hub error for yolov5 in ubuntu aws ec2 instance Question: I install torch and open cv like this pip3 install torch torchvision torchaudio –extra-index-url https://download.pytorch.org/whl/cpu pip install opencv-python then I run this code in ubuntu aws ec2 instance import torch # Model model = torch.hub.load(‘ultralytics/yolov5’, ‘yolov5s’) # Image im = ‘car.jpg’ # Inference results …

Total answers: 1

AttributeError: 'dict' object has no attribute 'Instance' python

AttributeError: 'dict' object has no attribute 'Instance' python Question: i am trying to start the EC2 Instance with PrivateIP where i provide as argument "PrivateIP" and below code will describe the ec2 and get InstanceId. Once InstanceId received, it starts the EC2 instance def status_ec2_instance(instanceIds_list, region_Name): ec2 = boto3.resource(‘ec2’, region_name=region_Name) ec2_client = boto3.client(‘ec2’, region_name=region_Name) print(instanceIds_list) …

Total answers: 1

How do I access the webpage that my Python script makes?

How do I access the webpage that my Python script makes? Question: I am using MobaXterm to SSH into an EC2 instance. In the EC2 instance, I made a script that looks like the following: ` #!/usr/bin/env python3 import mysql.connector # Connect to the MariaDB database host = "localhost" username = "DBUser" password = "DBUserPassword" …

Total answers: 1

How to run Xvfb with xvfbwrapper on AWS EC2 to records screen of selenium headless session

How to run Xvfb with xvfbwrapper on AWS EC2 to records screen of selenium headless session Question: I have a problem running selenium sesion with Xvfb to record video file with sesion. Below is my session and wrapper from selenium import webdriver from xvfbwrapper import Xvfb class TestPages(unittest.TestCase): def setUp(self): self.xvfb = Xvfb(width=1280, height=720) self.addCleanup(self.xvfb.stop) …

Total answers: 1

Flask session object does not persist between requests despite hardcoded secret key

Flask session object does not persist between requests despite hardcoded secret key Question: I am currently running into an issue deploying a Flask app on Amazon’s EB2 service. The Flask app works locally. When it is deployed, however, it only works for the first person who clicks the link. After that it throws the following …

Total answers: 1