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.
- OpenTofu v1.0.0 or higher
- Azure subscription
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.
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Initialize OpenTF:
tofu init
-
Create a
terraform.tfvarsfile:touch terraform.tfvars
Populate
terraform.tfvarswith 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>"
-
Plan the infrastructure:
tofu plan
-
Apply the infrastructure changes:
tofu apply
To destroy the infrastructure managed by OpenTF, run:
tofu destroyThis project is licensed under the Apache 2.0 License. See the LICENSE file for details.