Amazon S3 CLI 资助选项

Amazon S3 CLI Grants Options

在 AWS S3 控制台中,您可以为 "Any Authenticated AWS User" 授予文件权限并授予 "Open/Download" 权限。

执行相同操作的 CLI 命令是什么?

我已经知道 cp 命令(用于上传):

aws s3 cp filename s3://bucket/folder/filename

但是,我无法弄清楚 --grants 配置,文档也没有具体说明可接受的值。

如果您可以为 --grants 标志提供其余可接受的值(例如查看权限、编辑权限),将获得奖励?

这可以递归完成吗?

编辑 1 我发现了以下内容,但它使每个人都可以使用该文件 (public)。那么,我的组的 URI 在哪里?我假设它与组的 ARN 不同。

aws s3 cp file.txt s3://my-bucket/ --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers

我们也可以这样做:

aws s3 cp file.txt s3://my-bucket/ --grants full=emailaddress=user@example.com

这将为与该电子邮件地址关联的帐户提供全部权利。

仍然无处镜像 "Any Authenticated AWS User"(我假设这是在我的帐户中验证的)。

检查此 link:Using High-Level s3 Commands with the AWS Command Line Interface

您可能想做的事:

aws s3 cp filename s3://bucket/folder/filename --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers

对于递归,使用 --recursive 选项

When the --recursive option is used on a directory/folder with cp, mv, or rm, the command walks the directory tree, including all subdirectories. These commands also accept the --exclude, --include, and --acl options as the sync command does.

您应该使用 --acl 参数来获取固定权限:

aws s3 cp local.txt s3://some-bucket/remote.txt --acl authenticated-read

aws s3 cp 的文档描述了 CLI 的 shorthand 语法:

--acl (string) Sets the ACL for the object when the command is performed. If you use this parameter you must have the "s3:PutObjectAcl" permission included in the list of actions for your IAM policy. Only accepts values of private, public-read, public-read-write, authenticated-read, bucket-owner-read, bucket-owner-full-control and log-delivery-write. See Canned ACL for details

--grants 似乎允许微调自定义 ACL,但正如您发现的那样,语法更复杂。