Posts

Showing posts from January, 2023

Python code for launch EC2 instance in AWS

 Here is an example of how you can launch an EC2 instance in AWS using the boto3 library in Python import boto3 # Create an EC2 client ec2 = boto3.client('ec2') # Specify the ID of the AMI for the instance ami_id = 'ami-0c94855ba95c71c99' # Specify the instance type instance_type = 't2.micro' # Launch the instance response = ec2.run_instances(ImageId=ami_id,                              InstanceType=instance_type,                              MinCount=1,                              MaxCount=1) # Print the instance ID print(response['Instances'][0]['InstanceId']) library and create an EC2 client. Then, we specify the ID of the Amazon Machine Image (AMI) that we want to use for the instance, as well as the instance type (in this case, a t2.micro instance). Final...