Learn How to Create Terraform Custom Modules for Azure |

Поділитися
Вставка
  • Опубліковано 7 лип 2024
  • 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

  • @AdilKhan_
    @AdilKhan_ 2 роки тому +1

    Needed this! Great work and great content.

    • @SomeoneElsesCloud
      @SomeoneElsesCloud  2 роки тому +1

      Thanks mate! Hope it helps 🤗

    • @AdilKhan_
      @AdilKhan_ 2 роки тому +1

      @@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 роки тому +1

      @@AdilKhan_ thanks, sounds like a plan!

  • @uaena182
    @uaena182 Рік тому

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

  • @shekar1996
    @shekar1996 8 місяців тому

    Clear explanation.
    Thank You

  • @halitkurt1616
    @halitkurt1616 Рік тому

    exactly what I needed! Thanks a lot!

  • @cristianomachado7129
    @cristianomachado7129 10 місяців тому

    Thanks for sharing

  • @samtx
    @samtx 10 місяців тому

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

    • @SomeoneElsesCloud
      @SomeoneElsesCloud  9 місяців тому +1

      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! 😊

  • @i-am-oi
    @i-am-oi 2 роки тому +1

    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 роки тому +1

      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 роки тому +1

      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 роки тому +1

      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.

  • @srujanmettu
    @srujanmettu 2 роки тому +1

    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. ua-cam.com/video/ea4NjxjuM8U/v-deo.html You could also add variables via the GUI too but it would be better to define them in code.

  • @x123dddyy7
    @x123dddyy7 Рік тому +1

    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