Giter Site home page Giter Site logo

azure_vm_terraform's Introduction

Azure Virtual Machine creation using Terraform.

Explanation

This code is parameterized and we are using different modules for every Azure Resource. This allows us to manage our code along with enabling the reusability. This repositiry contains two subfolders :

  1. terraform-modules
    • This directory contains all the modules.
    • Any variable conditional needs to be checked in the variable.tf file under respective module
  2. terraform-resources
    • This folder has these files :
      • main.tf -> This file contains all the resources that we are going to deploy.
      • variables.tf -> Variables are defined in this file.
      • terraform.tfvars -> Tfvars file is automatically loaded without any additional option. This is the file where you need to update your resource values\names.

Usage :

Things to keep in mind are :

  1. We are using Azure BLOB as backend configuration, so you need to ensure the storage account and container mentioned in the backend configuration exists.
  2. Since we are using data block to fetch key vault secrets, where we store all our sensitive information. The key vault and the secrets should already exist.

To run this example, simply follow to steps below:

  1. Navigate to terraform-resources folder, if the terminal is opened in Linux Virtual Machine Deployment directory, use :
  cd terraform-resources
  terraform init
  terraform plan
  terraform apply

Explanation :

  1. Terraform init -> It initializes the directory and downloads required provider along with configuring the module.
  2. Terraform plan -> This helps you verify the code is going to deploy the resources as expected. This also ensures we don't face any unwanted surprise. This isn't mandatory, but a recommended step.
  3. Terraform apply -> This step applies the resources specified in this code. This will ask you to approve this later. We can skip manual approval by using --auto-approve parameter.

Best Practices & Recommendations

  1. Use Terraform workspaces for easier management of the deployments. This can also help us manage Dev, UAT and Production deployments instead of creating multiple state files\directories.
  2. If you are creating new resources\variables. Ensure naming convention is easily relatable, since we have a lot of variables in this code.
  3. Use conditionals to avoid unwanted surprises.

azure_vm_terraform's People

Contributors

bhatts11 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.