How to create a Jupyter Notebook in AWS using the CLI

To create a Jupyter Notebook in AWS, we can use a service called Amazon SageMaker. Follow the steps given below to create a Jupyter Notebook using the AWS Command Line Interface (CLI):

  1. Use the create-notebook-instance command to create a notebook instance in SageMaker:

    1. We can give any name to your Notebook instance, i.e., new-notebook-instance.

    2. We can give any valid instances as instance type, i.e. ml.t2.medium, in which we want to set up our notebook.

    3. We must create a role for SageMaker and replace <arn> in the command given below with the ARN of your role.

aws sagemaker create-notebook-instance --notebook-instance-name new-notebook-instance --instance-type ml.t2.medium --role-arn <arn>
  1. The notebook instance will take some time to start. The status of the instance that you created will change from “Pending” to “InService” once it starts. You can use the describe-notebook-instance command to check the status of the notebook instance.

aws sagemaker describe-notebook-instance --notebook-instance-name new-notebook-instance
  1. Wait until the status changes to InService before proceeding. Once the notebook instance is in the InService status, you can access the Jupyter Notebook through the AWS console by performing the following steps:

    1. Search “SageMaker” on the AWS console and click “Amazon SageMaker” from the search results.

    2. Under the “Notebook” section in the sidebar, click “Notebook instances.”

    3. Under the “Actions” column of the notebook you have created, click “Open Jupyter.” This will redirect you to Jupyter Notebook. You can create a new notebook there and train models.

Practice

Run the commands given above using this widget. Enter your AWS access_key_id and secret_access_key in the widget below before running any commands. If you don’t have these keys, follow the steps in thishttps://docs.aws.amazon.com/powershell/latest/userguide/creds-idc.html documentation to generate the keys.

Note: The IAM user whose credentials are used must have permissions to perform all the required actions.

Terminal 1
Terminal
Loading...

Congratulations! You’ve successfully created a Jupyter Notebook instance in AWS SageMaker using the CLI.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved