This repo contains the terraform template to install jupyterlab on docker in a GCP VM.
You must have the following installed on your machine:
- Terraform
- Google Cloud SDK
*Both of these are pre-installed in gcp cloud shell:
Clone this repository to your local machine by running the following command:
https://github.com/vkt1414/jupyterlabOnGcpVM.git
Change your working directory to the cloned repository:
cd jupyterlabOnGcpVM/Terraform
Edit the values in the myvars.tfvars.example
file and rename it to myvars.tfvars
file to match your desired configuration.
Run the following command to initialize Terraform:
terraform init
Run the following command to see what changes Terraform will make:
terraform plan
Run the following command to apply the changes:
terraform apply -var-file=myvars.tfvars
After running the above command, Terraform will create a virtual machine instance on GCP with JupyterLab running on Docker. To access the JupyterLab:
- Go to the Compute Engine section of your GCP console.
- Find the instance with the name you specified in your
myvars.tfvars
file. - Copy the external IP address of the instance.
- Open a web browser and go to
http://external-ip-address:8888
to access JupyterLab. - If prompted for a token, leave the field blank and click the "Log in" button.
You can now use JupyterLab on your GCP instance!
Destroying the Infrastructure:To destroy the infrastructure created by Terraform, navigate to the directory where you ran Terraform and run the following command:
terraform destroy -var-file=myvars.tfvars
This will destroy the virtual machine instance and delete all associated resources, including the disk and firewall rule. Be careful when running this command, as it cannot be undone.
Security Implications:By default, the JupyterLab instance is accessible to anyone who has the external IP address and port number. This can pose a security risk, especially if you are not using a secure connection. To improve security:
- Consider using a firewall rule to restrict access to specific IP ranges.
- Use a secure connection (HTTPS) to access the JupyterLab.
- Consider using authentication tokens for JupyterLab to restrict access to authorized users.
It is important to be aware of these security implications and take appropriate measures to secure your JupyterLab instance.