Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https://github.com/IKruglyak/terraform_task_6_create_simple_module/actions/runs/9922118922/job/27410814442 #2

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
88 changes: 48 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -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-<PROVIDER>-<MODULE_NAME>`.
- 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**
# 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.
4 changes: 4 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module "resource_group_storage" {
source = "IKruglyak/resource_group_storage/azurerm"
version = "1.0.0"
}
30 changes: 30 additions & 0 deletions modules/resource_group_storage/main.tf
Original file line number Diff line number Diff line change
@@ -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"
}
16 changes: 16 additions & 0 deletions modules/resource_group_storage/outputs.tf
Original file line number Diff line number Diff line change
@@ -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"
}
14 changes: 14 additions & 0 deletions modules/resource_group_storage/variables.tf
Original file line number Diff line number Diff line change
@@ -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
}
16 changes: 16 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -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"
}
14 changes: 14 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -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
}