github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/docs/integrations/aws_cli.md (about) 1 --- 2 title: AWS CLI 3 description: This section shows how to use the AWS CLI for AWS S3 to access lakeFS. 4 parent: Integrations 5 redirect_from: /using/aws_cli.html 6 --- 7 8 # Using lakeFS with AWS CLI 9 {: .no_toc} 10 lakeFS exposes an S3-compatible API, so you can use the [AWS S3 CLI](https://docs.aws.amazon.com/cli/latest/reference/s3/) to interact with objects in your repositories. 11 {:.pb-5 } 12 13 ## Table of contents 14 {: .no_toc .text-delta } 15 16 1. TOC 17 {:toc .pb-5 } 18 19 ## Configuration 20 21 You would like to configure an AWS profile for lakeFS. 22 23 To configure the lakeFS credentials, run: 24 ```shell 25 aws configure --profile lakefs 26 ``` 27 You will be prompted to enter the _AWS Access Key ID_ and the _AWS Secret Access Key_. 28 29 It should look like this: 30 ```shell 31 aws configure --profile lakefs 32 # output: 33 # AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE 34 # AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY 35 # Default region name [None]: 36 # Default output format [None]: 37 ``` 38 39 40 ## Path convention 41 42 When accessing objects in S3, you will need to use the lakeFS path convention: 43 ```s3://[REPOSITORY]/[BRANCH]/PATH/TO/OBJECT``` 44 45 ## Usage 46 47 After configuring the credentials, this is what a command should look: 48 ```shell 49 aws s3 --profile lakefs \ 50 --endpoint-url https://lakefs.example.com \ 51 ls s3://example-repo/main/example-directory 52 ``` 53 54 You can use an [alias](aws_cli.html#adding-an-alias) to make it shorter and more convenient. 55 56 ## Examples 57 58 ### List directory 59 60 ```shell 61 aws --profile lakefs \ 62 --endpoint-url https://lakefs.example.com \ 63 s3 ls s3://example-repo/main/example-directory 64 ``` 65 66 ### Copy from lakeFS to lakeFS 67 68 ```shell 69 aws --profile lakefs \ 70 --endpoint-url https://lakefs.example.com \ 71 s3 cp s3://example-repo/main/example-file-1 s3://example-repo/main/example-file-2 72 ``` 73 74 ### Copy from lakeFS to a local path 75 76 ```shell 77 aws --profile lakefs \ 78 --endpoint-url https://lakefs.example.com \ 79 s3 cp s3://example-repo/main/example-file-1 /path/to/local/file 80 ``` 81 ### Copy from a local path to lakeFS 82 83 ```shell 84 aws --profile lakefs \ 85 --endpoint-url https://lakefs.example.com \ 86 s3 cp /path/to/local/file s3://example-repo/main/example-file-1 87 ``` 88 ### Delete file 89 90 ```shell 91 aws --profile lakefs \ 92 --endpoint-url https://lakefs.example.com \ 93 s3 rm s3://example-repo/main/example-directory/example-file 94 ``` 95 96 ### Delete directory 97 98 ```shell 99 aws --profile lakefs \ 100 --endpoint-url https://lakefs.example.com \ 101 s3 rm s3://example-repo/main/example-directory/ --recursive 102 ``` 103 104 ## Adding an alias 105 106 To make the command shorter and more convenient, you can create an alias: 107 108 ```shell 109 alias awslfs='aws --endpoint https://lakefs.example.com --profile lakefs' 110 ``` 111 112 Now, the ls command using the alias will be as follows: 113 ```shell 114 awslfs s3 ls s3://example-repo/main/example-directory 115 ```