-
Notifications
You must be signed in to change notification settings - Fork 3
/
cfn-developer-access.yml
87 lines (81 loc) · 2.33 KB
/
cfn-developer-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
AWSTemplateFormatVersion: 2010-09-09
Description: |
Template that sets up an IAM user, IAM roles and an IAM group to facilitate developer access to the AWS account.
Parameters:
UserName:
Type: String
Description: "The name of the IAM user to create (e.g., `<first-name>.<last-name>`)"
AllowedPattern: ^[a-z0-9.]+$
NamePrefix:
Type: String
Default: "capra"
Description: "A prefix to use when naming the IAM roles and group"
MinLength: 1
Resources:
User:
Type: AWS::IAM::User
Properties:
UserName: !Ref UserName
Groups:
- !Ref AdminGroup
Path: "/"
DeveloperRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub "${NamePrefix}-developer"
Path: "/"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
AWS: !Sub "arn:aws:iam::${AWS::AccountId}:root"
Action: "sts:AssumeRole"
Condition:
Bool:
aws:MultiFactorAuthPresent: true
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/ReadOnlyAccess"
AdminRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub "${NamePrefix}-admin"
Path: "/"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
AWS: !Sub "arn:aws:iam::${AWS::AccountId}:root"
Action: "sts:AssumeRole"
Condition:
Bool:
aws:MultiFactorAuthPresent: true
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/AdministratorAccess"
Policies:
- PolicyName: "policy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Deny
Action:
- "aws-portal:Modify*"
Resource:
- "*"
AdminGroup:
Type: AWS::IAM::Group
Properties:
GroupName: !Sub "${NamePrefix}-admin-group"
Path: "/"
Policies:
- PolicyName: "policy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- "sts:AssumeRole"
Resource:
- !GetAtt AdminRole.Arn
- !GetAtt DeveloperRole.Arn