Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ azure-vm Public

This project sets up Azure infrastructure using OpenTF. It includes network security groups, network interfaces, and other necessary resources to create a virtual machine (VM) in Azure. The project is managed using OpenTF, ensuring infrastructure as code for easy deployment and management.

License

Notifications You must be signed in to change notification settings

SRodi/azure-vm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Azure Virtual Machine Infrastructure

This project sets up Azure infrastructure using OpenTF. It includes network security groups, network interfaces, and other necessary resources to create a VM. For more information, visit the OpenTF website.

Prerequisites

  • OpenTofu v1.0.0 or higher
  • Azure subscription

Project Structure

The initial project structure is as follows:

.
├── .gitignore
├── LICENCE
├── .terraform.lock.hcl
├── main.tf
├── providers.tf
└── variables.tf

After running the instructions mentioned in the section Usage the structure will look as follows:

.
├── .gitignore
├── LICENCE
├── .terraform/
│   ├── providers/
│   │   ├── registry.opentofu.org/
│   │   │   ├── hashicorp/
│   │   │   │   ├── azurerm/
│   │   │   │   │   ├── 4.4.0/
│   │   │   │   │   │   ├── linux_amd64/
│   │   │   │   │   │   │   ├── CHANGELOG.md
│   │   │   │   │   │   │   ├── LICENSE
│   │   │   │   │   │   │   ├── README.md
│   │   │   │   │   │   │   └── terraform-provider-azurerm
├── .terraform.lock.hcl
├── main.tf
├── providers.tf
├── terraform.tfstate
├── terraform.tfstate.backup
├── terraform.tfvars
└── variables.tf
  • .terraform.lock.hcl: Used to lock the versions of Terraform providers to ensure consistent and reproducible builds.
  • main.tf: Defines the main infrastructure resources.
  • providers.tf: Specifies the required providers and their configurations.
  • terraform.tfvars: Contains variable values. See Usage
  • variables.tf: Defines the variables used in the project.
  • .gitignore: Specifies files and directories to be ignored by git.

Usage

  1. Clone the repository:

    git clone <repository-url>
    cd <repository-directory>
  2. Initialize OpenTF:

    tofu init
  3. Create a terraform.tfvars file:

    touch terraform.tfvars

    Populate terraform.tfvars with the required variables:

    subscription_id    = "<your-subscription-id>"
    tenant_id          = "<your-tenant-id>"
    prefix             = "<resource-prefix>"
    location           = "<resource-location>"
    path_to_public_key = "<path-to-your-local-ssh-public-key>"
  4. Plan the infrastructure:

    tofu plan
  5. Apply the infrastructure changes:

    tofu apply

Cleanup

To destroy the infrastructure managed by OpenTF, run:

tofu destroy

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.

About

This project sets up Azure infrastructure using OpenTF. It includes network security groups, network interfaces, and other necessary resources to create a virtual machine (VM) in Azure. The project is managed using OpenTF, ensuring infrastructure as code for easy deployment and management.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages