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

fix: updated terraform module and fixed depriciation variables #54

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
.github/* @clouddrove/approvers

* @clouddrove/clouddrovians @clouddrove/approvers

.github/mergify.yml @clouddrove/admins
.github/CODEOWNERS @clouddrove/admins
# These owners will be the default owners for everything in the repo.
* @anmolnagpal @clouddrove-ci
d4kverma marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ jobs:
secrets:
GITHUB: ${{ secrets.GITHUB }}
with:
tfcheck: 'basic-example / Check code format'
tfcheck: 'complete-example / Check code format'
...
8 changes: 3 additions & 5 deletions examples/basic/example.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
provider "azurerm" {
features {}
subscription_id = "01111111111110-11-11-11-11"
skip_provider_registration = "true"
subscription_id = "068245d4-3c94-42fe-9c4d-9e5e1cabc60c"
vedant990 marked this conversation as resolved.
Show resolved Hide resolved
}

provider "azurerm" {
features {}
alias = "peer"
subscription_id = "01111111111110-11-11-11-11"
skip_provider_registration = "true"
alias = "peer"
subscription_id = "01111111111110-11-11-11-11"
vedant990 marked this conversation as resolved.
Show resolved Hide resolved
}

locals {
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.112.0"
version = ">=4.0.0"
}
}
}
11 changes: 5 additions & 6 deletions examples/complete/example.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
provider "azurerm" {
features {}
subscription_id = "01111111111110-11-11-11-11"
skip_provider_registration = "true"
subscription_id = "068245d4-3c94-42fe-9c4d-9e5e1cabc60c"
vedant990 marked this conversation as resolved.
Show resolved Hide resolved
}

provider "azurerm" {
features {}
alias = "peer"
subscription_id = "01111111111110-11-11-11-11"
skip_provider_registration = "true"
alias = "peer"
subscription_id = "068245d4-3c94-42fe-9c4d-9e5e1cabc60c"
vedant990 marked this conversation as resolved.
Show resolved Hide resolved
}


Expand Down Expand Up @@ -78,11 +76,12 @@ module "subnet" {
##-----------------------------------------------------------------------------
module "log-analytics" {
source = "clouddrove/log-analytics/azure"
version = "1.0.1"
version = "1.1.0"
name = local.name
environment = local.environment
create_log_analytics_workspace = true
log_analytics_workspace_sku = "PerGB2018"
log_analytics_workspace_id = module.log-analytics.workspace_id
resource_group_name = module.resource_group.resource_group_name
log_analytics_workspace_location = module.resource_group.resource_group_location
}
Expand Down
2 changes: 1 addition & 1 deletion examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.112.0"
version = ">=4.0.0"
}
}
}
17 changes: 9 additions & 8 deletions examples/with_existing_dns_zone_in_diff_rg/example.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
provider "azurerm" {
features {}
subscription_id = "01111111111110-11-11-11-11"
skip_provider_registration = "true"
subscription_id = "000000-11111-1223-XXX-XXXXXXXXXXXX"
}

provider "azurerm" {
features {}
alias = "peer"
subscription_id = "01111111111110-11-11-11-11"
skip_provider_registration = "true"
alias = "peer"
subscription_id = "000000-11111-1223-XXX-XXXXXXXXXXXX"
vedant990 marked this conversation as resolved.
Show resolved Hide resolved
}

locals {
Expand Down Expand Up @@ -77,11 +75,12 @@ module "subnet" {
##-----------------------------------------------------------------------------
module "log-analytics" {
source = "clouddrove/log-analytics/azure"
version = "1.0.1"
version = "1.1.0"
name = local.name
environment = local.environment
create_log_analytics_workspace = true
log_analytics_workspace_sku = "PerGB2018"
log_analytics_workspace_id = module.log-analytics.workspace_id
resource_group_name = module.resource_group.resource_group_name
log_analytics_workspace_location = module.resource_group.resource_group_location
}
Expand All @@ -106,9 +105,11 @@ module "container-registry" {
environment = local.environment
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location

container_registry_config = {
name = "cdacr1234" # Name of Container Registry
sku = "Premium"
name = "cdacr1234" # Name of Container Registry
sku = "Premium"
retention_policy_in_days = 5
}
log_analytics_workspace_id = module.log-analytics.workspace_id
##-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion examples/with_existing_dns_zone_in_diff_rg/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.112.0"
version = ">=4.0.0"
}
}
}
11 changes: 5 additions & 6 deletions examples/with_existing_dns_zone_in_diff_subs/example.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
provider "azurerm" {
features {}
subscription_id = "01111111111110-11-11-11-11"
skip_provider_registration = "true"
subscription_id = "000000-11111-1223-XXX-XXXXXXXXXXXX"
}

provider "azurerm" {
features {}
alias = "peer"
subscription_id = "01111111111110-11-11-11-11"
skip_provider_registration = "true"
alias = "peer"
subscription_id = "000000-11111-1223-XXX-XXXXXXXXXXXX"
vedant990 marked this conversation as resolved.
Show resolved Hide resolved
}
locals {
name = "app"
Expand Down Expand Up @@ -75,11 +73,12 @@ module "subnet" {
##-----------------------------------------------------------------------------
module "log-analytics" {
source = "clouddrove/log-analytics/azure"
version = "1.0.1"
version = "1.1.0"
name = local.name
environment = local.environment
create_log_analytics_workspace = true
log_analytics_workspace_sku = "PerGB2018"
log_analytics_workspace_id = module.log-analytics.workspace_id
resource_group_name = module.resource_group.resource_group_name
log_analytics_workspace_location = module.resource_group.resource_group_location
}
Expand Down
2 changes: 1 addition & 1 deletion examples/with_existing_dns_zone_in_diff_subs/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.112.0"
version = ">=4.0.0"
}
}
}
30 changes: 8 additions & 22 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,17 @@ resource "azurerm_container_registry" "main" {
}
}

dynamic "virtual_network" {
vedant990 marked this conversation as resolved.
Show resolved Hide resolved
for_each = network_rule_set.value.virtual_network
content {
action = "Allow"
subnet_id = virtual_network.value.subnet_id
}
}
}
}

dynamic "retention_policy" {
for_each = var.retention_policy != null && var.container_registry_config.sku == "Premium" ? [var.retention_policy] : []
content {
days = lookup(retention_policy.value, "days", 7)
enabled = lookup(retention_policy.value, "enabled", true)
}
}

dynamic "trust_policy" {
for_each = var.enable_content_trust ? [1] : []
content {
enabled = var.enable_content_trust
}
}
# dynamic "trust_policy" {
vedant990 marked this conversation as resolved.
Show resolved Hide resolved
# for_each = var.enable_content_trust ? [1] : []
# content {
# enabled = var.enable_content_trust
# }
# }
trust_policy_enabled = var.container_registry_config.sku == "Premium" ? var.enable_content_trust : false
retention_policy_in_days = var.retention_policy != null && var.container_registry_config.sku == "Premium" ? var.retention_policy : null

identity {
type = var.identity_ids != null || var.encryption ? "SystemAssigned, UserAssigned" : "SystemAssigned"
Expand All @@ -85,7 +72,6 @@ resource "azurerm_container_registry" "main" {
dynamic "encryption" {
for_each = var.encryption && var.container_registry_config.sku == "Premium" ? ["encryption"] : []
content {
enabled = true
key_vault_key_id = azurerm_key_vault_key.kvkey[0].id
identity_client_id = azurerm_user_assigned_identity.identity[0].client_id
}
Expand Down
11 changes: 3 additions & 8 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,10 @@ variable "network_rule_set" {
description = "Manage network rules for Azure Container Registries"
}


variable "retention_policy" {
type = object({
days = optional(number)
enabled = optional(bool)
})
default = {
days = 10
enabled = true
}
type = number
default = 5
description = "Set a retention policy for untagged manifests"
}

Expand Down
5 changes: 3 additions & 2 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ terraform {
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.102.0"
source = "hashicorp/azurerm"
version = ">=4.0.0"
configuration_aliases = [azurerm.main_sub, azurerm.dns_sub]
}
}
}