EC2 (Elastic Compute Cloud)

 EC2 (Elastic Compute Cloud)

EC2 is a virtual machine that you can use to run your applications. Here is an example of how to create an EC2 instance using the AWS SDK for Python (boto3):

python


import boto3


ec2 = boto3.resource('ec2')


instance = ec2.create_instances(

    ImageId='ami-0c55b159cbfafe1f0',

    MinCount=1,

    MaxCount=1,

    InstanceType='t2.micro',

    KeyName='my-key-pair'

)

This code creates an EC2 instance with the Amazon Linux AMI, uses a t2.micro instance type, and specifies a key pair for SSH access.

No comments:

Post a Comment

The Importance of Cybersecurity in the Digital Age

 The Importance of Cybersecurity in the Digital Age Introduction: In today's digital age, where technology is deeply intertwined with ev...