README.md 1.1 KB
Newer Older
Erik Schwartz's avatar
Erik Schwartz committed
1
2
3
4
5
6
7
8
# stop-sagemaker

Stop an AWS SageMaker notebook instance.

## Set up environment

### Onetime install/configuration

Erik Schwartz's avatar
Erik Schwartz committed
9
1. Download and install [Node.js LTS](https://nodejs.org/)
Erik Schwartz's avatar
Erik Schwartz committed
10
2. Clone this repository
Erik Schwartz's avatar
Erik Schwartz committed
11
3. Install required packages: `npm ci --production`
Erik Schwartz's avatar
Erik Schwartz committed
12

13
### Export AWS variables
Erik Schwartz's avatar
Erik Schwartz committed
14
15

```bash
16
17
18
export AWS_ACCESS_KEY_ID='bbaa'
export AWS_SECRET_ACCESS_KEY='yyzz'
export AWS_REGION='us-east-2'
Erik Schwartz's avatar
Erik Schwartz committed
19
20
```

21
## Run
Erik Schwartz's avatar
Erik Schwartz committed
22
23

```bash
24
node app.js --name BazNotebook
Erik Schwartz's avatar
Erik Schwartz committed
25
26
```

27
The `--name` option should specify the SageMaker notebook name to be stopped.
Erik Schwartz's avatar
Erik Schwartz committed
28
29
30

---

31
32
33
# AWS IAM

IAM policy suggestion for AWS service account:
Erik Schwartz's avatar
Erik Schwartz committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "sagemaker:StopNotebookInstance",
                "sagemaker:DescribeNotebookInstance"
            ],
            "Resource": "arn:aws:sagemaker:*:*:notebook-instance/*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": "sagemaker:ListNotebookInstances",
            "Resource": "*"
        }
    ]
}
```