You can use the Boto3 Python library to interact with AWS services. Below is an example code snippet to create an EC2 instance:
import boto3
ec2 = boto3.resource('ec2')
instance = ec2.create_instances(
ImageId='ami-12345678', # replace with your AMI ID
MinCount=1,
MaxCount=1,
InstanceType='t2.micro'
)
print(instance[0].id)