From the course: Advanced Terraform
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Custom modules - Terraform Tutorial
From the course: Advanced Terraform
Custom modules
- [Instructor] We've got one more thing to do with modules. Let's create one of our own. Execute git checkout 03_02 to see the code for this video. In main.tf, scroll down to line 33. And here we have a custom module declaration. This custom webservers module has replaced the compute instance resource declaration I've used up until now. We've seen a module declaration before. If we take a peek into the service_accounts declaration, we can see that they look similar, but there's one key difference. The service_account module uses a URL-like source. Our module uses a local source. The webservers module is defined here in modules/webservers. I'll open main.tf of our root module side by side with the variables.tf of the child module. You can see that for every attribute in our module declaration there's an input variable in the module. The server_settings variable is an object that matches the environment instance settings…