Skip to content

bcochofel/terraform-azurerm-resource-group

Repository files navigation

Terraform module to create Azure Resource Group

This module creates Azure Resource Group. It also has the option to create a lock on the Resource Group scope. This module also validates the name according to the Azure Resource naming restrictions.

NOTE: To use the lock level option the service principal must have the "Owner" or "User Access Administrator" roles.

Usage

provider "azurerm" {
  features {}
}

module "rg" {
  source = "../../"

  name     = "rgdemo"
  location = "North Europe"

  tags = {
    ManagedBy   = "Terraform"
    Environment = "sandbox"
  }
}

Requirements

Name Version
terraform ~> 1.9.0
azurerm >= 3.106.1, < 4.0

Providers

Name Version
azurerm >= 3.106.1, < 4.0

Modules

No modules.

Resources

Name Type
azurerm_management_lock.resource-group-level-lock resource
azurerm_resource_group.rg resource

Inputs

Name Description Type Default Required
location The Azure Region where the Resource Group should exist.
Changing this forces a new Resource Group to be created.
string n/a yes
lock_level Specifies the Level to be used for this RG Lock.
Possible values are Empty (no lock), CanNotDelete and ReadOnly.
string "" no
name The Name which should be used for this Resource Group.
Changing this forces a new Resource Group to be created.
string n/a yes
tags A mapping of tags which should be assigned to the Resource Group. map(string) {} no

Outputs

Name Description
id The Resource Group id.
location The Resource Group location.
name The Resource Group name.
tags The Resource Group tags.

Contributing

This repository uses semantic versioning and conventional commits. Some automation need this to work correctly. There are 2 GitHub Workflows:

  • lint.yml: runs on Pull Request to validate Terraform
  • release.yml: runs on merge to the default branch. This workflow generates a Changelog file and creates a GitHub release based on the conventional commit messages.

Run tests

cd test/
go test -v

pre-commit hooks

This repository uses pre-commit.

To install execute:

pre-commit install
pre-commit install --install-hooks -t commit-msg

To run the hooks you need to install:

References