DE Zoomcamp 1.3.1 - Introduction to Terraform Concepts & GCP Pre-Requisites

DataTalksClub ⬛
17 Jan 202222:17

Summary

TLDRThis session introduces Terraform, an open-source tool by HashiCorp, for provisioning infrastructure with declarative configuration files. It emphasizes Infrastructure as Code (IaC) for managing infrastructure safely and consistently. The tutorial covers setting up a GCP account, creating a project, and generating a service account with necessary permissions. It also guides through installing the Terraform client and Google Cloud SDK, authenticating with GCP, and enabling APIs for Terraform to interact with GCP resources like Cloud Storage and BigQuery.

Takeaways

  • πŸ˜€ Terraform is an open-source tool by HashiCorp used for provisioning infrastructure resources with declarative configuration files.
  • πŸ› οΈ Terraform supports Infrastructure as Code (IaC), enabling DevOps best practices for change management and version control of infrastructure.
  • πŸ’Ύ It allows you to manage infrastructure lifecycle with stack-based deployment, enabling the creation and destruction of resource clusters.
  • πŸ”— The Terraform state is crucial for tracking resource changes throughout deployments.
  • πŸ’» To use Terraform, you need the Terraform client and a GCP account, with the free tier offering up to 300 euros in credits.
  • πŸ”‘ A service account in GCP is created for services to interact with cloud resources, with restricted permissions for security.
  • πŸ”— Service accounts are used to grant specific permissions to interact with GCP resources like Cloud Storage and BigQuery.
  • πŸ”— The Google Cloud SDK (gcloud) is necessary for local interaction with GCP services, and it can be authenticated using OAuth.
  • πŸ› οΈ For the tutorial, permissions are kept simple with admin roles, but in production, custom roles with specific permissions are recommended.
  • πŸ”„ APIs need to be enabled in GCP for services like IAM and BigQuery to interact with the cloud resources through the local environment.

Q & A

  • What is Terraform and what does it enable?

    -Terraform is an open-source tool by Hashicorp that allows you to provision infrastructure resources with declarative configuration files. It supports Infrastructure as Code (IaC), enabling DevOps best practices for change management.

  • What are the types of resources Terraform can manage?

    -Terraform can manage various types of resources including virtual machines, containers, storage, and networking resources.

  • What is Infrastructure as Code (IaC) and how does it benefit infrastructure management?

    -Infrastructure as Code (IaC) is a framework that allows you to build, change, and manage infrastructure in a safe, consistent, and repeatable way by defining resource configurations that can be version-controlled, reused, and shared.

  • How does Terraform's state feature help in managing infrastructure?

    -Terraform's state feature allows you to track resource changes throughout your deployments, enabling you to manage the infrastructure lifecycle and collaborate safely on your infrastructure.

  • What are the prerequisites for setting up Terraform with GCP?

    -The prerequisites include the Terraform client, which can be downloaded from the official site, and a GCP account, which can be a free account with a certain amount of credit depending on the region.

  • Why is a service account important in GCP when using Terraform?

    -A service account in GCP is important as it provides credentials for services to interact with GCP resources. It has restricted permissions, allowing specific services to perform necessary actions without requiring the owner's account or admin account.

  • How can you create a service account in GCP?

    -You can create a service account in GCP by navigating to the 'Service accounts' section in the IAM & Admin panel, providing a name and description, and assigning it a role, such as 'Viewer' to start with.

  • What is the purpose of generating and downloading a key for a service account in GCP?

    -Generating and downloading a key for a service account in GCP provides credentials that the service account can use to authenticate and interact with GCP resources, allowing the service to perform actions on behalf of the account.

  • What is the Google Cloud SDK and why is it necessary?

    -The Google Cloud SDK is a CLI tool that allows you to interact with your cloud services, list them, and authenticate your Google application credentials or service account key to interact with the cloud from your local machine.

  • How do you authenticate your local setup with GCP using the service account key?

    -You authenticate your local setup with GCP by setting the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable to the path of the downloaded service account key and then using the 'gcloud auth' command to authenticate.

  • What are the two resources that will be created in the GCP environment during the exercise?

    -The two resources that will be created are Google Cloud Storage, which is a bucket for storing data, and BigQuery, which is Google's equivalent of a data warehouse.

  • Why is it necessary to enable APIs in GCP for Terraform to work?

    -Enabling APIs in GCP is necessary because they are the enablers of communication between your local environment and the cloud resources. They allow Terraform to interact with services like IAM and manage credentials.

Outlines

00:00

πŸ› οΈ Introduction to Terraform and GCP Infrastructure Setup

The speaker begins by introducing the session's focus on Terraform, an open-source tool by Hashicorp, which is used for provisioning infrastructure resources through declarative configuration files. These resources can range from virtual machines to storage and networking. Terraform supports Infrastructure as Code (IaC), aligning with DevOps best practices for change management. It allows for version control of infrastructure, enabling the management of resources through configuration files rather than a GUI. The session aims to cover Terraform basics and setting up GCP infrastructure using Terraform. The speaker shares their screen and proceeds to demonstrate the setup process, starting with downloading the Terraform client and accessing a GCP account, which can be obtained for free and includes a 300-euro credit for the first 90 days.

05:00

πŸ”‘ Setting Up Service Accounts and Keys in GCP

The speaker demonstrates how to create a service account in GCP, explaining that it is an account designated for services, allowing them to interact with GCP resources with restricted permissions. A service account is created with a unique name and description, and the 'Viewer' role is assigned initially. The speaker then guides through generating a JSON key for the service account, which is essential for authenticating the service account with GCP. The Google Cloud SDK (gcloud) is also introduced as a CLI tool for interacting with cloud services, and instructions are provided for checking its installation and installing it if necessary. The process involves setting an environment variable for the service account key and authenticating it, which allows the local setup to interact with the cloud environment.

10:02

πŸ”— Authenticating Local Setup with Cloud Environment

The speaker discusses the process of authenticating the local setup with the cloud environment using the Google Cloud SDK. They mention that the authentication process involves setting an environment variable for the service account key and using a command to authenticate it. The speaker also touches upon different authentication methods, including OAuth, which may be used in different scenarios. They provide a practical demonstration by setting the environment variable and authenticating it, which successfully links the local setup with the cloud, allowing for interaction between the two environments.

15:03

πŸ“¦ Creating Resources in GCP Using Terraform

The speaker outlines the next steps in the tutorial, which involve creating two resources in the Google Cloud Platform: Cloud Storage and BigQuery. They explain that Cloud Storage is akin to a data lake for storing raw data, while BigQuery serves as a data warehouse for structured data storage. The speaker emphasizes the importance of adding permissions to the service account to enable Terraform to create these resources. They guide through adding 'Storage Admin' and 'BigQuery Admin' roles to the service account and mention the need to enable APIs for communication between the local environment and cloud resources. The speaker also advises on the importance of selecting the correct project when enabling APIs and reassures the audience that the provided credits are sufficient for the course's exercises.

20:04

πŸš€ Starting the Terraform Setup

The final paragraph sees the speaker preparing to begin the Terraform setup. They recap the steps taken so far, including enabling APIs and ensuring that the service account has the necessary permissions. The speaker also acknowledges that the APIs and permissions setup is complete and moves on to the actual Terraform configuration. They provide a link for downloading Terraform based on the user's operating system and express readiness to proceed with the Terraform part of the tutorial.

Mindmap

Keywords

πŸ’‘Terraform

Terraform is an open-source infrastructure as code (IaC) tool developed by HashiCorp. It allows users to define and provision infrastructure resources such as virtual machines, containers, storage, and networking using declarative configuration files. In the video, Terraform is introduced as a tool to set up GCP (Google Cloud Platform) infrastructure, highlighting its ability to manage infrastructure lifecycle and track resource changes through its state functionality.

πŸ’‘Infrastructure as Code (IaC)

Infrastructure as Code (IaC) is a methodology that involves managing and provisioning computer data centers through machine-readable definition files, rather than physical hardware configuration or interactive configuration tools. The video emphasizes IaC as a framework that enables the safe, consistent, and repeatable management of infrastructure through version-controlled configuration files, akin to using Git for infrastructure.

πŸ’‘HashiCorp

HashiCorp is a software company that provides DevOps tools, including Terraform, which is the main focus of the video. The company is known for its suite of tools that address various aspects of infrastructure management, and Terraform is one of its flagship products for IaC.

πŸ’‘Google Cloud Platform (GCP)

Google Cloud Platform (GCP) is a suite of cloud computing services offered by Google. It provides a variety of services including computing, data storage, and machine learning. In the context of the video, GCP is used as the cloud environment where Terraform provisions and manages infrastructure resources.

πŸ’‘Service Account

A service account in GCP is a special type of account used by applications or services, rather than humans. It has restricted permissions and is used to authenticate interactions between the local Terraform client and GCP resources. The video describes the process of creating a service account and generating a key for secure API access.

πŸ’‘Version Control

Version control is a system that records changes to a file or set of files over time so that specific versions can be recalled later. In the video, version control is mentioned in the context of managing Terraform configuration files, which allows for collaboration and tracking changes to infrastructure in a controlled manner.

πŸ’‘Google Cloud Storage

Google Cloud Storage is a service provided by Google as part of its cloud platform that offers online file storage and access through the Internet. In the video, it is mentioned as one of the resources that Terraform can provision, where data can be stored in a manner similar to a local file system.

πŸ’‘BigQuery

BigQuery is Google's fully-managed, serverless data warehouse that enables scalable analysis over petabytes of data. The video introduces BigQuery as a resource that Terraform can set up, which is used for structured data storage and complex querying capabilities.

πŸ’‘OAuth

OAuth is an open standard for access delegation, commonly used as a way for Internet users to grant websites or applications access to their information on other websites without giving them the passwords. In the video, OAuth is discussed as a method for authenticating the local setup with the cloud environment using a service account key.

πŸ’‘APIs

APIs, or Application Programming Interfaces, are sets of rules and protocols for building and interacting with software applications. In the context of the video, APIs are mentioned as enablers for communication between the local environment and GCP resources, such as IAM and service account credentials.

πŸ’‘Data Lake

A data lake is a storage repository that holds a vast amount of raw data in its native format until it is needed. In the video, the concept of a data lake is introduced as a place to store raw data in an organized fashion within Google Cloud Storage, which is partitioned and compressed for efficient use.

Highlights

Introduction to Terraform, an open-source tool by Hashicorp for infrastructure provisioning.

Terraform uses declarative configuration files to manage infrastructure resources.

Explanation of Infrastructure as Code (IaC) and its benefits for DevOps.

Advantages of managing infrastructure lifecycle with Terraform.

How to download and install the Terraform client.

Requirements for setting up GCP infrastructure with Terraform.

Details on creating a GCP account and accessing free credits.

Step-by-step guide to creating a GCP project.

Understanding the role of service accounts in GCP.

Process of creating a service account and assigning roles in GCP.

Importance of managing keys for service accounts in GCP.

Installation and setup of the Google Cloud SDK.

Authentication of local setup with GCP using OAuth.

How to set environment variables for Google Application Credentials.

Explanation of the difference between admin roles and custom roles in GCP.

Enabling APIs for services like IAM and BigQuery.

Introduction to Google Cloud Storage and BigQuery as resources in GCP.

Concept of a data lake and its role in organizing raw data.

Terraform's role in managing resources like cloud storage and data warehouses.

Transcripts

play00:00

hi everyone

play00:01

so now we we are going to cover a

play00:04

terraform and say we'll do that so

play00:07

yeah let's start

play00:08

hey everyone how's it going

play00:10

so yeah today's session is uh the part

play00:14

of the week one session where we are

play00:16

we'll be covering the concepts of

play00:18

terraform at an introductory level and

play00:21

also how to set up your gcp

play00:25

infrastructure using terraform so let's

play00:27

get started

play00:29

and

play00:30

i'll just share my screen now

play00:35

so terraform is actually an open source

play00:38

tool

play00:39

by hashicorp and

play00:41

it lets you provision infrastructure

play00:43

resources with declarative configuration

play00:46

files these resources can be virtual

play00:48

machines or containers or storage or

play00:51

even networking resources

play00:53

and apart from this terraform also uses

play00:56

an iac style approach which supports

play00:59

devops best practices for change

play01:01

management which lets you manage

play01:03

terraform configuration files and source

play01:05

control to maintain an ideal provision

play01:07

state for testing and production

play01:09

environments

play01:10

now what really is ise ise is

play01:14

infrastructure as code

play01:16

this allows

play01:18

you to build it's a framework which

play01:20

allows you to build change and manage

play01:22

your infrastructure in a safe consistent

play01:24

and repeatable way by defining resource

play01:27

configurations that you can version

play01:29

reuse and share so think of this as a

play01:32

git version control but for

play01:33

infrastructure

play01:36

and this also allows you to manage the

play01:37

infrastructure with configuration files

play01:39

alone rather than through a graphical

play01:42

user interface

play01:43

so mainly the advantages are

play01:47

it helps you manage your

play01:49

infrastructure life cycle

play01:51

in a very stack based deployment style

play01:53

so basically you can deploy an entire

play01:56

cluster of resources together

play02:00

like create your entire set of resources

play02:02

together and destroy it at any point in

play02:04

time while all of these resources within

play02:07

a cluster are connected with each other

play02:09

you can also commit your configurations

play02:11

to version control to safely collaborate

play02:14

on your infrastructure

play02:15

and the most important part is the

play02:18

terraforms state

play02:20

which allows you to track resource

play02:22

changes throughout your deployments

play02:24

so i'll explain more about that a little

play02:26

later

play02:27

so what we need is only two things here

play02:30

one is the terraform client

play02:33

which you can download from this link

play02:35

based on whatever is your os type

play02:38

and follow the instructions through and

play02:40

i already have it installed so

play02:43

i

play02:44

won't exactly show you the steps but

play02:46

it's just a two step two to three step

play02:48

process and thread it will be

play02:49

straightforward

play02:51

and the other thing that you would need

play02:52

is your gcp account

play02:55

uh basically with your google

play02:57

id you can also get a free account if

play03:00

you have not

play03:02

set up an account previously on that id

play03:04

and the free version provides up to 300

play03:07

euro credits uh this i mean euro in

play03:10

terms of the region that we are

play03:12

currently in which is germany uh based

play03:15

on the region that you are set in you'll

play03:17

be getting some free amount of credits

play03:19

which would be

play03:21

mostly more than enough for all of the

play03:24

exercises that we'll be performing

play03:26

throughout our course

play03:27

uh this is also with a 90-day

play03:31

life cycle

play03:32

so you do not really need to worry if

play03:34

you're going to like you know meet the

play03:36

nd 20 so

play03:38

so

play03:40

as you can see here

play03:42

i already have an account created and

play03:45

i already have like a

play03:47

first project set up for child but i can

play03:51

walk you through creating the first

play03:53

project and whatever things you'll be

play03:55

needing in

play03:57

terms of coordinating in terms of your

play03:59

local client coordinating with the cloud

play04:01

resources which is a service account and

play04:03

im access and so on and so forth so

play04:06

let's begin

play04:08

so once you already have your

play04:11

gcp account set up what you do is create

play04:15

a project

play04:16

i already have it but i will create a

play04:19

new one here

play04:22

and

play04:23

let's call this something like

play04:26

dtcde

play04:28

whatever you feel like putting

play04:31

um

play04:32

my project id is dt dtcde

play04:36

but i'm going to edit this and put this

play04:39

to

play04:41

something more unique which generally

play04:43

happens so let me refresh this and okay

play04:46

now it's set some unique project id for

play04:49

myself

play04:50

uh you can always customize it but

play04:52

please make sure that i'm a unique

play04:54

project id um across the entire gcp

play04:57

environment

play04:58

otherwise it won't

play05:00

allow you to do that

play05:02

all right so now

play05:05

we create this

play05:10

and we have a notification here that

play05:12

it's creating a project

play05:16

perfect now let's

play05:19

wait so

play05:20

now i'm switching to the project that we

play05:23

just created

play05:25

and

play05:26

what we will do now is

play05:28

go to

play05:30

im admin

play05:33

the service accounts

play05:40

okay let's go ahead and create our

play05:42

service account um so alexi do you know

play05:45

what a sales account is

play05:47

not really but

play05:49

so i think the way i understood it

play05:52

is that a service account is an account

play05:54

that you create for a service as the

play05:56

name suggests and service could be

play05:58

anything

play05:59

usually it's a service so it can be your

play06:01

data pipeline or your

play06:03

i don't know web service or something

play06:04

like this but this is a specific project

play06:06

that you work on

play06:08

um like specific service

play06:12

and everything that this service needs

play06:15

will be configured here in this service

play06:17

account

play06:18

so like if a service needs to go to

play06:20

cloud storage we will grant access to

play06:22

this cloud storage in this service

play06:24

account

play06:25

and what it lets us

play06:28

do is it will give us a

play06:30

credentials some credentials and these

play06:32

credentials will belong to this server

play06:34

and then this server will get access to

play06:37

all the things from gcp that we need

play06:40

and

play06:41

does it sound right

play06:43

that is perfect yeah so in in a nutshell

play06:46

services a service account is actually

play06:48

an account for

play06:50

as name suggests services so you

play06:53

basically you won't need your owner's

play06:56

account or the admin account for the

play06:58

resources to interact with each other it

play07:01

has restricted or limited permissions so

play07:05

let's begin with

play07:07

creating it so

play07:09

let's um

play07:10

call this service account dtcde

play07:15

user or anything you would like to keep

play07:18

it as

play07:20

this does not need to be globally unique

play07:22

because this in combination to the email

play07:26

address of your project

play07:29

will already make it globally unique so

play07:31

you do not need to worry

play07:33

um description can be anything you want

play07:35

to put

play07:36

maybe dtcd course something

play07:39

so

play07:41

let's go to next and let's let's use the

play07:43

viewer um role for now but this is only

play07:46

to begin with

play07:48

all right and this step is not something

play07:50

that we need for now but this is uh

play07:53

useful if you're setting up production

play07:55

environment and

play07:57

want to

play07:58

have multiple users associated to a

play08:01

certain service account which share the

play08:03

same level of permissions

play08:05

okay and

play08:08

let's click done

play08:10

and

play08:11

as you see here there is

play08:13

there are no keys generated yet so what

play08:16

we do is like

play08:18

go here

play08:19

to manage keys

play08:22

and then

play08:23

create a new key

play08:25

let's keep it json so that in case you

play08:28

ever want to break you know open the

play08:30

file in the text editor and read and

play08:32

retrieve your password you can always do

play08:34

that

play08:35

so

play08:36

create it

play08:38

and now

play08:40

downloads it into your default default

play08:43

download directory the other thing you

play08:46

need is your sdk

play08:48

which is a cli uh the google sdk which

play08:51

is a cli tool in for you to interact

play08:55

with your cloud services maybe list them

play08:58

or maybe even authenticate your

play09:01

google application credentials or the

play09:02

service account key in order to interact

play09:05

with the cloud from your local so so on

play09:07

and so forth so in case you want to

play09:10

check if your

play09:12

gcloud is sdk is already installed then

play09:15

you can do a gcloud hyphen v

play09:18

and

play09:20

you will see it here

play09:22

um if you do not have it then i would

play09:24

suggest

play09:26

this link

play09:27

and install it

play09:29

from here

play09:33

based on your os it will suggest which

play09:36

which one you need to like you know

play09:39

download and it's a very straightforward

play09:40

installation process just follow it

play09:42

through not for windows though so for

play09:44

windows i prepared like a set of

play09:46

instructions that we will include also

play09:49

because i had

play09:51

some problems doing that so i will

play09:54

add a link to windows instructions there

play09:57

i had to to try

play09:59

multiple options before i finally had

play10:01

one that worked

play10:03

oh okay wow sorry to hear that

play10:06

but yeah i guess

play10:08

the google client is not um yet as

play10:11

mature as the aws client or many

play10:14

comparable providers but it's it's

play10:17

getting there so hopefully we would have

play10:19

uh like you know more stable client for

play10:21

windows as well soon

play10:24

cool but yeah thanks alexi for preparing

play10:27

that um

play10:29

so once you have the sdk installed

play10:33

go to

play10:34

go back to your instructions and set

play10:37

your environment variable

play10:40

google applications credentials

play10:42

to the downloaded service key service

play10:45

account key that you

play10:47

have generated

play10:49

now that we have our gcloud installed

play10:53

we'll go look for our

play10:55

service account key that we downloaded

play10:58

so in because i'm using a mac os it by

play11:02

default downloads into the download

play11:04

directory in my home directory

play11:07

and

play11:08

my project is actually my project id is

play11:12

global maxim

play11:14

338113

play11:16

so

play11:17

the key should also be something related

play11:21

to that let's search okay now we have it

play11:24

there let me check the time stamp again

play11:30

yes okay that we just generated

play11:34

a few months ago so i am going to

play11:43

set the google applications credentials

play11:45

uh environment variable which is a

play11:49

system um specific or let's say uh

play11:53

google cloud specific um environment

play11:56

variable for it to for for the for the

play11:59

invite basically for the system or

play12:01

google to understand that this is your

play12:04

application key or the authentication

play12:06

key and this is uh with which you have

play12:10

to authenticate uh your other resources

play12:13

so let me

play12:17

set that

play12:19

[Music]

play12:21

and provide this key as the path

play12:28

all right

play12:29

and now

play12:32

i use this command

play12:35

[Music]

play12:36

to to authenticate it so that it picks

play12:40

up the key from this environment

play12:41

variable

play12:47

so

play12:48

okay

play12:49

so what's what what it is saying it what

play12:52

it is saying is um

play12:54

it was using and uh you know an earlier

play12:58

uh default credentials which i had

play13:00

already set up for myself uh mostly with

play13:02

the owner account and now it's detected

play13:05

a new set of keys

play13:06

associated with a new project or a new

play13:08

service account so

play13:10

do i want to replace that so i will

play13:13

set yes

play13:15

and the next step is i have to

play13:17

authenticate it so this will redirect me

play13:20

to a browser link

play13:21

i just choose my email

play13:25

allow it

play13:27

and now it says my cloud sdk is

play13:30

authenticated with the

play13:33

basically my local setup is

play13:34

authenticated with the cloud environment

play13:36

so

play13:36

if you get this too congratulations your

play13:39

local is now um able to interact with

play13:41

the cloud deployment

play13:44

i think this way of authenticating is

play13:46

called o

play13:47

auth way of authenticating that's not

play13:50

the only one i think there is a

play13:52

different one i think when i was playing

play13:54

with this i came across with

play13:56

across another one so i'll also have

play13:58

this in the notes so you can check it

play14:00

out

play14:01

which doesn't involve a browser

play14:04

but i think it's uh it's very similar

play14:07

okay nice does it refresh the token on

play14:10

your yeah i think it doesn't like let's

play14:12

say when you do this on

play14:14

some instance and you don't have access

play14:16

to your browser you cannot actually

play14:17

authenticate using all auth

play14:20

then there is a different way of doing

play14:22

this so i'll include this in notes

play14:25

sounds like your sso and aws

play14:28

which

play14:29

which you refresh the token every time

play14:31

in order to log in yeah

play14:33

okay nice nice to know that

play14:36

so

play14:37

okay now we press now that you already

play14:40

have your local setup ready

play14:43

we proceed to the actual part

play14:46

um

play14:47

also just to show you this is the

play14:50

download link for terraform and based on

play14:53

your kind of os you can install it via

play14:57

whichever package manager you're using

play14:59

for example brew

play15:01

or

play15:02

choco or anything else

play15:06

all right so

play15:09

let's move on

play15:14

i just want to add that

play15:15

installing terraform on windows was

play15:17

surprisingly smooth

play15:19

so i just needed to unpack the

play15:21

executable to a folder in my path

play15:24

and that was it so it picked it up and

play15:28

it just worked

play15:29

so i was surprised

play15:31

so usually on windows i need to

play15:34

do a lot of googling to figure out how

play15:35

to actually make things work

play15:38

but this one was very smooth

play15:41

nice

play15:42

awesome

play15:43

so

play15:44

all right so what we're going to do with

play15:46

this exercise now is create two

play15:51

resources in the google environment one

play15:53

is the cloud storage and one is uh the

play15:56

bigquery warehouse

play15:58

and we'll be explaining uh the concept

play16:01

of like you know

play16:03

those resources in the data sections but

play16:06

for now uh

play16:08

a cloud storage is actually a bucket in

play16:12

in your gcp environment uh where you can

play16:15

store the data in a manner of flat files

play16:20

so if you've uh seen any local file

play16:23

storage with directories and like with

play16:25

csvs or jsons in it it it basically is

play16:28

just like that

play16:30

uh we also refer to it in our course as

play16:33

a data lake uh which you will understand

play16:36

as we proceed in the course but

play16:39

a data lake is where we are going to

play16:41

store all the raw data in a more

play16:43

organized fashion uh partitioned by uh

play16:47

more sensible directories and also

play16:50

compressed with uh

play16:53

like you know compressed with certain

play16:55

file types not only with csvs and jsons

play16:58

but also parquet files

play17:00

and bigquery is actually

play17:02

your google equivalent of data warehouse

play17:05

where the data is like uh modeled into a

play17:08

more structured format with fact and

play17:10

dimension tables and like you know the

play17:13

classical data warehouse concepts that

play17:15

you may already be familiar with

play17:17

all right but we will definitely explain

play17:20

more about that in the upcoming lectures

play17:22

but let's move on to the rest of the

play17:24

setup

play17:25

so now that your local is already

play17:28

authenticated with the cloud environment

play17:30

let's go and add more permissions for

play17:34

your service account

play17:35

um

play17:37

this is the one that we just created

play17:40

so

play17:41

what we are going to do is uh we will

play17:44

try to keep it simple for this tutorial

play17:46

but it is not

play17:47

advisable for a production environment

play17:51

but we will

play17:52

add

play17:54

in order to create uh the google cloud

play17:56

storage we'd add a storage admin

play18:00

[Music]

play18:03

do you know what this role actually does

play18:04

i think it allows

play18:06

to

play18:07

create

play18:09

buckets and then

play18:11

create files there right and this is

play18:13

what we need so our terraform job

play18:15

needs to

play18:17

go there to google cloud and create a

play18:19

bucket there so right now we're granting

play18:21

our service permissions to do that

play18:24

that's correct right right right

play18:26

so we are granting two kinds of storage

play18:29

rules one is uh for

play18:32

the bucket itself and the other is for

play18:35

the objects within the bucket

play18:38

and uh by admin it has it means it has

play18:42

all the ownership level positions that

play18:44

is create update um

play18:47

delete uh write read and

play18:50

yeah you know grant access across and so

play18:52

on and so forth

play18:54

um and in real production we would

play18:57

restrict it to a particular

play18:59

uh bucket for example right that's

play19:01

that's right in in real production you

play19:04

would not generally use the like you

play19:07

know the self the google provided roles

play19:10

the uh what you see here is actually the

play19:13

predefined roads created by uh gcp

play19:15

themselves in production what you would

play19:17

do is actually custom create custom

play19:20

roles

play19:21

and associate specific permissions

play19:24

uh associated to certain resources

play19:27

but

play19:28

for just for the simplicity of our

play19:30

course we will keep it for uh to this

play19:32

for now

play19:34

yeah i guess it will make sense for it

play19:36

to create maybe as

play19:38

one service account for terraform which

play19:40

will have all the admin roles and then

play19:42

for another service for a different

play19:44

service for our data pipeline it would

play19:46

be a separate service with its own

play19:48

permissions right

play19:50

yes

play19:50

yes that that's actually uh what uh like

play19:53

you know the ideal production style is

play19:56

uh with most companies so good point

play20:00

cool and finally we are also going to

play20:04

add a big query

play20:07

oops a big query admin

play20:10

because we also want to interact with

play20:16

[Music]

play20:18

bigquery we also need to enable apis so

play20:22

what really happens is when the cloud

play20:25

when the local environment interacts

play20:27

with the cloud environment it does not

play20:30

interact directly with the resource it

play20:34

basically these apis are the enablers of

play20:38

communication

play20:40

so one is for the iam itself

play20:43

and the other one is for im credentials

play20:47

possibly i may have already

play20:48

authenticated it but let's see

play20:55

and i think it's important to to note

play20:57

here that when you open this page you

play21:00

have a

play21:02

drop down list so for this one yeah so

play21:05

at the top you have like a drop down

play21:07

list with projects so you need to make

play21:08

sure that you select the project for

play21:10

which you want to authenticate like this

play21:12

this one exactly because sometimes you

play21:15

may have multiple projects

play21:18

yes

play21:19

good point

play21:22

um another thing that i wanted to

play21:24

mention is um

play21:26

uh don't be like you know uh

play21:28

worried about this uh currently i think

play21:31

you should see only 300 credits in my

play21:34

case it's 265 because i already have

play21:36

multiple projects and multiple resources

play21:38

created in each project so

play21:41

i've already used some credits but

play21:44

only some of it has been depleted so far

play21:46

in like the last two weeks so i think we

play21:49

have a lot more left to go

play21:52

for you guys to run your experiments on

play21:57

so okay once we have the apis enabled um

play22:03

this is something that you've already

play22:04

done

play22:07

this is also something you've already

play22:09

done but if your session has expired

play22:11

then you can try it again

play22:13

and now we begin with the terraform part

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
TerraformGCPInfrastructureDevOpsCloud StorageBigQueryService AccountIAMAPIsAuthentication