简体   繁体   中英

Granting permission to ALL objects in a bucket via AWS Powershell Tools?

I can grant specific permissions to a specific file easily, like this:

Set-S3ACL -BucketName "bucket" -Key "file.txt"

However, now I'm trying to do it for all the files:

Set-S3ACL -BucketName "bucket" -Key "*"

This does not work and it throws:

Set-S3ACL : The specified key does not exist.

What is the valid syntax in this case?

If you need to recursively apply the function to every file, you can achieve that with Get-ChildItem to get all of the files in a folder, and using Recurse to also search subfolders. Then loop those results and call the function for each one.

Get-ChildItem -Path $topfolder -Recurse | ForEach-object { Set-S3ACL -BucketName "bucket" -Key $_.Name }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM