From 3ef1c772d69e619975545d5c35968f4c0236d162 Mon Sep 17 00:00:00 2001 From: Serveladus Date: Tue, 17 Sep 2024 15:22:27 +0300 Subject: [PATCH 1/7] Soution --- .gitignore | 5 +++++ main.tf | 12 ++++++++++++ modules/resource_group_storage/main.tf | 12 ++++++++++++ modules/resource_group_storage/outputs.tf | 3 +++ modules/resource_group_storage/variables.tf | 14 ++++++++++++++ outputs.tf | 3 +++ variables.tf | 11 +++++++++++ 7 files changed, 60 insertions(+) create mode 100644 .gitignore 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 outputs.tf create mode 100644 variables.tf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..334946d --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.terraform/ +terraform.tfstate +terraform.tfstate.backup +*.tfvars +.terraform.lock* \ No newline at end of file diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..13d3a10 --- /dev/null +++ b/main.tf @@ -0,0 +1,12 @@ +provider "azurerm" { + features {} + subscription_id = "d345fa5d-4fda-4d1e-abf1-c8a7e4fb0576" + tenant_id = "e84abfc3-c8c5-4892-8f6d-942a64e5bfc4" +} + +module "resource_group_storage" { + source = "./modules/resource_group_storage" + resource_group_name = var.resource_group_name + location = var.location + storage_account_name = var.storage_account_name +} diff --git a/modules/resource_group_storage/main.tf b/modules/resource_group_storage/main.tf new file mode 100644 index 0000000..4039f22 --- /dev/null +++ b/modules/resource_group_storage/main.tf @@ -0,0 +1,12 @@ +resource "azurerm_resource_group" "example" { + name = var.resource_group_name + location = var.location +} + +resource "azurerm_storage_account" "example" { + name = var.storage_account_name + resource_group_name = azurerm_resource_group.example.name + location = var.location + account_tier = "Standard" + account_replication_type = "LRS" +} diff --git a/modules/resource_group_storage/outputs.tf b/modules/resource_group_storage/outputs.tf new file mode 100644 index 0000000..1fcb22d --- /dev/null +++ b/modules/resource_group_storage/outputs.tf @@ -0,0 +1,3 @@ +output "resource_group_name" { + value = azurerm_resource_group.example.name +} diff --git a/modules/resource_group_storage/variables.tf b/modules/resource_group_storage/variables.tf new file mode 100644 index 0000000..e67ac38 --- /dev/null +++ b/modules/resource_group_storage/variables.tf @@ -0,0 +1,14 @@ +variable "resource_group_name" { + type = string + default = "default-resource-group" +} + +variable "location" { + type = string + default = "Poland Central" +} + +variable "storage_account_name" { + type = string + default = "defaultstorageaccount" +} diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..a30e3fa --- /dev/null +++ b/outputs.tf @@ -0,0 +1,3 @@ +output "resource_group_name" { + value = module.resource_group_storage.resource_group_name +} diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..285f06d --- /dev/null +++ b/variables.tf @@ -0,0 +1,11 @@ +variable "resource_group_name" { + type = string +} + +variable "storage_account_name" { + type = string +} + +variable "location" { + type = string +} From d623d49e4beae46d783388663f9cebf4045ac122 Mon Sep 17 00:00:00 2001 From: Serveladus Date: Tue, 17 Sep 2024 15:32:19 +0300 Subject: [PATCH 2/7] Solution2 --- main.tf | 8 ++++---- outputs.tf | 2 +- variables.tf | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/main.tf b/main.tf index 13d3a10..aa1443f 100644 --- a/main.tf +++ b/main.tf @@ -5,8 +5,8 @@ provider "azurerm" { } module "resource_group_storage" { - source = "./modules/resource_group_storage" - resource_group_name = var.resource_group_name - location = var.location - storage_account_name = var.storage_account_name + source = "./modules/resource_group_storage" + resource_group_name = var.resource_group_name + location = var.location + storage_account_name = var.storage_account_name } diff --git a/outputs.tf b/outputs.tf index a30e3fa..943f1d9 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,3 +1,3 @@ output "resource_group_name" { - value = module.resource_group_storage.resource_group_name + value = module.resource_group_storage.resource_group_name } diff --git a/variables.tf b/variables.tf index 285f06d..b3c33e6 100644 --- a/variables.tf +++ b/variables.tf @@ -1,11 +1,11 @@ variable "resource_group_name" { - type = string + type = string } variable "storage_account_name" { - type = string + type = string } variable "location" { - type = string + type = string } From 948b9c3d9326285c0ed53989bdbce94fe67f8601 Mon Sep 17 00:00:00 2001 From: Serveladus Date: Tue, 17 Sep 2024 15:38:58 +0300 Subject: [PATCH 3/7] Solution3 --- main.tf | 3 ++- modules/resource_group_storage/main.tf | 12 ------------ modules/resource_group_storage/outputs.tf | 3 --- modules/resource_group_storage/variables.tf | 14 -------------- 4 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 modules/resource_group_storage/main.tf delete mode 100644 modules/resource_group_storage/outputs.tf delete mode 100644 modules/resource_group_storage/variables.tf diff --git a/main.tf b/main.tf index aa1443f..d957502 100644 --- a/main.tf +++ b/main.tf @@ -5,7 +5,8 @@ provider "azurerm" { } module "resource_group_storage" { - source = "./modules/resource_group_storage" + source = "Serveladik/resource_group_storage/azurerm" + resource_group_name = var.resource_group_name location = var.location storage_account_name = var.storage_account_name diff --git a/modules/resource_group_storage/main.tf b/modules/resource_group_storage/main.tf deleted file mode 100644 index 4039f22..0000000 --- a/modules/resource_group_storage/main.tf +++ /dev/null @@ -1,12 +0,0 @@ -resource "azurerm_resource_group" "example" { - name = var.resource_group_name - location = var.location -} - -resource "azurerm_storage_account" "example" { - name = var.storage_account_name - resource_group_name = azurerm_resource_group.example.name - location = var.location - account_tier = "Standard" - account_replication_type = "LRS" -} diff --git a/modules/resource_group_storage/outputs.tf b/modules/resource_group_storage/outputs.tf deleted file mode 100644 index 1fcb22d..0000000 --- a/modules/resource_group_storage/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "resource_group_name" { - value = azurerm_resource_group.example.name -} diff --git a/modules/resource_group_storage/variables.tf b/modules/resource_group_storage/variables.tf deleted file mode 100644 index e67ac38..0000000 --- a/modules/resource_group_storage/variables.tf +++ /dev/null @@ -1,14 +0,0 @@ -variable "resource_group_name" { - type = string - default = "default-resource-group" -} - -variable "location" { - type = string - default = "Poland Central" -} - -variable "storage_account_name" { - type = string - default = "defaultstorageaccount" -} From d9ab8bf8dac81f4152cd4d07b6a0e592e42618f1 Mon Sep 17 00:00:00 2001 From: Serveladus Date: Tue, 17 Sep 2024 15:44:09 +0300 Subject: [PATCH 4/7] Solution4 --- .github/workflows/terraform-validate.yml | 2 +- main.tf | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/terraform-validate.yml b/.github/workflows/terraform-validate.yml index 6b77b22..91d21f8 100644 --- a/.github/workflows/terraform-validate.yml +++ b/.github/workflows/terraform-validate.yml @@ -45,7 +45,7 @@ jobs: exit 1 fi echo "outputs.tf is present in module 'resource_group_storage'." - + - name: Terraform Fmt run: terraform fmt -check -recursive -diff diff --git a/main.tf b/main.tf index d957502..aa1443f 100644 --- a/main.tf +++ b/main.tf @@ -5,8 +5,7 @@ provider "azurerm" { } module "resource_group_storage" { - source = "Serveladik/resource_group_storage/azurerm" - + source = "./modules/resource_group_storage" resource_group_name = var.resource_group_name location = var.location storage_account_name = var.storage_account_name From 031ea6660a7e1063037670d1019bbcd596d3f4a5 Mon Sep 17 00:00:00 2001 From: Serveladus Date: Tue, 17 Sep 2024 15:45:49 +0300 Subject: [PATCH 5/7] added module back --- modules/resource_group_storage/main.tf | 12 ++++++++++++ modules/resource_group_storage/outputs.tf | 3 +++ modules/resource_group_storage/variables.tf | 14 ++++++++++++++ 3 files changed, 29 insertions(+) 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 diff --git a/modules/resource_group_storage/main.tf b/modules/resource_group_storage/main.tf new file mode 100644 index 0000000..4039f22 --- /dev/null +++ b/modules/resource_group_storage/main.tf @@ -0,0 +1,12 @@ +resource "azurerm_resource_group" "example" { + name = var.resource_group_name + location = var.location +} + +resource "azurerm_storage_account" "example" { + name = var.storage_account_name + resource_group_name = azurerm_resource_group.example.name + location = var.location + account_tier = "Standard" + account_replication_type = "LRS" +} diff --git a/modules/resource_group_storage/outputs.tf b/modules/resource_group_storage/outputs.tf new file mode 100644 index 0000000..1fcb22d --- /dev/null +++ b/modules/resource_group_storage/outputs.tf @@ -0,0 +1,3 @@ +output "resource_group_name" { + value = azurerm_resource_group.example.name +} diff --git a/modules/resource_group_storage/variables.tf b/modules/resource_group_storage/variables.tf new file mode 100644 index 0000000..e67ac38 --- /dev/null +++ b/modules/resource_group_storage/variables.tf @@ -0,0 +1,14 @@ +variable "resource_group_name" { + type = string + default = "default-resource-group" +} + +variable "location" { + type = string + default = "Poland Central" +} + +variable "storage_account_name" { + type = string + default = "defaultstorageaccount" +} From f6fab6b5ede4d06095982770f5c8964325256668 Mon Sep 17 00:00:00 2001 From: Serveladus Date: Tue, 17 Sep 2024 15:48:50 +0300 Subject: [PATCH 6/7] Soution6 --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 334946d..fc1aaeb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .terraform/ -terraform.tfstate +terraform.tfstate* terraform.tfstate.backup *.tfvars .terraform.lock* \ No newline at end of file From ec4f3f0a090ba71c0ccef4727916e892649bf0bd Mon Sep 17 00:00:00 2001 From: Serveladus Date: Tue, 17 Sep 2024 15:50:06 +0300 Subject: [PATCH 7/7] fmt --- modules/resource_group_storage/outputs.tf | 2 +- modules/resource_group_storage/variables.tf | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/resource_group_storage/outputs.tf b/modules/resource_group_storage/outputs.tf index 1fcb22d..9232759 100644 --- a/modules/resource_group_storage/outputs.tf +++ b/modules/resource_group_storage/outputs.tf @@ -1,3 +1,3 @@ output "resource_group_name" { - value = azurerm_resource_group.example.name + value = azurerm_resource_group.example.name } diff --git a/modules/resource_group_storage/variables.tf b/modules/resource_group_storage/variables.tf index e67ac38..809cb91 100644 --- a/modules/resource_group_storage/variables.tf +++ b/modules/resource_group_storage/variables.tf @@ -1,14 +1,14 @@ variable "resource_group_name" { - type = string - default = "default-resource-group" + type = string + default = "default-resource-group" } variable "location" { - type = string - default = "Poland Central" + type = string + default = "Poland Central" } variable "storage_account_name" { - type = string - default = "defaultstorageaccount" + type = string + default = "defaultstorageaccount" }