diff --git a/LICENSE b/LICENSE index 5860527..a990273 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Maciej Michalski +Copyright (c) 2024 ThinkCube Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index dcd60a9..d805ccd 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,14 @@ | Name | Version | |------|---------| -| [terraform](#requirement\_terraform) | >= 0.15 | -| [azurerm](#requirement\_azurerm) | 3.3.0 | +| [terraform](#requirement\_terraform) | >= 1.6.4 | +| [azurerm](#requirement\_azurerm) | 3.94.0 | ## Providers | Name | Version | |------|---------| -| [azurerm](#provider\_azurerm) | 3.3.0 | +| [azurerm](#provider\_azurerm) | 3.94.0 | ## Modules @@ -20,9 +20,9 @@ No modules. | Name | Type | |------|------| -| [azurerm_container_registry.main](https://registry.terraform.io/providers/hashicorp/azurerm/3.3.0/docs/resources/container_registry) | resource | -| [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/3.3.0/docs/data-sources/client_config) | data source | -| [azurerm_resource_group.rg](https://registry.terraform.io/providers/hashicorp/azurerm/3.3.0/docs/data-sources/resource_group) | data source | +| [azurerm_container_registry.main](https://registry.terraform.io/providers/hashicorp/azurerm/3.94.0/docs/resources/container_registry) | resource | +| [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/3.94.0/docs/data-sources/client_config) | data source | +| [azurerm_resource_group.main](https://registry.terraform.io/providers/hashicorp/azurerm/3.94.0/docs/data-sources/resource_group) | data source | ## Inputs @@ -31,10 +31,11 @@ No modules. | [acr\_admin\_enabled](#input\_acr\_admin\_enabled) | Specifies whether the admin user is enabled. Defaults to false. | `string` | `"false"` | no | | [acr\_name](#input\_acr\_name) | Specifies the name of the Container Registry. Changing this forces a new resource to be created. | `string` | n/a | yes | | [acr\_tier](#input\_acr\_tier) | The SKU name of the container registry. Possible values are Basic, Standard and Premium. Classic (which was previously Basic) is supported only for existing resources. | `string` | `"Basic"` | no | -| [default\_tags](#input\_default\_tags) | A mapping of tags to assign to the resource. | `map` | n/a | yes | -| [envirioment](#input\_envirioment) | Specifies the name of the envirioment | `string` | n/a | yes | -| [resource\_group\_location](#input\_resource\_group\_location) | The location of the resource group in which to create the Container Registry. Changing this forces a new resource to be created. | `string` | n/a | yes | -| [resource\_group\_name](#input\_resource\_group\_name) | The name of the resource group in which to create the Container Registry. Changing this forces a new resource to be created. | `string` | n/a | yes | +| [default\_tags](#input\_default\_tags) | A mapping of tags to assign to the resource. | `map(any)` |
{| no | +| [environment](#input\_environment) | Variable that defines the name of the environment. | `string` | `"dev"` | no | +| [region](#input\_region) | Region in which resources are deployed. | `string` | `"weu"` | no | +| [resource\_group\_location](#input\_resource\_group\_location) | Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. | `string` | `"West Europe"` | no | +| [resource\_group\_name](#input\_resource\_group\_name) | The name of the resource group in which to create the container registry component. Changing this forces a new resource to be created. | `string` | n/a | yes | ## Outputs diff --git a/acr.tf b/acr.tf index 2f5d798..c7e9fe8 100644 --- a/acr.tf +++ b/acr.tf @@ -1,9 +1,8 @@ resource "azurerm_container_registry" "main" { - name = "${var.envirioment}${var.acr_name}" - resource_group_name = "${data.azurerm_resource_group.rg.name}" - location = "${data.azurerm_resource_group.rg.location}" - sku = "${var.acr_tier}" - admin_enabled = "${var.acr_admin_enabled}" - - tags = "${var.default_tags}" + name = "${var.environment}${var.acr_name}" + resource_group_name = data.azurerm_resource_group.rg.name + location = data.azurerm_resource_group.rg.location + sku = var.acr_tier + admin_enabled = var.acr_admin_enabled + tags = var.default_tags } \ No newline at end of file diff --git a/backend.tf b/backend.tf index e83be4b..7f32883 100644 --- a/backend.tf +++ b/backend.tf @@ -1,9 +1,9 @@ terraform { required_providers { azurerm = { - source = "hashicorp/azurerm" - version = "3.3.0" + source = "hashicorp/azurerm" + version = "3.94.0" } } -required_version = ">= 0.15" -} + required_version = ">= 1.6.4" +} \ No newline at end of file diff --git a/examples/azure_acr/README.md b/examples/azure_acr/README.md index 4095a4a..8a50364 100644 --- a/examples/azure_acr/README.md +++ b/examples/azure_acr/README.md @@ -1,27 +1,54 @@ -## How to use +# Terraform Module: Azure Container Registry (ACR) -``` +This Terraform module provisions an Azure Container Registry (ACR) in Azure. + +## Usage + +```hcl provider "azurerm" { features {} } -module "acr" { - source = "spy86/acr/azure" - version = "1.0.4" - - envirioment = "dev" - acr_name = "registry4test" - resource_group_name = "weu-test-rg" +module "container_registry" { + source = "Think-Cube/container-registry/azure" + version = "1.0.0" + envirioment = "dev" + acr_name = "registry4test" + resource_group_name = "weu-test-rg" resource_group_location = "West Europe" - acr_tier = "Basic" - acr_admin_enabled = "true" - + acr_tier = "Basic" + acr_admin_enabled = "true" default_tags = { - Administrator = "Someone" - Department = "IT" - CostCentre = "ABC123" - ContactPerson = "Someone@example.com" + Administrator = "John Doe" + Department = "IT" + CostCentre = "CC123" + ContactPerson = "Jane Smith" ManagedByTerraform = "True" } } -``` \ No newline at end of file +``` + +### Variables + +* `environment`: The environment name (e.g., dev, stage, prod). +* `acr_name`: The name of the Azure Container Registry. +* `resource_group_name`: The name of the resource group in which to create the ACR. +* `resource_group_location`: The location of the resource group. +* `acr_tier`: The pricing tier for the ACR. +* `acr_admin_enabled`: Whether admin user should be enabled for the ACR. +* `default_tags`: Default tags to be applied to all resources. + +### Outputs + +* `id`: The ID of the Container Registry. +* `login_server`: The URL that can be used to log into the container registry. +* `admin_username`: The Username associated with the Container Registry Admin account. +* `admin_password`: The Password associated with the Container Registry Admin account. + +## License + +This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). + +## Contribution + +Feel free to contribute by opening issues or pull requests. Your feedback and improvements are highly appreciated! diff --git a/examples/azure_acr/main.tf b/examples/azure_acr/main.tf index 0e485a1..379e58c 100644 --- a/examples/azure_acr/main.tf +++ b/examples/azure_acr/main.tf @@ -3,8 +3,8 @@ features {} } module "acr" { - source = "spy86/acr/azure" - version = "1.0.4" + source = "Think-Cube/container-registry/azure" + version = "1.0.0" envirioment = "dev" acr_name = "registry4test" @@ -12,12 +12,11 @@ module "acr" { resource_group_location = "West Europe" acr_tier = "Basic" acr_admin_enabled = "true" - default_tags = { - Administrator = "Someone" - Department = "IT" - CostCentre = "ABC123" - ContactPerson = "Someone@example.com" + Administrator = "John Doe" + Department = "IT" + CostCentre = "CC123" + ContactPerson = "Jane Smith" ManagedByTerraform = "True" } } \ No newline at end of file diff --git a/main.tf b/main.tf index 5656c08..49fe4f0 100644 --- a/main.tf +++ b/main.tf @@ -1,5 +1,5 @@ data "azurerm_client_config" "current" {} -data "azurerm_resource_group" "rg" { - name = "${var.resource_group_name}" +data "azurerm_resource_group" "main" { + name = var.resource_group_name } \ No newline at end of file diff --git a/output.tf b/output.tf index 053d79c..f662a84 100644 --- a/output.tf +++ b/output.tf @@ -1,20 +1,20 @@ output "id" { description = "The ID of the Container Registry." - value = "${azurerm_container_registry.main.id}" + value = azurerm_container_registry.main.id sensitive = false } output "login_server" { description = "The URL that can be used to log into the container registry." - value = "${azurerm_container_registry.main.login_server}" + value = azurerm_container_registry.main.login_server sensitive = false } output "admin_username" { description = "The Username associated with the Container Registry Admin account - if the admin account is enabled." - value = "${azurerm_container_registry.main.admin_username}" + value = azurerm_container_registry.main.admin_username sensitive = true } output "admin_password" { description = "The Password associated with the Container Registry Admin account - if the admin account is enabled." - value = "${azurerm_container_registry.main.admin_password}" + value = azurerm_container_registry.main.admin_password sensitive = true } \ No newline at end of file diff --git a/variables.tf b/variables.tf index 9b6a954..070d2bf 100644 --- a/variables.tf +++ b/variables.tf @@ -1,40 +1,55 @@ -############################ -#Common vars -############################ -variable "envirioment" { - description = "Specifies the name of the envirioment" - type = string +########################### +# Common vars +########################### +variable "environment" { + description = "Variable that defines the name of the environment." + type = string + default = "dev" } variable "default_tags" { description = "A mapping of tags to assign to the resource." - type = map + type = map(any) + default = { + "ManagedByTerraform" = "True" + } +} +variable "region" { + description = "Region in which resources are deployed." + type = string + default = "weu" } -############################ -#Resource gropus vars -############################ +########################### +# Resource groups vars +########################### variable "resource_group_location" { - description = "The location of the resource group in which to create the Container Registry. Changing this forces a new resource to be created." - type = string + description = "Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created." + default = "West Europe" + type = string } variable "resource_group_name" { - description = "The name of the resource group in which to create the Container Registry. Changing this forces a new resource to be created." - type = string + description = "The name of the resource group in which to create the container registry component. Changing this forces a new resource to be created." + type = string } ############################ -#ACR variable +#Container registry variable ############################ variable "acr_tier" { - description = "The SKU name of the container registry. Possible values are Basic, Standard and Premium. Classic (which was previously Basic) is supported only for existing resources." - type = string - default = "Basic" + description = "The SKU name of the container registry. Possible values are Basic, Standard and Premium. Classic (which was previously Basic) is supported only for existing resources." + type = string + default = "Basic" + + validation { + condition = can(regex("^(Basic|Premium)$", var.acr_tier)) + error_message = "Invalid value for acr_tier. Valid values are Basic or Premium." + } } variable "acr_name" { - description = "Specifies the name of the Container Registry. Changing this forces a new resource to be created." - type = string + description = "Specifies the name of the Container Registry. Changing this forces a new resource to be created." + type = string } variable "acr_admin_enabled" { - description = "Specifies whether the admin user is enabled. Defaults to false." - type = string - default = "false" + description = "Specifies whether the admin user is enabled. Defaults to false." + type = string + default = "false" } \ No newline at end of file
"ManagedByTerraform": "True"
}