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

132 views Asked by At

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?

1

There are 1 answers

0
joelforsyth On

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 }