Amazon Web Services (AWS) provides a robust platform for deploying and managing cloud infrastructure. In this blog, we’ll guide you through the steps to set up an EC2 instance, connect to it via SSH, assign an IAM role, and upload a file to an S3 bucket.
Step 1: Launching an EC2 Instance
1.Log in to AWS Management Console: Navigate to the EC2 service.
2.Choose Amazon Linux as the Amazon Machine Image (AMI): Select the free tier-eligible Amazon Linux AMI.
3.Select Instance Type: Choose t2.micro for free tier eligibility.
4.Create or Choose a Key Pair: Create a new key pair or select an existing one. Download the private key file (.pem).
5.Launch the Instance: Review your configuration and launch the instance.
Step 2: Configuring Security Groups
Edit Inbound Rules: Go to the instance's security group and add an inbound rule to allow SSH traffic (port 22) from your IP address.
Step 3: Setting Up puTTY
Download puTTY: Download and install puTTY along with puTTYgen from putty.org.
Convert .pem to .ppk: Use puTTYgen to convert your .pem file to a .ppk file.
Step 4: Connecting to the Instance
Open puTTY: Enter the public IP address of your EC2 instance in the "Host Name" field.
Upload Key: Navigate to the SSH > Auth section and upload your .ppk file.
Connect: Click "Open" and log in as ec2-user.
Step 5: Assigning an IAM Role to the Instance
1.Create an IAM Role:Navigate to the IAM service and create a role with Amazon S3 full access.
Attach the role to your EC2 instance.
2.Verify Role Assignment: Confirm that the instance has the appropriate permissions.
Step 6: Uploading a File to S3
Prepare a File: Create or copy a file in your EC2 instance.
Use AWS CLI: Use the following command to upload a file to your S3 bucket:
aws s3 cp <file-path> s3://<bucket-name>/
Step 7: Cleaning Up Resources
Terminate the Instance: Stop and terminate the EC2 instance to avoid unnecessary charges.
Delete the IAM Role: Remove the role from your instance and delete it if no longer needed.
Top comments (0)