Does anyone know if it is possible to set a rule or some kind of config to S3 server which will allow fallback to a different virtual folder if some resource is not found on given path?
Here is an example:
Url that is called is https://bucket.s3.domain/virtual-folder/1/res.ext
. If res.ext
can not be found in virtual folder 1
I would like it to redirect it to it's parent https://bucket.s3.domain/virtual-folder/res.ext
Parent will contain default versions of resources. So the idea is if you can't find specific resource S3 should automatically return the default one.
I have made some research but all I get is about website redirections. What I need here is a raw resources that devices will pull in a single request, and S3 will take care of everything.
Is this stuff even possible?
Thanks, Ante.
If the IAM user and S3 bucket belong to the same AWS account, then you can grant the user access to a specific bucket folder using an IAM policy. As long as the bucket policy doesn't explicitly deny the user access to the folder, you don't need to update the bucket policy if access is granted by the IAM policy.
With S3 Object Lock, you can store objects using a write-once-read-many (WORM) model. Object Lock can help prevent objects from being deleted or overwritten for a fixed amount of time or indefinitely.
Amazon S3 Replication now gives you the ability to replicate data from one source bucket to multiple destination buckets. With S3 Replication (multi-destination) you can replicate data in the same AWS Regions using S3 SRR or across different AWS Regions by using S3 CRR, or a combination of both.
It is possible now with new feature is S3! You have to set your bucket to be a static website (which will require you to change a URL you use to asses files) and then set a following redirection rule:
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>artist-media/staging</KeyPrefixEquals>
<HttpErrorCodeReturnedEquals>403</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>someotherbucket.s3.amazonaws.com</HostName>
<ReplaceKeyPrefixWith>artist-media/production</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
What I wanted to do is to serve pictures from a developer bucket if a file was uploaded and if not then fallback to the production one.
For that reason I have to use KeyPrefixEquals
and ReplaceKeyPrefixWith
, you can just remove it if this is not what you need.
As for the redirection itself the rule catches 403 error (denied because file is missing. If you make the bucket public you probably need to use 404 there) and then just sets a new host (bucket URL) to point to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With