# Use the AWS CLI

Set up an AWS CLI profile for the S3 endpoint and copy, list and sync objects.

Replace _EWS1EXAMPLEEXAMPLE00_ and _&lt;secret&gt;_ with your access key, _example-uploads_ with
your bucket's name and `https://s3.<domain>` with the endpoint (a bucket's **Address** without the
bucket name in front).

## Prerequisites

- An access key (see [Create an access key](create-an-access-key.md)) whose IAM user may do what
  you run, for example `s3:ListObjects`, `s3:GetObject` and `s3:PutObject` on the bucket.
- The AWS CLI, in a version that reads `endpoint_url` from a profile.

## Set up a profile

These are the lines the bucket's **Overview** shows under **Connect** › **AWS CLI**:

```sh
aws configure set aws_access_key_id EWS1EXAMPLEEXAMPLE00 --profile dcloud
aws configure set aws_secret_access_key <secret> --profile dcloud
aws configure set region de1 --profile dcloud
aws configure set endpoint_url https://s3.<domain> --profile dcloud
aws configure set s3.addressing_style virtual --profile dcloud
```

Use the bucket's region: `de1` for a bucket in `de1a` or `de1b`. A signature made for any region
name is accepted.

## Copy, list and sync

```sh
aws --profile dcloud s3 cp ./report.pdf s3://example-uploads/report.pdf
aws --profile dcloud s3 ls s3://example-uploads/
aws --profile dcloud s3 sync ./site s3://example-uploads/site
```

Large files are uploaded in parts automatically. Uploads signed per chunk or with a trailing
checksum, the AWS CLI's defaults, are accepted.

## Result

The commands read and write the bucket as the key's IAM user. A key limited to one bucket cannot
list your buckets: `aws s3 ls` without a bucket answers `AccessDenied`, so name the bucket in every
command.

Buckets are not created or deleted over S3: `aws s3 mb` answers `NotImplemented` for a new name
(`BucketAlreadyOwnedByYou` for one of yours), and `aws s3 rb` answers `NotImplemented`. Create and
delete buckets in the console, with `dcloud s3 buckets`, or the API.

## Related

- [S3 compatibility](s3-compatibility.md)
- [Share an object with a presigned URL](share-an-object.md)
- [Troubleshooting](troubleshooting.md)
