From a09ca0f5e1acf848225a5d8bd73425dc60ba675a Mon Sep 17 00:00:00 2001 From: Ivan Kruglyak Date: Sat, 13 Jul 2024 21:04:40 +0300 Subject: [PATCH 1/7] Initial commit --- LICENSE | 21 +++++ README.md | 88 +++++++++++---------- modules/resource_group_storage/.gitignore | 32 ++++++++ modules/resource_group_storage/main.tf | 16 ++++ modules/resource_group_storage/outputs.tf | 16 ++++ modules/resource_group_storage/variables.tf | 14 ++++ 6 files changed, 147 insertions(+), 40 deletions(-) create mode 100644 LICENSE create mode 100644 modules/resource_group_storage/.gitignore 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/LICENSE b/LICENSE new file mode 100644 index 0000000..bd2166b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [2024] Ivan Kruglyak + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 0a55345..5e1cb3a 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,48 @@ -# Working with Terraform Modules - -## Prerequisites - -To complete this task, you must have Terraform and Azure CLI installed and configured on your machine. - -## Steps to Complete the Task - -**1. Fork this Repository** - -**2. Create a Simple Terraform Module** - -- Create a directory named `modules/resource_group_storage` in the root of your repository. -- Inside the `modules/resource_group_storage` directory, create the following files: - * `main.tf`: Define the resources. - * `variables.tf`: Define the variables. - * `outputs.tf`: Define the outputs. - -**3. Publish the Module on GitHub** - -- Create a new repository on GitHub named according to Terraform's naming convention, e.g.`terraform-azurerm-resource_group_storage`. -- Add the module files (`main.tf`, `variables.tf`, `outputs.tf`) to this repository. -- Add a `README.md` file with detailed usage instructions. -- Add a `LICENSE` file to specify the usage rights. -- Add a `.gitignore` file to ignore Terraform state files and other sensitive information. -- Commit and push the files to GitHub. - -**4. Publish the Module to Terraform Registry** - -- Ensure your GitHub repository name follows the format `terraform--`. -- Sign in to the Terraform Registry with your GitHub account. -- Publish the module by linking your GitHub repository to the Terraform Registry. -- Tag the repository with a version (e.g., `v1.0.0`) following semantic versioning. - -**5. Use the Module from Terraform Registry** - -- In your main Terraform configuration (`main.tf`), use the module from the Terraform Registry. -- Initialize and apply the configuration to verify that the module is used correctly. - -**6. Pull request's description should also contain a reference to a successful workflow run** \ No newline at end of file +# terraform-azurerm-resource_group_storage + +## Overview + +This Terraform module creates an Azure Resource Group and Storage Account. + +## Usage + +```hcl +module "resource_group_storage" { + source = "github.com/YOUR_GITHUB_USERNAME/terraform-azurerm-resource_group_storage" + + resource_group_name = "example-rg" + location = "West Europe" + storage_account_name = "examplestorageacct" +} +Inputs +Name Description Type Default Required +resource_group_name The name of the resource group string n/a yes +location The location of the resource group string n/a yes +storage_account_name The name of the storage account string n/a yes +Outputs +Name Description +resource_group_name The name of the resource group +storage_account_name The name of the storage account +Example +hcl +Copy code +module "resource_group_storage" { + source = "github.com/YOUR_GITHUB_USERNAME/terraform-azurerm-resource_group_storage" + + resource_group_name = "example-rg" + location = "West Europe" + storage_account_name = "examplestorageacct" +} + +output "resource_group_name" { + value = module.resource_group_storage.resource_group_name +} + +output "storage_account_name" { + value = module.resource_group_storage.storage_account_name +} +License +This project is licensed under the MIT License - see the LICENSE file for details. + +Contributing +Contributions are welcome! Please open an issue or submit a pull request for any changes. diff --git a/modules/resource_group_storage/.gitignore b/modules/resource_group_storage/.gitignore new file mode 100644 index 0000000..d2dd9d2 --- /dev/null +++ b/modules/resource_group_storage/.gitignore @@ -0,0 +1,32 @@ +# Local Terraform directories +.terraform/ +.terraform.lock.hcl + +# Terraform state files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log + +# Terraform variable override files +*.tfvars + +# Sensitive personal data +*.tfvars.json + +# Ignore editor specific files +.vscode/ +.idea/ + +# Ignore OS generated files +.DS_Store +Thumbs.db + +# Ignore logs and temporary files +*.log +*.tmp +*.swp +*.bak +*.backup +*.old diff --git a/modules/resource_group_storage/main.tf b/modules/resource_group_storage/main.tf new file mode 100644 index 0000000..eefa719 --- /dev/null +++ b/modules/resource_group_storage/main.tf @@ -0,0 +1,16 @@ +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "rg" { + name = var.resource_group_name + location = var.location +} + +resource "azurerm_storage_account" "sa" { + name = var.storage_account_name + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.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..eefa719 --- /dev/null +++ b/modules/resource_group_storage/outputs.tf @@ -0,0 +1,16 @@ +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "rg" { + name = var.resource_group_name + location = var.location +} + +resource "azurerm_storage_account" "sa" { + name = var.storage_account_name + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.location + account_tier = "Standard" + account_replication_type = "LRS" +} diff --git a/modules/resource_group_storage/variables.tf b/modules/resource_group_storage/variables.tf new file mode 100644 index 0000000..350ef2c --- /dev/null +++ b/modules/resource_group_storage/variables.tf @@ -0,0 +1,14 @@ +variable "resource_group_name" { + description = "The name of the resource group" + type = string +} + +variable "location" { + description = "The location of the resource group" + type = string +} + +variable "storage_account_name" { + description = "The name of the storage account" + type = string +} From 2d391aa8e0d2909083f5c1d69af293be90a9424b Mon Sep 17 00:00:00 2001 From: Ivan Kruglyak Date: Sat, 13 Jul 2024 21:23:34 +0300 Subject: [PATCH 2/7] Solution --- modules/resource_group_storage/main.tf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/resource_group_storage/main.tf b/modules/resource_group_storage/main.tf index eefa719..dedcabf 100644 --- a/modules/resource_group_storage/main.tf +++ b/modules/resource_group_storage/main.tf @@ -2,6 +2,11 @@ provider "azurerm" { features {} } +module "resource_group_storage" { + source = "IKruglyak/resource_group_storage/azurerm" + version = "1.0.0" +} + resource "azurerm_resource_group" "rg" { name = var.resource_group_name location = var.location From 6a4513dc2850c1d2bc78a21c738b1c77dda6a929 Mon Sep 17 00:00:00 2001 From: Ivan Kruglyak Date: Sat, 13 Jul 2024 21:33:21 +0300 Subject: [PATCH 3/7] Solution --- modules/resource_group_storage/main.tf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/resource_group_storage/main.tf b/modules/resource_group_storage/main.tf index dedcabf..a77b46c 100644 --- a/modules/resource_group_storage/main.tf +++ b/modules/resource_group_storage/main.tf @@ -1,3 +1,12 @@ +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "3.110.0" + } + } +} + provider "azurerm" { features {} } From 358d2e20fd29c717bbf2941a9f00eee50918d3ba Mon Sep 17 00:00:00 2001 From: Ivan Kruglyak Date: Sat, 13 Jul 2024 21:35:43 +0300 Subject: [PATCH 4/7] Solution --- main.tf | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 main.tf diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..a77b46c --- /dev/null +++ b/main.tf @@ -0,0 +1,30 @@ +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "3.110.0" + } + } +} + +provider "azurerm" { + features {} +} + +module "resource_group_storage" { + source = "IKruglyak/resource_group_storage/azurerm" + version = "1.0.0" +} + +resource "azurerm_resource_group" "rg" { + name = var.resource_group_name + location = var.location +} + +resource "azurerm_storage_account" "sa" { + name = var.storage_account_name + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.location + account_tier = "Standard" + account_replication_type = "LRS" +} From b51d37761a0ac97fae1d659814a6aa873b7ddc7e Mon Sep 17 00:00:00 2001 From: Ivan Kruglyak Date: Sat, 13 Jul 2024 21:40:55 +0300 Subject: [PATCH 5/7] Solution --- main.tf | 22 ---------------------- outputs.tf | 16 ++++++++++++++++ variables.tf | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 outputs.tf create mode 100644 variables.tf diff --git a/main.tf b/main.tf index a77b46c..b1715ba 100644 --- a/main.tf +++ b/main.tf @@ -1,12 +1,3 @@ -terraform { - required_providers { - azurerm = { - source = "hashicorp/azurerm" - version = "3.110.0" - } - } -} - provider "azurerm" { features {} } @@ -15,16 +6,3 @@ module "resource_group_storage" { source = "IKruglyak/resource_group_storage/azurerm" version = "1.0.0" } - -resource "azurerm_resource_group" "rg" { - name = var.resource_group_name - location = var.location -} - -resource "azurerm_storage_account" "sa" { - name = var.storage_account_name - resource_group_name = azurerm_resource_group.rg.name - location = azurerm_resource_group.rg.location - account_tier = "Standard" - account_replication_type = "LRS" -} diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..eefa719 --- /dev/null +++ b/outputs.tf @@ -0,0 +1,16 @@ +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "rg" { + name = var.resource_group_name + location = var.location +} + +resource "azurerm_storage_account" "sa" { + name = var.storage_account_name + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.location + account_tier = "Standard" + account_replication_type = "LRS" +} diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..350ef2c --- /dev/null +++ b/variables.tf @@ -0,0 +1,14 @@ +variable "resource_group_name" { + description = "The name of the resource group" + type = string +} + +variable "location" { + description = "The location of the resource group" + type = string +} + +variable "storage_account_name" { + description = "The name of the storage account" + type = string +} From c2e0347b5e6792df6167da2cd00948e6262acdaf Mon Sep 17 00:00:00 2001 From: Ivan Kruglyak Date: Sat, 13 Jul 2024 21:44:22 +0300 Subject: [PATCH 6/7] Solution --- main.tf | 4 ---- 1 file changed, 4 deletions(-) diff --git a/main.tf b/main.tf index b1715ba..8d09462 100644 --- a/main.tf +++ b/main.tf @@ -1,7 +1,3 @@ -provider "azurerm" { - features {} -} - module "resource_group_storage" { source = "IKruglyak/resource_group_storage/azurerm" version = "1.0.0" From d16999e50904e3d6ee76bf4c7e271c5f69fcf2e5 Mon Sep 17 00:00:00 2001 From: IKruglyak <141446484+IKruglyak@users.noreply.github.com> Date: Sat, 20 Jul 2024 12:50:54 +0300 Subject: [PATCH 7/7] Delete modules/resource_group_storage/.gitignore --- modules/resource_group_storage/.gitignore | 32 ----------------------- 1 file changed, 32 deletions(-) delete mode 100644 modules/resource_group_storage/.gitignore diff --git a/modules/resource_group_storage/.gitignore b/modules/resource_group_storage/.gitignore deleted file mode 100644 index d2dd9d2..0000000 --- a/modules/resource_group_storage/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -# Local Terraform directories -.terraform/ -.terraform.lock.hcl - -# Terraform state files -*.tfstate -*.tfstate.* - -# Crash log files -crash.log - -# Terraform variable override files -*.tfvars - -# Sensitive personal data -*.tfvars.json - -# Ignore editor specific files -.vscode/ -.idea/ - -# Ignore OS generated files -.DS_Store -Thumbs.db - -# Ignore logs and temporary files -*.log -*.tmp -*.swp -*.bak -*.backup -*.old