I've two scenarios
- Single S3 bucket will hold data for multiple environments
- Single S3 bucket which will holds data for single environment
In both these scenarios bucket will be private and public to CloudFront only
Where I want to restrict access to S3 resources, other than files prefix/folder.
I want to allow access by CloudFront to only files prefix
- which can be at nested level (Scenario 1 ->
env1/{files}/images/image1.jpg
) - or at root level (Scenario 2 ->
{files}/images/image1.jpg
) - any other prefix/folder than
/files/
should be restricted
Bucket scenarios :
Scenario 1 (common bucket for multiple environments)
bucket1.s3.{region}.amazonaws.com
├── env1
│ ├── files
| ├── images
│ ├── image1.jpg
│ ├── image2.jpg
│
├── env2
│ ├── files
| ├── images
│ ├── image1.jpg
│ ├── image2.jpg
├── env3
│ ├── files
| ├── images
│ ├── image1.jpg
│ ├── image2.jpg
Scenario 2 (bucket dedicated to environment)
bucket2.s3.{region}.amazonaws.com
|── files
| |── images
│ ├── image1.jpg
│ ├── image2.jpg
I want to setup common (or individual) CloudFront distribution with configuration for both the scenarios
where
Origin: {bucketname}.s3.{region}.amazonaws.com
Behaviors
Path pattern 1: /*/files* (scenario 1 : common bucket for multiple environments))
Path pattern 2: files/* (scenario 2 : bucket dedicated to environment)
but it seems origin path as /*/files*
or files/*
is not working, with above behaviors
Do we have any way to setup such kind of Origin and Behaviors in CloudFront distribution to achieve mentioned behavior?