GCP Terraform Tutorial | What Is Terraform | Terraform With Google Cloud Platform (GCP) | Edureka

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] terraform created by hashicorp is a configuration orchestration tool as well as an open source software tool hashicorp's terraform has a market share of 4.82 percent in the configuration management market top industries that use hashicorp terraform for configuration management are devops cloud and kubernetes around the world in 2021 over 591 companies have started using hashicorp terraform as configuration management tool hello everyone this is dhrup from eduraka and i welcome you all to this session where i will be talking about tcp terraform so without any further ado let's take a look at today's agenda we will start this session by first having an overview of google cloud platform and then we will understand why one must go for terraform and what actually it is after that we will get a brief of tools for using terraform with google cloud platform as well as terraform support for gcp and then finally we will try our hands on terraform supported by tcp before we begin do consider subscribing to our youtube channel and hit the bell icon to stay updated on trending technologies and also if you are interested in online training certification in google cloud platform check out the link given in the description box below so first let's get an overview of the google cloud platform offered by google it is suite of cloud computing services that runs on the same infrastructure that google uses internally for its end user products such as google search gmail file storage and youtube along with a set of management tools it provides a series of modular cloud services including computing data storage data analytics and machine learning for organizations with large amounts of data to store or analyze google cloud storage prices are up to 20 cheaper than aws and the price of database services also compares favorably while there is no difference in the price of container services google cloud is an industry leader in the field and is also investing heavily in ai and machine learning technologies many small and large enterprises are increasingly adopting google cloud platform which boards well since it disengages things and makes them more secure at reasonable costs let us now see the reasons why one should consider terraform so terraform lets you define infrastructure in configuration code and will enable you to rebuild and track changes to infrastructure with ease so telephone provides a high level description of infrastructure which means its infrastructure descriptive second it has a lively community and is open source there is a massive community developing around this tool many people are already using it and it's easier to find people who know how to use it like plugins extensions professional support etc this also means terraform is evolving at a much faster rate they do releases very often so third is like speedy operations so terraforms speed and operations are like exceptional one cool thing about terraform is its planned command lets you see what changes you are about to apply before you apply them code reuse features and terraform tends to make most changes faster than similar tools like cloud formation also it is like the right tool for infrastructure management as many other tools have a severe impedance mismatch from trying to wrangle an api design for configuring management to control an infrastructure environment instead terraform matches correctly with what you want to do the api alliance with the way you think about infrastructure also like terraform is the only sophisticated tool that is completely platform agnostic as well as supports other services while there are a few alternatives but they are focused on a single cloud provider there's a declarative code so terraform enables you to implement all kinds of coding principles like having your code in source control the ability to write automated tests etc now that we have understood why one must choose terraform now let's briefly understand what terraform actually is terraform is a configuration orchestration tool designed to provision the servers themselves it refers to arrangement and coordination of automated tasks resulting in a consolidated process of workflow so it is also like open source tool means open source software tool created by hashicob so hashicorp created tetherform to manage present as well as popular service along with the custom in-house solutions so terraform lets you provision google cloud resources with declarative configuration files resources such as virtual machines containers storage and networking terraforms infrastructure is a code that is isc approach supports devops best practices for change management which lets you manage telephone configuration files in source control to maintain an ideal provisioning state for testing and production environments terraform manages external resources with providers external resources like public cloud infrastructure private cloud infrastructure network appliances software as a service and platform as a service hashicorp maintains an extensive list of official providers and can also integrate with community developed providers users can interact with terraform providers by declaring resources or by calling data sources rather than using imperative commands to provision resources terraform uses declarative configuration to describe the desired final state now let's look at some tools for using terraform with google cloud we will briefly understand these tools so there are like variety of tools you can use to optimize your terraform experience so first let's explore the cloud foundation toolkit which provides a series of reference modules for terraform the modules reflect google cloud best practices and using these modules help you get started with terraform more quickly the modules are documented in the terraform registry and open sourced on github so these are some of the features of cloud foundation toolkit so first is ready-made templates so the cloud foundation toolkit provides a series of reference templates for deployment manager and terraform which reflect google cloud best practices these templates can be used off the shelf to quickly build a repeatable enterprise radio foundation in google cloud this frees you to focus on deploying your applications in this baseline secure environment and with infrastructure as a code you can easily update the foundation as your needs change second like you can treat your infrastructure like software so through the open source templates you can automate repeatable tasks and provision entire environments in a consistent fashion plus your teams can collaborate on the infrastructure by participating in code reviews and suggesting source code changes third it's like built for enterprise so the cloud foundation toolkit is designed spatially to meet the compliance and security needs of enterprises by creating a foundational environment using these templates you can be confident that best practices are implemented out of the box including key security and governance controls also you can like maintain consistency easily by adopting the toolkit you can be confident that different teams are deploying their applications and environments using a consistent set of tools and patents this reduces the potential for misconfigurations and inconsistencies while along easier collaboration across different teams also you can choose your adoption strategy each template from the cloud foundation toolkit can be used independently you can choose which patterns make sense for your organization and add new ones as your environment evolves the open source templates can easily be formed and modified to suit your organization's needs lastly you can save time and resources with pre-built templates with the cloud foundation toolkit you don't need to spend time developing your own templates and patterns for google cloud instead you can build and open source templates and focus only on the customizations which are required to your company and workloads developers can like move faster and migrations are less time consuming because of it so the second tool is terraform validator so leverage terraform validator to enforce policies on terraform configurations for google cloud so terraform validator is a tool for validating compliance with organizational policies prior to applying terraform plan it can be used either as a standalone tool or in conjugation with for seti or other policy enforcement tooling terraform validator relies on policies that are compatible with conflict volley data note that using terraform validator does not require an active installation of for city terraform validator is a self-contained binary so you can see the for city conflict validator shown here which is the newest addition to the first city security toolkit so config validator helps cloud admins put guard rails in place to protect against mis configurations in google cloud platform environments this allows developers to move quickly and give security and governance teams the ability to enforce security at scale so how does the terraform validator works so cloud admins write security and governance constraints as yml files once and stored them within their company's dedicated git repo as a central source of truth then facility ingests constraints and uses them as a new scanner to monitor for violations then terraform variator reads the same constraints to check for violations before provisioning in order to help prevent misconfigurations from happening that's how the whole process of terraform validator works the next tool we have is terraformer so by importing existing google cloud resources into terraform with terraformer it is a command line interface tool that generates tf or json and tier state files terraform already has existing resources in your environment performing the reverse of what terraform is designed to do this tool can be thought of as infrastructure to code next and the last tool is a cloud shell so terraform is integrated with a cloud shell and cloud shell automatically authenticates terraform letting you get started with less setup using cloud shell you can manage your infrastructure and develop your applications from any browser cloud shell is an online development and operations environment accessible anywhere with your browser you can manage your resources with its online terminal pre-loaded with utilities such as the gcloud command line tool you can also develop build debug and deploy your cloud-based apps using the online cloud share editor so some of the features of cloud shell are like full power access from anywhere you can manage your google cloud resources with the flexibility of a linux shell cloud shell provides command line access to a virtual machine instance in a terminal window then it has a developer ready environment so you can develop your apps directly from your browser with the cloud shell editor streamlined to increase your productivity with features such as go java node.js python and c language support an integrated debugger source control refactoring and a customizable interface run your app on the cloud share virtual machine or in the mini cube kubernetes emulator preview it directly in your browser then commit changes back to your wrapper from your grid clients then the next feature is like your favorite tools pre-installed and up-to-date so many of your favorite command line tools from bash and sh to max and bim are already pre-installed and kept up to date with cloud shell admin and development tools such as command line tool mysql kubernetes docker mini cube are configured and ready to use no more hunting around for how to install the latest version and all its dependencies just connect to cloud shell and go so the last feature is a cloud code tools for maximizing development productivity with this you can easily develop cloud-based applications with the tools provided by our cloud-code extensions allowing you to develop and deploy your kubernetes and cloud-run applications manage your clusters and integrate google cloud apis into your project all directly from the cloud shell editor so now let's understand like the support that telecom provides for gcp the code terraform command line interface is developed by hashicorp use the following resources for support like for provider related issues open an issue on github for questions about terraform in general and common patterns check the hashicorp community portal for general troubleshooting advice see terraforms debugging documentation and joining the google cloud community slack terraform channel if you haven't already you can like register for the google cloud community slack now that you have a theoretical understanding of terraform with gcp let's demonstrate it practically with an example of launching a virtual machine instance in gcp through terraform so the first step is to download the google cloud sdk installer so just search out google cloud is triggered so over here so you can just directly go to the install section here yeah yeah so yeah here like if you have a linux os you can go to linux and follow the steps to download or you can go for bank os also because i have windows so i will start download directly from here like auto downloaded okay open takes a few seconds yeah let's go next next next so i already have a sdk installed so i don't have to continue but if you don't have sdk installed so do continue like get the installation complete so yeah the next step is to download the data form so you can just directly go to releases.hashicorp.com terraform so hashicorp as i've told you is the company that created terraform so from here like all the versions are given a lot of versions are there so you can just go and download one yeah if you have a linux os you can just copy the address from here and unzip it okay that's what you have to do so if you're a windows user you can just download it from here yeah it got downloaded download it twice so you can get this one yeah so and just extract it from here yeah record it just copy it and paste it somewhere where you are going to like place other files like separately like i have a different place to copy so i will just go to my section like not here just a second okay i will just go to my place like because i am going to provide the path also i will keep that in mind too place it separately in demo section in the terraform yeah like this one i have got it before so i would delete this one and i will paste the new one yeah i will name it as teraform only so the next step is to go to the build infrastructure so here go to the hashicorp website from here you will go to tutorial section of the google cloud okay the prerequisites are given like you can create you have to create the account on google cloud platform so if you don't have an account create one it's a like it's a very good platform to have your account on and it provides a free trial like it's given their free time so free trial account is provided for 90 days with 300 credits and when you're going to register it plus for your debit or credit card details and it will just give it one rupee and that will also be refunded very soon also like 300 dollar diet is provided so that is like a lot of credits even means the exercise which i'm going to provide you it's like it doesn't cost anything it will only cut around 15 twenty dollars it's not more than that or maybe maximum fifty dollar that's it so that's how you can use it so next uh crowdshell trouser i've already explained you how it works and what are its features then is a set of the gcp so what you have to do in the gcp is you have to create a project then you have to create a service account and you have to generate a key okay so let's go to the gcp console so this is how the gcp console like google cloud platforms console looks like okay from here you go here and create a project so we can create a project from here but i already had like created the project my project name is demo so i will use this project only so now what i have to do is i have to make a service account so i will type service account and yeah this is the default one and this is the one i have created recently so i will create a new one with the name tf demo service account we will name it as s a okay so create and continue now for access purpose you have to give the role so like different access options are provided for like different services are given you can provide uh like for specific service you can provide the access like app engine or yeah notebooks and everything auto ml ca service cloud asset cloud data labeling a specific service which of course whatever purpose you want to give you can give it specifically for this service account i want to complete access so i will just go to the project and in project i will give the owner to get the complete access so yeah continue done so yeah the service account is created for tkf demo essay okay for the next step you can go to the registry telephone and i have already opened okay in this way you have to go to the getting started with cloud provider you will get the code for here at the basic code for virtual machine launching instance it's simple this one and it's the basic code of a terraform okay so if you're going to use aws now so in aws you will just use instead of google you will use aws that's it all the things will be same and similarly the provider code is provided below so just copy this code also and make a provider file and for this create a vm file like i have created one so this is how i have copied it here like this is the va the basic quotes and then the provider code is provided here so you can see in vm like the credentials are given project and then region is given everything similarly like the provider in this uh the name like with the virtual machine sensor that will be created now it will be named by flask vm and whatever the id will be there so and that name the virtual machine will be created similarly machine type is given and zone is green also one more thing so i have to generate a key in this like this i have created now i have to generate the key i have like remember i told you in this like the third step is to create a service account key so you can go here like the service account we have created in that we have to create a key so manage keys and add key create new so in json file you will be created from here so yeah got created so we can just go to downloads yeah so it is here so we can just copy here and you will just paste it where we have all the platform files and name it as a tf underscore underscore sorry here let's go demo underscore authorization this is what i have named in the code also that's why i'm naming this so yeah tf underscore demonstration.json so that's what it is same so coming back so yeah all the codes and everything is done so now what we have to do is take that so it's the key is active now you can see so what we have to do is now open the command prompt you just have to provide the path first so the path is a cd demo slash telephone so yeah the path is here then we have to revoke the authorization so gcloud authorization purpose for g cloud authorization revoke one more thing i will show you the json file if you see everything is given like privately for project id is game private eid is also given from the name the virtual machine will be launched now the key will be given this flask id and the key then private key is given in client email client id authorization token everything is given in this okay so we got this authorization revoke credentials are here so after that we have to configure so gcloud config configurations list so yeah so everything is right in my account but if you want to change so what you can do is you can initialize this so first clear this one so you can initialize it for changing anything in your configuration list okay so cheap cloud oh sorry gcloud initialize init so yeah foreign it's been done then would you like to login yes i want to log in just have to log in from here now it's authenticated it will be done now so in this comeback you can choose the project from here so your project name is if you remember it's chrome sensor 313404 okay so there's chrome sensor so it's second and i think then ah there's one and region we have to select so yeah we want to select so my region is south asia yeah so i will select 37 south asia bunny so yeah everything is done now so we can just again configure now so yeah everything is that place account yeah so last time if you see like i was saying like everything is there but it last and also like everything wasn't right because in the place of account now my account wasn't selected so it wouldn't have worked do check it properly then just clear this my sends let's start with the terraform initialization there's a form in it we have to go with i think we are it's getting initializing so yeah it's not initialized and you go with plan so telephone so you can stop nice i have already initialized that sorry so telephone plan now so yeah so it will be like create so if you like got done but you can go so you can see like cool compute instance will be created now okay so what we have to do is we just have to apply so here the command is terraform apply only yes will be accepted so yeah yes yeah so it's got created so let's check let's go to the virtual machine instance pure engine virtual machine instances the flask will be created with the name class or some id will be given again class vm id something i hope it get will be created because it's showing so positive got created yeah plus vm in the private id so yeah that's how it got created and if you want to delete it you can just give the command of destroy okay so you can just come here you can give teleport destroy only yes is accepted so yes it takes a few seconds so yeah so it got destroyed let's check now it is here so we will just refresh it you will find that it will get deleted from here yeah so it got deleted with this we come to the end of today's session of gcp telephone i hope you had a great time learning and understanding about it and if you have any queries please feel free to leave them down in the comment section below until next time thank you i hope you have enjoyed listening to this video please be kind enough to like it and you can comment any of your doubts and queries and we will reply them at the earliest do look out for more videos in our playlist and subscribe to edureka channel to learn more happy learning you
Info
Channel: edureka!
Views: 11,027
Rating: undefined out of 5
Keywords: yt:cc=on, gcp terraform, google cloud terraform, terraform gcp, terraform, gcp terraform tutorial, google cloud terraform tutorial, terraform for gcp, terraform gcp tutorial, gcp terraform setup, gcp terraform getting started, terraform tutorial gcp, terraform google cloud example, terraform gcp network tags, terraform google cloud storage, terraform google cloud tutorial, terraform tutorial for beginners gcp, google cloud edureka, edureka, gcp training, Google cloud training
Id: nZCdWbWU0P8
Channel Id: undefined
Length: 23min 31sec (1411 seconds)
Published: Sun Jun 13 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.