This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserverless.yml
156 lines (153 loc) · 5.37 KB
/
serverless.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
service: aws-mfa-enforce
provider:
name: aws
runtime: nodejs8.10
stage: prod
memorySize: 128
role: customRole
functions:
cron:
handler: handler.handler
environment:
EMAIL: ${ssm:email}
PASSWORD: ${ssm:email_password}
EMAIL_SUBJECT: Activate Multi Factor Authentication to access AWS services
EMAIL_BODY: >
Hello,<br/>
<p>Your email was recently added our organizational AWS account. To enhance the security of your account Multi Factor Authentication (MFA) has been enforced. <b><i>You cannot access any AWS service until you activate MFA</i></b>.</p>
<p>To activate MFA for your AWS user account, please follow the steps provided at: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_enable_virtual.html#enable-virt-mfa-for-iam-user</p><br/>
Regards,<br/>
Security Bot
events:
- schedule: rate(12 hours)
resources:
Resources:
customRole:
Type: AWS::IAM::Role
Properties:
RoleName: ServerlessFrameworkRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: ServerlessPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AllowIAMForLambdaPolicy
Effect: Allow
Action:
- iam:GetGroup
- iam:ListUsers
- iam:AddUserToGroup
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: "*"
mfaGroup:
Type: AWS::IAM::Group
Properties:
GroupName: MFA-enforced
Policies:
- PolicyName: MFA
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AllowAllUsersToListAccounts
Effect: Allow
Action:
- iam:ListAccountAliases
- iam:ListUsers
- iam:ListVirtualMFADevices
- iam:GetAccountPasswordPolicy
- iam:GetAccountSummary
Resource: "*"
- Sid: AllowIndividualUserToSeeAndManageOnlyTheirOwnAccountInformation
Effect: Allow
Action:
- iam:ChangePassword
- iam:CreateAccessKey
- iam:CreateLoginProfile
- iam:DeleteAccessKey
- iam:DeleteLoginProfile
- iam:GetLoginProfile
- iam:ListAccessKeys
- iam:UpdateAccessKey
- iam:UpdateLoginProfile
- iam:ListSigningCertificates
- iam:DeleteSigningCertificate
- iam:UpdateSigningCertificate
- iam:UploadSigningCertificate
- iam:ListSSHPublicKeys
- iam:GetSSHPublicKey
- iam:DeleteSSHPublicKey
- iam:UpdateSSHPublicKey
- iam:UploadSSHPublicKey
Resource:
- 'Fn::Join':
- ''
- - 'arn:aws:iam::*:user/'
- '${aws:username'
- '}'
- Sid: AllowIndividualUserToViewAndManageTheirOwnMFA
Effect: Allow
Action:
- iam:CreateVirtualMFADevice
- iam:DeleteVirtualMFADevice
- iam:EnableMFADevice
- iam:ListMFADevices
- iam:ResyncMFADevice
Resource:
- 'Fn::Join':
- ''
- - 'arn:aws:iam::*:mfa/'
- '${aws:username'
- '}'
- 'Fn::Join':
- ''
- - 'arn:aws:iam::*:user/'
- '${aws:username'
- '}'
- Sid: AllowIndividualUserToDeactivateOnlyTheirOwnMFAOnlyWhenUsingMFA
Effect: Allow
Action:
- iam:DeactivateMFADevice
Resource:
- 'Fn::Join':
- ''
- - 'arn:aws:iam::*:mfa/'
- '${aws:username'
- '}'
- 'Fn::Join':
- ''
- - 'arn:aws:iam::*:user/'
- '${aws:username'
- '}'
Condition:
Bool:
aws:MultiFactorAuthPresent: 'true'
- Sid: BlockMostAccessUnlessSignedInWithMFA
Effect: Deny
NotAction:
- iam:CreateVirtualMFADevice
- iam:DeleteVirtualMFADevice
- iam:ListVirtualMFADevices
- iam:EnableMFADevice
- iam:ResyncMFADevice
- iam:ListAccountAliases
- iam:ListUsers
- iam:ListSSHPublicKeys
- iam:ListAccessKeys
- iam:ListServiceSpecificCredentials
- iam:ListMFADevices
- iam:GetAccountSummary
- sts:GetSessionToken
Resource: "*"
Condition:
BoolIfExists:
aws:MultiFactorAuthPresent: 'false'