-
Notifications
You must be signed in to change notification settings - Fork 4
/
s3-folder-access.yml
124 lines (122 loc) · 3.82 KB
/
s3-folder-access.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
AWSTemplateFormatVersion: '2010-09-09'
Description: Create Policy and Group to allow Cyberduck access to a specific folder in
a S3 bucket
Parameters:
Name:
Type: String
Description: This should only use letters, numbers, and dashes. It is will be used to label
resources created by the template so you can find them again.
AllowedPattern: '[a-zA-Z0-9\-]+'
S3Bucket:
Type: String
Description: The name of the bucket that the policy grants access to.
FolderPath:
Type: String
Description: The path to the folder in the S3 bucket that the policy grants access to.
It should not contain any slashes.
AllowedPattern: '[^/]+'
Resources:
AccessGroup:
Type: AWS::IAM::Group
Properties:
GroupName: !Sub '${Name}-Group-CF-Managed'
AccessPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
ManagedPolicyName: !Sub '${Name}-Access-CF-Managed'
Groups:
- !Ref AccessGroup
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AllowUserToSeeBucketListInTheConsole
Action:
- s3:ListAllMyBuckets
- s3:GetBucketLocation
Effect: Allow
Resource: '*'
- Sid: AllowRootAndHomeListingOfBucket
Action:
- s3:ListBucket
Effect: Allow
Resource:
- !Sub 'arn:aws:s3:::${S3Bucket}'
Condition:
StringEquals:
s3:prefix:
- ''
s3:delimiter:
- "/"
- Sid: AllowRootListingWithoutPrefix
Action:
- s3:ListBucket
Effect: Allow
Resource:
- !Sub 'arn:aws:s3:::${S3Bucket}'
Condition:
'Null':
s3:prefix: 'true'
StringEquals:
s3:delimiter:
- "/"
- Sid: AllowListingOfProjectFolder
Action:
- s3:ListBucket
Effect: Allow
Resource:
- !Sub 'arn:aws:s3:::${S3Bucket}'
Condition:
StringLike:
s3:prefix:
- !Sub '${FolderPath}/*'
- Sid: AllowMostReadActionsOnBucket
Effect: Allow
Action:
- s3:GetAccelerateConfiguration
- s3:GetAnalyticsConfiguration
- s3:GetBucketAcl
- s3:GetBucketCORS
- s3:GetBucketLogging
- s3:GetBucketNotification
- s3:GetBucketPolicy
- s3:GetBucketRequestPayment
- s3:GetBucketTagging
- s3:GetBucketVersioning
- s3:GetBucketWebsite
- s3:GetInventoryConfiguration
- s3:GetIpConfiguration
- s3:GetLifecycleConfiguration
- s3:GetMetricsConfiguration
- s3:GetReplicationConfiguration
Resource:
- !Sub 'arn:aws:s3:::${S3Bucket}'
- Sid: AllowAllS3ActionsOnObjectsInProjectFolder
Effect: Allow
Action:
- s3:GetObject
- s3:GetObjectAcl
- s3:GetObjectTagging
- s3:GetObjectTorrent
- s3:GetObjectVersion
- s3:GetObjectVersionAcl
- s3:GetObjectVersionForReplication
- s3:GetObjectVersionTagging
- s3:GetObjectVersionTorrent
- s3:ListMultipartUploadParts
- s3:AbortMultipartUpload
- s3:DeleteObject
- s3:DeleteObjectTagging
- s3:DeleteObjectVersionTagging
- s3:PutObject
- s3:PutObjectTagging
- s3:PutObjectVersionTagging
- s3:ReplicateDelete
- s3:ReplicateObject
- s3:ReplicateTags
- s3:RestoreObject
- s3:ObjectOwnerOverrideToBucketOwner
- s3:PutObjectAcl
- s3:PutObjectVersionAcl
Resource:
- !Sub 'arn:aws:s3:::${S3Bucket}/${FolderPath}'
- !Sub 'arn:aws:s3:::${S3Bucket}/${FolderPath}/*'