S3: make a public folder private again?

前端 未结 12 1882
北恋
北恋 2021-01-30 20:16

How do you make an AWS S3 public folder private again?

I was testing out some staging data, so I made the entire folder public within a bucket. I\'d like to restrict it

12条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-30 20:43

    If you want a delightfully simple one-liner, you can use the AWS Powershell Tools. The reference for the AWS Powershell Tools can be found here. We'll be using the Get-S3Object and Set-S3ACL commandlets.

    $TargetS3Bucket = "myPrivateBucket"
    $TargetDirectory = "accidentallyPublicDir"
    $TargetRegion = "us-west-2"
    
    Set-DefaultAWSRegion $TargetRegion
    
    Get-S3Object -BucketName $TargetS3Bucket -KeyPrefix $TargetDirectory | Set-S3ACL -CannedACLName private
    

提交回复
热议问题