-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdatamasque-s3-bucket-access-iam-policy.yaml
More file actions
94 lines (84 loc) · 3.3 KB
/
Copy pathdatamasque-s3-bucket-access-iam-policy.yaml
File metadata and controls
94 lines (84 loc) · 3.3 KB
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
AWSTemplateFormatVersion: "2010-09-09"
Description: The CFN stack to enable DataMasque to mask data on S3 buckets in same account.
Parameters:
DmRoleName:
Type: String
Description: The name of the DataMasque instance IAM role to which the policy will be attached (role name, not ARN).
DestinationBuckets:
Type: CommaDelimitedList
Description: Comma separated ARNs of target S3 buckets on which masked data is written.
SourceBuckets:
Type: CommaDelimitedList
Description: Comma separated ARNs of source S3 buckets on which data needs to be masked.
SourceBucketsPrefixes:
Type: CommaDelimitedList
Description: Comma separated prefixes of source S3 buckets from which data needs to be masked.
DestinationBucketsPrefixes:
Type: CommaDelimitedList
Description: Comma separated prefixes of destination S3 buckets to which masked data is written.
PolicyName:
Type: String
Default: datamasque-policy
Description: The name of the managed policy.
KmsKeyArns:
Type: CommaDelimitedList
Default: ""
Description: >-
Optional. ARNs of the SSE-KMS keys protecting the source/destination buckets, separated by commas.
Leave empty when buckets use SSE-S3 (AES256). When set, the policy grants kms:Decrypt and
kms:GenerateDataKey on those keys so masking can read/write KMS-encrypted objects.
Conditions:
# True when at least one KMS key ARN was supplied (Default "" yields a single empty element).
HasKmsKeys: !Not [!Equals [!Join ["", !Ref KmsKeyArns], ""]]
Resources:
DmManagedPolicy:
Type: "AWS::IAM::ManagedPolicy"
Properties:
ManagedPolicyName: !Ref PolicyName
Description: "Policy to enable DataMasque to mask data on S3 buckets in same account"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: ListBucketInfo
Effect: Allow
Action:
- s3:ListBucket
- s3:GetBucketAcl
- s3:GetBucketPolicyStatus
- s3:GetBucketPublicAccessBlock
- s3:GetBucketObjectLockConfiguration
- s3:GetEncryptionConfiguration
Resource: !Split
- ","
- !Join
- ","
- - !Join [",", !Ref SourceBuckets]
- !Join [",", !Ref DestinationBuckets]
- Sid: ReadBucket
Effect: Allow
Action:
- s3:GetObject
Resource: !Ref SourceBucketsPrefixes
- Sid: ReadWriteDeleteAccess
Effect: Allow
Action:
- s3:PutObject
- s3:GetObject
- s3:DeleteObject
Resource: !Ref DestinationBucketsPrefixes
# SSE-KMS support: only present when KmsKeyArns is provided.
- !If
- HasKmsKeys
- Sid: KmsDataKeyAccess
Effect: Allow
Action:
- kms:Decrypt
- kms:GenerateDataKey
Resource: !Ref KmsKeyArns
- !Ref AWS::NoValue
Roles:
- !Ref DmRoleName
Outputs:
DatamasqueS3Access:
Description: "ARN of the managed policy created to enable DataMasque to mask data on S3 buckets."
Value: !Ref DmManagedPolicy