Next: s3 API, Previous: CLI CloudFront Command Reference, Up: CLI Command Reference [Index]
This section explains prominent concepts and notations in the set of high-level S3 commands provided.
https://docs.aws.amazon.com/cli/latest/reference/s3/index.html
Whenever using a command, at least one path argument must be specified. There are two types of path arguments: ‘LocalPath’ and ‘S3Uri’.
LocalPath
represents the path of a local file or directory. It can be written as an absolute path or relative path.
S3Uri
represents the location of a S3 object, prefix, or bucket. This must be written in the form:
s3://mybucket/mykey
Every command takes one or two positional path arguments.
Some commands perform operations only on single files and S3 objects. The following commands are single file/object operations if no --recursive flag is provided.
For this type of operation, the first path argument, the source, must exist and be a local file or S3 object. The second path argument, the destination, can be the name of a local file, local directory, S3 object, S3 prefix, or S3 bucket.
The destination is indicated as a local directory, S3 prefix, or S3 bucket if
it ends with a forward slash or back slash. The use of slash depends on the
path argument type. If the path argument is a ‘LocalPath’, the type of slash
is the separator used by the operating system. If the path is a =S3Uri, the
forward slash must always be used. If a slash is at the end of the
destination, the destination file or object will adopt the name of the source
file or object. Otherwise, if there is no slash at the end, the file or object
will be saved under the name provided. See examples in cp
and mv
to
illustrate this description.
Some commands only perform operations on the contents of a local directory or S3 prefix/bucket. Adding or omitting a forward slash or back slash to the end of any path argument, depending on its type, does not affect the results of the operation. The following commands will always result in a directory or S3 prefix/bucket operation:
Currently, there is no support for the use of UNIX style wildcards in a command’s path arguments. However, most commands have --exclude "<value>" and @texinfo:@option{–include "<value>"} parameters that can achieve the desired result. These parameters perform pattern matching to either exclude or include a particular file or object. The following pattern symbols are supported.
Matches everything
Matches any single character
Matches any character in sequence
Matches any character not in sequence
Any number of these parameters can be passed to a command. You can do this by providing an --exclude or --include argument multiple times, e.g. ‘--include "*.txt"--include "*.png"’. When there are multiple filters, the rule is the filters that appear later in the command take precedence over filters that appear earlier in the command.
Each filter is evaluated against the source directory. If the source location is a file instead of a directory, the directory containing the file is used as the source directory.
Note that, by default, all files are included. This means that providing only an --include filter will not change what files are transferred. --include will only re-include files that have been excluded from an texinfo:@option{–exclude}@@ filter. If you only want to upload files with a particular extension, you need to first exclude all files, then re-include the files with the particular extension.
cp
ls
mb
mv
presign
rb
rm
sync
website
Set the website configuration for a bucket.
website <S3Uri > [--index-document <value>] [--error-document <value>]
The following command configures a bucket named ‘my-bucket’ as a static website:
aws s3 website s3://my-bucket/ --index-document index.html --error-document error.html
Next: s3 API, Previous: CLI CloudFront Command Reference, Up: CLI Command Reference [Index]