1
00:00:00,000 --> 00:00:02,290
Let's get into IAM Permission Boundaries.

2
00:00:02,290 --> 00:00:03,920
And so these permission boundaries

3
00:00:03,920 --> 00:00:05,850
are supported for users and roles

4
00:00:05,850 --> 00:00:08,760
and they're not available for groups, so remember this.

5
00:00:08,760 --> 00:00:10,220
And they're an advanced feature

6
00:00:10,220 --> 00:00:13,350
that allow you to define the maximum amount of permissions

7
00:00:13,350 --> 00:00:15,110
an IAM entity can get.

8
00:00:15,110 --> 00:00:16,560
So let's have an example.

9
00:00:16,560 --> 00:00:18,720
We have this IAM permission boundaries.

10
00:00:18,720 --> 00:00:19,770
It looks just like an IAM policy.

11
00:00:19,770 --> 00:00:24,750
So we're saying, allow everything on S3 CloudWatch and EC2.

12
00:00:24,750 --> 00:00:27,430
So we attach this, for example, to an IAM user

13
00:00:27,430 --> 00:00:29,030
and that's its permission boundaries.

14
00:00:29,030 --> 00:00:31,120
That means that it can only do things

15
00:00:31,120 --> 00:00:33,440
within S3 CloudWatch and EC2.

16
00:00:33,440 --> 00:00:36,360
And then you need to specify on top of things

17
00:00:36,360 --> 00:00:39,320
an IAM permission through policy.

18
00:00:39,320 --> 00:00:42,430
And so here, say we attach to the very same user,

19
00:00:42,430 --> 00:00:45,270
allow iam:CreateUser, resource *.

20
00:00:45,270 --> 00:00:46,440
So there is a boundary

21
00:00:46,440 --> 00:00:49,090
and there is an IAM policy with permissions.

22
00:00:49,090 --> 00:00:52,580
What is going to be the results permission in this case?

23
00:00:52,580 --> 00:00:54,600
Well, nothing, no permissions

24
00:00:54,600 --> 00:00:56,270
because the IAM policy

25
00:00:56,270 --> 00:00:59,080
is outside the IAM permission boundary.

26
00:00:59,080 --> 00:01:02,750
Therefore, our user is not allowed to create other IAM users

27
00:01:02,750 --> 00:01:06,080
because that is not in its IAM permission boundary.

28
00:01:06,080 --> 00:01:06,920
So I want to show you

29
00:01:06,920 --> 00:01:08,910
where IAM permission boundaries are created.

30
00:01:08,910 --> 00:01:10,570
So let's go create a user.

31
00:01:10,570 --> 00:01:12,900
I'm going to call the user John,

32
00:01:12,900 --> 00:01:15,820
and then I'm going to give him programmatic access.

33
00:01:15,820 --> 00:01:17,010
Next permissions.

34
00:01:17,010 --> 00:01:18,620
I will not set anything,

35
00:01:18,620 --> 00:01:19,790
and next Tags.

36
00:01:19,790 --> 00:01:21,820
Review, and Create user.

37
00:01:21,820 --> 00:01:23,560
So we have created John

38
00:01:23,560 --> 00:01:25,990
and we're going to set permission boundaries for John.

39
00:01:25,990 --> 00:01:28,300
So imagine John is a developer in our company

40
00:01:28,300 --> 00:01:29,890
and he needs to have certain permissions

41
00:01:29,890 --> 00:01:32,210
but we want to make sure that he has a permission boundary.

42
00:01:32,210 --> 00:01:34,350
So for this, we could assign a policy,

43
00:01:34,350 --> 00:01:35,340
for example, for John,

44
00:01:35,340 --> 00:01:38,699
so if I add permission and I say, "Hey, John,

45
00:01:38,699 --> 00:01:41,030
I'm going to attach to you AdministratorAccess."

46
00:01:41,030 --> 00:01:43,880
It seems like John can do everything right now.

47
00:01:43,880 --> 00:01:45,600
So John is a super user.

48
00:01:45,600 --> 00:01:49,070
But I'm also going to set a permission boundary on John.

49
00:01:49,070 --> 00:01:50,630
And I'm going say, okay, here is your boundary

50
00:01:50,630 --> 00:01:52,060
and this is an advanced feature.

51
00:01:52,060 --> 00:01:53,980
And I'm gonna say the only thing you can do, actually,

52
00:01:53,980 --> 00:01:56,957
John, is to have AmazonS3FullAccess.

53
00:01:58,150 --> 00:02:00,190
And so here, what I've been setting

54
00:02:00,190 --> 00:02:02,530
is a permission boundary for John.

55
00:02:02,530 --> 00:02:07,530
And so through this AWS S3 full access managed policy,

56
00:02:07,640 --> 00:02:10,539
even though John has an administrator access,

57
00:02:10,539 --> 00:02:15,270
when John logs in, the only thing he can do is to access S3

58
00:02:15,270 --> 00:02:17,460
because S3 is its boundary.

59
00:02:17,460 --> 00:02:18,450
So here we've seen that,

60
00:02:18,450 --> 00:02:20,100
even though there is a policy attached to John

61
00:02:20,100 --> 00:02:21,890
that gives him an administrator access,

62
00:02:21,890 --> 00:02:25,000
the boundary is actually going to be more restrictive.

63
00:02:25,000 --> 00:02:27,110
So IAM permission boundaries can be used

64
00:02:27,110 --> 00:02:30,360
in combinations of AWS Organizations SCP.

65
00:02:30,360 --> 00:02:32,730
So if look at this diagram,

66
00:02:32,730 --> 00:02:34,970
we have the effective permissions

67
00:02:34,970 --> 00:02:38,460
to be in the middle of your identity-based policy,

68
00:02:38,460 --> 00:02:41,350
so whatever is attached to your user or your group.

69
00:02:41,350 --> 00:02:43,360
The permission boundary, which by the way,

70
00:02:43,360 --> 00:02:46,750
only applies to a user or a role and not a group.

71
00:02:46,750 --> 00:02:48,740
And your organization SCP,

72
00:02:48,740 --> 00:02:51,910
which applies to every single IAM entity in your account.

73
00:02:51,910 --> 00:02:55,710
So in the middle lies what the users can do.

74
00:02:55,710 --> 00:02:58,950
So we can use permission boundaries for a few use cases.

75
00:02:58,950 --> 00:03:01,470
For example, to delegate responsibilities

76
00:03:01,470 --> 00:03:04,210
to non-administrators within their permission boundaries,

77
00:03:04,210 --> 00:03:06,550
for example to create new IAM users.

78
00:03:06,550 --> 00:03:08,730
Or to allow developers to self assign

79
00:03:08,730 --> 00:03:10,070
and manage their own permissions,

80
00:03:10,070 --> 00:03:12,760
while making sure they can't escalate their privileges,

81
00:03:12,760 --> 00:03:15,420
that means making themselves administrators.

82
00:03:15,420 --> 00:03:18,840
Or for example, restrict one very specific user

83
00:03:18,840 --> 00:03:21,100
inside yours organization

84
00:03:21,100 --> 00:03:25,250
instead of applying an entire SCP to your account

85
00:03:25,250 --> 00:03:27,773
and restricting everyone in your whole account.

86
00:03:29,690 --> 00:03:33,190
So let's have a look at the IAM Policy Evaluation Logic.

87
00:03:33,190 --> 00:03:35,870
Because this diagram basically explains to you

88
00:03:35,870 --> 00:03:40,870
how you are authorized, or not, to do actions within AWS.

89
00:03:41,000 --> 00:03:42,060
And you don't need to know by heart,

90
00:03:42,060 --> 00:03:43,900
but it should make sense to you.

91
00:03:43,900 --> 00:03:45,780
So we can see there's a whole flow,

92
00:03:45,780 --> 00:03:48,800
but at every step, there is an evaluation.

93
00:03:48,800 --> 00:03:51,350
And so we're going to look at Deny evaluation,

94
00:03:51,350 --> 00:03:53,510
we're going to look at Organizations SCP,

95
00:03:53,510 --> 00:03:54,660
Resource-based policy,

96
00:03:54,660 --> 00:03:55,780
Identity-based policy,

97
00:03:55,780 --> 00:03:56,810
IAM permission boundaries,

98
00:03:56,810 --> 00:03:58,940
and then finally, Session policies

99
00:03:58,940 --> 00:04:02,920
to allow or deny a specific IAM action.

100
00:04:02,920 --> 00:04:04,840
So let's have a look in details to see how that works.

101
00:04:04,840 --> 00:04:09,270
So we're going to look at all the possible policies in here.

102
00:04:09,270 --> 00:04:10,540
And if there is an explicit deny,

103
00:04:10,540 --> 00:04:13,550
then we know that it's going to be denied automatically.

104
00:04:13,550 --> 00:04:16,220
Then we look at the organizations SCP,

105
00:04:16,220 --> 00:04:18,029
and is there an allow?

106
00:04:18,029 --> 00:04:19,470
If yes, then go to next step.

107
00:04:19,470 --> 00:04:23,990
If not, then it's a deny because it's an implicit deny.

108
00:04:23,990 --> 00:04:25,780
Then we look at resource-based policy,

109
00:04:25,780 --> 00:04:28,540
for example, that can be applied to S3 buckets.

110
00:04:28,540 --> 00:04:30,650
They can be applied to SQS and so on.

111
00:04:30,650 --> 00:04:31,500
And again, we have a look,

112
00:04:31,500 --> 00:04:33,010
is there a resource-based policy?

113
00:04:33,010 --> 00:04:35,130
If so, is there an allow?

114
00:04:35,130 --> 00:04:37,110
Yes or no?

115
00:04:37,110 --> 00:04:38,890
Then we have identity-based policy.

116
00:04:38,890 --> 00:04:40,730
So we look, again, as whether or not

117
00:04:40,730 --> 00:04:42,020
there's an identity-based policy,

118
00:04:42,020 --> 00:04:43,490
whether or not there's an allow,

119
00:04:43,490 --> 00:04:47,600
and then we deny implicitly or go onto the next step.

120
00:04:47,600 --> 00:04:50,350
Then we look at IAM permission boundaries that we just saw.

121
00:04:50,350 --> 00:04:52,150
And then finally, we look at session policies

122
00:04:52,150 --> 00:04:54,840
that won't go over them, this is more related to SDS.

123
00:04:54,840 --> 00:04:56,290
But what I want you to remember is

124
00:04:56,290 --> 00:04:58,950
that all these things are evaluated

125
00:04:58,950 --> 00:05:02,790
when making a specific IAM action.

126
00:05:02,790 --> 00:05:06,080
And so, only if all these things are allowing

127
00:05:06,080 --> 00:05:08,930
and working together, or not denying specifically,

128
00:05:08,930 --> 00:05:11,050
then you will have a final decision allow,

129
00:05:11,050 --> 00:05:13,810
and you'll be able to do your action.

130
00:05:13,810 --> 00:05:15,610
So it's just to give you a bit more overview

131
00:05:15,610 --> 00:05:16,870
but hopefully you understand better

132
00:05:16,870 --> 00:05:18,617
how security works in AWS.

133
00:05:19,870 --> 00:05:21,130
So let's have a look at this policy

134
00:05:21,130 --> 00:05:24,340
and see what it can do to make it a bit more concrete.

135
00:05:24,340 --> 00:05:27,500
So we have sqs:*, Deny on resource *,

136
00:05:27,500 --> 00:05:31,230
and we have action, sqs:DeleteQueue, Allow on resource *.

137
00:05:32,130 --> 00:05:33,900
So first question is,

138
00:05:33,900 --> 00:05:36,613
can you perform sqs:CreateQueue?

139
00:05:38,210 --> 00:05:39,970
The answer is no, you cannot

140
00:05:39,970 --> 00:05:42,930
because there is a Deny star on SQS,

141
00:05:42,930 --> 00:05:45,270
and CreateQueue belongs to that block

142
00:05:45,270 --> 00:05:46,870
and there's a deny on it,

143
00:05:46,870 --> 00:05:49,210
so it's definitely going to be denied.

144
00:05:49,210 --> 00:05:52,123
Now, can you perform an sqs:DeleteQueue?

145
00:05:52,980 --> 00:05:54,910
So there's a deny on the top part

146
00:05:54,910 --> 00:05:57,010
and there's an allow on the bottom part

147
00:05:57,010 --> 00:05:57,843
and they conflict.

148
00:05:57,843 --> 00:05:59,330
There's a deny and allow.

149
00:05:59,330 --> 00:06:00,810
But what did I just tell you?

150
00:06:00,810 --> 00:06:04,250
I told you that as soon as you have an explicit deny,

151
00:06:04,250 --> 00:06:06,590
then the decision is going to be denied.

152
00:06:06,590 --> 00:06:10,120
So because there is an explicit deny on sqs:*,

153
00:06:10,120 --> 00:06:13,530
and sqs:DeleteQueue is within that sqs:*,

154
00:06:13,530 --> 00:06:15,920
then no matter what, even there's an allow here,

155
00:06:15,920 --> 00:06:17,720
this is going to be denied this action.

156
00:06:17,720 --> 00:06:20,200
So you cannot perform sqs:DeleteQueue,

157
00:06:20,200 --> 00:06:22,710
even though you have allowed it explicitly

158
00:06:22,710 --> 00:06:23,780
in the second block.

159
00:06:23,780 --> 00:06:25,300
So very important to know.

160
00:06:25,300 --> 00:06:29,360
And finally, can you perform ec2:DescribeInstances?

161
00:06:29,360 --> 00:06:32,690
So as we can see, there's nothing on EC2 in this thing.

162
00:06:32,690 --> 00:06:34,660
And this is an IAM policy.

163
00:06:34,660 --> 00:06:36,250
And so, because there is no explicit deny

164
00:06:36,250 --> 00:06:38,350
but also there's no explicit allow,

165
00:06:38,350 --> 00:06:41,530
then you cannot perform ec2:DescribeInstances

166
00:06:41,530 --> 00:06:43,440
with this IAM policy.

167
00:06:43,440 --> 00:06:45,060
All right, hope that makes sense.

168
00:06:45,060 --> 00:06:46,420
So that's it for this lecture.

169
00:06:46,420 --> 00:06:48,120
Hopefully you understand IAM better.

170
00:06:48,120 --> 00:06:50,070
And I will see you in the next lecture.

