{"id":14957750,"url":"https://github.com/yousafkhamza/terraform-sagemaker-notebook","last_synced_at":"2025-07-21T10:32:30.532Z","repository":{"id":195965570,"uuid":"404299795","full_name":"yousafkhamza/terraform-sagemaker-notebook","owner":"yousafkhamza","description":"It's just a terraform code for build a sagemaker notebook instance infrastructure to an AWS account. The code created a sagemaker notebook instance and needful things with a click. Maybe it's helpful to ML/DE Engineers.","archived":false,"fork":false,"pushed_at":"2021-09-10T08:15:49.000Z","size":14,"stargazers_count":5,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-07T00:27:13.569Z","etag":null,"topics":["aws","bashscript","datascientist","hashicorp-terraform","jupyter-notebook","machine-learning","notebook","sagemaker"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yousafkhamza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-09-08T10:09:48.000Z","updated_at":"2023-01-31T11:41:19.000Z","dependencies_parsed_at":"2023-09-20T20:13:41.117Z","dependency_job_id":null,"html_url":"https://github.com/yousafkhamza/terraform-sagemaker-notebook","commit_stats":null,"previous_names":["yousafkhamza/terraform-sagemaker-notebook"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yousafkhamza/terraform-sagemaker-notebook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fterraform-sagemaker-notebook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fterraform-sagemaker-notebook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fterraform-sagemaker-notebook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fterraform-sagemaker-notebook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yousafkhamza","download_url":"https://codeload.github.com/yousafkhamza/terraform-sagemaker-notebook/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fterraform-sagemaker-notebook/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266285441,"owners_count":23905348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","bashscript","datascientist","hashicorp-terraform","jupyter-notebook","machine-learning","notebook","sagemaker"],"created_at":"2024-09-24T13:15:31.054Z","updated_at":"2025-07-21T10:32:30.510Z","avatar_url":"https://github.com/yousafkhamza.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SageMaker Jupyter-Notebook Instance (Terraform)\n[![Build](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger)\n\n---\n## Description\nIt's a terraform code to build the infrastructure of AWS SageMaker Notebook Instance. Maybe, it's helpful to Machine Learning Engineers and Data Engineers to build their projects via this notebook.\n\n----\n## Feature\n- Easy to create a sagemaker notebook instance \n- It automatically fetches Default VPC and subnet (if you would like to change Default VPC to custom VPC. Therefore, you can change that VPC id on vpc,tf file.)\n- IAM Role and Policy created and attached to that notebook.\n- A sample security group created for the same\n- You can change the notebook name, instance type, and volume size as a variable (either it chooses the default value)\n\n----\n## Pre-Requests\n```\n-RedHat-\nyum install git -y\n\n-Debian-\nsudo apt install git -y\n```\n- It needs to install terraform (use the below terraform git for installation)\n```\ngit clone https://github.com/yousafkhamza/Terraform_installation.git\ncd Terraform_installation\nchmod +x terraform.sh\n./ terraform.sh\n```\n- I just used the same with the IAM role attached EC2 instance as an infrastructure deployment machine. Therefore, if you're using your local machine please create an IAM user and configure the same in \"_provider.tf_\".\n\u003e Using with IAM role instance be like\n```\nprovider \"aws\" {\n  region = var.region\n}\n```\n\u003e LocalMachine be like\n```\nprovider \"aws\" {\n  region     = var.region\n  access_key = var.access_key            \u003c----------- Please create the same in variable.tf and mention the key in terraform.tfvars\n  secret_key = var.secret_key            \u003c----------- Please create the same in variable.tf and mention the key in terraform.tfvars\n}\n```\n\n\u003e Please reconfigure the file when after your cloned this repository. then you may use the below command for terraform initialization\n```\nterraform init\n```\n- Basic Knowledge of terraforming\n\n---\n## How to Get\n```\ngit clone https://github.com/yousafkhamza/terraform-sagemaker-notebook.git\ncd terraform-sagemaker-notebook\n```\n\n---\n## Changable variables\n_terraform.tfvars (Do you need to change any size or name please be change under the values)_\n```\nregion = \"ap-south-1\"                    \u003c---------------- Please enter your region as you wish\ninstance_type = \"ml.t2.medium\"           \u003c---------------- Please enter your instance type as you wish\nnotebook_name = \"my-notebook\"            \u003c---------------- Please enter your notebook name as you wish\nvolume_size = \"6\"                        \u003c---------------- Please enter your instance volume size as you wish.\n```\n_vpc.tf (Do you want swiich your custome VPC ID please be change the values under this file)_\n```\ndata \"aws_vpc\" \"default\" {\n    default = true\n#   id = \"vpc-04218dfaf2b5c7216\"         \u003c--------------- Please comment the above default and uncomment this line and change your vpc id as you wish.\n} \n```\n\n---\n## Execution\n_Exicute the terraform code on your machine with terraform and aws integrated. if you're not configured the same please check the pre-request section and configure the same then please follow the below_\n```\nterraform init           \u003c------------------- Please configure aws provider (check the pre-requests)\nterraform plan\nterraform apply\n```\n_Also, if you would like to remove the created infrastructure please use the below command to destroy the same_\n```\nterraform destroy\n```\n_Referance URL:: https://www.terraform.io/docs/cli/run/index.html_\n\n----\n## Architecture\n![alt_txt](https://i.ibb.co/1dpM9Xg/tf.jpg)\n\n----\n## Output Be Like\n### Screenshots\n_Output_\n![alt_txt](https://i.ibb.co/XVPHycH/output.png)\n_Notebook instance_\n![alt_txt](https://i.ibb.co/t4VY1MC/Screenshot-1.png)\n\n\n### Output in lines\n```\naws_iam_role.sagemaker_role: Creating...\naws_security_group.sg-sgmkr: Creating...\naws_security_group.sg-sgmkr: Creation complete after 1s [id=sg-0c50309cfaff067d7]\naws_iam_role.sagemaker_role: Creation complete after 3s [id=sagemaker_role]\naws_sagemaker_notebook_instance.sgmkr: Creating...\naws_iam_instance_profile.sagemaker_profile: Creating...\naws_iam_role_policy.sagemaker_policy: Creating...\naws_iam_role_policy.sagemaker_policy: Creation complete after 2s [id=sagemaker_role:sagemaker]\naws_iam_instance_profile.sagemaker_profile: Creation complete after 2s [id=sagemaker_profile]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [10s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [20s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [30s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [40s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [50s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [1m0s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [1m10s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [1m20s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [1m30s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [1m40s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [1m50s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [2m0s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [2m10s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [2m20s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [2m30s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [2m40s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [2m50s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [3m0s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Still creating... [3m10s elapsed]\naws_sagemaker_notebook_instance.sgmkr: Creation complete after 3m14s [id=my-notebook]\n\nApply complete! Resources: 5 added, 0 changed, 0 destroyed.\n\nOutputs:\n\naws_sagemaker_notebook_url = \"my-notebook-qje6.notebook.ap-south-1.sagemaker.aws\"           \u003c----------- Notebook URL.\n```\n\n----\n## Behind the Code\n_sagemaker creation code (Please go and check other codes in GitHub...)\n```\nresource \"aws_sagemaker_notebook_instance\" \"sgmkr\" {\n  name          = var.notebook_name\n  role_arn      = aws_iam_role.sagemaker_role.arn\n  instance_type = var.instance_type\n  security_groups = [aws_security_group.sg-sgmkr.id]\n  subnet_id = tolist(data.aws_subnet_ids.my_vpc.ids)[1]\n  volume_size = var.volume_size\n\n  tags = {\n    Name = \"SageMaker\"\n  }\n}\n```\n\n----\n## Conclusio\nIt's just a terraform code for build a sagemaker notebook instance infrastructure to an AWS account. The code created a sagemaker notebook instance and needful things with a click. Maybe it's helpful to ML/DE Engineers. \n### ⚙️ Connect with Me \n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"mailto:yousaf.k.hamza@gmail.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/Gmail-D14836?style=for-the-badge\u0026logo=gmail\u0026logoColor=white\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://www.linkedin.com/in/yousafkhamza\"\u003e\u003cimg src=\"https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\"/\u003e\u003c/a\u003e \n\u003ca href=\"https://www.instagram.com/yousafkhamza\"\u003e\u003cimg src=\"https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge\u0026logo=instagram\u0026logoColor=white\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://wa.me/%2B917736720639?text=This%20message%20from%20GitHub.\"\u003e\u003cimg src=\"https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge\u0026logo=whatsapp\u0026logoColor=white\"/\u003e\u003c/a\u003e\u003cbr /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyousafkhamza%2Fterraform-sagemaker-notebook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyousafkhamza%2Fterraform-sagemaker-notebook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyousafkhamza%2Fterraform-sagemaker-notebook/lists"}