Uploading File To AWS S3 Using AWS CLI

Introduction 

 
Today, in this article, we are going to learn how to upload a file(s) or project on Amazon S3 using AWS CLI. To start with, first, we need to have an AWS account.
 
What is Amazon S3?
 
Here is the short description of Amazon S3.
 
Amazon S3 stands for Amazon Simple Storage Service. It helps the developer community to make computing scalable and more simple. Amazon S3 provides a platform where developers can store and download the data from anywhere and at any time on the web. Amazon S3 is a very fast and reliable storage infrastructure.
 
You can create a free AWS account or log into your account from here. Once you are logged into your AWS account, the next step is to create security credentials for your account which include an access key.
 
To get your credentials, follow the below steps.
  1. Click Account name > My Security Credentials.
     
    Uploading File To AWS S3 Using AWS CLI
  2. Select "Users" from the left panel.
     
    Uploading File To AWS S3 Using AWS CLI
  3. Click on the username.
     
    Uploading File To AWS S3 Using AWS CLI
     
  4. Now, from the below screen, you can set permissions and create your credentials by clicking on the "Create access key" button.
     
    Uploading File To AWS S3 Using AWS CLI
     
  5. Copy your credentials or download the crendetials.csv to use later.
     
    Uploading File To AWS S3 Using AWS CLI
     
  6. Download and install AWS CLI. You can install AWS CLI for any major operating system,
     
    1. macOS
    2. Linux
    3. Windows
       
      Here, we are using Windows OS so you can download the installer for Windows from here.
       
  7. Once you successfully install the AWS CLI, open command prompt and execute the below commands.
     
    1. First, execute “aws configure“ to configure your account (This is a one-time process) and press the Enter key.
    2. Now, it must be asking for AWS access key ID, secrete key, region name, and output format. Enter all the inputs and press Enter.
       
      Uploading File To AWS S3 Using AWS CLI
       
      Your AWS account is configured with your workstation.
       
  8. Now, it is time to create an S3 bucket.
     
    1. To create a bucket, execute this command:
       
      aws s3 mb s3://{YOUR-BUCKET-NAME}
       
    2. See the example here - (aws s3 mb s3://my-first-csharp-bucket)
       
      Uploading File To AWS S3 Using AWS CLI
       
      Check on the AWS S3 account if your bucket is created.
       
      Uploading File To AWS S3 Using AWS CLI
  9. Now, it's time to upload the files.
     
    To upload the files or projects, execute the below command in CMD.
     
    1. aws s3 sync "{YOUR-LOCAL-PATH}" s3://{YOUR-BUCKET-NAME}
       
      example:aws s3 sync "C:\Users\faisa\Documents\image" s3://my-first-csharp-bucket
       
      Uploading File To AWS S3 Using AWS CLI
       
  10. If the path and bucket name is valid, then your files/project is successfully uploaded.
     
    Uploading File To AWS S3 Using AWS CLI
Output
 
Uploading File To AWS S3 Using AWS CLI


Similar Articles