Showing posts with label Role. Show all posts
Showing posts with label Role. Show all posts

Service Accounts and Roles: Fundamentals

Service accounts are a special type of Google account that grant permissions to virtual machines instead of end users. Service accounts are primarily used to ensure safe, managed connections to APIs and Google Cloud services. Granting access to trusted connections and rejecting malicious ones is a must-have security feature for any Google Cloud project. In this lab, you get hands-on practice with the ins and outs of service accounts.



Create and manage service accounts.

Create a virtual machine and associate it with a service account.

Use client libraries to access BigQuery from a service account.

Run a query on a BigQuery public dataset from a Compute Engine instance.





What are service accounts?
A service account is a special Google account that belongs to your application or a virtual machine (VM) instead of an individual end user. Your application uses the service account to call the Google API of a service, so that the users aren't directly involved.

For example, a Compute Engine VM may run as a service account, and that account can be given permissions to access the resources it needs. This way the service account is the identity of the service, and the service account's permissions control which resources the service can access.

A service account is identified by its email address, which is unique to the account.

Types of service accounts
User-managed service accounts
When you create a new Cloud project using Google Cloud console and if Compute Engine API is enabled for your project, a Compute Engine Service account is created for you by default. It is identifiable using the email:

PROJECT_NUMBER-compute@developer.gserviceaccount.com
If your project contains an App Engine application, the default App Engine service account is created in your project by default. It is identifiable using the email:

PROJECT_ID@appspot.gserviceaccount.com
Google-managed service accounts
In addition to the user-managed service accounts, you might see some additional service accounts in your project’s IAM policy or in the console. These service accounts are created and owned by Google. These accounts represent different Google services and each account is automatically granted IAM roles to access your Google Cloud project.

Google APIs service account
An example of a Google-managed service account is a Google API service account identifiable using the email:

PROJECT_NUMBER@cloudservices.gserviceaccount.com
This service account is designed specifically to run internal Google processes on your behalf and is not listed in the Service Accounts section of the console. By default, the account is automatically granted the project editor role on the project and is listed in the IAM section of the console. This service account is deleted only when the project is deleted.

Note: Google services rely on the account having access to your project, so you should not remove or change the service account’s role on your project.
Task 1. Creating and managing service accounts
When you create a new Cloud project, Google Cloud automatically creates one Compute Engine service account and one App Engine service account under that project. You can create up to 98 additional service accounts to your project to control access to your resources.

Creating a service account
Creating a service account is similar to adding a member to your project, but the service account belongs to your applications rather than an individual end user.



















student_04_717d1aa28d01@cloudshell:~ (qwiklabs-gcp-03-f3d72bb5968f)$ history
    1  gcloud compute ssh source-instance --zone=$ZONE
    2  gcloud auth list
    3  gauth config list
    4  gcloud config list
    5  PROJECT_NUMBER-compute@developer.gserviceaccount.com
    6   
    7   
    8  gcloud config set compute/region us-west4
    9  gcloud config list project
   10  gcloud iam service-accounts create my-sa-123 --display-name "my service account"
   11  gcloud projects add-iam-policy-binding $DEVSHELL_PROJECT_ID     --member serviceAccount:my-sa-123@$DEVSHELL_PROJECT_ID.iam.gserviceaccount.com --role roles/editor


Linux bigquery-instance 5.10.0-23-cloud-amd64 #1 SMP Debian 5.10.179-1 (2023-05-12) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Creating directory '/home/student-04-717d1aa28d01'.
student-04-717d1aa28d01@bigquery-instance:~$ sudo apt-get update
Hit:1 https://deb.debian.org/debian bullseye InRelease
Get:2 https://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:3 https://packages.cloud.google.com/apt google-compute-engine-bullseye-stable InRelease [5146 B]
Get:4 https://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Get:5 https://deb.debian.org/debian bullseye-backports InRelease [49.0 kB]
Get:6 https://packages.cloud.google.com/apt cloud-sdk-bullseye InRelease [6406 B]
Get:7 https://deb.debian.org/debian-security bullseye-security/main Sources [204 kB]
Get:8 https://deb.debian.org/debian-security bullseye-security/main amd64 Packages [252 kB]
Get:9 https://deb.debian.org/debian-security bullseye-security/main Translation-en [164 kB]
Get:10 https://packages.cloud.google.com/apt google-compute-engine-bullseye-stable/main amd64 Packages [1942 B]
Get:11 https://deb.debian.org/debian bullseye-updates/main Sources.diff/Index [19.6 kB]
Get:12 https://deb.debian.org/debian bullseye-updates/main amd64 Packages.diff/Index [19.6 kB]
Get:13 https://deb.debian.org/debian bullseye-updates/main Translation-en.diff/Index [8361 B]
Get:14 https://deb.debian.org/debian bullseye-updates/main Sources T-2023-07-31-2005.11-F-2023-07-31-2005.11.pdiff [1673 B]
Get:15 https://deb.debian.org/debian bullseye-updates/main amd64 Packages T-2023-07-31-2005.11-F-2023-07-31-2005.11.pdiff [3382 B]
Get:14 https://deb.debian.org/debian bullseye-updates/main Sources T-2023-07-31-2005.11-F-2023-07-31-2005.11.pdiff [1673 B]
Get:15 https://deb.debian.org/debian bullseye-updates/main amd64 Packages T-2023-07-31-2005.11-F-2023-07-31-2005.11.pdiff [3382 B]
Get:16 https://deb.debian.org/debian bullseye-updates/main Translation-en T-2023-07-31-2005.11-F-2023-07-31-2005.11.pdiff [2273 B]
Get:16 https://deb.debian.org/debian bullseye-updates/main Translation-en T-2023-07-31-2005.11-F-2023-07-31-2005.11.pdiff [2273 B]
Get:17 https://deb.debian.org/debian bullseye-backports/main Sources.diff/Index [63.3 kB]
Get:18 https://deb.debian.org/debian bullseye-backports/main amd64 Packages.diff/Index [63.3 kB]
Get:19 https://deb.debian.org/debian bullseye-backports/main Translation-en.diff/Index [63.3 kB]
Get:20 https://deb.debian.org/debian bullseye-backports/main Sources T-2023-07-18-0816.49-F-2023-07-18-0209.04.pdiff [28.3 kB]
Get:20 https://deb.debian.org/debian bullseye-backports/main Sources T-2023-07-18-0816.49-F-2023-07-18-0209.04.pdiff [28.3 kB]
Get:21 https://deb.debian.org/debian bullseye-backports/main amd64 Packages T-2023-07-18-1410.09-F-2023-07-18-0209.04.pdiff [20.1 kB]
Get:21 https://deb.debian.org/debian bullseye-backports/main amd64 Packages T-2023-07-18-1410.09-F-2023-07-18-0209.04.pdiff [20.1 kB]
Get:22 https://deb.debian.org/debian bullseye-backports/main Translation-en T-2023-07-18-2011.14-F-2023-07-18-0209.04.pdiff [5503 B]
Get:23 https://packages.cloud.google.com/apt cloud-sdk-bullseye/main amd64 Packages [339 kB]
Get:22 https://deb.debian.org/debian bullseye-backports/main Translation-en T-2023-07-18-2011.14-F-2023-07-18-0209.04.pdiff [5503 B]
Fetched 1413 kB in 1s (1222 kB/s)                                                                          
Reading package lists... Done
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ sudo apt-get install -y git python3-pip
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu build-essential bzip2 cpp cpp-10 dpkg-dev fakeroot
  fontconfig-config fonts-dejavu-core g++ g++-10 gcc gcc-10 git-man javascript-common libalgorithm-diff-perl
  libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan6 libatomic1 libbinutils libc-dev-bin
  libc-devtools libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libdeflate0 libdpkg-perl liberror-perl
  libexpat1-dev libfakeroot libfile-fcntllock-perl libfontconfig1 libgcc-10-dev libgd3 libgdbm-compat4
  libgomp1 libisl23 libitm1 libjbig0 libjpeg62-turbo libjs-jquery libjs-sphinxdoc libjs-underscore
  liblocale-gettext-perl liblsan0 libmpc3 libmpfr6 libnsl-dev libperl5.32 libpython3-dev libpython3.9-dev
  libquadmath0 libstdc++-10-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp6 libx11-6 libx11-data
  libxau6 libxcb1 libxdmcp6 libxpm4 linux-libc-dev make manpages-dev patch perl perl-modules-5.32
  python-pip-whl python3-dev python3-distutils python3-lib2to3 python3-setuptools python3-wheel python3.9-dev
  zlib1g-dev
Suggested packages:
  binutils-doc bzip2-doc cpp-doc gcc-10-locales debian-keyring g++-multilib g++-10-multilib gcc-10-doc
  gcc-multilib autoconf automake libtool flex bison gdb gcc-doc gcc-10-multilib git-daemon-run
  | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn apache2
  | lighttpd | httpd glibc-doc bzr libgd-tools libstdc++-10-doc make-doc ed diffutils-doc perl-doc
  libterm-readline-gnu-perl | libterm-readline-perl-perl libtap-harness-archive-perl python-setuptools-doc
The following NEW packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu build-essential bzip2 cpp cpp-10 dpkg-dev fakeroot
  fontconfig-config fonts-dejavu-core g++ g++-10 gcc gcc-10 git git-man javascript-common
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan6 libatomic1 libbinutils
  libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libdeflate0 libdpkg-perl
  liberror-perl libexpat1-dev libfakeroot libfile-fcntllock-perl libfontconfig1 libgcc-10-dev libgd3
  libgdbm-compat4 libgomp1 libisl23 libitm1 libjbig0 libjpeg62-turbo libjs-jquery libjs-sphinxdoc
  libjs-underscore liblocale-gettext-perl liblsan0 libmpc3 libmpfr6 libnsl-dev libperl5.32 libpython3-dev
  libpython3.9-dev libquadmath0 libstdc++-10-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp6 libx11-6
  libx11-data libxau6 libxcb1 libxdmcp6 libxpm4 linux-libc-dev make manpages-dev patch perl perl-modules-5.32
  python-pip-whl python3-dev python3-distutils python3-lib2to3 python3-pip python3-setuptools python3-wheel
  python3.9-dev zlib1g-dev
0 upgraded, 85 newly installed, 0 to remove and 11 not upgraded.
Need to get 91.4 MB of archives.
After this operation, 358 MB of additional disk space will be used.
Get:1 https://deb.debian.org/debian bullseye/main amd64 perl-modules-5.32 all 5.32.1-4+deb11u2 [2823 kB]
Get:2 https://deb.debian.org/debian bullseye/main amd64 libgdbm-compat4 amd64 1.19-2 [44.7 kB]
Get:3 https://deb.debian.org/debian bullseye/main amd64 libperl5.32 amd64 5.32.1-4+deb11u2 [4106 kB]
Get:4 https://deb.debian.org/debian bullseye/main amd64 perl amd64 5.32.1-4+deb11u2 [293 kB]
Get:5 https://deb.debian.org/debian bullseye/main amd64 liblocale-gettext-perl amd64 1.07-4+b1 [19.0 kB]
Get:6 https://deb.debian.org/debian bullseye/main amd64 bzip2 amd64 1.0.8-4 [49.3 kB]
Get:7 https://deb.debian.org/debian bullseye/main amd64 binutils-common amd64 2.35.2-2 [2220 kB]
Get:8 https://deb.debian.org/debian bullseye/main amd64 libbinutils amd64 2.35.2-2 [570 kB]
Get:9 https://deb.debian.org/debian bullseye/main amd64 libctf-nobfd0 amd64 2.35.2-2 [110 kB]
Get:10 https://deb.debian.org/debian bullseye/main amd64 libctf0 amd64 2.35.2-2 [53.2 kB]
Get:11 https://deb.debian.org/debian bullseye/main amd64 binutils-x86-64-linux-gnu amd64 2.35.2-2 [1809 kB]
Get:12 https://deb.debian.org/debian bullseye/main amd64 binutils amd64 2.35.2-2 [61.2 kB]
Get:13 https://deb.debian.org/debian bullseye/main amd64 libc-dev-bin amd64 2.31-13+deb11u6 [276 kB]
Get:14 https://deb.debian.org/debian-security bullseye-security/main amd64 linux-libc-dev amd64 5.10.179-3 [1619 kB]
Get:15 https://deb.debian.org/debian bullseye/main amd64 libcrypt-dev amd64 1:4.4.18-4 [104 kB]
Get:16 https://deb.debian.org/debian bullseye/main amd64 libtirpc-dev amd64 1.3.1-1+deb11u1 [191 kB]
Get:17 https://deb.debian.org/debian bullseye/main amd64 libnsl-dev amd64 1.3.0-2 [66.4 kB]
Get:18 https://deb.debian.org/debian bullseye/main amd64 libc6-dev amd64 2.31-13+deb11u6 [2360 kB]
Get:19 https://deb.debian.org/debian bullseye/main amd64 libisl23 amd64 0.23-1 [676 kB]
Get:20 https://deb.debian.org/debian bullseye/main amd64 libmpfr6 amd64 4.1.0-3 [2012 kB]
Get:21 https://deb.debian.org/debian bullseye/main amd64 libmpc3 amd64 1.2.0-1 [45.0 kB]
Get:22 https://deb.debian.org/debian bullseye/main amd64 cpp-10 amd64 10.2.1-6 [8528 kB]
Get:23 https://deb.debian.org/debian bullseye/main amd64 cpp amd64 4:10.2.1-1 [19.7 kB]
Get:24 https://deb.debian.org/debian bullseye/main amd64 libcc1-0 amd64 10.2.1-6 [47.0 kB]
Get:25 https://deb.debian.org/debian bullseye/main amd64 libgomp1 amd64 10.2.1-6 [99.9 kB]
Get:26 https://deb.debian.org/debian bullseye/main amd64 libitm1 amd64 10.2.1-6 [25.8 kB]
Get:27 https://deb.debian.org/debian bullseye/main amd64 libatomic1 amd64 10.2.1-6 [9008 B]
Get:28 https://deb.debian.org/debian bullseye/main amd64 libasan6 amd64 10.2.1-6 [2065 kB]
Get:29 https://deb.debian.org/debian bullseye/main amd64 liblsan0 amd64 10.2.1-6 [828 kB]
Get:30 https://deb.debian.org/debian bullseye/main amd64 libtsan0 amd64 10.2.1-6 [2000 kB]
Get:31 https://deb.debian.org/debian bullseye/main amd64 libubsan1 amd64 10.2.1-6 [777 kB]
Get:32 https://deb.debian.org/debian bullseye/main amd64 libquadmath0 amd64 10.2.1-6 [145 kB]
Get:33 https://deb.debian.org/debian bullseye/main amd64 libgcc-10-dev amd64 10.2.1-6 [2328 kB]
Get:34 https://deb.debian.org/debian bullseye/main amd64 gcc-10 amd64 10.2.1-6 [17.0 MB]
Get:35 https://deb.debian.org/debian bullseye/main amd64 gcc amd64 4:10.2.1-1 [5192 B]
Get:36 https://deb.debian.org/debian bullseye/main amd64 libstdc++-10-dev amd64 10.2.1-6 [1741 kB]
Get:37 https://deb.debian.org/debian bullseye/main amd64 g++-10 amd64 10.2.1-6 [9380 kB]
Get:38 https://deb.debian.org/debian bullseye/main amd64 g++ amd64 4:10.2.1-1 [1644 B]
Get:39 https://deb.debian.org/debian bullseye/main amd64 make amd64 4.3-4.1 [396 kB]
Get:40 https://deb.debian.org/debian bullseye/main amd64 libdpkg-perl all 1.20.12 [1551 kB]
Get:41 https://deb.debian.org/debian bullseye/main amd64 patch amd64 2.7.6-7 [128 kB]
Get:42 https://deb.debian.org/debian bullseye/main amd64 dpkg-dev all 1.20.12 [2312 kB]
Get:43 https://deb.debian.org/debian bullseye/main amd64 build-essential amd64 12.9 [7704 B]
Get:44 https://deb.debian.org/debian bullseye/main amd64 libfakeroot amd64 1.25.3-1.1 [47.0 kB]
Get:45 https://deb.debian.org/debian bullseye/main amd64 fakeroot amd64 1.25.3-1.1 [87.0 kB]
Get:46 https://deb.debian.org/debian bullseye/main amd64 fonts-dejavu-core all 2.37-2 [1069 kB]
Get:47 https://deb.debian.org/debian bullseye/main amd64 fontconfig-config all 2.13.1-4.2 [281 kB]
Get:48 https://deb.debian.org/debian bullseye/main amd64 liberror-perl all 0.17029-1 [31.0 kB]
Get:49 https://deb.debian.org/debian bullseye/main amd64 git-man all 1:2.30.2-1+deb11u2 [1828 kB]
Get:50 https://deb.debian.org/debian bullseye/main amd64 git amd64 1:2.30.2-1+deb11u2 [5518 kB]
Get:51 https://deb.debian.org/debian bullseye/main amd64 javascript-common all 11+nmu1 [6260 B]
Get:52 https://deb.debian.org/debian bullseye/main amd64 libalgorithm-diff-perl all 1.201-1 [43.3 kB]
Get:53 https://deb.debian.org/debian bullseye/main amd64 libalgorithm-diff-xs-perl amd64 0.04-6+b1 [12.0 kB]
Get:54 https://deb.debian.org/debian bullseye/main amd64 libalgorithm-merge-perl all 0.08-3 [12.7 kB]
Get:55 https://deb.debian.org/debian bullseye/main amd64 libfontconfig1 amd64 2.13.1-4.2 [347 kB]
Get:56 https://deb.debian.org/debian bullseye/main amd64 libjpeg62-turbo amd64 1:2.0.6-4 [151 kB]
Get:57 https://deb.debian.org/debian bullseye/main amd64 libdeflate0 amd64 1.7-1 [53.1 kB]
Get:58 https://deb.debian.org/debian bullseye/main amd64 libjbig0 amd64 2.1-3.1+b2 [31.0 kB]
Get:59 https://deb.debian.org/debian-security bullseye-security/main amd64 libwebp6 amd64 0.6.1-2.1+deb11u1 [258 kB]
Get:60 https://deb.debian.org/debian bullseye/main amd64 libtiff5 amd64 4.2.0-1+deb11u4 [290 kB]
Get:61 https://deb.debian.org/debian bullseye/main amd64 libxau6 amd64 1:1.0.9-1 [19.7 kB]
Get:62 https://deb.debian.org/debian bullseye/main amd64 libxdmcp6 amd64 1:1.1.2-3 [26.3 kB]
Get:63 https://deb.debian.org/debian bullseye/main amd64 libxcb1 amd64 1.14-3 [140 kB]
Get:64 https://deb.debian.org/debian-security bullseye-security/main amd64 libx11-data all 2:1.7.2-1+deb11u1 [311 kB]
Get:65 https://deb.debian.org/debian-security bullseye-security/main amd64 libx11-6 amd64 2:1.7.2-1+deb11u1 [772 kB]
Get:66 https://deb.debian.org/debian bullseye/main amd64 libxpm4 amd64 1:3.5.12-1.1~deb11u1 [49.6 kB]
Get:67 https://deb.debian.org/debian bullseye/main amd64 libgd3 amd64 2.3.0-2 [137 kB]
Get:68 https://deb.debian.org/debian bullseye/main amd64 libc-devtools amd64 2.31-13+deb11u6 [246 kB]
Get:69 https://deb.debian.org/debian bullseye/main amd64 libexpat1-dev amd64 2.2.10-2+deb11u5 [141 kB]
Get:70 https://deb.debian.org/debian bullseye/main amd64 libfile-fcntllock-perl amd64 0.22-3+b7 [35.5 kB]
Get:71 https://deb.debian.org/debian bullseye/main amd64 libjs-jquery all 3.5.1+dfsg+~3.5.5-7 [315 kB]
Get:72 https://deb.debian.org/debian bullseye/main amd64 libjs-underscore all 1.9.1~dfsg-3 [100 kB]
Get:73 https://deb.debian.org/debian bullseye/main amd64 libjs-sphinxdoc all 3.4.3-2 [127 kB]
Get:74 https://deb.debian.org/debian bullseye/main amd64 libpython3.9-dev amd64 3.9.2-1 [4028 kB]
Get:75 https://deb.debian.org/debian bullseye/main amd64 libpython3-dev amd64 3.9.2-3 [21.7 kB]
Get:76 https://deb.debian.org/debian bullseye/main amd64 manpages-dev all 5.10-1 [2309 kB]
Get:77 https://deb.debian.org/debian bullseye/main amd64 python-pip-whl all 20.3.4-4+deb11u1 [1948 kB]
Get:78 https://deb.debian.org/debian bullseye/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-2+deb11u2 [191 kB]
Get:79 https://deb.debian.org/debian bullseye/main amd64 python3.9-dev amd64 3.9.2-1 [515 kB]
Get:80 https://deb.debian.org/debian bullseye/main amd64 python3-lib2to3 all 3.9.2-1 [77.8 kB]
Get:81 https://deb.debian.org/debian bullseye/main amd64 python3-distutils all 3.9.2-1 [143 kB]
Get:82 https://deb.debian.org/debian bullseye/main amd64 python3-dev amd64 3.9.2-3 [24.8 kB]
Get:83 https://deb.debian.org/debian bullseye/main amd64 python3-setuptools all 52.0.0-4 [366 kB]
Get:84 https://deb.debian.org/debian bullseye/main amd64 python3-wheel all 0.34.2-1 [24.0 kB]
Get:85 https://deb.debian.org/debian bullseye/main amd64 python3-pip all 20.3.4-4+deb11u1 [337 kB]
Fetched 91.4 MB in 1s (97.3 MB/s)       
Extracting templates from packages: 100%
Preconfiguring packages ...
Selecting previously unselected package perl-modules-5.32.
(Reading database ... 57457 files and directories currently installed.)
Preparing to unpack .../00-perl-modules-5.32_5.32.1-4+deb11u2_all.deb ...
Unpacking perl-modules-5.32 (5.32.1-4+deb11u2) ...
Selecting previously unselected package libgdbm-compat4:amd64.
Preparing to unpack .../01-libgdbm-compat4_1.19-2_amd64.deb ...
Unpacking libgdbm-compat4:amd64 (1.19-2) ...
Selecting previously unselected package libperl5.32:amd64.
Preparing to unpack .../02-libperl5.32_5.32.1-4+deb11u2_amd64.deb ...
Unpacking libperl5.32:amd64 (5.32.1-4+deb11u2) ...
Selecting previously unselected package perl.
Preparing to unpack .../03-perl_5.32.1-4+deb11u2_amd64.deb ...
Unpacking perl (5.32.1-4+deb11u2) ...
Selecting previously unselected package liblocale-gettext-perl.
Preparing to unpack .../04-liblocale-gettext-perl_1.07-4+b1_amd64.deb ...
Unpacking liblocale-gettext-perl (1.07-4+b1) ...
Selecting previously unselected package bzip2.
Preparing to unpack .../05-bzip2_1.0.8-4_amd64.deb ...
Unpacking bzip2 (1.0.8-4) ...
Selecting previously unselected package binutils-common:amd64.
Preparing to unpack .../06-binutils-common_2.35.2-2_amd64.deb ...
Unpacking binutils-common:amd64 (2.35.2-2) ...
Selecting previously unselected package libbinutils:amd64.
Preparing to unpack .../07-libbinutils_2.35.2-2_amd64.deb ...
Unpacking libbinutils:amd64 (2.35.2-2) ...
Selecting previously unselected package libctf-nobfd0:amd64.
Preparing to unpack .../08-libctf-nobfd0_2.35.2-2_amd64.deb ...
Unpacking libctf-nobfd0:amd64 (2.35.2-2) ...
Selecting previously unselected package libctf0:amd64.
Preparing to unpack .../09-libctf0_2.35.2-2_amd64.deb ...
Unpacking libctf0:amd64 (2.35.2-2) ...
Selecting previously unselected package binutils-x86-64-linux-gnu.
Preparing to unpack .../10-binutils-x86-64-linux-gnu_2.35.2-2_amd64.deb ...
Unpacking binutils-x86-64-linux-gnu (2.35.2-2) ...
Selecting previously unselected package binutils.
Preparing to unpack .../11-binutils_2.35.2-2_amd64.deb ...
Unpacking binutils (2.35.2-2) ...
Selecting previously unselected package libc-dev-bin.
Preparing to unpack .../12-libc-dev-bin_2.31-13+deb11u6_amd64.deb ...
Unpacking libc-dev-bin (2.31-13+deb11u6) ...
Selecting previously unselected package linux-libc-dev:amd64.
Preparing to unpack .../13-linux-libc-dev_5.10.179-3_amd64.deb ...
Unpacking linux-libc-dev:amd64 (5.10.179-3) ...
Selecting previously unselected package libcrypt-dev:amd64.
Preparing to unpack .../14-libcrypt-dev_1%3a4.4.18-4_amd64.deb ...
Unpacking libcrypt-dev:amd64 (1:4.4.18-4) ...
Selecting previously unselected package libtirpc-dev:amd64.
Preparing to unpack .../15-libtirpc-dev_1.3.1-1+deb11u1_amd64.deb ...
Unpacking libtirpc-dev:amd64 (1.3.1-1+deb11u1) ...
Selecting previously unselected package libnsl-dev:amd64.
Preparing to unpack .../16-libnsl-dev_1.3.0-2_amd64.deb ...
Unpacking libnsl-dev:amd64 (1.3.0-2) ...
Selecting previously unselected package libc6-dev:amd64.
Preparing to unpack .../17-libc6-dev_2.31-13+deb11u6_amd64.deb ...
Unpacking libc6-dev:amd64 (2.31-13+deb11u6) ...
Selecting previously unselected package libisl23:amd64.
Preparing to unpack .../18-libisl23_0.23-1_amd64.deb ...
Unpacking libisl23:amd64 (0.23-1) ...
Selecting previously unselected package libmpfr6:amd64.
Preparing to unpack .../19-libmpfr6_4.1.0-3_amd64.deb ...
Unpacking libmpfr6:amd64 (4.1.0-3) ...
Selecting previously unselected package libmpc3:amd64.
Preparing to unpack .../20-libmpc3_1.2.0-1_amd64.deb ...
Unpacking libmpc3:amd64 (1.2.0-1) ...
Selecting previously unselected package cpp-10.
Preparing to unpack .../21-cpp-10_10.2.1-6_amd64.deb ...
Unpacking cpp-10 (10.2.1-6) ...
Selecting previously unselected package cpp.
Preparing to unpack .../22-cpp_4%3a10.2.1-1_amd64.deb ...
Unpacking cpp (4:10.2.1-1) ...
Selecting previously unselected package libcc1-0:amd64.
Preparing to unpack .../23-libcc1-0_10.2.1-6_amd64.deb ...
Unpacking libcc1-0:amd64 (10.2.1-6) ...
Selecting previously unselected package libgomp1:amd64.
Preparing to unpack .../24-libgomp1_10.2.1-6_amd64.deb ...
Unpacking libgomp1:amd64 (10.2.1-6) ...
Selecting previously unselected package libitm1:amd64.
Preparing to unpack .../25-libitm1_10.2.1-6_amd64.deb ...
Unpacking libitm1:amd64 (10.2.1-6) ...
Selecting previously unselected package libatomic1:amd64.
Preparing to unpack .../26-libatomic1_10.2.1-6_amd64.deb ...
Unpacking libatomic1:amd64 (10.2.1-6) ...
Selecting previously unselected package libasan6:amd64.
Preparing to unpack .../27-libasan6_10.2.1-6_amd64.deb ...
Unpacking libasan6:amd64 (10.2.1-6) ...
Selecting previously unselected package liblsan0:amd64.
Preparing to unpack .../28-liblsan0_10.2.1-6_amd64.deb ...
Unpacking liblsan0:amd64 (10.2.1-6) ...
Selecting previously unselected package libtsan0:amd64.
Preparing to unpack .../29-libtsan0_10.2.1-6_amd64.deb ...
Unpacking libtsan0:amd64 (10.2.1-6) ...
Selecting previously unselected package libubsan1:amd64.
Preparing to unpack .../30-libubsan1_10.2.1-6_amd64.deb ...
Unpacking libubsan1:amd64 (10.2.1-6) ...
Selecting previously unselected package libquadmath0:amd64.
Preparing to unpack .../31-libquadmath0_10.2.1-6_amd64.deb ...
Unpacking libquadmath0:amd64 (10.2.1-6) ...
Selecting previously unselected package libgcc-10-dev:amd64.
Preparing to unpack .../32-libgcc-10-dev_10.2.1-6_amd64.deb ...
Unpacking libgcc-10-dev:amd64 (10.2.1-6) ...
Selecting previously unselected package gcc-10.
Preparing to unpack .../33-gcc-10_10.2.1-6_amd64.deb ...
Unpacking gcc-10 (10.2.1-6) ...
Selecting previously unselected package gcc.
Preparing to unpack .../34-gcc_4%3a10.2.1-1_amd64.deb ...
Unpacking gcc (4:10.2.1-1) ...
Selecting previously unselected package libstdc++-10-dev:amd64.
Preparing to unpack .../35-libstdc++-10-dev_10.2.1-6_amd64.deb ...
Unpacking libstdc++-10-dev:amd64 (10.2.1-6) ...
Selecting previously unselected package g++-10.
Preparing to unpack .../36-g++-10_10.2.1-6_amd64.deb ...
Unpacking g++-10 (10.2.1-6) ...
Selecting previously unselected package g++.
Preparing to unpack .../37-g++_4%3a10.2.1-1_amd64.deb ...
Unpacking g++ (4:10.2.1-1) ...
Selecting previously unselected package make.
Preparing to unpack .../38-make_4.3-4.1_amd64.deb ...
Unpacking make (4.3-4.1) ...
Selecting previously unselected package libdpkg-perl.
Preparing to unpack .../39-libdpkg-perl_1.20.12_all.deb ...
Unpacking libdpkg-perl (1.20.12) ...
Selecting previously unselected package patch.
Preparing to unpack .../40-patch_2.7.6-7_amd64.deb ...
Unpacking patch (2.7.6-7) ...
Selecting previously unselected package dpkg-dev.
Preparing to unpack .../41-dpkg-dev_1.20.12_all.deb ...
Unpacking dpkg-dev (1.20.12) ...
Selecting previously unselected package build-essential.
Preparing to unpack .../42-build-essential_12.9_amd64.deb ...
Unpacking build-essential (12.9) ...
Selecting previously unselected package libfakeroot:amd64.
Preparing to unpack .../43-libfakeroot_1.25.3-1.1_amd64.deb ...
Unpacking libfakeroot:amd64 (1.25.3-1.1) ...
Selecting previously unselected package fakeroot.
Preparing to unpack .../44-fakeroot_1.25.3-1.1_amd64.deb ...
Unpacking fakeroot (1.25.3-1.1) ...
Selecting previously unselected package fonts-dejavu-core.
Preparing to unpack .../45-fonts-dejavu-core_2.37-2_all.deb ...
Unpacking fonts-dejavu-core (2.37-2) ...
Selecting previously unselected package fontconfig-config.
Preparing to unpack .../46-fontconfig-config_2.13.1-4.2_all.deb ...
Unpacking fontconfig-config (2.13.1-4.2) ...
Selecting previously unselected package liberror-perl.
Preparing to unpack .../47-liberror-perl_0.17029-1_all.deb ...
Unpacking liberror-perl (0.17029-1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../48-git-man_1%3a2.30.2-1+deb11u2_all.deb ...
Unpacking git-man (1:2.30.2-1+deb11u2) ...
Selecting previously unselected package git.
Preparing to unpack .../49-git_1%3a2.30.2-1+deb11u2_amd64.deb ...
Unpacking git (1:2.30.2-1+deb11u2) ...
Selecting previously unselected package javascript-common.
Preparing to unpack .../50-javascript-common_11+nmu1_all.deb ...
Unpacking javascript-common (11+nmu1) ...
Selecting previously unselected package libalgorithm-diff-perl.
Preparing to unpack .../51-libalgorithm-diff-perl_1.201-1_all.deb ...
Unpacking libalgorithm-diff-perl (1.201-1) ...
Selecting previously unselected package libalgorithm-diff-xs-perl.
Preparing to unpack .../52-libalgorithm-diff-xs-perl_0.04-6+b1_amd64.deb ...
Unpacking libalgorithm-diff-xs-perl (0.04-6+b1) ...
Selecting previously unselected package libalgorithm-merge-perl.
Preparing to unpack .../53-libalgorithm-merge-perl_0.08-3_all.deb ...
Unpacking libalgorithm-merge-perl (0.08-3) ...
Selecting previously unselected package libfontconfig1:amd64.
Preparing to unpack .../54-libfontconfig1_2.13.1-4.2_amd64.deb ...
Unpacking libfontconfig1:amd64 (2.13.1-4.2) ...
Selecting previously unselected package libjpeg62-turbo:amd64.
Preparing to unpack .../55-libjpeg62-turbo_1%3a2.0.6-4_amd64.deb ...
Unpacking libjpeg62-turbo:amd64 (1:2.0.6-4) ...
Selecting previously unselected package libdeflate0:amd64.
Preparing to unpack .../56-libdeflate0_1.7-1_amd64.deb ...
Unpacking libdeflate0:amd64 (1.7-1) ...
Selecting previously unselected package libjbig0:amd64.
Preparing to unpack .../57-libjbig0_2.1-3.1+b2_amd64.deb ...
Unpacking libjbig0:amd64 (2.1-3.1+b2) ...
Selecting previously unselected package libwebp6:amd64.
Preparing to unpack .../58-libwebp6_0.6.1-2.1+deb11u1_amd64.deb ...
Unpacking libwebp6:amd64 (0.6.1-2.1+deb11u1) ...
Selecting previously unselected package libtiff5:amd64.
Preparing to unpack .../59-libtiff5_4.2.0-1+deb11u4_amd64.deb ...
Unpacking libtiff5:amd64 (4.2.0-1+deb11u4) ...
Selecting previously unselected package libxau6:amd64.
Preparing to unpack .../60-libxau6_1%3a1.0.9-1_amd64.deb ...
Unpacking libxau6:amd64 (1:1.0.9-1) ...
Selecting previously unselected package libxdmcp6:amd64.
Preparing to unpack .../61-libxdmcp6_1%3a1.1.2-3_amd64.deb ...
Unpacking libxdmcp6:amd64 (1:1.1.2-3) ...
Selecting previously unselected package libxcb1:amd64.
Preparing to unpack .../62-libxcb1_1.14-3_amd64.deb ...
Unpacking libxcb1:amd64 (1.14-3) ...
Selecting previously unselected package libx11-data.
Preparing to unpack .../63-libx11-data_2%3a1.7.2-1+deb11u1_all.deb ...
Unpacking libx11-data (2:1.7.2-1+deb11u1) ...
Selecting previously unselected package libx11-6:amd64.
Preparing to unpack .../64-libx11-6_2%3a1.7.2-1+deb11u1_amd64.deb ...
Unpacking libx11-6:amd64 (2:1.7.2-1+deb11u1) ...
Selecting previously unselected package libxpm4:amd64.
Preparing to unpack .../65-libxpm4_1%3a3.5.12-1.1~deb11u1_amd64.deb ...
Unpacking libxpm4:amd64 (1:3.5.12-1.1~deb11u1) ...
Selecting previously unselected package libgd3:amd64.
Preparing to unpack .../66-libgd3_2.3.0-2_amd64.deb ...
Unpacking libgd3:amd64 (2.3.0-2) ...
Selecting previously unselected package libc-devtools.
Preparing to unpack .../67-libc-devtools_2.31-13+deb11u6_amd64.deb ...
Unpacking libc-devtools (2.31-13+deb11u6) ...
Selecting previously unselected package libexpat1-dev:amd64.
Preparing to unpack .../68-libexpat1-dev_2.2.10-2+deb11u5_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.2.10-2+deb11u5) ...
Selecting previously unselected package libfile-fcntllock-perl.
Preparing to unpack .../69-libfile-fcntllock-perl_0.22-3+b7_amd64.deb ...
Unpacking libfile-fcntllock-perl (0.22-3+b7) ...
Selecting previously unselected package libjs-jquery.
Preparing to unpack .../70-libjs-jquery_3.5.1+dfsg+~3.5.5-7_all.deb ...
Unpacking libjs-jquery (3.5.1+dfsg+~3.5.5-7) ...
Selecting previously unselected package libjs-underscore.
Preparing to unpack .../71-libjs-underscore_1.9.1~dfsg-3_all.deb ...
Unpacking libjs-underscore (1.9.1~dfsg-3) ...
Selecting previously unselected package libjs-sphinxdoc.
Preparing to unpack .../72-libjs-sphinxdoc_3.4.3-2_all.deb ...
Unpacking libjs-sphinxdoc (3.4.3-2) ...
Selecting previously unselected package libpython3.9-dev:amd64.
Preparing to unpack .../73-libpython3.9-dev_3.9.2-1_amd64.deb ...
Unpacking libpython3.9-dev:amd64 (3.9.2-1) ...
Selecting previously unselected package libpython3-dev:amd64.
Preparing to unpack .../74-libpython3-dev_3.9.2-3_amd64.deb ...
Unpacking libpython3-dev:amd64 (3.9.2-3) ...
Selecting previously unselected package manpages-dev.
Preparing to unpack .../75-manpages-dev_5.10-1_all.deb ...
Unpacking manpages-dev (5.10-1) ...
Selecting previously unselected package python-pip-whl.
Preparing to unpack .../76-python-pip-whl_20.3.4-4+deb11u1_all.deb ...
Unpacking python-pip-whl (20.3.4-4+deb11u1) ...
Selecting previously unselected package zlib1g-dev:amd64.
Preparing to unpack .../77-zlib1g-dev_1%3a1.2.11.dfsg-2+deb11u2_amd64.deb ...
Unpacking zlib1g-dev:amd64 (1:1.2.11.dfsg-2+deb11u2) ...
Selecting previously unselected package python3.9-dev.
Preparing to unpack .../78-python3.9-dev_3.9.2-1_amd64.deb ...
Unpacking python3.9-dev (3.9.2-1) ...
Selecting previously unselected package python3-lib2to3.
Preparing to unpack .../79-python3-lib2to3_3.9.2-1_all.deb ...
Unpacking python3-lib2to3 (3.9.2-1) ...
Selecting previously unselected package python3-distutils.
Preparing to unpack .../80-python3-distutils_3.9.2-1_all.deb ...
Unpacking python3-distutils (3.9.2-1) ...
Selecting previously unselected package python3-dev.
Preparing to unpack .../81-python3-dev_3.9.2-3_amd64.deb ...
Unpacking python3-dev (3.9.2-3) ...
Selecting previously unselected package python3-setuptools.
Preparing to unpack .../82-python3-setuptools_52.0.0-4_all.deb ...
Unpacking python3-setuptools (52.0.0-4) ...
Selecting previously unselected package python3-wheel.
Preparing to unpack .../83-python3-wheel_0.34.2-1_all.deb ...
Unpacking python3-wheel (0.34.2-1) ...
Selecting previously unselected package python3-pip.
Preparing to unpack .../84-python3-pip_20.3.4-4+deb11u1_all.deb ...
Unpacking python3-pip (20.3.4-4+deb11u1) ...
Setting up javascript-common (11+nmu1) ...
Setting up manpages-dev (5.10-1) ...
Setting up libxau6:amd64 (1:1.0.9-1) ...
Setting up libxdmcp6:amd64 (1:1.1.2-3) ...
Setting up libxcb1:amd64 (1.14-3) ...
Setting up perl-modules-5.32 (5.32.1-4+deb11u2) ...
Setting up binutils-common:amd64 (2.35.2-2) ...
Setting up libdeflate0:amd64 (1.7-1) ...
Setting up linux-libc-dev:amd64 (5.10.179-3) ...
Setting up libctf-nobfd0:amd64 (2.35.2-2) ...
Setting up libgomp1:amd64 (10.2.1-6) ...
Setting up bzip2 (1.0.8-4) ...
Setting up python3-wheel (0.34.2-1) ...
Setting up libjbig0:amd64 (2.1-3.1+b2) ...
Setting up libfakeroot:amd64 (1.25.3-1.1) ...
Setting up libasan6:amd64 (10.2.1-6) ...
Setting up fakeroot (1.25.3-1.1) ...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libtirpc-dev:amd64 (1.3.1-1+deb11u1) ...
Setting up libjpeg62-turbo:amd64 (1:2.0.6-4) ...
Setting up libx11-data (2:1.7.2-1+deb11u1) ...
Setting up make (4.3-4.1) ...
Setting up libmpfr6:amd64 (4.1.0-3) ...
Setting up libquadmath0:amd64 (10.2.1-6) ...
Setting up libmpc3:amd64 (1.2.0-1) ...
Setting up libatomic1:amd64 (10.2.1-6) ...
Setting up patch (2.7.6-7) ...
Setting up libwebp6:amd64 (0.6.1-2.1+deb11u1) ...
Setting up fonts-dejavu-core (2.37-2) ...
Setting up libgdbm-compat4:amd64 (1.19-2) ...
Setting up libperl5.32:amd64 (5.32.1-4+deb11u2) ...
Setting up libubsan1:amd64 (10.2.1-6) ...
Setting up libnsl-dev:amd64 (1.3.0-2) ...
Setting up libcrypt-dev:amd64 (1:4.4.18-4) ...
Setting up git-man (1:2.30.2-1+deb11u2) ...
Setting up libx11-6:amd64 (2:1.7.2-1+deb11u1) ...
Setting up python-pip-whl (20.3.4-4+deb11u1) ...
Setting up libtiff5:amd64 (4.2.0-1+deb11u4) ...
Setting up libjs-jquery (3.5.1+dfsg+~3.5.5-7) ...
Setting up libbinutils:amd64 (2.35.2-2) ...
Setting up libisl23:amd64 (0.23-1) ...
Setting up libc-dev-bin (2.31-13+deb11u6) ...
Setting up python3-lib2to3 (3.9.2-1) ...
Setting up libcc1-0:amd64 (10.2.1-6) ...
Setting up liblocale-gettext-perl (1.07-4+b1) ...
Setting up liblsan0:amd64 (10.2.1-6) ...
Setting up cpp-10 (10.2.1-6) ...
Setting up libitm1:amd64 (10.2.1-6) ...
Setting up libjs-underscore (1.9.1~dfsg-3) ...
Setting up libtsan0:amd64 (10.2.1-6) ...
Setting up libctf0:amd64 (2.35.2-2) ...
Setting up python3-distutils (3.9.2-1) ...
Setting up python3-setuptools (52.0.0-4) ...
Setting up libxpm4:amd64 (1:3.5.12-1.1~deb11u1) ...
Setting up fontconfig-config (2.13.1-4.2) ...
Setting up libgcc-10-dev:amd64 (10.2.1-6) ...
Setting up perl (5.32.1-4+deb11u2) ...
Setting up python3-pip (20.3.4-4+deb11u1) ...
Setting up libjs-sphinxdoc (3.4.3-2) ...
Setting up libdpkg-perl (1.20.12) ...
Setting up cpp (4:10.2.1-1) ...
Setting up libc6-dev:amd64 (2.31-13+deb11u6) ...
Setting up libfontconfig1:amd64 (2.13.1-4.2) ...
Setting up binutils-x86-64-linux-gnu (2.35.2-2) ...
Setting up libstdc++-10-dev:amd64 (10.2.1-6) ...
Setting up libfile-fcntllock-perl (0.22-3+b7) ...
Setting up libalgorithm-diff-perl (1.201-1) ...
Setting up binutils (2.35.2-2) ...
Setting up dpkg-dev (1.20.12) ...
Setting up liberror-perl (0.17029-1) ...
Setting up libexpat1-dev:amd64 (2.2.10-2+deb11u5) ...
Setting up libgd3:amd64 (2.3.0-2) ...
Setting up git (1:2.30.2-1+deb11u2) ...
Setting up gcc-10 (10.2.1-6) ...
Setting up zlib1g-dev:amd64 (1:1.2.11.dfsg-2+deb11u2) ...
Setting up libalgorithm-diff-xs-perl (0.04-6+b1) ...
Setting up libc-devtools (2.31-13+deb11u6) ...
Setting up libalgorithm-merge-perl (0.08-3) ...
Setting up g++-10 (10.2.1-6) ...
Setting up libpython3.9-dev:amd64 (3.9.2-1) ...
Setting up gcc (4:10.2.1-1) ...
Setting up g++ (4:10.2.1-1) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up python3.9-dev (3.9.2-1) ...
Setting up build-essential (12.9) ...
Setting up libpython3-dev:amd64 (3.9.2-3) ...
Setting up python3-dev (3.9.2-3) ...
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for libc-bin (2.31-13+deb11u6) ...
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ pip3 install --upgrade pip
Requirement already satisfied: pip in /usr/lib/python3/dist-packages (20.3.4)
Collecting pip
  Downloading pip-23.2.1-py3-none-any.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 7.3 MB/s 
Installing collected packages: pip
  WARNING: The scripts pip, pip3, pip3.11 and pip3.9 are installed in '/home/student-04-717d1aa28d01/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-23.2.1
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ pip3 install google-cloud-bigquery
Defaulting to user installation because normal site-packages is not writeable
Collecting google-cloud-bigquery
  Obtaining dependency information for google-cloud-bigquery from https://files.pythonhosted.org/packages/cc/6a/d0ef792288f2fa2cfea80899a82de302b3332dfda41984fe114e2cfbf700/google_cloud_bigquery-3.11.4-py2.py3-none-any.whl.metadata
  Downloading google_cloud_bigquery-3.11.4-py2.py3-none-any.whl.metadata (8.5 kB)
Collecting grpcio<2.0dev,>=1.47.0 (from google-cloud-bigquery)
  Obtaining dependency information for grpcio<2.0dev,>=1.47.0 from https://files.pythonhosted.org/packages/f5/f6/57fbd39af17aaae321109411ef2faf121768473ebc1bbf3694b06d3282c8/grpcio-1.56.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Downloading grpcio-1.56.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.0 kB)
Collecting google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5 (from google-cloud-bigquery)
  Obtaining dependency information for google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5 from https://files.pythonhosted.org/packages/6e/c4/c3cd048b6cbeba8d9ae50dd7643ac065b85237338aa7501b0efae91eb4d9/google_api_core-2.11.1-py3-none-any.whl.metadata
  Downloading google_api_core-2.11.1-py3-none-any.whl.metadata (2.7 kB)
Collecting proto-plus<2.0.0dev,>=1.15.0 (from google-cloud-bigquery)
  Obtaining dependency information for proto-plus<2.0.0dev,>=1.15.0 from https://files.pythonhosted.org/packages/36/5b/e02636d221917d6fa2a61289b3f16002eb4c93d51c0191ac8e896d527182/proto_plus-1.22.3-py3-none-any.whl.metadata
  Downloading proto_plus-1.22.3-py3-none-any.whl.metadata (2.2 kB)
Collecting google-cloud-core<3.0.0dev,>=1.6.0 (from google-cloud-bigquery)
  Obtaining dependency information for google-cloud-core<3.0.0dev,>=1.6.0 from https://files.pythonhosted.org/packages/a2/40/02045f776fdb6e44194f34b6375a26ce8a61bd9bd03cd8930ed91cf51a62/google_cloud_core-2.3.3-py2.py3-none-any.whl.metadata
  Downloading google_cloud_core-2.3.3-py2.py3-none-any.whl.metadata (2.5 kB)
Collecting google-resumable-media<3.0dev,>=0.6.0 (from google-cloud-bigquery)
  Downloading google_resumable_media-2.5.0-py2.py3-none-any.whl (77 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.7/77.7 kB 5.4 MB/s eta 0:00:00
Collecting packaging>=20.0.0 (from google-cloud-bigquery)
  Downloading packaging-23.1-py3-none-any.whl (48 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 9.9 MB/s eta 0:00:00
Collecting protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.19.5 (from google-cloud-bigquery)
  Obtaining dependency information for protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.19.5 from https://files.pythonhosted.org/packages/01/cb/445b3e465abdb8042a41957dc8f60c54620dc7540dbcf9b458a921531ca2/protobuf-4.23.4-cp37-abi3-manylinux2014_x86_64.whl.metadata
  Downloading protobuf-4.23.4-cp37-abi3-manylinux2014_x86_64.whl.metadata (540 bytes)
Collecting python-dateutil<3.0dev,>=2.7.2 (from google-cloud-bigquery)
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 19.0 MB/s eta 0:00:00
Requirement already satisfied: requests<3.0.0dev,>=2.21.0 in /usr/lib/python3/dist-packages (from google-cloud-bigquery) (2.25.1)
Collecting googleapis-common-protos<2.0.dev0,>=1.56.2 (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-cloud-bigquery)
  Obtaining dependency information for googleapis-common-protos<2.0.dev0,>=1.56.2 from https://files.pythonhosted.org/packages/a7/bc/416a1ffeba4dcd072bc10523dac9ed97f2e7fc4b760580e2bdbdc1e2afdd/googleapis_common_protos-1.60.0-py2.py3-none-any.whl.metadata
  Downloading googleapis_common_protos-1.60.0-py2.py3-none-any.whl.metadata (1.5 kB)
Collecting google-auth<3.0.dev0,>=2.14.1 (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-cloud-bigquery)
  Obtaining dependency information for google-auth<3.0.dev0,>=2.14.1 from https://files.pythonhosted.org/packages/9c/8d/bff87fc722553a5691d8514da5523c23547f3894189ba03b57592e37bdc2/google_auth-2.22.0-py2.py3-none-any.whl.metadata
  Downloading google_auth-2.22.0-py2.py3-none-any.whl.metadata (4.2 kB)
Collecting grpcio-status<2.0.dev0,>=1.33.2 (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-cloud-bigquery)
  Obtaining dependency information for grpcio-status<2.0.dev0,>=1.33.2 from https://files.pythonhosted.org/packages/ef/16/3018689d96918e9c4c7407adf96b721df4d6748ba65db82c5eaa63564335/grpcio_status-1.56.2-py3-none-any.whl.metadata
  Downloading grpcio_status-1.56.2-py3-none-any.whl.metadata (1.3 kB)
Collecting google-crc32c<2.0dev,>=1.0 (from google-resumable-media<3.0dev,>=0.6.0->google-cloud-bigquery)
  Downloading google_crc32c-1.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32 kB)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil<3.0dev,>=2.7.2->google-cloud-bigquery) (1.16.0)
Collecting cachetools<6.0,>=2.0.0 (from google-auth<3.0.dev0,>=2.14.1->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-cloud-bigquery)
  Obtaining dependency information for cachetools<6.0,>=2.0.0 from https://files.pythonhosted.org/packages/a9/c9/c8a7710f2cedcb1db9224fdd4d8307c9e48cbddc46c18b515fefc0f1abbe/cachetools-5.3.1-py3-none-any.whl.metadata
  Downloading cachetools-5.3.1-py3-none-any.whl.metadata (5.2 kB)
Collecting pyasn1-modules>=0.2.1 (from google-auth<3.0.dev0,>=2.14.1->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-cloud-bigquery)
  Downloading pyasn1_modules-0.3.0-py2.py3-none-any.whl (181 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 181.3/181.3 kB 35.5 MB/s eta 0:00:00
Collecting rsa<5,>=3.1.4 (from google-auth<3.0.dev0,>=2.14.1->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-cloud-bigquery)
  Downloading rsa-4.9-py3-none-any.whl (34 kB)
Requirement already satisfied: urllib3<2.0 in /usr/lib/python3/dist-packages (from google-auth<3.0.dev0,>=2.14.1->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-cloud-bigquery) (1.26.5)
Collecting pyasn1<0.6.0,>=0.4.6 (from pyasn1-modules>=0.2.1->google-auth<3.0.dev0,>=2.14.1->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-cloud-bigquery)
  Downloading pyasn1-0.5.0-py2.py3-none-any.whl (83 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.9/83.9 kB 18.3 MB/s eta 0:00:00
Downloading google_cloud_bigquery-3.11.4-py2.py3-none-any.whl (219 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 219.6/219.6 kB 38.2 MB/s eta 0:00:00
Downloading google_cloud_core-2.3.3-py2.py3-none-any.whl (29 kB)
Downloading grpcio-1.56.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.2/5.2 MB 51.1 MB/s eta 0:00:00
Downloading proto_plus-1.22.3-py3-none-any.whl (48 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.1/48.1 kB 10.2 MB/s eta 0:00:00
Downloading protobuf-4.23.4-cp37-abi3-manylinux2014_x86_64.whl (304 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 304.5/304.5 kB 43.7 MB/s eta 0:00:00
Downloading google_api_core-2.11.1-py3-none-any.whl (120 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 120.5/120.5 kB 23.7 MB/s eta 0:00:00
Downloading google_auth-2.22.0-py2.py3-none-any.whl (181 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 181.8/181.8 kB 34.6 MB/s eta 0:00:00
Downloading googleapis_common_protos-1.60.0-py2.py3-none-any.whl (227 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 227.6/227.6 kB 38.1 MB/s eta 0:00:00
Downloading grpcio_status-1.56.2-py3-none-any.whl (5.1 kB)
Downloading cachetools-5.3.1-py3-none-any.whl (9.3 kB)
Installing collected packages: python-dateutil, pyasn1, protobuf, packaging, grpcio, google-crc32c, cachetools, rsa, pyasn1-modules, proto-plus, googleapis-common-protos, google-resumable-media, grpcio-status, google-auth, google-api-core, google-cloud-core, google-cloud-bigquery
  WARNING: The scripts pyrsa-decrypt, pyrsa-encrypt, pyrsa-keygen, pyrsa-priv2pub, pyrsa-sign and pyrsa-verify are installed in '/home/student-04-717d1aa28d01/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed cachetools-5.3.1 google-api-core-2.11.1 google-auth-2.22.0 google-cloud-bigquery-3.11.4 google-cloud-core-2.3.3 google-crc32c-1.5.0 google-resumable-media-2.5.0 googleapis-common-protos-1.60.0 grpcio-1.56.2 grpcio-status-1.56.2 packaging-23.1 proto-plus-1.22.3 protobuf-4.23.4 pyasn1-0.5.0 pyasn1-modules-0.3.0 python-dateutil-2.8.2 rsa-4.9
student-04-717d1aa28d01@bigquery-instance:~$ pip3 install pyarrow
Defaulting to user installation because normal site-packages is not writeable
Collecting pyarrow
  Obtaining dependency information for pyarrow from https://files.pythonhosted.org/packages/54/a2/5976df95323c4ca2b7baba31cb7a2a61a17461706043239d38a8e9dc281e/pyarrow-12.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Downloading pyarrow-12.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.0 kB)
Collecting numpy>=1.16.6 (from pyarrow)
  Obtaining dependency information for numpy>=1.16.6 from https://files.pythonhosted.org/packages/69/1f/c95b1108a9972a52d7b1b63ed8ca70466b59b8c1811bd121f1e667cc45d8/numpy-1.25.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Downloading numpy-1.25.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.6 kB)
Downloading pyarrow-12.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (39.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 39.0/39.0 MB 24.2 MB/s eta 0:00:00
Downloading numpy-1.25.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.3/18.3 MB 49.3 MB/s eta 0:00:00
Installing collected packages: numpy, pyarrow
  WARNING: The scripts f2py, f2py3 and f2py3.9 are installed in '/home/student-04-717d1aa28d01/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.25.2 pyarrow-12.0.1
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ pip3 install pandas
Defaulting to user installation because normal site-packages is not writeable
Collecting pandas
  Obtaining dependency information for pandas from https://files.pythonhosted.org/packages/9e/0d/91a9fd2c202f2b1d97a38ab591890f86480ecbb596cbc56d035f6f23fdcc/pandas-2.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Downloading pandas-2.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (18 kB)
Requirement already satisfied: python-dateutil>=2.8.2 in ./.local/lib/python3.9/site-packages (from pandas) (2.8.2)
Collecting pytz>=2020.1 (from pandas)
  Downloading pytz-2023.3-py2.py3-none-any.whl (502 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 502.3/502.3 kB 13.8 MB/s eta 0:00:00
Collecting tzdata>=2022.1 (from pandas)
  Downloading tzdata-2023.3-py2.py3-none-any.whl (341 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 341.8/341.8 kB 48.7 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.20.3 in ./.local/lib/python3.9/site-packages (from pandas) (1.25.2)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)
Downloading pandas-2.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.4 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.4/12.4 MB 51.1 MB/s eta 0:00:00
Installing collected packages: pytz, tzdata, pandas
Successfully installed pandas-2.0.3 pytz-2023.3 tzdata-2023.3
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ pip3 install db-dtypes
Defaulting to user installation because normal site-packages is not writeable
Collecting db-dtypes
  Downloading db_dtypes-1.1.1-py2.py3-none-any.whl (14 kB)
Requirement already satisfied: packaging>=17.0 in ./.local/lib/python3.9/site-packages (from db-dtypes) (23.1)
Requirement already satisfied: pandas>=0.24.2 in ./.local/lib/python3.9/site-packages (from db-dtypes) (2.0.3)
Requirement already satisfied: pyarrow>=3.0.0 in ./.local/lib/python3.9/site-packages (from db-dtypes) (12.0.1)
Requirement already satisfied: numpy>=1.16.6 in ./.local/lib/python3.9/site-packages (from db-dtypes) (1.25.2)
Requirement already satisfied: python-dateutil>=2.8.2 in ./.local/lib/python3.9/site-packages (from pandas>=0.24.2->db-dtypes) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in ./.local/lib/python3.9/site-packages (from pandas>=0.24.2->db-dtypes) (2023.3)
Requirement already satisfied: tzdata>=2022.1 in ./.local/lib/python3.9/site-packages (from pandas>=0.24.2->db-dtypes) (2023.3)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas>=0.24.2->db-dtypes) (1.16.0)
Installing collected packages: db-dtypes
Successfully installed db-dtypes-1.1.1
student-04-717d1aa28d01@bigquery-instance:~$ vi query.py
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ sed -i -e "s/qwiklabs-gcp-03-f3d72bb5968f/$(gcloud config get-value project)/g" query.py
student-04-717d1aa28d01@bigquery-instance:~$ vi query.py
student-04-717d1aa28d01@bigquery-instance:~$ rm query.py 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ echo "
from google.auth import compute_engine
from google.cloud import bigquery
credentials = compute_engine.Credentials(
    service_account_email='YOUR_SERVICE_ACCOUNT')
query = '''
SELECT
  year,
  COUNT(1) as num_babies
FROM
  publicdata.samples.natality
WHERE
  year > 2000
GROUP BY
  year
'''
client = bigquery.Client(
    project='qwiklabs-gcp-03-f3d72bb5968f',
    credentials=credentials)
print(client.query(query).to_dataframe())
" > query.py
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ cat query.py 

from google.auth import compute_engine
from google.cloud import bigquery
credentials = compute_engine.Credentials(
    service_account_email='YOUR_SERVICE_ACCOUNT')
query = '''
SELECT
  year,
  COUNT(1) as num_babies
FROM
  publicdata.samples.natality
WHERE
  year > 2000
GROUP BY
  year
'''
client = bigquery.Client(
    project='qwiklabs-gcp-03-f3d72bb5968f',
    credentials=credentials)
print(client.query(query).to_dataframe())

student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ sed -i -e "s/qwiklabs-gcp-03-f3d72bb5968f/$(gcloud config get-value project)/g" query.py
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ cat query.py 

from google.auth import compute_engine
from google.cloud import bigquery
credentials = compute_engine.Credentials(
    service_account_email='YOUR_SERVICE_ACCOUNT')
query = '''
SELECT
  year,
  COUNT(1) as num_babies
FROM
  publicdata.samples.natality
WHERE
  year > 2000
GROUP BY
  year
'''
client = bigquery.Client(
    project='qwiklabs-gcp-03-f3d72bb5968f',
    credentials=credentials)
print(client.query(query).to_dataframe())

student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ sed -i -e "s/YOUR_SERVICE_ACCOUNT/bigquery-qwiklab@$(gcloud config get-value project).iam.gserviceaccount.com/g" query.py
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ cat query.py 

from google.auth import compute_engine
from google.cloud import bigquery
credentials = compute_engine.Credentials(
    service_account_email='bigquery-qwiklab@qwiklabs-gcp-03-f3d72bb5968f.iam.gserviceaccount.com')
query = '''
SELECT
  year,
  COUNT(1) as num_babies
FROM
  publicdata.samples.natality
WHERE
  year > 2000
GROUP BY
  year
'''
client = bigquery.Client(
    project='qwiklabs-gcp-03-f3d72bb5968f',
    credentials=credentials)
print(client.query(query).to_dataframe())

student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ 
student-04-717d1aa28d01@bigquery-instance:~$ python3 query.py
   year  num_babies
0  2006     4273225
1  2004     4118907
2  2005     4145619
3  2002     4027376
4  2007     4324008
5  2008     4255156
6  2001     4031531
7  2003     4096092
student-04-717d1aa28d01@bigquery-instance:~$ history
    1  sudo apt-get update
    2  sudo apt-get install -y git python3-pip
    3  pip3 install --upgrade pip
    4  pip3 install google-cloud-bigquery
    5  pip3 install pyarrow
    6  pip3 install pandas
    7  pip3 install db-dtypes
    8  vi query.py
    9  sed -i -e "s/qwiklabs-gcp-03-f3d72bb5968f/$(gcloud config get-value project)/g" query.py
   10  vi query.py
   11  rm query.py 
   12  echo "
from google.auth import compute_engine
from google.cloud import bigquery
credentials = compute_engine.Credentials(
    service_account_email='YOUR_SERVICE_ACCOUNT')
query = '''
SELECT
  year,
  COUNT(1) as num_babies
FROM
  publicdata.samples.natality
WHERE
  year > 2000
GROUP BY
  year
'''
client = bigquery.Client(
    project='qwiklabs-gcp-03-f3d72bb5968f',
    credentials=credentials)
print(client.query(query).to_dataframe())
" > query.py
   13  cat query.py 
   14  sed -i -e "s/qwiklabs-gcp-03-f3d72bb5968f/$(gcloud config get-value project)/g" query.py
   15  cat query.py 
   16  sed -i -e "s/YOUR_SERVICE_ACCOUNT/bigquery-qwiklab@$(gcloud config get-value project).iam.gserviceaccount.com/g" query.py
   17  cat query.py 
   18  python3 query.py
   19  history
student-04-717d1aa28d01@bigquery-instance:~$

Configuring IAM Permissions with gcloud

What is IAM?
Google Cloud offers Cloud Identity and Access Management (IAM), which lets you manage access control by defining who (identity) has what access (role) for which resource.

In IAM, permission to access a resource isn't granted directly to the end user. Instead, permissions are grouped into roles, and roles are granted to authenticated principals. (In the past, IAM often referred to principals as members. Some APIs still use this term.)

Identities
In Cloud IAM, you grant access to principals. Principals can be of the following types:

Google Account
Service account
Google group
Google Workspace account
Cloud Identity domain
All authenticated users
All users
Learn more about these identity types from the Concepts related to identity Guide.

In this lab, you use Google accounts, service accounts, and Cloud Identity domain groups.

Roles
A role is a collection of permissions. You cannot assign a permission to the user directly; instead you grant them a role. When you grant a role to a user, you grant them all the permissions that the role contains.




Overview
This lab looks at three common areas to understand with regards to IAM and gcloud:

the configuration of the gcloud environment
the use of multiple gcloud configurations
the use of services accounts
In this lab you use the gcloud CLI tool to set up and configure command features of Cloud Identity and Access Management (IAM).

What you'll learn
In this lab, you do the following:

Review IAM and using the gcloud client

Create and switch between multiple IAM configurations

Identify and assign correct IAM permissions

Create and use a service account

Starting environment
You start with two user accounts and two projects;

user1 is the "owner" of both projects
user2 is the "viewer" of only the first project.
There is a Linux virtual machine (vm) running in the first project.










You can run:

  $ gcloud config set account `ACCOUNT`

to switch accounts if necessary.

Your credentials may be visible to others with access to this
virtual machine. Are you sure you want to authenticate with
your personal account?

Do you want to continue (Y/n)?  Y

Go to the following link in your browser:

    https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fsdk.cloud.google.com%2Fauthcode.html&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice.login+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=dY4JfRm3mhdf7HDgbEoWpIwfsS1AFS&prompt=consent&access_type=offline&code_challenge=woUOXswqaJT5TmpGs11XKtcCEcVCbPM9eSvTplVjM_o&code_challenge_method=S256

Enter authorization code: 4/0AZEOvhVrKbPSDmowePe1BKnU8Li-prGyiQBtkzzzWJMAd8b5Kf3wQboQbjAhqhdZaKpDIw

You are now logged in as [student-04-6234289191d9@qwiklabs.net].
Your current project is [qwiklabs-gcp-01-2f669a123a64].  You can change this setting by running:
  $ gcloud config set project PROJECT_ID
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[core]
account = student-04-6234289191d9@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [default]
[student-04-6234289191d9@centos-clean ~]$ gcloud config set compute/regions us-west1
ERROR: (gcloud.config.set) Section [compute] has no property [regions].
[student-04-6234289191d9@centos-clean ~]$ gcloud config set compute/region us-west1
Updated property [compute/region].
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
[core]
account = student-04-6234289191d9@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [default]
[student-04-6234289191d9@centos-clean ~]$ gcloud config set compute/zone us-west1-a
Updated property [compute/zone].
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
zone = us-west1-a
[core]
account = student-04-6234289191d9@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [default]
[student-04-6234289191d9@centos-clean ~]$ gcloud config list zone
ERROR: (gcloud.config.list) Section [core] has no property [zone].
[student-04-6234289191d9@centos-clean ~]$ gcloud config list project
[core]
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [default]
[student-04-6234289191d9@centos-clean ~]$ gcloud config list region
ERROR: (gcloud.config.list) Section [core] has no property [region].
[student-04-6234289191d9@centos-clean ~]$ gcloud config list account
[core]
account = student-04-6234289191d9@qwiklabs.net

Your active configuration is: [default]
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud compute instances create lab-1 --zone us-west1-a --machine-type=e2-standard-2
Created [https://www.googleapis.com/compute/v1/projects/qwiklabs-gcp-01-2f669a123a64/zones/us-west1-a/instances/lab-1].
NAME   ZONE        MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP   STATUS
lab-1  us-west1-a  e2-standard-2               10.138.0.3   35.197.89.11  RUNNING
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
zone = us-west1-a
[core]
account = student-04-6234289191d9@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [default]
[student-04-6234289191d9@centos-clean ~]$ gcloud compute zones list
NAME                       REGION                   STATUS  NEXT_MAINTENANCE  TURNDOWN_DATE
us-east1-b                 us-east1                 UP
us-west3-b                 us-west3                 UP
us-west3-c                 us-west3                 UP
us-west4-a                 us-west4                 UP
us-west4-b                 us-west4                 UP
us-west4-c                 us-west4                 UP
[student-04-6234289191d9@centos-clean ~]$ gcloud config list zones
ERROR: (gcloud.config.list) Section [core] has no property [zones].
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
zone = us-west1-a
[core]
account = student-04-6234289191d9@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [default]
[student-04-6234289191d9@centos-clean ~]$ gcloud config set compute/zone us-west1-b
Updated property [compute/zone].
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
zone = us-west1-b
[core]
account = student-04-6234289191d9@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [default]
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ cat ~/.config/gcloud/configurations/config_default 
[core]
account = student-04-6234289191d9@qwiklabs.net

[compute]
region = us-west1
zone = us-west1-b

[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud init --no-launch-browser
Welcome! This command will take you through the configuration of gcloud.

Settings from your current configuration [default] are:
compute:
  region: us-west1
  zone: us-west1-b
core:
  account: student-04-6234289191d9@qwiklabs.net
  disable_usage_reporting: 'True'
  project: qwiklabs-gcp-01-2f669a123a64

Pick configuration to use:
 [1] Re-initialize this configuration [default] with new settings 
 [2] Create a new configuration
Please enter your numeric choice:  2

Enter configuration name. Names start with a lower case letter and contain only lower case letters a-z, digits 
0-9, and hyphens '-':  user2
Your current configuration has been set to: [user2]

You can skip diagnostics next time by using the following flag:
  gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.                                                                           
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).

Choose the account you would like to use to perform operations for this configuration:
 [1] 96240167141-compute@developer.gserviceaccount.com
 [2] student-04-6234289191d9@qwiklabs.net
 [3] Log in with a new account
Please enter your numeric choice:  3


You are running on a Google Compute Engine virtual machine.
It is recommended that you use service accounts for authentication.

You can run:

  $ gcloud config set account `ACCOUNT`

to switch accounts if necessary.

Your credentials may be visible to others with access to this
virtual machine. Are you sure you want to authenticate with
your personal account?

Do you want to continue (Y/n)?  Y

Go to the following link in your browser:

    https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fsdk.cloud.google.com%2Fauthcode.html&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice.login+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=gtlxDq0NvdMAFrnIXDgtAh8C0TopqO&prompt=consent&access_type=offline&code_challenge=ZBemYpx4BlVynDQT7cQLB9cHljUVdPwbVHS4DJ9LPeA&code_challenge_method=S256

Enter authorization code: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fsdk.cloud.google.com%2Fauthcode.html&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice.login+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=gtlxDq0NvdMAFrnIXDgtAh8C0TopqO&prompt=consent&access_type=offline&code_challenge=ZBemYpx4BlVynDQT7cQLB9cHljU                                           
ERROR: gcloud crashed (InvalidGrantError): (invalid_grant) Malformed auth code.

If you would like to report this issue, please run the following command:
  gcloud feedback

To check gcloud for common problems, please run the following command:
  gcloud info --run-diagnostics
[student-04-6234289191d9@centos-clean ~]$ gcloud init --no-launch-browser
Welcome! This command will take you through the configuration of gcloud.

Settings from your current configuration [user2] are:
core:
  account: 96240167141-compute@developer.gserviceaccount.com
  disable_usage_reporting: 'True'
  project: qwiklabs-gcp-01-2f669a123a64

Pick configuration to use:
 [1] Re-initialize this configuration [user2] with new settings 
 [2] Create a new configuration
 [3] Switch to and re-initialize existing configuration: [default]
Please enter your numeric choice:  3

Your current configuration has been set to: [default]

You can skip diagnostics next time by using the following flag:
  gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.                                                                           
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).

Choose the account you would like to use to perform operations for this configuration:
 [1] 96240167141-compute@developer.gserviceaccount.com
 [2] student-04-6234289191d9@qwiklabs.net
 [3] Log in with a new account
Please enter your numeric choice:  ^C

Command killed by keyboard interrupt


[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud init --no-launch-browser
Welcome! This command will take you through the configuration of gcloud.

Settings from your current configuration [default] are:
compute:
  region: us-west1
  zone: us-west1-b
core:
  account: student-04-6234289191d9@qwiklabs.net
  disable_usage_reporting: 'True'
  project: qwiklabs-gcp-01-2f669a123a64

Pick configuration to use:
 [1] Re-initialize this configuration [default] with new settings 
 [2] Create a new configuration
 [3] Switch to and re-initialize existing configuration: [user2]
Please enter your numeric choice:  2

Enter configuration name. Names start with a lower case letter and contain only lower case letters a-z, digits 
0-9, and hyphens '-':  user2
ERROR: (gcloud.init) Cannot create configuration [user2], it already exists.
[student-04-6234289191d9@centos-clean ~]$ gcloud init --no-launch-browser
Welcome! This command will take you through the configuration of gcloud.

Settings from your current configuration [default] are:
compute:
  region: us-west1
  zone: us-west1-b
core:
  account: student-04-6234289191d9@qwiklabs.net
  disable_usage_reporting: 'True'
  project: qwiklabs-gcp-01-2f669a123a64

Pick configuration to use:
 [1] Re-initialize this configuration [default] with new settings 
 [2] Create a new configuration
 [3] Switch to and re-initialize existing configuration: [user2]
Please enter your numeric choice:  3

Your current configuration has been set to: [user2]

You can skip diagnostics next time by using the following flag:
  gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.                                                                           
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).

Choose the account you would like to use to perform operations for this configuration:
 [1] 96240167141-compute@developer.gserviceaccount.com
 [2] student-04-6234289191d9@qwiklabs.net
 [3] Log in with a new account
Please enter your numeric choice:  3


You are running on a Google Compute Engine virtual machine.
It is recommended that you use service accounts for authentication.

You can run:

  $ gcloud config set account `ACCOUNT`

to switch accounts if necessary.

Your credentials may be visible to others with access to this
virtual machine. Are you sure you want to authenticate with
your personal account?

Do you want to continue (Y/n)?  Y

Go to the following link in your browser:

    https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fsdk.cloud.google.com%2Fauthcode.html&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice.login+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=xT3TGNy8SDdU8gVsRpd2FdQYBo6yDO&prompt=consent&access_type=offline&code_challenge=d9bwXXCn_9ZKUZMjGvU5dNP05DhAHT_isrp0yKQC5ig&code_challenge_method=S256

Enter authorization code: 4/0AZEOvhUTiOMUx2CoEb5QEZUhhjprxzx3fsiucf9MiGw8ocazBSAL6BqzDczXjdb5mVdbAA
You are logged in as: [student-01-2053c649e0fc@qwiklabs.net].

Pick cloud project to use: 
 [1] qwiklabs-gcp-01-2f669a123a64
 [2] qwiklabs-resources
 [3] Enter a project ID
 [4] Create a new project
Please enter numeric choice or text value (must exactly match list item):  1

Your current project has been set to: [qwiklabs-gcp-01-2f669a123a64].

Your project default Compute Engine zone has been set to [us-west1-a].
You can change it by running [gcloud config set compute/zone NAME].

Your project default Compute Engine region has been set to [us-west1].
You can change it by running [gcloud config set compute/region NAME].

Created a default .boto configuration file at [/home/student-04-6234289191d9/.boto]. See this file and
[https://cloud.google.com/storage/docs/gsutil/commands/config] for more
information about configuring Google Cloud Storage.
Your Google Cloud SDK is configured and ready to use!

* Commands that require authentication will use student-01-2053c649e0fc@qwiklabs.net by default
* Commands will reference project `qwiklabs-gcp-01-2f669a123a64` by default
* Compute Engine commands will use region `us-west1` by default
* Compute Engine commands will use zone `us-west1-a` by default

Run `gcloud help config` to learn how to change individual settings

This gcloud configuration is called [user2]. You can create additional configurations if you work with multiple accounts and/or projects.
Run `gcloud topic configurations` to learn more.

Some things to try next:

* Run `gcloud --help` to see the Cloud Platform services you can interact with. And run `gcloud help COMMAND` to get help on any gcloud command.
* Run `gcloud topic --help` to learn about advanced features of the SDK like arg files and output formatting
* Run `gcloud cheat-sheet` to see a roster of go-to `gcloud` commands.
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud compute instance list
ERROR: (gcloud.compute) Invalid choice: 'instance'.
Maybe you meant:
  gcloud compute instance-groups list-instances
  gcloud compute instances list
  gcloud compute instance-groups list
  gcloud compute instance-groups managed instance-configs list
  gcloud compute instance-templates list
  gcloud compute target-instances list
  gcloud compute instances os-inventory list-instances
  gcloud compute instance-groups managed list-instances
  gcloud compute instance-groups unmanaged list-instances
  gcloud compute instances add-access-config

To search the help text of gcloud commands, run:
  gcloud help -- SEARCH_TERMS
[student-04-6234289191d9@centos-clean ~]$ gcloud confi glist
ERROR: (gcloud) Invalid choice: 'confi'.
Maybe you meant:
  gcloud config

To search the help text of gcloud commands, run:
  gcloud help -- SEARCH_TERMS
[student-04-6234289191d9@centos-clean ~]$ gcloud configlist
ERROR: (gcloud) Invalid choice: 'configlist'.
Maybe you meant:
  gcloud config get
  gcloud config list
  gcloud config set
  gcloud config unset

To search the help text of gcloud commands, run:
  gcloud help -- SEARCH_TERMS
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
zone = us-west1-a
[core]
account = student-01-2053c649e0fc@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [user2]
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud compute instances list
NAME          ZONE        MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP    STATUS
centos-clean  us-west1-a  e2-medium                   10.138.0.2   34.127.54.190  RUNNING
lab-1         us-west1-a  e2-standard-2               10.138.0.3   35.197.89.11   RUNNING
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud compute instances create lab-2 --machine-type=e2-standard-2
ERROR: (gcloud.compute.instances.create) Could not fetch resource:
 - Required 'compute.instances.create' permission for 'projects/qwiklabs-gcp-01-2f669a123a64/zones/us-west1-a/instances/lab-2'

[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations activate default
[student-04-6234289191d9@centos-clean ~]$


[student-04-6234289191d9@centos-clean ~]$ gcloud iam roles list | grep "name:"
name: roles/accessapproval.approver
name: roles/accessapproval.configEditor
name: roles/actions.Admin
name: roles/actions.Viewer
name: roles/advisorynotifications.viewer
- compute.zoneOperations.get
- compute.zoneOperations.list
- compute.zones.get
- compute.zones.list
- resourcemanager.projects.get
- resourcemanager.projects.list
- serviceusage.quotas.get
- serviceusage.services.get
- serviceusage.services.list
name: roles/compute.instanceAdmin
stage: GA
title: Compute Instance Admin (beta)
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 



[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations activate user2
Activated [user2].
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations 
ERROR: (gcloud.config.configurations) Command name argument expected.

Available commands for gcloud config configurations:

      activate                Activates an existing named configuration.
      create                  Creates a new named configuration.
      delete                  Deletes a named configuration.
      describe                Describes a named configuration by listing its
                              properties.
      list                    Lists existing named configurations.
      rename                  Renames a named configuration.

For detailed information on this command and its flags, run:
  gcloud config configurations --help
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations  list
NAME     IS_ACTIVE  ACCOUNT                               PROJECT                       COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  False      student-04-6234289191d9@qwiklabs.net                                us-west1-b            us-west1
user2    True       student-01-2053c649e0fc@qwiklabs.net  qwiklabs-gcp-01-2f669a123a64  us-west1-a            us-west1
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
zone = us-west1-a
[core]
account = student-01-2053c649e0fc@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [user2]
[student-04-6234289191d9@centos-clean ~]$ qwiklabs-gcp-02-7ffb63561000
-bash: qwiklabs-gcp-02-7ffb63561000: command not found
[student-04-6234289191d9@centos-clean ~]$ qwiklabs-gcp-01-2f669a123a64
-bash: qwiklabs-gcp-01-2f669a123a64: command not found
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations activate user1
ERROR: (gcloud.config.configurations.activate) Cannot activate configuration [user1], it does not exist.
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations activate user2
Activated [user2].
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
zone = us-west1-a
[core]
account = student-01-2053c649e0fc@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [user2]
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations  list
NAME     IS_ACTIVE  ACCOUNT                               PROJECT                       COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  False      student-04-6234289191d9@qwiklabs.net                                us-west1-b            us-west1
user2    True       student-01-2053c649e0fc@qwiklabs.net  qwiklabs-gcp-01-2f669a123a64  us-west1-a            us-west1
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud compute instances create lab-2 --machine-type=e2-standard-2
ERROR: (gcloud.compute.instances.create) Could not fetch resource:
 - Required 'compute.instances.create' permission for 'projects/qwiklabs-gcp-01-2f669a123a64/zones/us-west1-a/instances/lab-2'

[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ id
uid=733073824(student-04-6234289191d9) gid=1000(google-sudoers) groups=1000(google-sudoers),39(video) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[student-04-6234289191d9@centos-clean ~]$ cat ~/.config/gcloud/configurations/config_default 
[core]
account = student-04-6234289191d9@qwiklabs.net

[compute]
region = us-west1
zone = us-west1-b

[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ echo "export PROJECTID2=qwiklabs-gcp-02-7ffb63561000" >> ~/.bashrc
[student-04-6234289191d9@centos-clean ~]$ cat ~/.bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
export PROJECTID2=qwiklabs-gcp-02-7ffb63561000
[student-04-6234289191d9@centos-clean ~]$ . ~/.bashrc
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
zone = us-west1-a
[core]
account = student-01-2053c649e0fc@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [user2]
[student-04-6234289191d9@centos-clean ~]$ gcloud config set project $PROJECTID2
WARNING: You do not appear to have access to project [qwiklabs-gcp-02-7ffb63561000] or it does not exist.
Are you sure you wish to set property [core/project] to qwiklabs-gcp-02-7ffb63561000?

Do you want to continue (Y/n)?  N

[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations activate default
Activated [default].
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations list
NAME     IS_ACTIVE  ACCOUNT                               PROJECT                       COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  True       student-04-6234289191d9@qwiklabs.net                                us-west1-b            us-west1
user2    False      student-01-2053c649e0fc@qwiklabs.net  qwiklabs-gcp-01-2f669a123a64  us-west1-a            us-west1
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ sudo yum -y install epel-release
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink                                                                                                |  28 kB  00:00:00     
 * base: mirror.web-ster.com

[student-04-6234289191d9@centos-clean ~]$ sudo yum -y install jq
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.web-ster.com

Complete!


[student-04-6234289191d9@centos-clean ~]$ echo "export USERID2=student-01-2053c649e0fc@qwiklabs.net" >> ~/.bashrc
[student-04-6234289191d9@centos-clean ~]$ cat ~/.bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
export PROJECTID2=qwiklabs-gcp-02-7ffb63561000
export USERID2=student-01-2053c649e0fc@qwiklabs.net
[student-04-6234289191d9@centos-clean ~]$ . ~/.bashrc
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud projects add-iam-policy-binding $PROJECTID2 --member user:$USERID2 --role=roles/viewer
Updated IAM policy for project [qwiklabs-gcp-02-7ffb63561000].
bindings:
- members:
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  role: roles/bigquery.admin
- members:
  - serviceAccount:295933315945@cloudbuild.gserviceaccount.com
  role: roles/cloudbuild.builds.builder
- members:
  - serviceAccount:service-295933315945@gcp-sa-cloudbuild.iam.gserviceaccount.com
  role: roles/cloudbuild.serviceAgent
- members:
  - serviceAccount:service-295933315945@compute-system.iam.gserviceaccount.com
  role: roles/compute.serviceAgent
- members:
  - serviceAccount:service-295933315945@container-engine-robot.iam.gserviceaccount.com
  role: roles/container.serviceAgent
- members:
  - serviceAccount:295933315945-compute@developer.gserviceaccount.com
  - serviceAccount:295933315945@cloudservices.gserviceaccount.com
  role: roles/editor
- members:
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/iam.serviceAccountAdmin
- members:
  - serviceAccount:admiral@qwiklabs-services-prod.iam.gserviceaccount.com
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/owner
- members:
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/resourcemanager.projectIamAdmin
- members:
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  role: roles/storage.admin
- members:
  - user:student-01-2053c649e0fc@qwiklabs.net
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/viewer
etag: BwYByx85k8c=
version: 1
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations list
NAME     IS_ACTIVE  ACCOUNT                               PROJECT                       COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  True       student-04-6234289191d9@qwiklabs.net                                us-west1-b            us-west1
user2    False      student-01-2053c649e0fc@qwiklabs.net  qwiklabs-gcp-01-2f669a123a64  us-west1-a            us-west1
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations activate user2
Activated [user2].
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations list
NAME     IS_ACTIVE  ACCOUNT                               PROJECT                       COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  False      student-04-6234289191d9@qwiklabs.net                                us-west1-b            us-west1
user2    True       student-01-2053c649e0fc@qwiklabs.net  qwiklabs-gcp-01-2f669a123a64  us-west1-a            us-west1
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
zone = us-west1-a
[core]
account = student-01-2053c649e0fc@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [user2]
[student-04-6234289191d9@centos-clean ~]$ gcloud config set project $PROJECTID2
Updated property [core/project].
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
zone = us-west1-a
[core]
account = student-01-2053c649e0fc@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-02-7ffb63561000

Your active configuration is: [user2]
[student-04-6234289191d9@centos-clean ~]$ echo $PROJECTID2
qwiklabs-gcp-02-7ffb63561000
[student-04-6234289191d9@centos-clean ~]$ gcloud compute instances list
Listed 0 items.
[student-04-6234289191d9@centos-clean ~]$ gcloud compute instances create lab-2 --machine-type=e2-standard-2
ERROR: (gcloud.compute.instances.create) Could not fetch resource:
 - Required 'compute.instances.create' permission for 'projects/qwiklabs-gcp-02-7ffb63561000/zones/us-west1-a/instances/lab-2'

[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations list
NAME     IS_ACTIVE  ACCOUNT                               PROJECT                       COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  False      student-04-6234289191d9@qwiklabs.net                                us-west1-b            us-west1
user2    True       student-01-2053c649e0fc@qwiklabs.net  qwiklabs-gcp-02-7ffb63561000  us-west1-a            us-west1
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations activate default
Activated [default].
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations list
NAME     IS_ACTIVE  ACCOUNT                               PROJECT                       COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  True       student-04-6234289191d9@qwiklabs.net                                us-west1-b            us-west1
user2    False      student-01-2053c649e0fc@qwiklabs.net  qwiklabs-gcp-02-7ffb63561000  us-west1-a            us-west1
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 

[student-04-6234289191d9@centos-clean ~]$ gcloud iam roles create devops --project $PROJECTID2 --permissions "compute.instances.create,compute.instances.delete,compute.instances.start,compute.instances.stop,compute.instances.update,compute.disks.create,compute.subnetworks.use,compute.subnetworks.useExternalIp,compute.instances.setMetadata,compute.instances.setServiceAccount"
Created role [devops].
etag: BwYByy6i1rA=
includedPermissions:
- compute.disks.create
- compute.instances.create
- compute.instances.delete
- compute.instances.setMetadata
- compute.instances.setServiceAccount
- compute.instances.start
- compute.instances.stop
- compute.instances.update
- compute.subnetworks.use
- compute.subnetworks.useExternalIp
name: projects/qwiklabs-gcp-02-7ffb63561000/roles/devops
stage: ALPHA
title: devops
[student-04-6234289191d9@centos-clean ~]$ gcloud iam roles list | grep devops
[student-04-6234289191d9@centos-clean ~]$ gcloud iam roles list | more
---
description: Ability to view or act on access approval requests and view configuration
etag: AA==
name: roles/accessapproval.approver
stage: GA
title: Access Approval Approver
---
description: Ability to update the Access Approval configuration
etag: AA==
name: roles/accessapproval.configEditor
stage: GA
title: Access Approval Config Editor
---
description: Ability to invalidate existing approved approval requests
etag: AA==
name: roles/accessapproval.invalidator
stage: GA
title: Access Approval Invalidator
---
description: Ability to view access approval requests and configuration
etag: AA==
name: roles/accessapproval.viewer
stage: GA
title: Access Approval Viewer
---
description: Create, edit, and change Cloud access bindings.
etag: AA==
name: roles/accesscontextmanager.gcpAccessAdmin
stage: GA
title: Cloud Access Binding Admin
---
description: Read access to Cloud access bindings.
etag: AA==
name: roles/accesscontextmanager.gcpAccessReader
stage: GA
title: Cloud Access Binding Reader
---
description: Full access to policies, access levels, access zones and authorized orgs
[student-04-6234289191d9@centos-clean ~]$ gcloud iam roles list | grep "name:" | grep devops

[student-04-6234289191d9@centos-clean ~]$ gcloud projects add-iam-policy-binding $PROJECTID2 --member user:$USERID2 --role=roles/iam.serviceAccountUser
Updated IAM policy for project [qwiklabs-gcp-02-7ffb63561000].
bindings:
- members:
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  role: roles/bigquery.admin
- members:
  - serviceAccount:295933315945@cloudbuild.gserviceaccount.com
  role: roles/cloudbuild.builds.builder
- members:
  - serviceAccount:service-295933315945@gcp-sa-cloudbuild.iam.gserviceaccount.com
  role: roles/cloudbuild.serviceAgent
- members:
  - serviceAccount:service-295933315945@compute-system.iam.gserviceaccount.com
  role: roles/compute.serviceAgent
- members:
  - serviceAccount:service-295933315945@container-engine-robot.iam.gserviceaccount.com
  role: roles/container.serviceAgent
- members:
  - serviceAccount:295933315945-compute@developer.gserviceaccount.com
  - serviceAccount:295933315945@cloudservices.gserviceaccount.com
  role: roles/editor
- members:
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/iam.serviceAccountAdmin
- members:
  - user:student-01-2053c649e0fc@qwiklabs.net
  role: roles/iam.serviceAccountUser
- members:
  - serviceAccount:admiral@qwiklabs-services-prod.iam.gserviceaccount.com
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/owner
- members:
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/resourcemanager.projectIamAdmin
- members:
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  role: roles/storage.admin
- members:
  - user:student-01-2053c649e0fc@qwiklabs.net
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/viewer
etag: BwYByzuIIdY=
version: 1
[student-04-6234289191d9@centos-clean ~]$ gcloud projects add-iam-policy-binding $PROJECTID2 --member user:$USERID2 --role=projects/$PROJECTID2/roles/devops
Updated IAM policy for project [qwiklabs-gcp-02-7ffb63561000].
bindings:
- members:
  - user:student-01-2053c649e0fc@qwiklabs.net
  role: projects/qwiklabs-gcp-02-7ffb63561000/roles/devops
- members:
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  role: roles/bigquery.admin
- members:
  - serviceAccount:295933315945@cloudbuild.gserviceaccount.com
  role: roles/cloudbuild.builds.builder
- members:
  - serviceAccount:service-295933315945@gcp-sa-cloudbuild.iam.gserviceaccount.com
  role: roles/cloudbuild.serviceAgent
- members:
  - serviceAccount:service-295933315945@compute-system.iam.gserviceaccount.com
  role: roles/compute.serviceAgent
- members:
  - serviceAccount:service-295933315945@container-engine-robot.iam.gserviceaccount.com
  role: roles/container.serviceAgent
- members:
  - serviceAccount:295933315945-compute@developer.gserviceaccount.com
  - serviceAccount:295933315945@cloudservices.gserviceaccount.com
  role: roles/editor
- members:
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/iam.serviceAccountAdmin
- members:
  - user:student-01-2053c649e0fc@qwiklabs.net
  role: roles/iam.serviceAccountUser
- members:
  - serviceAccount:admiral@qwiklabs-services-prod.iam.gserviceaccount.com
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/owner
- members:
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/resourcemanager.projectIamAdmin
- members:
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  role: roles/storage.admin
- members:
  - user:student-01-2053c649e0fc@qwiklabs.net
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/viewer
etag: BwYByz02VDM=
version: 1
[student-04-6234289191d9@centos-clean ~]$ history
    1  gcloud --version
    2  gcloud auth login
    3  gcloud config list
    4  gcloud config set compute/regions us-west1
    5  gcloud config set compute/region us-west1
    6  gcloud config list
    7  gcloud config set compute/zone us-west1-a
    8  gcloud config list
    9  gcloud config list zone
   10  gcloud config list project
   11  gcloud config list region
   12  gcloud config list account
   13  gcloud compute instances create lab-1 --zone us-west1-a --machine-type=e2-standard-2
   14  gcloud config list
   15  gcloud compute zones list
   16  gcloud config list zones
   17  gcloud config list
   18  gcloud config set compute/zone us-west1-b
   19  gcloud config list
   20  cat ~/.config/gcloud/configurations/config_default 
   21  gcloud init --no-launch-browser
   22  gcloud compute instance list
   23  gcloud confi glist
   24  gcloud configlist
   25  gcloud config list
   26  gcloud compute instances list
   27  gcloud compute instances create lab-2 --machine-type=e2-standard-2
   28  gcloud config configuration activate default
   29  gcloud config configurations activate default
   30  history
   31  gcloud iam roles list
   32  gcloud iam roles list | grep "name:"
   33  gcloud iam roles describe roles/compute.instanceAdmin
   34  gcloud config configurations activate user2
   35  gcloud config configurations 
   36  gcloud config configurations  list
   37  gcloud config list
   38  qwiklabs-gcp-02-7ffb63561000
   39  qwiklabs-gcp-01-2f669a123a64
   40  gcloud config configurations activate user1
   41  gcloud config configurations activate user2
   42  gcloud config list
   43  gcloud config configurations  list
   44  gcloud compute instances create lab-2 --machine-type=e2-standard-2
   45  id
   46  cat ~/.config/gcloud/configurations/config_default 
   47  echo "export PROJECTID2=qwiklabs-gcp-02-7ffb63561000" >> ~/.bashrc
   48  cat ~/.bashrc
   49  . ~/.bashrc
   50  gcloud config list
   51  gcloud config set project $PROJECTID2
   52  gcloud config configurations activate default
   53  gcloud config configurations list
   54  sudo yum -y install epel-release
   55  sudo yum -y install jq
   56  echo "export USERID2=student-01-2053c649e0fc@qwiklabs.net" >> ~/.bashrc
   57  cat ~/.bashrc
   58  . ~/.bashrc
   59  gcloud projects add-iam-policy-binding $PROJECTID2 --member user:$USERID2 --role=roles/viewer
   60  gcloud config configurations list
   61  gcloud config configurations activate user2
   62  gcloud config configurations list
   63  gcloud config list
   64  gcloud config set project $PROJECTID2
   65  gcloud config list
   66  echo $PROJECTID2
   67  gcloud compute instances list
   68  gcloud compute instances create lab-2 --machine-type=e2-standard-2
   69  gcloud config configurations list
   70  gcloud config configurations activate default
   71  gcloud config configurations list
   72  gcloud iam roles create devops --project $PROJECTID2 --permissions 
   73  gcloud iam roles create devops --project $PROJECTID2 --permissions "compute.instances.create,compute.instances.delete,compute.instances.start,compute.instances.stop,compute.instances.update,compute.disks.create,compute.subnetworks.use,compute.subnetworks.useExternalIp,compute.instances.setMetadata,compute.instances.setServiceAccount"
   74  gcloud iam roles list | grep devops
   75  gcloud iam roles list | more
   76  gcloud iam roles list | grep "name:" | grep devops
   77  gcloud iam roles 
   78  gcloud projects add-iam-policy-binding $PROJECTID2 --member user:$USERID2 --role=roles/iam.serviceAccountUser
   79  gcloud projects add-iam-policy-binding $PROJECTID2 --member user:$USERID2 --role=projects/$PROJECTID2/roles/devops
   80  history
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations list
NAME     IS_ACTIVE  ACCOUNT                               PROJECT                       COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  True       student-04-6234289191d9@qwiklabs.net                                us-west1-b            us-west1
user2    False      student-01-2053c649e0fc@qwiklabs.net  qwiklabs-gcp-02-7ffb63561000  us-west1-a            us-west1
[student-04-6234289191d9@centos-clean ~]$ gcloud iam roles list | grep devops
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations activate user2
Activated [user2].
[student-04-6234289191d9@centos-clean ~]$ gcloud compute instances create lab-2 --machine-type=e2-standard-2
Created [https://www.googleapis.com/compute/v1/projects/qwiklabs-gcp-02-7ffb63561000/zones/us-west1-a/instances/lab-2].
NAME   ZONE        MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP    STATUS
lab-2  us-west1-a  e2-standard-2               10.138.0.2   34.105.80.208  RUNNING
[student-04-6234289191d9@centos-clean ~]$ gcloud compute instances list
NAME   ZONE        MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP    STATUS
lab-2  us-west1-a  e2-standard-2               10.138.0.2   34.105.80.208  RUNNING
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 















[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations list
NAME     IS_ACTIVE  ACCOUNT                               PROJECT                       COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  False      student-04-6234289191d9@qwiklabs.net                                us-west1-b            us-west1
user2    True       student-01-2053c649e0fc@qwiklabs.net  qwiklabs-gcp-02-7ffb63561000  us-west1-a            us-west1
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations activate default
Activated [default].
[student-04-6234289191d9@centos-clean ~]$ gcloud config configurations list
NAME     IS_ACTIVE  ACCOUNT                               PROJECT                       COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  True       student-04-6234289191d9@qwiklabs.net                                us-west1-b            us-west1
user2    False      student-01-2053c649e0fc@qwiklabs.net  qwiklabs-gcp-02-7ffb63561000  us-west1-a            us-west1
[student-04-6234289191d9@centos-clean ~]$ gcloud compute instances list
NAME          ZONE        MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP    STATUS
centos-clean  us-west1-a  e2-medium                   10.138.0.2   34.127.54.190  RUNNING
lab-1         us-west1-a  e2-standard-2               10.138.0.3   35.197.89.11   RUNNING
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
zone = us-west1-b
[core]
account = student-04-6234289191d9@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-01-2f669a123a64

Your active configuration is: [default]
[student-04-6234289191d9@centos-clean ~]$ gcloud config set project $PROJECTID2
Updated property [core/project].
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud config list
[compute]
region = us-west1
zone = us-west1-b
[core]
account = student-04-6234289191d9@qwiklabs.net
disable_usage_reporting = True
project = qwiklabs-gcp-02-7ffb63561000

Your active configuration is: [default]
[student-04-6234289191d9@centos-clean ~]$ 


Task 5. Using a service account

You have seen how to authenticate and use gcloud to access Google Cloud services with roles. Now you'll look at a typical approach.

You have an application that uses the Application Programming Interfaces (APIs) to read and write to Cloud Storage buckets. You don't want to have to authenticate every time you launch a new server, that would be both painful and not in the spirit of using the cloud! So, you use service accounts.

A service account is a special Google account that belongs to your application or a virtual machine (VM) instead of to an individual end user. Your application uses the service account to call the Google API of a service so that the users aren't directly involved.

Learn more about service accounts from the Service accounts Guide.

Now you create a service account, use that service account with a compute instance, then test that the service account allows the access you need.

Create a service account

[student-04-6234289191d9@centos-clean ~]$ gcloud iam service-accounts create devops --display-name devops

Created service account [devops].
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud iam service-accounts list
DISPLAY NAME                            EMAIL                                                                              DISABLED
devops                                  devops@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com                        False
Qwiklabs User Service Account           qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com  False
Compute Engine default service account  295933315945-compute@developer.gserviceaccount.com                                 False
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud iam service-accounts list --filter "displayName=devops"
DISPLAY NAME  EMAIL                                                        DISABLED
devops        devops@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com  False
[student-04-6234289191d9@centos-clean ~]$ SA=$(gcloud iam service-accounts list --format="value(email)" --filter "displayName=devops")
[student-04-6234289191d9@centos-clean ~]$ echo $SA
devops@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud projects add-iam-policy-binding $PROJECTID2 --member serviceAccount:$SA --role=roles/iam.serviceAccountUser
Updated IAM policy for project [qwiklabs-gcp-02-7ffb63561000].
bindings:
- members:
  - user:student-01-2053c649e0fc@qwiklabs.net
  role: projects/qwiklabs-gcp-02-7ffb63561000/roles/devops
- members:
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  role: roles/bigquery.admin
- members:
  - serviceAccount:295933315945@cloudbuild.gserviceaccount.com
  role: roles/cloudbuild.builds.builder
- members:
  - serviceAccount:service-295933315945@gcp-sa-cloudbuild.iam.gserviceaccount.com
  role: roles/cloudbuild.serviceAgent
- members:
  - serviceAccount:service-295933315945@compute-system.iam.gserviceaccount.com
  role: roles/compute.serviceAgent
- members:
  - serviceAccount:service-295933315945@container-engine-robot.iam.gserviceaccount.com
  role: roles/container.serviceAgent
- members:
  - serviceAccount:295933315945-compute@developer.gserviceaccount.com
  - serviceAccount:295933315945@cloudservices.gserviceaccount.com
  role: roles/editor
- members:
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/iam.serviceAccountAdmin
- members:
  - serviceAccount:devops@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  - user:student-01-2053c649e0fc@qwiklabs.net
  role: roles/iam.serviceAccountUser
- members:
  - serviceAccount:admiral@qwiklabs-services-prod.iam.gserviceaccount.com
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/owner
- members:
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/resourcemanager.projectIamAdmin
- members:
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  role: roles/storage.admin
- members:
  - user:student-01-2053c649e0fc@qwiklabs.net
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/viewer
etag: BwYBy2F-0Xc=
version: 1
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud projects add-iam-policy-binding $PROJECTID2 --member serviceAccount:$SA --role=roles/compute.instanceAdmin
Updated IAM policy for project [qwiklabs-gcp-02-7ffb63561000].
bindings:
- members:
  - user:student-01-2053c649e0fc@qwiklabs.net
  role: projects/qwiklabs-gcp-02-7ffb63561000/roles/devops
- members:
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  role: roles/bigquery.admin
- members:
  - serviceAccount:295933315945@cloudbuild.gserviceaccount.com
  role: roles/cloudbuild.builds.builder
- members:
  - serviceAccount:service-295933315945@gcp-sa-cloudbuild.iam.gserviceaccount.com
  role: roles/cloudbuild.serviceAgent
- members:
  - serviceAccount:devops@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  role: roles/compute.instanceAdmin
- members:
  - serviceAccount:service-295933315945@compute-system.iam.gserviceaccount.com
  role: roles/compute.serviceAgent
- members:
  - serviceAccount:service-295933315945@container-engine-robot.iam.gserviceaccount.com
  role: roles/container.serviceAgent
- members:
  - serviceAccount:295933315945-compute@developer.gserviceaccount.com
  - serviceAccount:295933315945@cloudservices.gserviceaccount.com
  role: roles/editor
- members:
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/iam.serviceAccountAdmin
- members:
  - serviceAccount:devops@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  - user:student-01-2053c649e0fc@qwiklabs.net
  role: roles/iam.serviceAccountUser
- members:
  - serviceAccount:admiral@qwiklabs-services-prod.iam.gserviceaccount.com
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/owner
- members:
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/resourcemanager.projectIamAdmin
- members:
  - serviceAccount:qwiklabs-gcp-02-7ffb63561000@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
  role: roles/storage.admin
- members:
  - user:student-01-2053c649e0fc@qwiklabs.net
  - user:student-04-6234289191d9@qwiklabs.net
  role: roles/viewer
etag: BwYBy2TgJb0=
version: 1
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud compute instances create lab-3 --machine-type=e2-standard-2 --service-account $SA --scopes "https://www.googleapis.com/auth/compute"
Created [https://www.googleapis.com/compute/v1/projects/qwiklabs-gcp-02-7ffb63561000/zones/us-west1-b/instances/lab-3].
NAME   ZONE        MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP   STATUS
lab-3  us-west1-b  e2-standard-2               10.138.0.3   34.82.235.65  RUNNING
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ 
[student-04-6234289191d9@centos-clean ~]$ gcloud compute ssh lab-3
WARNING: The private SSH key file for gcloud does not exist.
WARNING: The public SSH key file for gcloud does not exist.
WARNING: You do not have an SSH key for gcloud.
WARNING: SSH keygen will be executed to generate a key.
This tool needs to create the directory [/home/student-04-6234289191d9/.ssh] before being able to generate SSH keys.

Do you want to continue (Y/n)?  Y

Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/student-04-6234289191d9/.ssh/google_compute_engine.
Your public key has been saved in /home/student-04-6234289191d9/.ssh/google_compute_engine.pub.
The key fingerprint is:
SHA256:4M9ZndBiNoqNNQf0a7A3+MFCH/E/2iFw5oWZLY9UMmY student-04-6234289191d9@centos-clean
The key's randomart image is:
+---[RSA 2048]----+
|       .o . E .  |
|         o * O   |
|      . = @ @ o  |
|     . B % & B   |
|      + S X * =  |
|       o B o + o |
|        + . . .  |
|                 |
|                 |
+----[SHA256]-----+
Warning: Permanently added 'compute.4968332160125261736' (ECDSA) to the list of known hosts.
Linux lab-3 5.10.0-23-cloud-amd64 #1 SMP Debian 5.10.179-1 (2023-05-12) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Creating directory '/home/student-04-6234289191d9'.
student-04-6234289191d9@lab-3:~$ 
student-04-6234289191d9@lab-3:~$ 
student-04-6234289191d9@lab-3:~$ gcloud config list
[core]
account = devops@qwiklabs-gcp-02-7ffb63561000.iam.gserviceaccount.com
disable_usage_reporting = True
project = qwiklabs-gcp-02-7ffb63561000

Your active configuration is: [default]
student-04-6234289191d9@lab-3:~$ gcloud compute instances create lab-4 --machine-type=e2-standard-2
Did you mean zone [us-west1-b] for instance: [lab-4] (Y/n)?  Y

Created [https://www.googleapis.com/compute/v1/projects/qwiklabs-gcp-02-7ffb63561000/zones/us-west1-b/instances/lab-4].
NAME   ZONE        MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP      STATUS
lab-4  us-west1-b  e2-standard-2               10.138.0.4   104.199.125.101  RUNNING
student-04-6234289191d9@lab-3:~$ gcloud compute instances list
NAME   ZONE        MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP      STATUS
lab-2  us-west1-a  e2-standard-2               10.138.0.2   34.105.80.208    RUNNING
lab-3  us-west1-b  e2-standard-2               10.138.0.3   34.82.235.65     RUNNING
lab-4  us-west1-b  e2-standard-2               10.138.0.4   104.199.125.101  RUNNING
student-04-6234289191d9@lab-3:~$ 






student-04-6234289191d9@lab-3:~$ history
    1  gcloud config list
    2  gcloud compute instances create lab-4 --machine-type=e2-standard-2
    3  gcloud compute instances list
    4  history
student-04-6234289191d9@lab-3:~$ 


student-04-6234289191d9@lab-3:~$ 
student-04-6234289191d9@lab-3:~$ exit
logout
Connection to 34.82.235.65 closed.
[student-04-6234289191d9@centos-clean ~]$ history
    1  gcloud --version
    2  gcloud auth login
    3  gcloud config list
    4  gcloud config set compute/regions us-west1
    5  gcloud config set compute/region us-west1
    6  gcloud config list
    7  gcloud config set compute/zone us-west1-a
    8  gcloud config list
    9  gcloud config list zone
   10  gcloud config list project
   11  gcloud config list region
   12  gcloud config list account
   13  gcloud compute instances create lab-1 --zone us-west1-a --machine-type=e2-standard-2
   14  gcloud config list
   15  gcloud compute zones list
   16  gcloud config list zones
   17  gcloud config list
   18  gcloud config set compute/zone us-west1-b
   19  gcloud config list
   20  cat ~/.config/gcloud/configurations/config_default 
   21  gcloud init --no-launch-browser
   22  gcloud compute instance list
   23  gcloud confi glist
   24  gcloud configlist
   25  gcloud config list
   26  gcloud compute instances list
   27  gcloud compute instances create lab-2 --machine-type=e2-standard-2
   28  gcloud config configuration activate default
   29  gcloud config configurations activate default
   30  history
   31  gcloud iam roles list
   32  gcloud iam roles list | grep "name:"
   33  gcloud iam roles describe roles/compute.instanceAdmin
   34  gcloud config configurations activate user2
   35  gcloud config configurations 
   36  gcloud config configurations  list
   37  gcloud config list
   38  qwiklabs-gcp-02-7ffb63561000
   39  qwiklabs-gcp-01-2f669a123a64
   40  gcloud config configurations activate user1
   41  gcloud config configurations activate user2
   42  gcloud config list
   43  gcloud config configurations  list
   44  gcloud compute instances create lab-2 --machine-type=e2-standard-2
   45  id
   46  cat ~/.config/gcloud/configurations/config_default 
   47  echo "export PROJECTID2=qwiklabs-gcp-02-7ffb63561000" >> ~/.bashrc
   48  cat ~/.bashrc
   49  . ~/.bashrc
   50  gcloud config list
   51  gcloud config set project $PROJECTID2
   52  gcloud config configurations activate default
   53  gcloud config configurations list
   54  sudo yum -y install epel-release
   55  sudo yum -y install jq
   56  echo "export USERID2=student-01-2053c649e0fc@qwiklabs.net" >> ~/.bashrc
   57  cat ~/.bashrc
   58  . ~/.bashrc
   59  gcloud projects add-iam-policy-binding $PROJECTID2 --member user:$USERID2 --role=roles/viewer
   60  gcloud config configurations list
   61  gcloud config configurations activate user2
   62  gcloud config configurations list
   63  gcloud config list
   64  gcloud config set project $PROJECTID2
   65  gcloud config list
   66  echo $PROJECTID2
   67  gcloud compute instances list
   68  gcloud compute instances create lab-2 --machine-type=e2-standard-2
   69  gcloud config configurations list
   70  gcloud config configurations activate default
   71  gcloud config configurations list
   72  gcloud iam roles create devops --project $PROJECTID2 --permissions 
   73  gcloud iam roles create devops --project $PROJECTID2 --permissions "compute.instances.create,compute.instances.delete,compute.instances.start,compute.instances.stop,compute.instances.update,compute.disks.create,compute.subnetworks.use,compute.subnetworks.useExternalIp,compute.instances.setMetadata,compute.instances.setServiceAccount"
   74  gcloud iam roles list | grep devops
   75  gcloud iam roles list | more
   76  gcloud iam roles list | grep "name:" | grep devops
   77  gcloud iam roles 
   78  gcloud projects add-iam-policy-binding $PROJECTID2 --member user:$USERID2 --role=roles/iam.serviceAccountUser
   79  gcloud projects add-iam-policy-binding $PROJECTID2 --member user:$USERID2 --role=projects/$PROJECTID2/roles/devops
   80  history
   81  gcloud config configurations list
   82  gcloud iam roles list | grep devops
   83  gcloud config configurations activate user2
   84  gcloud compute instances create lab-2 --machine-type=e2-standard-2
   85  gcloud compute instances list
   86  gcloud config configurations list
   87  gcloud config configurations activate default
   88  gcloud config configurations list
   89  gcloud compute instances list
   90  gcloud config list
   91  gcloud config set project $PROJECTID2
   92  gcloud config list
   93  gcloud iam service-accounts create devops --display-name devops
   94  gcloud iam service-accounts list
   95  gcloud iam service-accounts list --filter "displayName=devops"
   96  SA=$(gcloud iam service-accounts list --format="value(email)" --filter "displayName=devops")
   97  echo $SA
   98  gcloud projects add-iam-policy-binding $PROJECTID2 --member serviceAccount:$SA --role=roles/iam.serviceAccountUser
   99  gcloud projects add-iam-policy-binding $PROJECTID2 --member serviceAccount:$SA --role=roles/compute.instanceAdmin
  100  gcloud compute instances create lab-3 --machine-type=e2-standard-2 --service-account $SA --scopes "https://www.googleapis.com/auth/compute"
  101  gcloud compute ssh lab-3
  102  history
[student-04-6234289191d9@centos-clean ~]$ 

create a Data Fusion instance and deploy a sample pipeline

Create a Data Fusion instance and deploy a sample pipeline that reads an input file from Cloud Storage, transforms and filters the data to o...