DEV Community

Rafil
Rafil

Posted on

Uploading objects into S3 bucket using EC2(PuTTY) + IAM + S3

1.Launch an Instance

  • Open EC2
  • Open "Launch Instances"
  • Select a server name
  • Select an AMI (Amazon Linux)
  • Select Instance type (t2.micro)
  • Create new Key pair

  • Then, select "Launch Instance"

    Instance created Successfully !

2. PuTTY Installation

Install PuTTY in the system, if not already installed...

3. Whitewash IP address

Check the public IP of your device in online website like "(https://whatismyip.com/)"

4. Change Security Group Rules

After getting your device 'IP' change the inbound rules of the security group by following the below mentioned steps:

  • Select the "Security" to change the security group

  • Then, select the 'security group' and change the 'inbound rules'
    *security-> security-group -> Edit inbound rules *

  • In the 'Edit inbound rules' sections, change the type: 'SSH' , Source: 'Custom' and then put the public IP of your device

  • Click on 'Save changes'

5. PuTTYgen Key Configuration

  • Open 'PuTTYgen'
  • Select 'Load'
  • Then select the created 'pem key' to convert it into a 'private key'
  • Click 'Save private key'
  • Then save it in the system...

6. IAM Role Creation

Open IAM
IAM -> Roles -> Create role


IAM role created successfully !

7. Modify IAM role for the instance

Select the instance
Actions -> Security -> modify IAM role -> Update IAM role

8. PuTTY configuration

  • Copy the created EC2 instance's public ip address
  • Open 'PuTTY' In the PuTTY configuration:
  • In the 'Host Name or ( IP address)' column paste the ip address of the EC2 instance
  • Then in the side bar, select '+' that's before 'SSH' and then select the '+' before 'Auth'.
  • After that, click on 'Credentials' and browse the private key from your device.
  • Then click 'Open'

Category- + SSH -> + Auth -> Credentials -> Browse private key -> Open

9. Linux CLI Operations

Now, Linux command line will be opened...
Login as 'ec2-user'

Then run the following commands:
aws
aws s3 ls

Then create a text file using 'echo' command
Example : echo "this is a text file" > details.txt
At last, run the following command to upload the text file into the s3 bucket
aws s3 cp file-name s3://bucket-name/

Now go to amazon S3 and click on bucket to check whether the object is uploaded or not.

10. Terminate the instance and delete the bucket

Top comments (0)