How to Automate Infra setup in Azure Cloud using Terraform & Azure DevOps Pipeline | Terraform IAC

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.ย. 2023
  • www.coachdevops.com/2023/09/h...
    Pre-requisites:
    Azure subscription
    Azure DevOps organization and project
    Terraform Build & Release Tasks extension in Azure DevOps
    Terraform files created and stored in SCM for creating resources in Azure cloud
    Implementation Steps:
    Create a resource group first in Azure cloud
    Create storage account, container for Terraform to store state information in Azure cloud remotely.
    Create pipeline and add Terraform tasks
    Execute pipeline to deploy resources(App service plan and WebApp) in Azure cloud
    Verify resources are created in Azure cloud
    Confirm if the terraform.tfstate file is updated
    Create Resource Group in Azure cloud
    Login to Azure portal, Create a new RG, or you can skip this step if you already have existing group.
    Create Storage Account in Azure cloud
    Create a new resource, type storage account
    Create a container inside the storage account
    Select the storage account you just created, click on containers under Data storage
    enter a name for the container
    Create a pipeline in Azure DevOps
    Login to Azure Devops, select Pipelines, select use the classic editor to create a pipeline
    Configure Pipeline with tasks
    Add Terraform installer task to install Terraform on build agent
    Add Terraform task
    Configure the task
    enter storage account, container, key information as below:
    Add Terraform task for plan
    change the command to plan from drop down and also select azure subscription from drop down
    Add Terraform task for apply
    change the command to apply from drop down and also select azure subscription from drop down
    Now verify to make sure if we have correct values in each/every task. Now click on Save + Queue.
    Click on Save and Run
    This confirms that pipeline have successfully created resources in Azure cloud. You can login to Azure portal to see the resources - app service plan and web app.
    You can also verify terraform state info which has resources entry for all the resources created
    Click on Containers, mytfstatecontainer
    Click on terraform.tfstate
    Click on Edit to view the content of terraform state file
    Clean up resources created in Azure using the pipeline - destroy command
    change the command to destroy instead of apply from the drop down
    You can either add a new task for destroy or modify to destroy from apply in the existing task.
    Now save the pipeline and run the pipeline. check the output of destroy task
    Check terraform.tfstate file after destroy.
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 21

  • @SanjeevKumar-wi7hj
    @SanjeevKumar-wi7hj 11 หลายเดือนก่อน +3

    Big clapping 👏 for this awasome content

    • @DevOpsCoach
      @DevOpsCoach  11 หลายเดือนก่อน

      Thank you so much 🙏🙌

  • @AzuredaDhabba-GenuineRec-ix3gx
    @AzuredaDhabba-GenuineRec-ix3gx 2 หลายเดือนก่อน +1

    I cant thank you enough. !! Seriously awesome!!

    • @DevOpsCoach
      @DevOpsCoach  2 หลายเดือนก่อน

      Glad you liked the video 😍

  • @bindukillada7202
    @bindukillada7202 6 หลายเดือนก่อน +1

    Thank you so much such a clear and great video👏

    • @DevOpsCoach
      @DevOpsCoach  6 หลายเดือนก่อน

      Glad you enjoyed it!

  • @ShilpaReddyA
    @ShilpaReddyA 10 หลายเดือนก่อน +1

    Thanks a lot it was very nice session

    • @DevOpsCoach
      @DevOpsCoach  10 หลายเดือนก่อน

      Glad you like it 👏

  • @Teraflickstale
    @Teraflickstale 10 หลายเดือนก่อน

    Awesome tutorial - but can you please suggest what to do " The "backend" is the interface that Terraform uses to store state, perform operations, etc. If this message is showing up, it means that the Terraform configuration you're using is using a custom configuration for the Terraform backend" i am getting this problem while 'terraform plan' in pipeline.

  • @hotsteppers23
    @hotsteppers23 8 หลายเดือนก่อน

    Great detailed video. Can you also run through step by step setting up the environment and pushing the code via VM into Azure.

    • @balaganesh6992
      @balaganesh6992 7 หลายเดือนก่อน

      instead of app service scriipt put the vm script

  • @Cristianology7
    @Cristianology7 3 หลายเดือนก่อน +1

    i don't see these options in azure devops in my free account. do we need a pay as you go account for this?

    • @DevOpsCoach
      @DevOpsCoach  2 หลายเดือนก่อน

      see if you can enable classic pipeline option in Azure DevOps by following below steps.
      www.coachdevops.com/2024/01/how-to-enable-to-use-classic-editor-to.html

  • @balaganesh6992
    @balaganesh6992 7 หลายเดือนก่อน

    how to achieve terraform approve -----the plan manually by triggering the email and approve it manually , because in real time if plan is wrong it will create issue could you please give information ? pls

  • @charandevara2713
    @charandevara2713 4 หลายเดือนก่อน

    Sir is it possible build the storage account with the dame source code not manually?

    • @DevOpsCoach
      @DevOpsCoach  4 หลายเดือนก่อน

      Sorry I didn’t understand your question fully.

  • @satyadattavendrasundaranee2491
    @satyadattavendrasundaranee2491 10 หลายเดือนก่อน

    can you share the terraform source code of it to practice

  • @user-fd1wt6iq5j
    @user-fd1wt6iq5j หลายเดือนก่อน

    Is it possible to create subscription by using terraform

    • @DevOpsCoach
      @DevOpsCoach  หลายเดือนก่อน

      yes you can.. registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subscription

  • @user-oz7vg1wt1z
    @user-oz7vg1wt1z 10 หลายเดือนก่อน +1

    sir please provide terraform source code please for pracitce

    • @DevOpsCoach
      @DevOpsCoach  7 หลายเดือนก่อน +1

      github.com/akannan1087/myInfra2021Repo