-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpolicy-examples.dhall
78 lines (73 loc) · 2.42 KB
/
policy-examples.dhall
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
let P =
https://raw.githubusercontent.com/mjgpy3/iam-dhall/20bcc9c507d353fb3736a633280239a922b91aa6/policy.dhall
let policy =
https://raw.githubusercontent.com/mjgpy3/iam-dhall/20bcc9c507d353fb3736a633280239a922b91aa6/output.dhall
let specificBucketAccess =
λ(accountId : Text)
→ λ(region : Text)
→ λ(bucket : Text)
→ λ(key : Text)
→ policy
{ accountId = accountId, region = region }
[ P.serviceAllow P.Service.S3 [ "ListBucket" ] [ bucket ]
⫽ { sid = "BucketListing" }
, P.serviceAllow
P.Service.S3
[ "PutObject", "GetObject", "DeleteObject", "PutObjectAcl" ]
[ "${bucket}/${key}/*" ]
⫽ { sid = "ObjectAccess" }
]
let bucketExample1 =
assert
: specificBucketAccess
"0123456789"
"us-east-1"
"my.cool.bucket"
"my/object/key"
≡ { Version = "2012-10-17"
, Statement =
[ { Sid = "BucketListing0"
, Effect = "Allow"
, Action = [ "s3:ListBucket" ]
, Resource = [ "arn:aws:s3:::my.cool.bucket" ]
}
, { Sid = "ObjectAccess1"
, Effect = "Allow"
, Action =
[ "s3:PutObject"
, "s3:GetObject"
, "s3:DeleteObject"
, "s3:PutObjectAcl"
]
, Resource = [ "arn:aws:s3:::my.cool.bucket/my/object/key/*" ]
}
]
}
let bucketExample2 =
assert
: specificBucketAccess
"0123456789"
"us-east-1"
"yet.another.bucket"
"some/other/key"
≡ { Version = "2012-10-17"
, Statement =
[ { Sid = "BucketListing0"
, Effect = "Allow"
, Action = [ "s3:ListBucket" ]
, Resource = [ "arn:aws:s3:::yet.another.bucket" ]
}
, { Sid = "ObjectAccess1"
, Effect = "Allow"
, Action =
[ "s3:PutObject"
, "s3:GetObject"
, "s3:DeleteObject"
, "s3:PutObjectAcl"
]
, Resource =
[ "arn:aws:s3:::yet.another.bucket/some/other/key/*" ]
}
]
}
in { specificBucketAccess = specificBucketAccess }