0

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?

TFaws
  • 193
  • 2
  • 4
  • 15
  • Since `Key` does not accept wildcard input, I suspect you'll have to pipe the results and do it one at a time. If you can describe how you get `file.txt`, I can write up a solution. – joelforsyth May 02 '22 at 21:59
  • The files are a website, essentially. I'm using a pipeline to build my react app and upload the build folder to an S3 bucket in a different account. So I'm trying to give it permission to upload it there. – TFaws May 02 '22 at 22:05

1 Answers1

0

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 }
joelforsyth
  • 836
  • 1
  • 11
  • 28