Skip to content

Commit 590dbf8

Browse files
Removed ssm:DeregisterManagedInstance from IAM SSHSageMakerClientPolicy since it's an admin cleanup action
1 parent 1bc1bd5 commit 590dbf8

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

IAM_SSM_Setup.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,6 @@ a. Attach the inline policy named `SSHSageMakerClientPolicy`. Replace `<<ACCOUNT
183183
"Resource": "*",
184184
"Effect": "Allow"
185185
},
186-
{
187-
"Condition": {
188-
"StringLike": {
189-
"ssm:resourceTag/SSHOwner": "*"
190-
}
191-
},
192-
"Action": "ssm:DeregisterManagedInstance",
193-
"Resource": "arn:aws:ssm:*:<<ACCOUNT_ID>>:managed-instance/mi-*",
194-
"Effect": "Allow"
195-
},
196186
{
197187
"Condition": {
198188
"StringEquals": {

sagemaker_ssh_helper/cdk/iam_ssm/iam_ssm_stack.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
3232
],
3333
resources=["*"]
3434
),
35-
PolicyStatement(
36-
effect=Effect.ALLOW,
37-
actions=[
38-
"ssm:DeregisterManagedInstance",
39-
],
40-
resources=[f"arn:{Aws.PARTITION}:ssm:*:{Aws.ACCOUNT_ID}:managed-instance/mi-*"],
41-
conditions={
42-
"StringLike": {
43-
"ssm:resourceTag/SSHOwner": "*"
44-
}
45-
}
46-
),
4735
PolicyStatement(
4836
effect=Effect.ALLOW,
4937
actions=[

sagemaker_ssh_helper/cdk/iam_ssm/iam_ssm_stack_tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
160160
resources=[
161161
f"arn:{Aws.PARTITION}:logs:{Aws.REGION}:{Aws.ACCOUNT_ID}:log-group:/aws/codebuild/sagemaker-studio-image-build-*:log-stream:*"]
162162
),
163+
PolicyStatement(
164+
effect=Effect.ALLOW,
165+
actions=[
166+
"ssm:DeregisterManagedInstance",
167+
],
168+
resources=[f"arn:{Aws.PARTITION}:ssm:*:{Aws.ACCOUNT_ID}:managed-instance/mi-*"],
169+
conditions={
170+
"StringLike": {
171+
"ssm:resourceTag/SSHOwner": "*"
172+
}
173+
}
174+
),
163175
]))
164176

165177
sagemaker_core_policy.attach_to_role(user_role)

0 commit comments

Comments
 (0)