Skip to content

Instantly share code, notes, and snippets.

@supriya-premkumar
Last active February 21, 2025 08:34
Show Gist options
  • Select an option

  • Save supriya-premkumar/c233a34096adfdd8372b46d790b3136d to your computer and use it in GitHub Desktop.

Select an option

Save supriya-premkumar/c233a34096adfdd8372b46d790b3136d to your computer and use it in GitHub Desktop.

Revisions

  1. Supriya Premkumar revised this gist Mar 7, 2017. 1 changed file with 11 additions and 11 deletions.
    22 changes: 11 additions & 11 deletions Access S3 from AWS CLI.md
    Original file line number Diff line number Diff line change
    @@ -5,55 +5,55 @@
    https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454


    **Create S3 Bucket:**
    **1. Create S3 Bucket:**

    ```aws s3 mb s3://your-bucket-name```


    **_Delete S3 Bucket:_**
    **_2. Delete S3 Bucket:_**

    ```aws s3 rb s3://your-bucket-name```


    **Delete S3 bucket if it has content(Object/s) in S3 bucket:**
    **3. Delete S3 bucket if it has content(Object/s) in S3 bucket:**

    ```aws s3 rb s3://your-bucket-name —force```


    **List S3 bucket/s:**
    **4. List S3 bucket/s:**

    ```aws s3 ls```


    **Copy file from Local Machine to AWS S3:**
    **5. Copy file from Local Machine to AWS S3:**

    ```aws s3 cp test.txt s3://your-bucket-name```


    **Test if the copied file exists in the bucket:**
    **6. Test if the copied file exists in the bucket:**

    ```aws s3 ls s3://your-bucket-name```


    **To Sync all the folders/files from local machine to the s3 bucket:**
    **7. To Sync all the folders/files from local machine to the s3 bucket:**

    ```aws s3 sync . s3://your-bucket-name/create-new-folder```


    **To list all the keys in S3:**
    **8. To list all the keys in S3:**

    ```aws s3 ls s3://your-bucket-name —recursive```


    **Since there is not cat command to read the file, we can use the following command to read a file**
    **9. Since there is not cat command to read the file, we can use the following command to read a file**

    ```aws s3 cp s3://your-bucket-name/README - ```


    **To check the content size in the s3 bucket**
    **10. To check the content size in the s3 bucket**

    ```aws s3 ls s3://your-bucket-name/folder-name --recursive | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}' ```

    **To delete contents in the bucket**
    **11. To delete contents in the bucket**

    ```aws s3 rm s3://your-bucket-name --recursive ```
  2. Supriya Premkumar revised this gist Mar 7, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Access S3 from AWS CLI.md
    Original file line number Diff line number Diff line change
    @@ -54,4 +54,6 @@ https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454

    ```aws s3 ls s3://your-bucket-name/folder-name --recursive | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}' ```

    **To delete contents in the bucket**

    ```aws s3 rm s3://your-bucket-name --recursive ```
  3. Supriya Premkumar revised this gist Mar 7, 2017. 1 changed file with 24 additions and 2 deletions.
    26 changes: 24 additions & 2 deletions Access S3 from AWS CLI.md
    Original file line number Diff line number Diff line change
    @@ -1,35 +1,57 @@
    ##Access S3 from AWS CLI
    #Access S3 from AWS CLI

    #Pre-Requisite : Install AWS CLI and Configure AWS

    ##Pre-Requisite : Install AWS CLI and Configure AWS
    https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454


    **Create S3 Bucket:**

    ```aws s3 mb s3://your-bucket-name```


    **_Delete S3 Bucket:_**

    ```aws s3 rb s3://your-bucket-name```


    **Delete S3 bucket if it has content(Object/s) in S3 bucket:**

    ```aws s3 rb s3://your-bucket-name —force```


    **List S3 bucket/s:**

    ```aws s3 ls```


    **Copy file from Local Machine to AWS S3:**

    ```aws s3 cp test.txt s3://your-bucket-name```


    **Test if the copied file exists in the bucket:**

    ```aws s3 ls s3://your-bucket-name```


    **To Sync all the folders/files from local machine to the s3 bucket:**

    ```aws s3 sync . s3://your-bucket-name/create-new-folder```


    **To list all the keys in S3:**

    ```aws s3 ls s3://your-bucket-name —recursive```


    **Since there is not cat command to read the file, we can use the following command to read a file**

    ```aws s3 cp s3://your-bucket-name/README - ```


    **To check the content size in the s3 bucket**

    ```aws s3 ls s3://your-bucket-name/folder-name --recursive | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}' ```


  4. Supriya Premkumar revised this gist Mar 7, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Access S3 from AWS CLI.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #Access S3 from AWS CLI
    ##Access S3 from AWS CLI

    #Pre-Requisite : Install AWS CLI and Configure AWS
    https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454
  5. Supriya Premkumar renamed this gist Mar 7, 2017. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions Access S3 from AWS CLI → Access S3 from AWS CLI.md
    Original file line number Diff line number Diff line change
    @@ -4,32 +4,32 @@
    https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454

    **Create S3 Bucket:**
    aws s3 mb s3://your-bucket-name
    ```aws s3 mb s3://your-bucket-name```

    **_Delete S3 Bucket:_**
    aws s3 rb s3://your-bucket-name
    ```aws s3 rb s3://your-bucket-name```

    **Delete S3 bucket if it has content(Object/s) in S3 bucket:**
    aws s3 rb s3://your-bucket-name —force
    ```aws s3 rb s3://your-bucket-name —force```

    **List S3 bucket/s:**
    aws s3 ls
    ```aws s3 ls```

    **Copy file from Local Machine to AWS S3:**
    aws s3 cp test.txt s3://your-bucket-name
    ```aws s3 cp test.txt s3://your-bucket-name```

    **Test if the copied file exists in the bucket:**
    aws s3 ls s3://your-bucket-name
    ```aws s3 ls s3://your-bucket-name```

    **To Sync all the folders/files from local machine to the s3 bucket:**
    aws s3 sync . s3://your-bucket-name/create-new-folder
    ```aws s3 sync . s3://your-bucket-name/create-new-folder```

    **To list all the keys in S3:**
    aws s3 ls s3://your-bucket-name —recursive
    ```aws s3 ls s3://your-bucket-name —recursive```

    **Since there is not cat command to read the file, we can use the following command to read a file**
    aws s3 cp s3://your-bucket-name/README -
    ```aws s3 cp s3://your-bucket-name/README - ```

    **To check the content size in the s3 bucket**
    aws s3 ls s3://your-bucket-name/folder-name --recursive | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}'
    ```aws s3 ls s3://your-bucket-name/folder-name --recursive | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}' ```

  6. Supriya Premkumar revised this gist Mar 7, 2017. 1 changed file with 12 additions and 10 deletions.
    22 changes: 12 additions & 10 deletions Access S3 from AWS CLI
    Original file line number Diff line number Diff line change
    @@ -1,33 +1,35 @@
    #Access S3 from AWS CLI

    #Pre-Requisite : Install AWS CLI and Configure AWS
    ```https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454```
    https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454

    **Create S3 Bucket:**
    ```aws s3 mb s3://your-bucket-name```
    aws s3 mb s3://your-bucket-name

    **_Delete S3 Bucket:_**
    ```aws s3 rb s3://your-bucket-name```
    aws s3 rb s3://your-bucket-name

    **Delete S3 bucket if it has content(Object/s) in S3 bucket:**
    ```aws s3 rb s3://your-bucket-name —force```
    aws s3 rb s3://your-bucket-name —force

    **List S3 bucket/s:**
    ```aws s3 ls```
    aws s3 ls

    **Copy file from Local Machine to AWS S3:**
    ```aws s3 cp test.txt s3://your-bucket-name```
    aws s3 cp test.txt s3://your-bucket-name

    **Test if the copied file exists in the bucket:**
    ```aws s3 ls s3://your-bucket-name```
    aws s3 ls s3://your-bucket-name

    **To Sync all the folders/files from local machine to the s3 bucket:**
    ```aws s3 sync . s3://your-bucket-name/create-new-folder```
    aws s3 sync . s3://your-bucket-name/create-new-folder

    **To list all the keys in S3:**
    ```aws s3 ls s3://your-bucket-name —recursive```
    aws s3 ls s3://your-bucket-name —recursive

    **Since there is not cat command to read the file, we can use the following command to read a file**
    ```aws s3 cp s3://your-bucket-name/README - ```
    aws s3 cp s3://your-bucket-name/README -

    **To check the content size in the s3 bucket**
    aws s3 ls s3://your-bucket-name/folder-name --recursive | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}'

  7. Supriya Premkumar revised this gist Mar 7, 2017. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions Access S3 from AWS CLI
    Original file line number Diff line number Diff line change
    @@ -1,33 +1,33 @@
    #Access S3 from AWS CLI

    #Pre-Requisite : Install AWS CLI and Configure AWS
    ```
    https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454
    ```

    ```https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454```

    **Create S3 Bucket:**
    `aws s3 mb s3://your-bucket-name`
    ```aws s3 mb s3://your-bucket-name```

    **_Delete S3 Bucket:_**
    ```aws s3 rb s3://your-bucket-name```

    **Delete S3 bucket if it has content(Object/s) in S3 bucket:**
    ```aws s3 rb s3://test-bucket —force```
    ```aws s3 rb s3://your-bucket-name —force```

    **List S3 bucket/s:**
    ```aws s3 ls```

    **Copy file from Local Machine to AWS S3:**
    ```aws s3 cp test.txt s3://test-bucket```
    ```aws s3 cp test.txt s3://your-bucket-name```

    **Test if the copied file exists in the bucket:**
    ```aws s3 ls s3://test-bucket```
    ```aws s3 ls s3://your-bucket-name```

    **To Sync all the folders/files from local machine to the s3 bucket:**
    ```aws s3 sync . s3://test-bucket/create-new-folder```
    ```aws s3 sync . s3://your-bucket-name/create-new-folder```

    **To list all the keys in S3:**
    ```aws s3 ls s3://test-bucket —recursive```
    ```aws s3 ls s3://your-bucket-name —recursive```

    **Since there is not cat command to read the file, we can use the following command to read a file**
    ```aws s3 cp s3://your-bucket-name/README - ```


  8. Supriya Premkumar revised this gist Mar 7, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Access S3 from AWS CLI
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454
    ```


    __Create S3 Bucket:__
    **Create S3 Bucket:**
    `aws s3 mb s3://your-bucket-name`

    **_Delete S3 Bucket:_**
  9. Supriya Premkumar revised this gist Mar 6, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Access S3 from AWS CLI
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454
    __Create S3 Bucket:__
    `aws s3 mb s3://your-bucket-name`

    **Delete S3 Bucket:**
    **_Delete S3 Bucket:_**
    ```aws s3 rb s3://your-bucket-name```

    **Delete S3 bucket if it has content(Object/s) in S3 bucket:**
  10. Supriya Premkumar revised this gist Mar 6, 2017. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions Access S3 from AWS CLI
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,5 @@
    #Access S3 from AWS CLI

    #Install AWS CLI on MAC

    #Pre-Requisite : Install AWS CLI and Configure AWS
    ```
    https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454
  11. Supriya Premkumar revised this gist Mar 6, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Access S3 from AWS CLI
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    #Access S3 from AWS CLI

    #Install AWS CLI on MAC

    #Pre-Requisite : Install AWS CLI and Configure AWS
    ```
    https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454
  12. Supriya Premkumar revised this gist Mar 6, 2017. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions Access S3 from AWS CLI
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,9 @@
    # Access S3 from AWS CLI
    #Access S3 from AWS CLI

    ## Pre-Requisite : Install AWS CLI and Configure AWS
    ``` https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454 ```
    #Pre-Requisite : Install AWS CLI and Configure AWS
    ```
    https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454
    ```


    __Create S3 Bucket:__
  13. Supriya Premkumar revised this gist Mar 6, 2017. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions Access S3 from AWS CLI
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    #Access S3 from AWS CLI
    # Access S3 from AWS CLI

    ##Pre-Requisite : Install AWS CLI and Configure AWS
    ## Pre-Requisite : Install AWS CLI and Configure AWS
    ``` https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454 ```


    __Create S3 Bucket:__
    ```aws s3 mb s3://your-bucket-name```
    `aws s3 mb s3://your-bucket-name`

    **Delete S3 Bucket:**
    ```aws s3 rb s3://your-bucket-name```
  14. Supriya Premkumar revised this gist Mar 6, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Access S3 from AWS CLI
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Access S3 from AWS CLI
    #Access S3 from AWS CLI

    ## Pre-Requisite : Install AWS CLI and Configure AWS
    ##Pre-Requisite : Install AWS CLI and Configure AWS
    ``` https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454 ```


  15. Supriya Premkumar revised this gist Mar 6, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Access S3 from AWS CLI
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    ``` https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454 ```


    **Create S3 Bucket:**
    __Create S3 Bucket:__
    ```aws s3 mb s3://your-bucket-name```

    **Delete S3 Bucket:**
  16. Supriya Premkumar revised this gist Mar 6, 2017. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions Access S3 from AWS CLI
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,31 @@
    #Access S3 from AWS CLI
    # Access S3 from AWS CLI

    ##Pre-Requisite : Install AWS CLI and Configure AWS
    ## Pre-Requisite : Install AWS CLI and Configure AWS
    ``` https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454 ```


    Create S3 Bucket:
    **Create S3 Bucket:**
    ```aws s3 mb s3://your-bucket-name```

    Delete S3 Bucket:
    **Delete S3 Bucket:**
    ```aws s3 rb s3://your-bucket-name```

    Delete S3 bucket if it has content(Object/s) in S3 bucket:
    **Delete S3 bucket if it has content(Object/s) in S3 bucket:**
    ```aws s3 rb s3://test-bucket —force```

    List S3 bucket/s:
    **List S3 bucket/s:**
    ```aws s3 ls```

    Copy file from Local Machine to AWS S3:
    **Copy file from Local Machine to AWS S3:**
    ```aws s3 cp test.txt s3://test-bucket```

    Test if the copied file exists in the bucket:
    **Test if the copied file exists in the bucket:**
    ```aws s3 ls s3://test-bucket```

    To Sync all the folders/files from local machine to the s3 bucket:
    **To Sync all the folders/files from local machine to the s3 bucket:**
    ```aws s3 sync . s3://test-bucket/create-new-folder```

    To list all the keys in S3
    **To list all the keys in S3:**
    ```aws s3 ls s3://test-bucket —recursive```


  17. Supriya Premkumar created this gist Mar 6, 2017.
    31 changes: 31 additions & 0 deletions Access S3 from AWS CLI
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #Access S3 from AWS CLI

    ##Pre-Requisite : Install AWS CLI and Configure AWS
    ``` https://gist.github.com/supriya-premkumar/f51b4c61ac984c93934381dfa3d78454 ```


    Create S3 Bucket:
    ```aws s3 mb s3://your-bucket-name```

    Delete S3 Bucket:
    ```aws s3 rb s3://your-bucket-name```

    Delete S3 bucket if it has content(Object/s) in S3 bucket:
    ```aws s3 rb s3://test-bucket —force```

    List S3 bucket/s:
    ```aws s3 ls```

    Copy file from Local Machine to AWS S3:
    ```aws s3 cp test.txt s3://test-bucket```

    Test if the copied file exists in the bucket:
    ```aws s3 ls s3://test-bucket```

    To Sync all the folders/files from local machine to the s3 bucket:
    ```aws s3 sync . s3://test-bucket/create-new-folder```

    To list all the keys in S3
    ```aws s3 ls s3://test-bucket —recursive```