[MUSIC] In this video you will see some resource manager demos. And the first thing I'm going to show you is, I'm working in the Frankfort region and I have my resource manager setup available. I can create a stack and if I have my own resource manager configuration files I can upload them or use predefined templates that are given by Oracle or you can create your own templates. How do we create our templates? You can go to private templates and create your private template, which fundamentally means you have some terraform configuration files which you can upload and use them as a template. But right now, I'm not going to talk about private templates, we will use an Oracle provided template in the form of, let's say specific service related templates are available, or there are some architecture related templates available which can deploy certain solutions for you. Let's take the service template and say I want a VCN. If I choose this template, it creates a configuration file and will be created as a stack. So let me give it a name, resource manager VCN as the name of the template created in this compartment, the script that is provided as part of template is of this version and you create the stack. Now when you're creating the stack, it tells you some variables that are going to be given. For example, I will call it as resource manager VCN. The name of the stack and the name of the VCN are the same. So I will say remote VCN name to ensure it is different from the stack. Give the details about the cider you want. And the DNS label you want for the VCN. And it gives you a summary and create. Remember, this doesn't create any resources, instead it creates a stack for you. The stack that got created is available here. I can download the stack and look into the details of what has been created. When I open the stack file, I see that the following are created. And if I look at the main tf file that is created in this. I will see that terraform configuration that is created, including specifications that I gave. It is going to create a VCN based on the variables that are there, which we gave which is there in the variables configuration file, an Internet Gateway Collection of subnets etc. The variables are listed in this variables file. So if I open it, various variables are already there. So that's the stack that got created. And now I can use this to ask it to generate a plan. It tells me what is the name of the job that will be created. And running the plan command results in a job which will create a plan for the stack that we have. It takes a moment to create the plan. So let's wait for it to complete. And if I go back to the stacks page, I see this is the stack that I just now created. If I go into the details, there is a job that is currently running, which is of type plan. The various variables that are listed in that stack and any work requests that you have requested in terms of executing it will be displayed later. In case you want to make changes to the stack, you can make changes to the file that you download and upload a new version of the stack. So that would be the current configuration in resource manager. Now my plan is succeeded. If I click on it, it will show me the output that terraform provided as a result of plan. So if I go in here, it says terraform will perform the following actions, it creates a route table, it creates an internet gateway. It creates some subnets 1,2,3 and lastly the VCN that is created and it tells me 6 resources will be added nothing to change, nothing to destroy, standard plan output. Now that I have a plan in place, I may want to create the resource by clicking apply. Now, there is going to be a new job for the purpose of apply. And do you want it to automatically approve or do something from the previous plan you have, wherein based on the previous plan it will execute, let it create a new plan and apply it, the result will be. If I go to my VCN page, which I will open in another tab, I'm working in Frankfort, remember. So in a few minutes, the VCN will get created based on the stack that I had. It is still in progress. As it does it, we also will see one more option. When you create a stack there is an option to fetch stack configurations from an existing source control system, which means you have the ability to configure source providers. Any kind of source control system that is supported in OCI can be used. For example, right now GitHub and GETLab are supported. If you have an account then creating terraform configuration there, you can import a configuration from the source control system and create your stacks in OCI. Now, let's go and see what is the status of our plan. The plan was already executed right now the apply is executed. If I go to my VCN page, I see that my VCN is created and within this VCN there are various resources created based on the templates that are used. Similar to this I can also create my own VCN using the standard VCN wizard, so I will call it as wizard based VCN for example. Various options available and created will create a VC and based on the wizard. Once it is created, I will have two VCNs remember, the first VCN created was based on the stack, whereas this VCN is created from the console using the wizard. Both the VCNs are available here. This was created with the resource manager whereas this was created with the wizard. If I come back here, I see that my resource is applied and it is created. If I want to destroy it, I can destroy it. If I want to import state for something that I manually created, I can import state. Right now let me go and destroy it. This will result in the VCN that I created with resource managers stack should get terminated in a few moments. It is now performing the actions required to destroy that VCN and let's wait for it to complete, in a matter of a moment it will get destroyed. So you will see that the VCN that I created is still there whereas the with the wizard is still there, whereas the VCN created with terraform is destroyed. So the status should get updated. And it is in place. So that's how you can create but remember, the stack is still available, you can still use the stack and create a resource again. So if you say apply, it will end up creating it again. So that's an example of using terraform using resource manager. And another interesting thing you can see is, when you try to create instances using the wizard, you have the ability to create an instance using the wizard. So I will call it as instance, for the purpose of stack you can choose an image from the wizard, you can choose the shape, you can choose the VCN that we have, a subnet whether you want a public IP, upload the SSH key pair. So if you don't have an SSH key pair with you, you can generate the keypad here. What I'm going to do is, I'm going to generate an SSH key pair and upload it by pasting the public key. Let my Cloud Shell get created. And as part of my Cloud Shell, I will generate an SSH key pair that I can use for my compute instances. So that that will be available in the stack. You need to keep the private key safely. What you will upload is only the public key of that private key which will be uploaded into the compute instance. Now that my Cloud Shell is ready to use, I can go and say sshkeygen. This will result in a key pair generated in a directory given, I will accept the default directory. It says there is already one available, okay overwrite it. No passphrase for now. And if I go to .ssh location, I have my private key and public key generated here. Let me do a count of the id_ras.pub to get the contents. Copy the ssh public key, be careful to copy the entire string, put it here and I can create the instance or create as a stack. When I ask it to create as a stack, let us see what comes up. Compute stack will be the name. Created from the wizard in console and in the next screen it gives you the ability to get this stack in place. Now what I have got is a new stack created based on the compute wizard. I have a stack created and if I want, I can go and apply to get that compute instance created. So that's some kind of demonstrations with resource manager. As a result of this, you have understood how to use resource manager which is Terraform as a service. And let's do a quick knowledge check from what you have learned. What is the best practice from a recommendation perspective for where do you store the terraform configuration files? Do you store it in a USB thumb drive which you can share with others? On a network file server controlled with LDAP permissions. In a private source control repository like GitHub or etc, or lastly, create an Oracle Database and put it in as a row there with JSON. The recommended practice since it's a configuration file would be to use in a source control repository so that you can share, collaborate and work with people in a easy way. Another example here is something we didn't discuss in detail, but let's see how you understand this. You have deployed a 3-tier web application using Terraform. So you created a stack or you created your own terraform script which you use from your terraform server that you have. Either way it is finally Terraform whether you use resource manager or Terraform. And you have been asked to change the amount of storage to the database system that is available VM Database systems you can scale up storage. So you modified your terraform file, how would you apply this? So there are options to destroy, obviously not the case. You don't want to plan, you want to apply. In terraform there is an option to specifically target a specific resource and apply. So if you made the change to scale up storage, you can use option C to apply only the changes in a particular resource, inside the collection of configuration files that you have, which is what you would have to do. That brings us to the end of this chapter where you saw about using Terraform and resource manager and some time on stations as to how Terraform is used with the resource manager service. That is the end of this chapter.