-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrgS3InvSourceAccountPolicy.yaml
68 lines (68 loc) · 1.85 KB
/
OrgS3InvSourceAccountPolicy.yaml
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
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Template to Create an IAM Role on source accounts
Parameters:
DestinationAccountId:
Type: String
AllowedPattern: "\\d{12}"
Description: 'Enter 12-digit Destination AWS Account ID. Ex: 123456789012'
S3InventoryUser:
Type: String
Description: IAM user to assume the role from the source
account. Ensure that user name is accurate otherwise you will not be able to
assume the role
Default: ''
Resources:
SourceAccountRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
AWS:
Fn::Sub: arn:aws:iam::${DestinationAccountId}:user/${S3InventoryUser}
Action: sts:AssumeRole
Path: "/"
RoleName: OrgS3role
SourceAccountPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
Description: Managed Policy to attach to SourceAccountRole Role
ManagedPolicyName: OrgS3role_policy
Path: "/"
PolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- s3:ListAllMyBuckets
Effect: Allow
Resource:
- arn:aws:s3:::*
- Action:
- s3:ListBucket
- s3:GetBucketLocation
Effect: Allow
Resource: arn:aws:s3:::*
- Effect: Allow
Action:
- s3:GetInventoryConfiguration
- s3:ListBucket
- iam:GetUser
- s3:GetBucketLocation
- s3:PutInventoryConfiguration
Resource: arn:aws:s3:::*
Roles:
- Ref: SourceAccountRole
Outputs:
RoleName:
Description: Name of Created IAM Role
Value:
Ref: SourceAccountRole
RoleArn:
Description: Arn of Created Role
Value:
Fn::GetAtt:
- SourceAccountRole
- Arn