Skip to content

Commit 165e642

Browse files
nickdalaibersanoMS
andauthored
Prod infra (#29)
* update the location of the prod secondary service bus * updates for aca multi region * App Config and secrets refactoring * Prod environment infra updates (#26) * fix: move acr to hub in prod * fix: update app config to support prod * fix: remove namespace from secrets in prod and update app config keys * fix: add private endpoint and spoke vnet ids to service bus prod * feat: add aca subnet to spoke * Ensure unique name for Azure resources based on location * Terraform - set the service bus secondary spoke vnet * Terraform - set vm to a supported image * Terraform - remove secrets from 2nd region. * Configure App Config keys on the jump box * Storage account replication * update prod deployment readme * install docker on jump box * remove unused variable in terraform main.tfvars.json file * prod infra for Azure Container Apps and Azure Container Registry * Change default network rule to Deny for ACA * add images for dev container * add verification step for app config keys in the prod deployment readme --------- Co-authored-by: Isabelle Bersano <[email protected]>
1 parent fc665be commit 165e642

35 files changed

+1296
-573
lines changed

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,50 @@ This repository contains a collection of patterns and best practices for buildin
1515
- [Maven 3.9.1](https://maven.apache.org/download.cgi)
1616
- [Protoc](https://grpc.io/docs/protoc-installation/)
1717

18+
## Steps to deploy the reference implementation
19+
20+
The following detailed deployment steps assume you are using a Dev Container inside Visual Studio Code.
21+
22+
> For your convenience, we use Dev Containers with a fully-featured development environment. If you prefer to use another editor, we recommend installing the necessary [dependencies](./prerequisites.md) and skip to the deployment instructions starting in [Step 3](#3-log-in-to-azure).
23+
24+
### 1. Clone the repo
25+
26+
> For Windows users, we recommend using Windows Subsystem for Linux (WSL) to [improve Dev Container performance](https://code.visualstudio.com/remote/advancedcontainers/improve-performance).
27+
28+
```pwsh
29+
wsl
30+
```
31+
32+
Clone the repository and open the project using the Dev Container.
33+
34+
```shell
35+
git clone https://github.com/Azure/modern-web-app-pattern-java
36+
37+
cd modern-web-app-pattern-java
38+
```
39+
40+
### 2. Open Dev Container in Visual Studio Code
41+
42+
If required, ensure Docker Desktop is started. Open the repository folder in Visual Studio Code. You can do this from the command prompt:
43+
44+
```shell
45+
code .
46+
```
47+
48+
Once Visual Studio Code is launched, you should see a popup allowing you to click on the button **Reopen in Container**.
49+
50+
![Reopen in Container](docs/assets/vscode-reopen-in-container.png)
51+
52+
If you don't see the popup, open the Visual Studio Code Command Palette to execute the command. There are three ways to open the command palette:
53+
54+
- For Mac users, use the keyboard shortcut ⇧⌘P
55+
- For Windows and Linux users, use Ctrl+Shift+P
56+
- From the Visual Studio Code top menu, navigate to View -> Command Palette.
57+
58+
Once the command palette is open, search for `Dev Containers: Rebuild and Reopen in Container`.
59+
60+
![WSL Ubuntu](docs/assets/vscode-reopen-in-container-command.png)
61+
1862
## Login to Azure
1963

2064
Before deploying, you must be authenticated to Azure and have the appropriate subscription selected. Run the following command to authenticate:
209 KB
Loading
300 KB
Loading

infra/shared/terraform/modules/aca/main.tf

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ terraform {
1111
resource "azurecaf_name" "container_app_environment_name" {
1212
name = var.application_name
1313
resource_type = "azurerm_container_app_environment"
14-
suffixes = [var.environment]
14+
suffixes = [var.location, var.environment]
1515
}
1616

1717
# Create Azure Container Apps Environment in Dev
@@ -39,7 +39,7 @@ resource "azurerm_container_app_environment" "container_app_environment_prod" {
3939
log_analytics_workspace_id = var.log_analytics_workspace_id
4040
zone_redundancy_enabled = true
4141

42-
internal_load_balancer_enabled = var.isNetworkIsolated
42+
internal_load_balancer_enabled = true
4343
infrastructure_subnet_id = var.infrastructure_subnet_id
4444

4545
workload_profile {
@@ -56,6 +56,7 @@ resource "azurerm_container_app" "container_app" {
5656
resource_group_name = var.resource_group
5757
revision_mode = "Single"
5858
workload_profile_name = "Consumption"
59+
5960
ingress {
6061
allow_insecure_connections = false
6162
external_enabled = true
@@ -65,6 +66,7 @@ resource "azurerm_container_app" "container_app" {
6566
latest_revision = true
6667
}
6768
}
69+
6870
tags = {
6971
"environment" = var.environment
7072
"application-name" = var.application_name
@@ -139,19 +141,3 @@ resource "azurerm_container_app" "container_app" {
139141
}
140142
}
141143
}
142-
143-
# Create Private DNS Zone for Azure Container Apps in Prod if internal load balancer is enabled
144-
145-
resource "azurerm_private_dns_zone" "dns_for_aca" {
146-
count = var.environment == "prod" && var.isNetworkIsolated ? 1 : 0
147-
name = var.environment == "prod" ? azurerm_container_app_environment.container_app_environment_prod[0].default_domain : azurerm_container_app_environment.container_app_environment_dev[0].default_domain
148-
resource_group_name = var.resource_group
149-
}
150-
151-
resource "azurerm_private_dns_zone_virtual_network_link" "virtual_network_link_aca" {
152-
count = var.environment == "prod" && var.isNetworkIsolated ? 1 : 0
153-
name = "privatelink.azurecr.io"
154-
private_dns_zone_name = azurerm_private_dns_zone.dns_for_aca[0].name
155-
virtual_network_id = var.spoke_vnet_id
156-
resource_group_name = var.resource_group
157-
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
output "identity_principal_id" {
22
value = azurerm_container_app.container_app.identity[0].principal_id
3+
}
4+
5+
output "default_domain" {
6+
value = length(azurerm_container_app_environment.container_app_environment_prod) > 0 ? azurerm_container_app_environment.container_app_environment_prod[0].default_domain : ""
7+
}
8+
9+
output "static_ip_address" {
10+
value = length(azurerm_container_app_environment.container_app_environment_prod) > 0 ? azurerm_container_app_environment.container_app_environment_prod[0].static_ip_address : ""
311
}

infra/shared/terraform/modules/aca/variables.tf

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,10 @@ variable "email_response_queue_name" {
5959
description = "The name of the email response queue"
6060
}
6161

62-
variable "isNetworkIsolated" {
63-
type = bool
64-
description = "Indicates if the container app should be network isolated"
65-
default = false
66-
}
67-
6862
variable "infrastructure_subnet_id" {
6963
type = string
7064
description = "The ID of the subnet where the infrastructure resources should be created"
7165
default = null
7266
}
7367

74-
variable "spoke_vnet_id" {
75-
type = string
76-
description = "The ID of the spoke VNET"
77-
default = null
78-
}
68+

infra/shared/terraform/modules/acr/main.tf

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -84,38 +84,3 @@ resource "azurerm_role_assignment" "acr_contributor_user_role_assignement" {
8484
principal_id = data.azuread_client_config.current.object_id
8585
}
8686

87-
# Create Private DNS Zone and Endpoint for ACR
88-
89-
resource "azurerm_private_dns_zone" "dns_for_acr" {
90-
count = var.environment == "prod" ? 1 : 0
91-
name = "privatelink.azurecr.io"
92-
resource_group_name = var.resource_group
93-
}
94-
95-
resource "azurerm_private_dns_zone_virtual_network_link" "virtual_network_link_acr" {
96-
count = var.environment == "prod" ? 1 : 0
97-
name = "privatelink.azurecr.io"
98-
private_dns_zone_name = azurerm_private_dns_zone.dns_for_acr[0].name
99-
virtual_network_id = var.hub_vnet_id
100-
resource_group_name = var.resource_group
101-
}
102-
103-
resource "azurerm_private_endpoint" "acr_pe" {
104-
count = var.environment == "prod" ? 1 : 0
105-
name = "private-endpoint-acr"
106-
location = var.location
107-
resource_group_name = var.resource_group
108-
subnet_id = var.private_endpoint_subnet_id
109-
110-
private_dns_zone_group {
111-
name = "privatednsacrzonegroup"
112-
private_dns_zone_ids = [azurerm_private_dns_zone.dns_for_acr[0].id]
113-
}
114-
115-
private_service_connection {
116-
name = "peconnection-acr"
117-
private_connection_resource_id = azurerm_container_registry.acr.id
118-
is_manual_connection = false
119-
subresource_names = ["registry"]
120-
}
121-
}

infra/shared/terraform/modules/acr/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ output "acr_name" {
33
description = "The Azure Container Registry Name."
44
}
55

6+
output "acr_id" {
7+
value = azurerm_container_registry.acr.id
8+
description = "The Azure Container Registry ID."
9+
}
10+
611
output "acr_login_server" {
712
value = azurerm_container_registry.acr.login_server
813
description = "The Azure Container Registry Login Server."

infra/shared/terraform/modules/acr/variables.tf

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,3 @@ variable "georeplications" {
4343
default = []
4444
}
4545

46-
variable "private_endpoint_subnet_id" {
47-
type = string
48-
description = "The ID of the subnet where the private endpoint should be created"
49-
default = null
50-
}
51-
52-
variable "hub_vnet_id" {
53-
type = string
54-
description = "The ID of the Spoke VNET"
55-
default = null
56-
}

infra/shared/terraform/modules/app-config/main.tf

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ data "azuread_client_config" "current" {}
1313
resource "azurecaf_name" "azurerm_app_config" {
1414
name = var.application_name
1515
resource_type = "azurerm_app_configuration"
16-
suffixes = [var.environment]
16+
suffixes = [var.location, var.environment]
1717
}
1818

1919
# Create Azure App Configuration
@@ -84,38 +84,3 @@ resource "azurerm_role_assignment" "azconfig_owner_user_role_assignment" {
8484
principal_id = data.azuread_client_config.current.object_id
8585
}
8686

87-
# Create Private DNS Zone and Endpoint for App Configuration
88-
89-
resource "azurerm_private_dns_zone" "dns_for_azconfig" {
90-
count = var.environment == "prod" ? 1 : 0
91-
name = "privatelink.azconfig.io"
92-
resource_group_name = var.resource_group
93-
}
94-
95-
resource "azurerm_private_dns_zone_virtual_network_link" "virtual_network_link_azconfig" {
96-
count = var.environment == "prod" ? 1 : 0
97-
name = "privatelink.azconfig.io"
98-
private_dns_zone_name = azurerm_private_dns_zone.dns_for_azconfig[0].name
99-
virtual_network_id = var.spoke_vnet_id
100-
resource_group_name = var.resource_group
101-
}
102-
103-
resource "azurerm_private_endpoint" "azconfig_pe" {
104-
count = var.environment == "prod" ? 1 : 0
105-
name = "private-endpoint-ac"
106-
location = var.location
107-
resource_group_name = var.resource_group
108-
subnet_id = var.private_endpoint_subnet_id
109-
110-
private_dns_zone_group {
111-
name = "privatednsazconfigzonegroup"
112-
private_dns_zone_ids = [azurerm_private_dns_zone.dns_for_azconfig[0].id]
113-
}
114-
115-
private_service_connection {
116-
name = "peconnection-azconfig"
117-
private_connection_resource_id = azurerm_app_configuration.app_config.id
118-
is_manual_connection = false
119-
subresource_names = ["configurationStores"]
120-
}
121-
}

0 commit comments

Comments
 (0)