Skip to content

Commit

Permalink
fix: Allow sagemaker to have the proper IAM permission to autostop it…
Browse files Browse the repository at this point in the history
…self (awslabs#515)
  • Loading branch information
nguyen102 authored and ahl27 committed Jun 11, 2021
1 parent e8c3106 commit 5269f3f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Resources:
Action:
- 'sts:AssumeRole'
Resource: 'arn:aws:iam::*:role/swb-*'
- Effect: Allow
Action:
- sagemaker:DescribeNotebookInstance
- sagemaker:StopNotebookInstance
Resource: '*'
IAMRole:
Type: 'AWS::IAM::Role'
Properties:
Expand Down Expand Up @@ -175,7 +180,7 @@ Resources:
chmod a+x /usr/local/bin/autostop.py
IDLE_TIME=`expr ${AutoStopIdleTimeInMinutes} \* 60`
echo "Starting the SageMaker autostop script in cron"
(crontab -l 2>/dev/null; echo "5 * * * * /usr/bin/python /usr/local/bin/autostop.py --time $IDLE_TIME --ignore-connections") | crontab -
(crontab -l 2>/dev/null; echo "*/1 * * * * /usr/bin/python /usr/local/bin/autostop.py --time $IDLE_TIME --ignore-connections >> /var/log/autostop.log") | crontab -
fi

Outputs:
Expand Down
2 changes: 1 addition & 1 deletion main/solution/backend/config/infra/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ envStatusPollHandler:
description: Handles status polling for sc environments
events:
- schedule:
rate: rate(3 minutes)
rate: rate(1 minute)
description: 'Invokes the lambda function that polls and synchronize environment status.'
environment:
APP_CUSTOM_USER_AGENT: ${self:custom.settings.customUserAgent}
Expand Down

0 comments on commit 5269f3f

Please sign in to comment.