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/main.tf b/main.tf new file mode 100644 index 0000000..8d09462 --- /dev/null +++ b/main.tf @@ -0,0 +1,4 @@ +module "resource_group_storage" { + source = "IKruglyak/resource_group_storage/azurerm" + version = "1.0.0" +} diff --git a/modules/resource_group_storage/main.tf b/modules/resource_group_storage/main.tf new file mode 100644 index 0000000..a77b46c --- /dev/null +++ b/modules/resource_group_storage/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" +} 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 +} 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 +}