Skip to content

Commit

Permalink
[Release-177] Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolnagpal committed Apr 13, 2023
1 parent 7f3189f commit 4f220b3
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 61 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/static-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- ${{ needs.versionExtract.outputs.minVersion }}
- ${{ needs.versionExtract.outputs.maxVersion }}
directory:
- _example/complete
- _example/

steps:
- name: Checkout
Expand All @@ -49,6 +49,7 @@ jobs:
- name: tflint
uses: reviewdog/action-tflint@master
with:
tflint_version: v0.29.0
github_token: ${{ secrets.GITHUB_TOKEN }}
working_directory: ${{ matrix.directory }}
fail_on_error: 'true'
Expand All @@ -70,4 +71,4 @@ jobs:
terraform_version: ${{ needs.versionExtract.outputs.maxVersion }}

- name: Check Terraform format changes
run: terraform fmt --recursive -check=true
run: terraform fmt --recursive -check=true
35 changes: 7 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
# ignored files
*.tfstate
*.tfstate.*

# Crash log files
crash.log

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
*.tfstate.backup
.terraform
.idea
*.iml
.terraform.tfstate.lock.info
.terraform.lock.hcl
6 changes: 3 additions & 3 deletions _example/default/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module "log-analytics" {
}

module "ampls" {
source = "../"
source = "../../"
name = "app"
environment = "test"
label_order = ["name", "environment"]
Expand Down Expand Up @@ -100,14 +100,14 @@ data "azurerm_resource_group" "other_rg" {
}

module "ampls_diff_subs" {
source = "../"
source = "../../"
name = "app-1"
environment = "test-1"
label_order = ["name", "environment"]

diff_sub_resource_group_name = data.azurerm_resource_group.other_rg.name
diff_sub_location = module.resource_group.resource_group_location
subnet_id = "/subscriptions/82d2a91c-9e70-40c9-8a97-3c1e353b2a80/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/vnet-test/subnets/default"
subnet_id = "/subscriptions/82d2a91c-9e70-40c9-8a97-3c1e353b2a80/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/vnet-test/subnets/default"

azurerm_monitor_private_link_scope_id = "/subscriptions/cbaecd6a-2e7c-4524-bef7-eb0d2fba93db/resourceGroups/app-ampls-test-resource-group/providers/microsoft.insights/privateLinkScopes/app-test-ampls"
diff_sub = true
Expand Down
4 changes: 2 additions & 2 deletions _example/diff_sub/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ data "azurerm_resource_group" "other_rg" {
}

module "ampls_diff_subs" {
source = "../"
source = "../../"
name = "app-1"
environment = "test-1"
label_order = ["name", "environment"]

diff_sub_resource_group_name = data.azurerm_resource_group.other_rg.name
diff_sub_location = module.resource_group.resource_group_location
subnet_id = "****"
subnet_id = "****"

azurerm_monitor_private_link_scope_id = "**"
diff_sub = true
Expand Down
28 changes: 14 additions & 14 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,33 @@ module "labels" {
}

resource "azurerm_monitor_private_link_scope" "main" {
count = var.enabled && var.ampls_enabled && var.diff_sub == false ? 1 : 0
count = var.enabled && var.ampls_enabled && var.diff_sub == false ? 1 : 0
name = format("%s-ampls", module.labels.id)
resource_group_name = var.resource_group_name
tags = module.labels.tags
tags = module.labels.tags
}

resource "azurerm_monitor_private_link_scoped_service" "main" {
count = var.enabled && var.ampls_enabled && var.enable_private_endpoint && var.diff_sub == false ? length(var.linked_resource_ids) : 0
name = format("%s-amplsservice-%s", module.labels.id, count.index + 1)
count = var.enabled && var.ampls_enabled && var.enable_private_endpoint && var.diff_sub == false ? length(var.linked_resource_ids) : 0
name = format("%s-amplsservice-%s", module.labels.id, count.index + 1)
resource_group_name = var.resource_group_name
scope_name = join("", azurerm_monitor_private_link_scope.main.*.name)
linked_resource_id = element(var.linked_resource_ids, count.index)
linked_resource_id = element(var.linked_resource_ids, count.index)
}

locals {
private_dns_zones_names = var.private_dns_zones_names
diff_sub = true
diff_sub = true
}

resource "azurerm_private_dns_zone" "main" {
count = var.enable_private_endpoint && var.diff_sub == false ? length(var.private_dns_zones_names) : 0
count = var.enable_private_endpoint && var.diff_sub == false ? length(var.private_dns_zones_names) : 0
name = element(var.private_dns_zones_names, count.index)
resource_group_name = var.resource_group_name
}

resource "azurerm_private_endpoint" "this" {
count = var.enable_private_endpoint && var.diff_sub == false ? 1 : 0
count = var.enable_private_endpoint && var.diff_sub == false ? 1 : 0
name = format("%s-ampls-pe", module.labels.id)
location = var.location
resource_group_name = var.resource_group_name
Expand All @@ -50,9 +50,9 @@ resource "azurerm_private_endpoint" "this" {
}

private_service_connection {
name = format("%s-ampls-psc", module.labels.id )
name = format("%s-ampls-psc", module.labels.id)
is_manual_connection = false
private_connection_resource_id = var.azurerm_monitor_private_link_scope_id == null ? join("",azurerm_monitor_private_link_scope.main.*.id) : var.azurerm_monitor_private_link_scope_id
private_connection_resource_id = var.azurerm_monitor_private_link_scope_id == null ? join("", azurerm_monitor_private_link_scope.main.*.id) : var.azurerm_monitor_private_link_scope_id
subresource_names = ["azuremonitor"]
}
}
Expand All @@ -65,14 +65,14 @@ provider "azurerm" {

resource "azurerm_private_dns_zone" "diff_sub" {
provider = azurerm.peer
count = var.enable_private_endpoint && var.diff_sub == true ? length(var.private_dns_zones_names) : 0
count = var.enable_private_endpoint && var.diff_sub == true ? length(var.private_dns_zones_names) : 0
name = element(var.private_dns_zones_names, count.index)
resource_group_name = var.diff_sub_resource_group_name
}

resource "azurerm_private_endpoint" "diff_sub_pe" {
provider = azurerm.peer
count = var.enable_private_endpoint && var.diff_sub ? 1 : 0
count = var.enable_private_endpoint && var.diff_sub ? 1 : 0
name = format("%s-ampls-pe", module.labels.id)
location = var.diff_sub_location
resource_group_name = var.diff_sub_resource_group_name
Expand All @@ -84,9 +84,9 @@ resource "azurerm_private_endpoint" "diff_sub_pe" {
}

private_service_connection {
name = format("%s-ampls-psc", module.labels.id )
name = format("%s-ampls-psc", module.labels.id)
is_manual_connection = false
private_connection_resource_id = var.azurerm_monitor_private_link_scope_id == null ? join("",azurerm_monitor_private_link_scope.main.*.id) : var.azurerm_monitor_private_link_scope_id
private_connection_resource_id = var.azurerm_monitor_private_link_scope_id == null ? join("", azurerm_monitor_private_link_scope.main.*.id) : var.azurerm_monitor_private_link_scope_id
subresource_names = ["azuremonitor"]
}
}
20 changes: 10 additions & 10 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,26 @@ variable "ampls_enabled" {
}

variable "linked_resource_ids" {
type = list(string)
default = [ "" ]
type = list(string)
default = [""]
description = "(Required) The name of the Azure Monitor Private Link Scoped Service. Changing this forces a new resource to be created."
}

variable "subnet_id" {
type = string
default = ""
type = string
default = ""
description = "(Required) The ID of the Subnet from which Private IP Addresses will be allocated for this Private Endpoint. Changing this forces a new resource to be created."
}

variable "subscription_id" {
type = string
default = ""
type = string
default = ""
description = "(Optional) Specifies the ID of the subscription. If this argument is omitted, the subscription ID of the current Azure Resource Manager provider is used."
}

variable "private_dns_zones_names" {
type = list(string)
default = [""]
type = list(string)
default = [""]
description = "The name of the private dns zones from which private dns will be created for AMPLS"
}

Expand All @@ -109,8 +109,8 @@ variable "enable_private_endpoint" {
}

variable "azurerm_monitor_private_link_scope_id" {
type = string
default = null
type = string
default = null
description = "The id of the monitor private link scope from which private dns will be created for it"
}

Expand Down
4 changes: 2 additions & 2 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
terraform {
required_version = ">= 1.0.0"
required_version = ">= 1.3.6"
}

terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=2.90.0"
version = ">=3.0.0"
}
}
}

0 comments on commit 4f220b3

Please sign in to comment.