Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit

Permalink
GCP: Minor source-code cleanup and hide-output
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiddelkoop committed May 6, 2022
1 parent 417649b commit 0ed3eaa
Show file tree
Hide file tree
Showing 9 changed files with 261 additions and 128 deletions.
34 changes: 19 additions & 15 deletions content/GCP/01_intro_to_cloud_console.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"source": [
"# Introduction to the GCP Cloud Console\n",
"\n",
"```{admonition} Overview\n",
":::{admonition} Overview\n",
":class: tip\n",
"\n",
"**Teaching:** 15 min.\n",
Expand All @@ -25,7 +25,8 @@
" * Find and verify important information about your cloud environment.\n",
" * Learn important Google Cloud terminology\n",
" * Find and open the Cloud Shell\n",
"```"
"\n",
":::"
]
},
{
Expand Down Expand Up @@ -65,7 +66,7 @@
"tags": []
},
"source": [
"```{admonition} Exercise\n",
":::{admonition} Exercise\n",
":class: exercise\n",
"\n",
"Take a few moments to ask yourself the following questions:\n",
Expand All @@ -74,7 +75,8 @@
" * How do you know which account is being used?\n",
" \n",
" If you are not currently using the correct account, switch to it.\n",
"```"
"\n",
":::"
]
},
{
Expand Down Expand Up @@ -106,7 +108,7 @@
"id": "182e3a9a",
"metadata": {},
"source": [
"```{admonition} Exercise\n",
":::{admonition} Exercise\n",
":class: exercise\n",
"\n",
"Take a few moments to ask yourself the following questions:\n",
Expand All @@ -117,7 +119,8 @@
" * How do you know which project you are currently using?\n",
"\n",
"If you are currently not using the correct project for this lesson, switch to the correct one.\n",
"```"
"\n",
":::"
]
},
{
Expand Down Expand Up @@ -152,14 +155,15 @@
"source": [
"*Instructor: place instructions on the screen*\n",
"\n",
"```{admonition} Exercise 1\n",
":::{admonition} Exercise 1\n",
":class: exercise\n",
"\n",
"Take a few moments to navigate to a few key products and enable them.\n",
" * Navigate to \"Cloud Storage\" under the \"Storage\" product group.\n",
" * You may need to \"Enable\" this product first by clicking on the \"Enable\" button on the \"Cloud Storage API\" page. This will only need to be done once per project.\n",
" * Navigate to the \"Compute Engine\" product under the \"Compute\" product group and enable the product as well.\n",
"```"
"\n",
":::"
]
},
{
Expand Down Expand Up @@ -247,15 +251,15 @@
"tags": []
},
"source": [
"```{admonition} Exercise\n",
":::{admonition} Exercise\n",
":class: exercise\n",
"\n",
"Before we move on, do the following:\n",
"* Double check that you are in the correct account and project that you will be using for this lesson.\n",
"* Take a moment to reflect on the \"Who, Where, and What\" of the cloud. \n",
" * What is your Who, Where, and What?\n",
" * Why is this important?\n",
"```"
" * Double check that you are in the correct account and project that you will be using for this lesson.\n",
" * Take a moment to reflect on the \"Who, Where, and What\" of the cloud. \n",
" * What is your Who, Where, and What?\n",
" * Why is this important?\n",
":::"
]
}
],
Expand All @@ -275,7 +279,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.9.2"
}
},
"nbformat": 4,
Expand Down
22 changes: 13 additions & 9 deletions content/GCP/02_intro_to_compute.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"source": [
"# Introduction to Cloud Compute (Google Compute Engine)\n",
"\n",
"```{admonition} Overview\n",
":::{admonition} Overview\n",
":class: tip\n",
"\n",
"**Teaching:** 30 min.\n",
Expand All @@ -26,7 +26,8 @@
" * Use the cost estimator for Google Compute Engine.\n",
" * Learn what a service account is and how they are used.\n",
" * Learn how to connect to a virtual machine using ssh in the Cloud Shell with the web console.\n",
"```"
"\n",
":::"
]
},
{
Expand Down Expand Up @@ -84,13 +85,14 @@
"id": "6737d8ba-e6d4-437f-a652-5d9d4477b34c",
"metadata": {},
"source": [
"```{admonition} Exercise\n",
":::{admonition} Exercise\n",
":class: exercise\n",
"\n",
" * Find the most expensive VM. **DO NOT actually create!**\n",
" * Find the least expensive VM.\n",
" * Select `e2-medium`\n",
"```"
"\n",
":::"
]
},
{
Expand Down Expand Up @@ -281,11 +283,12 @@
"source": [
"## Delete the VM Instance\n",
"\n",
"```{admonition} Danger\n",
":::{admonition} Danger\n",
":class: danger\n",
"\n",
"This will destroy the VM instance and and ALL the data in it! You cannot undelete an instance!\n",
"```"
"\n",
":::"
]
},
{
Expand All @@ -297,12 +300,13 @@
"source": [
"Now that we have made that clear, we will now complete the resource life-cycle by deleting the *VM Instance* we just created. First, try to do this on your own.\n",
"\n",
"```{admonition} Exercise\n",
":::{admonition} Exercise\n",
":class: exercise\n",
"\n",
" * Try to delete the ***VM instance*** on your own\n",
" * Try to follow the process we just learned (hint: *track* and *list*)\n",
"```"
"\n",
":::"
]
},
{
Expand Down Expand Up @@ -353,7 +357,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.9.2"
}
},
"nbformat": 4,
Expand Down
31 changes: 21 additions & 10 deletions content/GCP/03_intro_to_cloud_storage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"source": [
"# Introduction to Google Cloud Storage\n",
"\n",
"```{admonition} Overview\n",
":::{admonition} Overview\n",
":class: tip\n",
"\n",
"**Teaching:** 20 min\n",
Expand All @@ -24,7 +24,8 @@
" * Recognize that resources have a \"location\"\n",
" * Recognize danger of public access\n",
" * De-allocate Google Cloud Storage storage\n",
"```"
"\n",
":::"
]
},
{
Expand Down Expand Up @@ -160,28 +161,38 @@
"source": [
"## Delete the Storage\n",
"\n",
"```{admonition} Danger\n",
":::{admonition} Danger\n",
":class: danger\n",
"\n",
"This will destroy the storage *Bucket* and and ALL the data in it! You cannot undelete a Bucket!\n",
"```"
"\n",
":::"
]
},
{
"cell_type": "markdown",
"id": "59005efb-2aad-4dcd-ac7b-f153f4295abc",
"id": "619c0350-6058-4162-9b4b-3a6aaf96041f",
"metadata": {
"tags": []
},
"source": [
"We will now complete the resource life-cycle by deleting the bucket we just created. Think about the process we did for creating the bucket and follow a similar one.\n",
"\n",
"```{admonition} Exercise\n",
"We will now complete the resource life-cycle by deleting the bucket we just created. Think about the process we did for creating the bucket and follow a similar one."
]
},
{
"cell_type": "markdown",
"id": "9a6973f1-07f4-4c72-bd92-1a6b9741eed9",
"metadata": {
"tags": []
},
"source": [
":::{admonition} Exercise\n",
":class: exercise\n",
"\n",
" * Try to delete the storage bucket on your own\n",
" * Verify that the storage bucket has been deleted.\n",
"```"
"\n",
":::"
]
},
{
Expand Down Expand Up @@ -248,7 +259,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.9.2"
}
},
"nbformat": 4,
Expand Down
39 changes: 24 additions & 15 deletions content/GCP/04_intro_to_cli.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"source": [
"# Introduction to the Command Line Interface (CLI)\n",
"\n",
"```{admonition} Overview\n",
":::{admonition} Overview\n",
":class: tip\n",
"\n",
"**Teaching:** 20 min\n",
Expand All @@ -24,7 +24,8 @@
" * Verify basic settings.\n",
" * Use environment variables for configuration.\n",
" * Understand the importance of using variables reproducibility and automation.\n",
"``` "
"\n",
":::"
]
},
{
Expand Down Expand Up @@ -61,11 +62,11 @@
"id": "8eb44568-1108-4963-aebf-7f6b98ddaffc",
"metadata": {},
"source": [
"```{admonition} Tip\n",
":class: tip\n",
":::{tip}\n",
"\n",
"You can access the cloud shell from your laptop via `gcloud cloud-shell ssh` if you have the [Google Cloud SDK installed](https://cloud.google.com/sdk/docs/install). Installing the Google Cloud SDK will also allow you to run `gcloud` and `gsutil` commands directly from your laptop, workstation, or cluster. *Pro-tip, you cannot use a service account to access the cloud shell.*\n",
"```"
"\n",
":::"
]
},
{
Expand Down Expand Up @@ -197,7 +198,7 @@
},
{
"cell_type": "markdown",
"id": "598b5d12-9bea-49de-a772-4113727e0859",
"id": "fe9c7d78-edbe-4c84-81d1-a83c20773181",
"metadata": {},
"source": [
"### Environment Variables\n",
Expand All @@ -206,13 +207,19 @@
"\n",
"*To make the point even clearer, we use environment variables in the Cloud Essentials notebooks instead of hard coding them, which makes it easy for anyone to run, use, and edit and thus collaborate and contribute to them!*\n",
"\n",
"We now demonstrate the basic use environment variables. As a reminder, environment variables are used to store configuration information that can be easily passed between programs and programming languages.\n",
"\n",
"```{admonition} Advanced Tip\n",
":class: tip\n",
"We now demonstrate the basic use environment variables. As a reminder, environment variables are used to store configuration information that can be easily passed between programs and programming languages."
]
},
{
"cell_type": "markdown",
"id": "b843dba2-3276-4e2e-9619-8598b2718e4d",
"metadata": {},
"source": [
":::{tip}\n",
"\n",
"Although we do not always need to, we should always enclose shell variables in double quotes and enclose the variable name in curly braces (funny things may happen otherwise) when writing scripts, for example `\"${TEST}\"`. In most cases it is easier to do this every time than try to figure out when it is possible to use the short form. We only use the short form (`$TEST`) when it is used frequently and known to always work (most cases here), in our case it is `$PROJECT` and `$BUCKET`. When in doubt, use the explicit form.\n",
"```"
"\n",
":::"
]
},
{
Expand Down Expand Up @@ -413,15 +420,16 @@
"source": [
"Note the \"Your active configuration is: ...\" line is a \"warning\" and not actually part of the output of the program.\n",
"\n",
"````{admonition} Advanced Tip\n",
"::::{admonition} Advanced Tip\n",
":class: tip\n",
"\n",
"You can also use \n",
"```\n",
"PROJECT=$(gcloud config list --format='value(core.project)')\n",
"```\n",
"to get the project id without the warning.\n",
"````"
"\n",
"::::"
]
},
{
Expand Down Expand Up @@ -462,12 +470,13 @@
"id": "270e0abb-d5e9-476a-af91-060cc0ea0349",
"metadata": {},
"source": [
"```{admonition} Exercise\n",
":::{admonition} Exercise\n",
":class: exercise\n",
"\n",
" * What command shows the account? (hint: we used it already)\n",
" * Set the `ACCOUNT` environment variable with the correct value. (hint: be careful with punctuation (single and double quotes) and matching brackets and punctuation)\n",
"```"
"\n",
":::"
]
},
{
Expand Down
Loading

0 comments on commit 0ed3eaa

Please sign in to comment.