From 0a5c1e93da4f84c2cae6394f4bf71151ae6b3944 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Tue, 1 Oct 2024 16:47:41 +0200 Subject: [PATCH 1/2] Solution --- main.tf | 16 +++++++++++++ modules/resource_group_storage/main.tf | 12 ++++++++++ modules/resource_group_storage/outputs.tf | 10 ++++++++ modules/resource_group_storage/variables.tf | 26 +++++++++++++++++++++ provider.tf | 12 ++++++++++ variable.tf | 19 +++++++++++++++ 6 files changed, 95 insertions(+) create mode 100644 main.tf create mode 100644 modules/resource_group_storage/main.tf create mode 100644 modules/resource_group_storage/outputs.tf create mode 100644 modules/resource_group_storage/variables.tf create mode 100644 provider.tf create mode 100644 variable.tf diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..1e07b61 --- /dev/null +++ b/main.tf @@ -0,0 +1,16 @@ +module "resource_group_storage" { + source = "yaroslavyvk/resource_group_storage/azurerm" + version = "v1.1.0" + + resource_group_name = var.resource_group_name + location = var.location + storage_account_name = var.storage_account_name +} + +output "resource_group_id" { + value = module.resource_group_storage.resource_group_id +} + +output "storage_account_id" { + value = module.resource_group_storage.storage_account_id +} diff --git a/modules/resource_group_storage/main.tf b/modules/resource_group_storage/main.tf new file mode 100644 index 0000000..58ff3bb --- /dev/null +++ b/modules/resource_group_storage/main.tf @@ -0,0 +1,12 @@ +resource "azurerm_resource_group" "rg" { + name = var.resource_group_name + location = var.location +} + +resource "azurerm_storage_account" "storage" { + name = var.storage_account_name + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.location + account_tier = var.account_tier + account_replication_type = var.replication_type +} diff --git a/modules/resource_group_storage/outputs.tf b/modules/resource_group_storage/outputs.tf new file mode 100644 index 0000000..fe7a7c9 --- /dev/null +++ b/modules/resource_group_storage/outputs.tf @@ -0,0 +1,10 @@ +output "resource_group_id" { + description = "ID of the Azure Resource Group" + value = azurerm_resource_group.rg.id +} + + +output "storage_account_id" { + description = "ID of the Storage Account" + value = azurerm_storage_account.storage.id +} diff --git a/modules/resource_group_storage/variables.tf b/modules/resource_group_storage/variables.tf new file mode 100644 index 0000000..7dceaa4 --- /dev/null +++ b/modules/resource_group_storage/variables.tf @@ -0,0 +1,26 @@ +variable "resource_group_name" { + description = "Name of the Azure Resource Group" + type = string +} + +variable "location" { + description = "Azure region where resources will be created" + type = string +} + +variable "storage_account_name" { + description = "Name of the Azure Storage Account" + type = string +} + +variable "account_tier" { + description = "The tier of the storage account" + type = string + default = "Standard" +} + +variable "replication_type" { + description = "The replication type of the storage account" + type = string + default = "LRS" +} diff --git a/provider.tf b/provider.tf new file mode 100644 index 0000000..bd3cb94 --- /dev/null +++ b/provider.tf @@ -0,0 +1,12 @@ +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "3.105.0" + } + } +} + +provider "azurerm" { + features {} +} diff --git a/variable.tf b/variable.tf new file mode 100644 index 0000000..6d71eb3 --- /dev/null +++ b/variable.tf @@ -0,0 +1,19 @@ +# variables.tf + +variable "resource_group_name" { + description = "The name of the resource group to create" + type = string + default = "task6-resources" +} + +variable "location" { + description = "The location where resources will be created" + type = string + default = "West Europe" +} + +variable "storage_account_name" { + description = "The name of the storage account to create" + type = string + default = "task6torageacct" +} From 1853695c2e4f325b25f9e71914621b94119a7327 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Tue, 1 Oct 2024 16:59:09 +0200 Subject: [PATCH 2/2] chore: ran 'terraform fmt' and fixed formatting issues --- main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index 1e07b61..058b3e6 100644 --- a/main.tf +++ b/main.tf @@ -2,9 +2,9 @@ module "resource_group_storage" { source = "yaroslavyvk/resource_group_storage/azurerm" version = "v1.1.0" - resource_group_name = var.resource_group_name - location = var.location - storage_account_name = var.storage_account_name + resource_group_name = var.resource_group_name + location = var.location + storage_account_name = var.storage_account_name } output "resource_group_id" {