-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Think-Cube/patch-1
Reorganization terraform module
- Loading branch information
Showing
9 changed files
with
116 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "[email protected]" | ||
Administrator = "John Doe" | ||
Department = "IT" | ||
CostCentre = "CC123" | ||
ContactPerson = "Jane Smith" | ||
ManagedByTerraform = "True" | ||
} | ||
} | ||
``` | ||
``` | ||
|
||
### 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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,21 +3,20 @@ 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" | ||
resource_group_name = "weu-test-rg" | ||
resource_group_location = "West Europe" | ||
acr_tier = "Basic" | ||
acr_admin_enabled = "true" | ||
|
||
default_tags = { | ||
Administrator = "Someone" | ||
Department = "IT" | ||
CostCentre = "ABC123" | ||
ContactPerson = "[email protected]" | ||
Administrator = "John Doe" | ||
Department = "IT" | ||
CostCentre = "CC123" | ||
ContactPerson = "Jane Smith" | ||
ManagedByTerraform = "True" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |