Learn How to Create Terraform Custom Modules for Azure |

Ғылым және технология

In this Episode, I’ll show you how to create your first Terraform Module to use in Azure! We will walk-through, the standard terraform code and how to generalise it into a module. I’ll run through a demo to show you how to write code.
Episode Timecodes:
0:00 Intro
0:38 Terraform Modules
1:00 Why use Modules?
2:37 Standard Structure - Terraform Configuration Files
3:14 Module Structure - Terraform Configuration Files
3:46 Terraform Base Code Breakdown
4:39 Turn your Code into a Module
5:03 Module Code Breakdown
7:22 Demonstration - Deployment Code
8:00 Creating the Module Code
11:57 Module Standards
14:32 Calling the Child Module
16:16 Lets Apply!
17:40 Module Nesting - Closing Notes
18:14 Create Modules for Everything? Closing Notes
Episode Code: github.com/someoneelsescloud/...
Hashicorp Learn - Reuse Configuration with Modules
learn.hashicorp.com/collectio...
Hashicorp - Modules Overview
www.terraform.io/docs/languag...
Hashicorp - Module Structure
www.terraform.io/docs/languag...
Hashicorp - Creating Modules
www.terraform.io/docs/languag...
Terraform Module Registry
registry.terraform.io/browse/...
Show your appreciation and support the channel: www.buymeacoffee.com/some1els...
Download Someone Else's Cloud Wallpapers! Add some vibrant colours and positive energy to your Work from Home environment to keep you amped! ✌️ www.someoneelsescloud.com/epi...
Instagram: / someoneelsescloud
Twitter: / some1elsescloud
Github: github.com/someoneelsescloud
Sign up for the Newsletter: eepurl.com/hEYUdP
See all links to all platforms here: www.someoneelsescloud.com/links
#azure #terraform #iac #modules

Пікірлер: 32

  • @tennroj
    @tennroj Жыл бұрын

    exactly what I needed, a clear explanation! thanks

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    Жыл бұрын

    Glad it helped!

  • @halitkurt1616
    @halitkurt1616 Жыл бұрын

    exactly what I needed! Thanks a lot!

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    Жыл бұрын

    Glad it helped!

  • @Motivatedpeoplezz
    @Motivatedpeoplezz2 жыл бұрын

    Needed this! Great work and great content.

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    2 жыл бұрын

    Thanks mate! Hope it helps 🤗

  • @Motivatedpeoplezz

    @Motivatedpeoplezz

    2 жыл бұрын

    @@SomeoneElsesCloud it definitely does. It would be great if you can carry on with this and use Terratest or something for integration/unit testing.

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    2 жыл бұрын

    @@Motivatedpeoplezz thanks, sounds like a plan!

  • @uaena182
    @uaena182 Жыл бұрын

    exactly what i needed... learned a lot.. subscribed! thanks!

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    Жыл бұрын

    Awesome, thank you!

  • @shekar1996
    @shekar19968 ай бұрын

    Clear explanation. Thank You

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    6 ай бұрын

    Glad it was helpful! ✌️

  • @cristianomachado7129
    @cristianomachado712911 ай бұрын

    Thanks for sharing

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    11 ай бұрын

    No problems, hope it helped! ✌️

  • @samtx
    @samtx10 ай бұрын

    Do you use source module git clone in production? How are variables dynamic changed if developers want to change

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    9 ай бұрын

    Hey there, this is an interesting question, but I'll try and keep it short. Depends on how your modules are structured, you could store them in a folder in your github repo with your terraform code or you could store them in github ideally per repository and use release tags to version control them. There's no right way to do this and it comes down to what works for your environment. If developers want to create their own variables, they could test the module locally or if it's in github they could just work from their own branch, but if it's changes for everyone using the module, it should be managed through versions or at least pull requests. Not really sure if this answers your question, but there definately multiple ways to approach modules! 😊

  • @x123dddyy7
    @x123dddyy7 Жыл бұрын

    do you have github repo for this?

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    Жыл бұрын

    Hey yep its in the comments, but this is whre its at github.com/someoneelsescloud/ep14_create_azure_terraform_module

  • @srujanmettu
    @srujanmettu2 жыл бұрын

    Hi Sunny, Can we use modules with Azure devops?

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    2 жыл бұрын

    Hey Srujan, sorry for the late reply! Yes modules are just code. Azure DevOps will just execute the code just like you do locally. If it's just a local module (stored in GitHub with your code) it should just work. It's it's a remote module (stored in a remote repository) then you would need to ensure connection and authentication is setup correctly.

  • @srujanmettu

    @srujanmettu

    2 жыл бұрын

    @@SomeoneElsesCloud thanks sunny for your reply ! I have another question can we use parameters in azure pipelines with terraform while running the pipeline can we put our required values of over writing the var file or tfvars file ?

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    2 жыл бұрын

    Hey Srujan, you would rather use variable groups or variables and inject then as variables with your command line options with Terraform, see this video, which will give you some ideas. kzread.info/dash/bejne/l5VosMyxmtizaLg.html You could also add variables via the GUI too but it would be better to define them in code.

  • @i-am-oi
    @i-am-oi2 жыл бұрын

    Great work Sonny! I hope somebody can help me to solve this issue and understand how to implement the best approach. I have a number of situations where I need to retry a task n-times if it fails. My ask is, I need help writing a Terraform module to monitor an azure task which is to restart it in case it encounters an exception. retry logic). If an exception is thrown, the task should be retried up to the max-retry count.

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    2 жыл бұрын

    Hey O'sean, to best honest I have not done anything like that, but it sounds like you need a scheduler and scripts. Terraform is not really a monitoring tool, because you would need it to constantly apply, thus sounds like you need a scheduler and script like runbooks or azure devops using a the cron scheduler. I've only really seen where null_resource is used to execute a script but eventually that becomes redundant as there is no state of this resouce, so it will just execute everytime with no real feedback.. So its really a bandaid untul Terraform supports the issue correctly. Not sure if this helps but if you have an issue running an Azure task, Terraform might not be the right way?

  • @i-am-oi

    @i-am-oi

    2 жыл бұрын

    @@SomeoneElsesCloud thank you so much for your response! Do you by any chance have plans to do anything like this in the future (using scheduler of course)

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    2 жыл бұрын

    I've mainly used it to execute PowerShell scripts. What do you need to do? Maybe a summarised version? I liked to solve problems 😬

  • @i-am-oi

    @i-am-oi

    2 жыл бұрын

    @UCrMpQutaRnhQV0mq7fEag0Q I want to retry a failed operation n-times, I have done my research and I found Terragrunt as a better alternative to achieve this. Let's say I try to create or delete a resource I want to be able to retry that operation using auto-retry/retry the operation a number of times if it fails on first try

  • @SomeoneElsesCloud

    @SomeoneElsesCloud

    2 жыл бұрын

    Interesting, I just read this auto-retry feature on terragrunt. We use Terraform Enterprise and we can re-queue old runs from the portal ui but I have only needed to do this when I'm trying to uplift modules and have to modify state or encounter a sequencing issue that needs some kind of depends_on.

Келесі