Skip to content

Commit

Permalink
fixed private endpoints for app svc slots
Browse files Browse the repository at this point in the history
  • Loading branch information
JinLee794 committed Nov 12, 2024
1 parent 2d0fdd9 commit 5092dc2
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 174 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/scenario1.terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ permissions:
env:
modulePath: 'scenarios/secure-baseline-multitenant/terraform'
terraformVersion: 1.9.7 # must be greater than or equal to 1.2 for OIDC
backendStateKey: 'scenario1.hub.tfstate'
backendStateKey: 'scenario1.appsvclza.tfstate'
tfvarPath: '_parameters/ase-multitenant.parameters.tfvars'

jobs:
Expand All @@ -65,7 +65,7 @@ jobs:
with:
modulePath: ${{ needs.prepare-environment.outputs.modulePath }}
terraformVersion: ${{ needs.prepare-environment.outputs.terraformVersion }}
backendStateKey: 'scenario1.hub.tfstate'
backendStateKey: ${{ env.backendStateKey}}
tfvarPath: ${{ needs.prepare-environment.outputs.tfvarPath }}
# Ensure this value is a boolean
destroy: ${{ github.event.inputs.destroy == 'true' }}
Expand Down
100 changes: 0 additions & 100 deletions deployment/bicep/main.bicep

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,11 @@ resource "azurerm_monitor_diagnostic_setting" "this" {
enabled_log {
category_group = "allLogs"

## `retention_policy` has been deprecated in favor of `azurerm_storage_management_policy` resource - to learn more https://aka.ms/diagnostic_settings_log_retention
# retention_policy {
# days = 0
# enabled = false
# }
}

metric {
category = "AllMetrics"
enabled = false

## `retention_policy` has been deprecated in favor of `azurerm_storage_management_policy` resource - to learn more https://aka.ms/diagnostic_settings_log_retention
# retention_policy {
# days = 0
# enabled = false
# }
}
}

Expand Down Expand Up @@ -159,23 +148,17 @@ resource "azurerm_linux_web_app_slot" "slot" {
}
}

resource "azurecaf_name" "slot" {
count = length(var.webapp_options.slots)
name = "${azurecaf_name.caf_name_linwebapp.result}-${var.webapp_options.slots[count.index]}"
resource_type = "azurerm_private_endpoint"
}

module "private_endpoint_slot" {
source = "../../private-endpoint"
count = length(var.webapp_options.slots)
count = length(azurerm_linux_web_app_slot.slot)

name = "${azurecaf_name.slot[count.index].result}-${azurerm_linux_web_app_slot.slot[count.index].name}"
name = "${azurerm_linux_web_app.this.name}-${azurerm_linux_web_app_slot.slot[count.index].name}"
resource_group = var.resource_group
location = var.location
subnet_id = var.frontend_subnet_id
private_connection_resource_id = azurerm_linux_web_app.this.id
private_connection_resource_id = azurerm_linux_web_app.this.id // Change this line

subresource_names = ["sites"]
subresource_names = ["sites-${azurerm_linux_web_app_slot.slot[count.index].name}"]

private_dns_zone = var.private_dns_zone

Expand Down
2 changes: 0 additions & 2 deletions scenarios/shared/terraform-modules/app-service/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ module "windows_web_app" {

resource_group = var.resource_group
web_app_name = var.application_name
# environment = var.environment
location = var.location
service_plan_id = azurerm_service_plan.this.id
service_plan_resource = azurerm_service_plan.this
Expand All @@ -68,7 +67,6 @@ module "linux_web_app" {

resource_group = var.resource_group
web_app_name = var.application_name
# environment = var.environment
location = var.location
service_plan_id = azurerm_service_plan.this.id
service_plan_resource = azurerm_service_plan.this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,11 @@ resource "azurerm_monitor_diagnostic_setting" "this" {

enabled_log {
category_group = "AllLogs"

## `retention_policy` has been deprecated in favor of `azurerm_storage_management_policy` resource - to learn more https://aka.ms/diagnostic_settings_log_retention
# retention_policy {
# days = 0
# enabled = false
# }
}

metric {
category = "AllMetrics"
enabled = false

## `retention_policy` has been deprecated in favor of `azurerm_storage_management_policy` resource - to learn more https://aka.ms/diagnostic_settings_log_retention
# retention_policy {
# days = 0
# enabled = false
# }
}
}

Expand Down Expand Up @@ -151,29 +139,26 @@ resource "azurerm_windows_web_app_slot" "slot" {
}
}

resource "azurecaf_name" "slot" {
count = length(var.webapp_options.slots)
name = "${var.web_app_name}-${var.webapp_options.slots[count.index]}"
resource_type = "azurerm_private_endpoint"
}

# module "private_endpoint_slot" {
# source = "../../private-endpoint"
module "private_endpoint_slot" {
source = "../../private-endpoint"
count = length(azurerm_windows_web_app_slot.slot)

# count = length(var.webapp_options.slots)
name = "${azurerm_windows_web_app.this.name}-${azurerm_windows_web_app_slot.slot[count.index].name}"
resource_group = var.resource_group
location = var.location
subnet_id = var.frontend_subnet_id
private_connection_resource_id = azurerm_windows_web_app.this.id // Change this line

# name = "${azurecaf_name.slot[count.index].result}-${azurerm_windows_web_app_slot.slot[count.index].name}"
# resource_group = var.resource_group
# location = var.location
# subnet_id = var.frontend_subnet_id
# private_connection_resource_id = azurerm_windows_web_app_slot.slot[count.index].id
subresource_names = ["sites-${azurerm_windows_web_app_slot.slot[count.index].name}"]

# subresource_names = ["sites"]
private_dns_zone = var.private_dns_zone

# private_dns_zone = var.private_dns_zone
private_dns_records = [
lower("${azurerm_windows_web_app.this.name}-${azurerm_windows_web_app_slot.slot[count.index].name}"),
lower("${azurerm_windows_web_app.this.name}-${azurerm_windows_web_app_slot.slot[count.index].name}.scm")
]

# private_dns_records = [
# lower("${azurerm_windows_web_app.this.name}-${azurerm_windows_web_app_slot.slot[count.index].name}"),
# lower("${azurerm_windows_web_app.this.name}-${azurerm_windows_web_app_slot.slot[count.index].name}.scm")
# ]
# }
depends_on = [
azurerm_windows_web_app_slot.slot
]
}
12 changes: 6 additions & 6 deletions scenarios/shared/terraform-modules/sql-database/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ resource "azurecaf_name" "caf_name_sqlserver" {
use_slug = var.global_settings.use_slug
}

data "azuread_group" "sql_admin_group" {
display_name = var.entra_admin_group_object_id == null ? var.entra_admin_group_name : null
object_id = var.entra_admin_group_object_id
security_enabled = true
data "azurerm_client_config" "current" { }

data "azuread_user" "current_user" {
object_id = data.azurerm_client_config.current.object_id
}

# Create the SQL Server
Expand All @@ -29,8 +29,8 @@ resource "azurerm_mssql_server" "this" {
tags = local.tags

azuread_administrator {
login_username = data.azuread_group.sql_admin_group.display_name
object_id = data.azuread_group.sql_admin_group.object_id
login_username = data.azuread_user.current_user.display_name
object_id = data.azurerm_client_config.current.object_id
azuread_authentication_only = true
tenant_id = var.tenant_id
}
Expand Down
10 changes: 0 additions & 10 deletions scenarios/shared/terraform-modules/sql-database/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ variable "tenant_id" {
description = "The tenant id where the resources will be created"
}

variable "entra_admin_group_object_id" {
type = string
default = null
}

variable "entra_admin_group_name" {
type = string
default = null
}

variable "private_link_subnet_id" {
type = string
description = "The subnet id where the SQL database will be integrated"
Expand Down

0 comments on commit 5092dc2

Please sign in to comment.