1. Trang chủ
  2. » Luận Văn - Báo Cáo

Final term report topic manage ec2 by python api

27 0 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 27
Dung lượng 2,7 MB

Nội dung

Amazon EC2 ElasticCompute Cloud is one of the most popular cloud infrastructure services today,allowing users to rent virtual machines with flexible computing resources.. Variety of Inst

Trang 1

VIETNAM-KOREA UNIVERSITY OF INFORMATION AND

COMMUNICATION TECHNOLOGY

Computer Science Department

FINAL TERM REPORT

Topic:

Manage EC2 by Python API

Implementing student: Hồ Nguyên Bảng -21IT004

Academic advisor: Prof Đặng Quang Hiển

Trang 2

ADVISOR’S COMMENT

Trang 3

We would like to extend our heartfelt thanks to Professor Đặng Quang Hiểnfor his dedication in teaching the Cloud Computing course at the Vietnam-KoreaUniversity of Information and Communication Technology We deeply appreciate hisextensive knowledge sharing and the opportunity he provided us to participate in ahigh-quality online learning platform During this course, we have understood thevalue of grasping knowledge about cloud computing technology and storage Despitesome limitations, we hope to receive his feedback and support to further develop ourproject and continue our learning journey We sincerely thank Professor Phụng for hissupport throughout the duration of this course We wish him abundant energy andenthusiasm in his teaching career, bringing many interesting and useful lectures tostudents in the future

Trang 4

TABLE OF CONTENTS

CHAPTER 1: INTRODUCTION TO THE TOPIC

1 Introduction to the topic

2 Research objectives and scopes

2.1 Research objective

2.2 Research scope

CHAPTER 2: THEORETICAL BASIS

1 Amazon Elastic Compute Cloud (EC2)

1.1 Definition

1.2 Key characteristics

1.2.1 Scalability

1.2.2 Variety of Instance Types

1.2.3 Flexible Pricing Options

1.2.4 Security and Compliance

1.2.5 Storage Options

1.2.6 Networking

1.2.7 Monitoring and Management

1.3 Components

1.3.1 Instances

1.3.2 AWS Identity and Access Management (IAM)

1.3.3 Elastic Block Store (EBS)

1.3.4 Security Groups

1.3.5 Elastic IP Address

1.3.6 Auto Scaling

1.3.7 Load Balancing

1.4 Benefit of EC2

2 Boto3

2.1 Definition

2.2 Using instruction

2.2.1 Install

2.2.2 Configuration

2.2.3 Using Boto3

2.3 Benefits of Boto3

CHAPTER 3: DEMO

1.1 Initiating EC2 on AWS:

1.2 Creating EC2 via VSCode

1.3 Successful Creation

2 Starting EC2:

3 Shutdown EC2:

3.1 Turn Off (Stop EC2 from Outside):

3.2 Shutdown (Stopping EC2 from Inside):

4 EC2 Security:

4.1 Delete Unused Security Groups

4.2 Display Security Groups

4.3 List EC2 Security Groups:

Trang 5

4.4 Delete Security Page

5 Creating Elastic IP:

6 Assigning Elastic IP to EC2:

6.1 Assign Elastic IP to EC2 Instance

6.2 Confirm Successful IP Assignment on AWS

6.3 Release Static Elastic IP (When No Longer Needed)

6.4 Confirm Successful IP Deletion on AWS

6.5 Display Successful IP Assignment on AWS

CONCLUSION

Trang 6

FIGURE LIST

Picture 1 Instances created on AWS

Picture 2 Creating EC2 via VSCode 10

Picture 3 Successful 10

Picture 4 Linux command 10

Picture 5 Instance After Turn On 11

Picture 6 Successful Startup of EC2 Instances 11

Picture 7 Stopped EC2 Instances IDs after the turn-off command 12

Picture 8 Commands to shutdown EC2 instances 12

Picture 9 Deleting a Security Group on EC2 13

Picture 10 Successful Security Group Deletion Command 13

Picture 11 Security Groups List on Command Line 14

Picture 12 Security Groups List on AWS 14

Picture 13 Listing EC2 Security Groups 15

Picture 14 Successful Security Group Deletion 15

Picture 15 Update Security Page After Deletion 15

Picture 16 Set up Elastic Ips 16

Picture 17 Click on Allocate button 16

Picture 18 Finish set up 16

Picture 19 Read the list of Elastic IP's 17

Picture 20 Terminal displaying the list of Elastic IPs 17

Picture 21 List reading Elastic IPs code 18

Picture 22 Terminal show Elastic IPs list 18

Picture 23 Static Elastic IP Deleting code 19

Picture 24 Successful Security Group deletion 19

Picture 25 Update Security Page After Deletion 20

Trang 7

CHAPTER 1: INTRODUCTION TO THE TOPIC

1 Introduction to the topic

In the context of modern technology, managing and operating IT infrastructure isincreasingly complex and requires high precision and efficiency Amazon EC2 (ElasticCompute Cloud) is one of the most popular cloud infrastructure services today,allowing users to rent virtual machines with flexible computing resources With thesupport of Boto3, AWS's Python library, automating EC2 management becomes easierthan ever The topic "Managing EC2 using Python API" will focus on researching andimplementing automated solutions for managing EC2 services, optimizing workflows,and saving resources

2 Research objectives and scopes

 Enhance Performance and Cost Efficiency: To find ways to optimize the use ofEC2 resources to improve system performance and reduce costs

 Develop Monitoring and Maintenance Tools: To deploy tools that monitor thestatus and performance of EC2 instances, ensuring stable and efficient systemoperations

 Practical Application: To evaluate and apply solutions in the practical management

of IT infrastructure for businesses, improving workflows and optimizing resources

 Performance and Cost Evaluation: Researching methods to optimize performanceand cost when using EC2

 Practical Application: Evaluating practical application scenarios in enterpriseenvironments to verify the effectiveness of proposed solutions

1

Trang 8

CHAPTER 2: THEORETICAL BASIS

1 Amazon Elastic Compute Cloud (EC2)

1.1 Definition

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that providessecure, resizable compute capacity in the cloud It is designed to make web-scalecloud computing easier for developers Amazon EC2's simple web service interfaceallows you to obtain and configure capacity with minimal friction It provides youwith complete control of your computing resources and lets you run on Amazon'sproven computing environment

1.2 Key characteristics

1.2.1 Scalability

 Elastic: You can quickly scale up or scale down instance capacity according to

your requirements This elasticity helps in handling varying workloads with efficiency

 Auto Scaling: EC2 integrates with Auto Scaling to automatically adjust the

number of instances to maintain performance and minimize costs

1.2.2 Variety of Instance Types

 General Purpose: Provides a balance of compute, memory, and networking

resources

 Compute Optimized: Ideal for compute-bound applications that benefit from high-performance processors

 Memory Optimized: Designed for memory-intensive tasks

 Storage Optimized: High, sequential read and write access to large datasets

 Accelerated Computing: GPU-based instances for graphics-intensive

applications

1.2.3 Flexible Pricing Options

 On-Demand Instances: Pay for compute capacity by the hour or second with

no long-term commitments.

2

Trang 9

 Reserved Instances: Provide a significant discount compared to On-Demand pricing when you commit to a term of 1 or 3 years.

 Spot Instances: Allow you to bid for unused EC2 capacity at potentially 1.2.4 Security and Compliance

 Security Groups: Acts as a virtual firewall to control inbound and outbound

traffic

 Key Pairs: Used to securely log into your instances.

 Compliance Certifications: Meets various industry certifications such as ISO,

PCI DSS, and HIPAA

 Virtual Private Cloud (VPC): Enables you to launch AWS resources in a

logically isolated virtual network

 Elastic IP Addresses: Static IP addresses for dynamic cloud computing.

 Placement Groups: Logical groupings of instances within a single availability

zone to reduce network latency

1.2.7 Monitoring and Management

 Amazon CloudWatch: Provides monitoring for AWS cloud resources and

Key characteristics of Instances:

 Virtual Machines: Instances are virtual machines running on physical

servers managed by AWS, configurable to run various operatingsystems and applications

 Scalability: Instances can be scaled up or down based on requirements,

supporting varying workloads efficiently

 Variety of Instance Types: Multiple types of instances are available,

each optimized for different tasks (general-purpose, optimized, memory-optimized, etc.)

compute- Flexible Pricing Options: Different pricing models (On-Demand,

Reserved, and Spot Instances) allow cost management based on usagepatterns

 Security: Instances are protected by security groups, virtual firewalls

controlling inbound and outbound traffic

1.3.2 AWS Identity and Access Management (IAM)

AWS Identity and Access Management (IAM) is a service that helps yousecurely control access to AWS resources It allows you to create and manage

3

Trang 10

AWS users and groups, and use permissions to allow and deny their access toAWS resources.

Key features:

 Users and Groups: Create individual user accounts and organize them

into groups

 Permissions: Define permissions using policies to control which

resources users and groups can access

 Roles: Create roles and assign them to AWS resources for

cross-account access or application permissions

 Security: Use multi-factor authentication (MFA) and manage access

keys for added security

1.3.3 Elastic Block Store (EBS)

Amazon Elastic Block Store (EBS) is a block storage service designed

to be used with Amazon EC2 instances It provides durable, high-performancestorage that can be used for a wide range of workloads, including databases,file systems, and applications that require fine-grained updates and access tostored data

Key features:

 Persistent Storage: EBS volumes are persistent, meaning the data

remains intact even after the instance to which it is attached is stopped

or terminated

 High Performance: EBS offers multiple volume types optimized for

different performance needs, including SSD-backed volumes for highI/O performance and HDD-backed volumes for throughput-intensiveapplications

 Scalability: EBS volumes can be dynamically scaled in size and

performance without downtime

 Backup and Restore: EBS provides snapshot capabilities to back up

volumes to Amazon S3, offering a convenient way to protect data

 Encryption: EBS supports encryption at rest and in transit, ensuring

data security and compliance with various regulatory requirements

 High Availability: EBS volumes are designed for 99.999% availability

and are replicated within their availability zone to protect againsthardware failures

1.3.4 Security Groups

Security Groups in Amazon Web Services (AWS) are virtual firewallsfor your EC2 instances, controlling inbound and outbound traffic to and frominstances They provide a way to manage access at the instance level, ensuringyour applications and data are secure

Key features:

 Inbound Rules: Control traffic allowed to enter your instances You

specify protocols (e.g., TCP, UDP), port ranges, and source IP ranges

or security groups

 Outbound Rules: Control traffic allowed to leave your instances.

Similar to inbound rules, you specify protocols, port ranges, anddestination IP ranges or security groups

 Stateful: Security groups are stateful, meaning if you allow an inbound

connection, the return traffic is automatically allowed, and vice versa

4

Trang 11

 Flexible Configuration: You can add, modify, or remove rules at any

time without needing to stop or restart the instances Changes takeeffect immediately

 Isolation: Each instance can belong to multiple security groups, and

each security group can be associated with multiple instances,providing flexible and isolated access control

 Default Deny Policy: By default, all inbound traffic is denied unless

explicitly allowed by a rule Outbound traffic is allowed by default, butcan be restricted by adding specific rules

1.3.5 Elastic IP Address

An Elastic IP Address in Amazon Web Services (AWS) is a static,public IPv4 address designed for dynamic cloud computing It is associatedwith your AWS account, not a specific instance, allowing you to mask thefailure of an instance or software by rapidly remapping the address to anotherinstance in your account

Key features:

 Static IP Address: Elastic IP addresses are static, meaning they do not

change unless you decide to release them This is in contrast to thedynamic public IP addresses automatically assigned by AWS, whichcan change when you stop and start your instances

 Account-Level Allocation: Elastic IP addresses are allocated to your

AWS account, allowing you to reassign them to any instance withinyour account

 High Availability: If an instance fails, you can quickly remap the

Elastic IP address to a standby instance, ensuring minimal downtimeand continuity of your application

 Configuration Flexibility: You can associate and disassociate Elastic

IP addresses with instances as needed, providing flexibility inmanaging your network and application deployments

 Cost Considerations: While associating an Elastic IP address with a

running instance is free, AWS charges for Elastic IP addresses that areallocated but not associated with any running instance, encouragingefficient use of IP addresses

1.3.6 Auto Scaling

Auto Scaling is an Amazon Web Services (AWS) feature thatautomatically adjusts the number of Amazon EC2 instances in response to thechanging demand for your applications This helps maintain the availability ofyour applications while ensuring that you only pay for the resources youactually need

Key features:

 Dynamic Scaling: Automatically scales out (adds instances) or scales

in (removes instances) based on predefined conditions, such as CPUutilization or network traffic

 Scheduled Scaling: Allows you to scale your EC2 capacity based on a

schedule For example, you can increase capacity during peak hoursand reduce it during off-peak hours

 Predictive Scaling: Uses machine learning models to predict future

traffic patterns and adjust the number of instances proactively

5

Trang 12

 Health Checks and Replacement: Continuously monitors the health

of instances and replaces any that are deemed unhealthy to ensure theoptimal performance of your applications

 Cost Efficiency: By scaling resources in and out based on demand,

Auto Scaling helps optimize costs by ensuring you use only thenecessary resources

 Integration with Other AWS Services: Works seamlessly with other

AWS services like Elastic Load Balancing (ELB) and AmazonCloudWatch to manage application traffic and monitor performancemetrics

1.3.7 Load Balancing

Load Balancing in Amazon Web Services (AWS) is a service thatdistributes incoming application or network traffic across multiple targets,such as EC2 instances, containers, and IP addresses, in different AvailabilityZones This helps ensure high availability and reliability of your applications

by spreading the load

Key features:

 Traffic Distribution: Distributes incoming traffic evenly across

multiple targets to ensure no single instance is overwhelmed,improving the overall performance and reliability of applications

 High Availability: Enhances the availability of applications by

automatically routing traffic to healthy instances and rerouting it awayfrom unhealthy ones

 Scalability: Automatically scales load balancers and targets up or

down based on the incoming traffic load, accommodating varyingtraffic patterns efficiently

 Health Monitoring: Continuously monitors the health of targets using

configurable health checks and only routes traffic to healthy instances

 Types of Load Balancers:

oApplication Load Balancer (ALB): Ideal for HTTP and HTTPS

traffic, providing advanced routing features targeted atmicroservices and container-based applications

oNetwork Load Balancer (NLB): Designed for ultra-high

performance and static IP addresses, suitable for TCP, UDP, andTLS traffic

oClassic Load Balancer (CLB): Provides basic load balancing

across multiple EC2 instances and operates at both the request andconnection levels

 Security:

oIntegrates with AWS Certificate Manager (ACM) to simplify themanagement of SSL/TLS certificates and ensure securecommunication

oSupports user authentication and authorization through AWSCognito and custom authentication mechanisms

 Integration with Other AWS Services: Works seamlessly with Auto

Scaling, Amazon CloudWatch, and AWS Global Accelerator toenhance application performance, monitoring, and global trafficmanagement

6

Trang 13

1.4 Benefit of EC2

 Flexible Scalability: Meets changing application demands by adding or

removing compute resources flexibly

 Cost-Effective: Pay based on actual usage, optimizing costs.

 High Reliability: Deployed on AWS's global infrastructure, ensuring

high availability and reliability

 Strong Security: Security groups and AWS security features help

protect user data and applications

 Service Integration: Seamless integration with other AWS services like

S3, RDS, DynamoDB, helping build comprehensive cloud solutions

2 Boto3

2.1 Definition

Boto3 is the Amazon Web Services (AWS) Software Development Kit (SDK)for Python It allows Python developers to write software that interacts with AWSservices, such as Amazon S3, Amazon EC2, Amazon DynamoDB, and more.Boto3 provides an easy-to-use, object-oriented API, as well as low-level access toAWS services

Key features:

 Easy Integration: Simplifies the process of interacting with AWS

services using Python code

 Object-Oriented Interface: Provides resource abstractions and service

clients, making it intuitive for developers to work with AWS resources

 Session Management: Supports sessions, allowing you to manage

multiple sets of credentials and configurations

 Support for All AWS Services: Comprehensive coverage of AWS

services, enabling a wide range of operations

 Flexibility: Allows for both high-level resource abstractions and

detailed, low-level service interactions

Ngày đăng: 20/12/2024, 16:24