Solution architecture outcome pattern: agent and its MCP servers
Some checks failed
check agents / check (push) Failing after 13s

The cp1-solution-architecture-agent and the sa-aws/azure/gcp-cloud MCP servers, a separate
stream from the individual and sub-agent patterns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-05 22:13:25 +00:00
parent 8bb62a4a42
commit bc84ee4df6
267 changed files with 44287 additions and 45 deletions

View File

@@ -0,0 +1,33 @@
---
name: azure-iac-patterns
description: >-
Terraform patterns for Azure products that validate against one pinned
version of the hashicorp/azurerm provider: virtual networks, managed identities,
Container Apps, PostgreSQL, Storage, Key Vault and Monitor. Use when writing
Terraform for an Azure product, before writing the resource.
metadata:
scope: deployment guidance
provider: hashicorp/azurerm 4.40.0
---
# Azure IaC patterns
Every pattern here passes `terraform validate` against `hashicorp/azurerm 4.40.0`. A test runs that on each of them, so an argument you copy from a pattern is in the right block.
## How to use them
1. Write `assets/versions.tf` to your working copy as `terraform/versions.tf`, unchanged. It pins the provider version these patterns and the `terraform_schema` tool describe. Declare the `subscription_id`, `location` and `resource_group_name` variables in `terraform/variables.tf`.
2. For each Element in the Target architecture, read the reference for its product with `load_skill_resource` and start from its pattern. Read only the references for products the Target architecture uses.
3. Change the pattern to meet the Element's Checks. For a setting the pattern does not show, call `terraform_schema` with `find` set to its name before you write it.
| Product | Reference |
| --- | --- |
| Virtual network | `references/networking.md` |
| Managed identity and role assignment | `references/identity.md` |
| Container Apps | `references/container-apps.md` |
| PostgreSQL Flexible Server | `references/postgresql.md` |
| Storage account | `references/storage.md` |
| Key Vault | `references/key-vault.md` |
| Azure Monitor alert | `references/monitoring.md` |
For a product with no reference, use `terraform_schema` to find its resource type and arguments. Never write an argument you haven't confirmed.

View File

@@ -0,0 +1,14 @@
terraform {
required_version = ">= 1.9"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "4.40.0"
}
}
}
provider "azurerm" {
subscription_id = var.subscription_id
features {}
}

View File

@@ -0,0 +1,60 @@
# Container Apps
An app in a Log Analytics-backed environment, with a user-assigned identity, HTTP ingress and scaling limits.
```hcl
variable "image" {
type = string
}
variable "identity_id" {
type = string
}
resource "azurerm_log_analytics_workspace" "main" {
name = "log-workload"
location = var.location
resource_group_name = var.resource_group_name
retention_in_days = 30
}
resource "azurerm_container_app_environment" "main" {
name = "cae-workload"
location = var.location
resource_group_name = var.resource_group_name
log_analytics_workspace_id = azurerm_log_analytics_workspace.main.id
}
resource "azurerm_container_app" "api" {
name = "ca-api"
container_app_environment_id = azurerm_container_app_environment.main.id
resource_group_name = var.resource_group_name
revision_mode = "Single"
identity {
type = "UserAssigned"
identity_ids = [var.identity_id]
}
ingress {
external_enabled = true
target_port = 8080
traffic_weight {
latest_revision = true
percentage = 100
}
}
template {
min_replicas = 2
max_replicas = 10
container {
name = "api"
image = var.image
cpu = 0.5
memory = "1Gi"
}
}
}
```

View File

@@ -0,0 +1,21 @@
# Managed identity and role assignment
Give a workload a user-assigned identity, and grant its role at the narrowest scope. `scope` here is one storage account's id.
```hcl
variable "storage_account_id" {
type = string
}
resource "azurerm_user_assigned_identity" "app" {
name = "id-app"
location = var.location
resource_group_name = var.resource_group_name
}
resource "azurerm_role_assignment" "app_blob_reader" {
scope = var.storage_account_id
role_definition_name = "Storage Blob Data Reader"
principal_id = azurerm_user_assigned_identity.app.principal_id
}
```

View File

@@ -0,0 +1,19 @@
# Key Vault
RBAC authorization, purge protection, and public access off.
```hcl
data "azurerm_client_config" "current" {}
resource "azurerm_key_vault" "main" {
name = "kv-workload-001"
location = var.location
resource_group_name = var.resource_group_name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
enable_rbac_authorization = true
purge_protection_enabled = true
soft_delete_retention_days = 90
public_network_access_enabled = false
}
```

View File

@@ -0,0 +1,45 @@
# Azure Monitor alert
A metric alert routed to an action group. `scopes` is the resource being watched.
```hcl
variable "watched_id" {
type = string
}
variable "on_call_email" {
type = string
}
resource "azurerm_monitor_action_group" "on_call" {
name = "ag-on-call"
resource_group_name = var.resource_group_name
short_name = "oncall"
email_receiver {
name = "on-call"
email_address = var.on_call_email
}
}
resource "azurerm_monitor_metric_alert" "cpu" {
name = "alert-cpu"
resource_group_name = var.resource_group_name
scopes = [var.watched_id]
severity = 2
frequency = "PT5M"
window_size = "PT15M"
criteria {
metric_namespace = "Microsoft.DBforPostgreSQL/flexibleServers"
metric_name = "cpu_percent"
aggregation = "Average"
operator = "GreaterThan"
threshold = 80
}
action {
action_group_id = azurerm_monitor_action_group.on_call.id
}
}
```

View File

@@ -0,0 +1,50 @@
# Virtual network
A virtual network with a delegated subnet, a network security group, and default deny for inbound traffic from the internet.
```hcl
resource "azurerm_virtual_network" "main" {
name = "vnet-workload"
location = var.location
resource_group_name = var.resource_group_name
address_space = ["10.0.0.0/16"]
}
resource "azurerm_subnet" "apps" {
name = "snet-apps"
resource_group_name = var.resource_group_name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = ["10.0.0.0/23"]
delegation {
name = "container-apps"
service_delegation {
name = "Microsoft.App/environments"
actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
}
}
}
resource "azurerm_network_security_group" "apps" {
name = "nsg-apps"
location = var.location
resource_group_name = var.resource_group_name
security_rule {
name = "deny-internet-inbound"
priority = 4000
direction = "Inbound"
access = "Deny"
protocol = "*"
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "Internet"
destination_address_prefix = "*"
}
}
resource "azurerm_subnet_network_security_group_association" "apps" {
subnet_id = azurerm_subnet.apps.id
network_security_group_id = azurerm_network_security_group.apps.id
}
```

View File

@@ -0,0 +1,28 @@
# PostgreSQL Flexible Server
Zone-redundant, with public access off, geo-redundant backup and Entra authentication.
```hcl
resource "azurerm_postgresql_flexible_server" "main" {
name = "psql-workload"
location = var.location
resource_group_name = var.resource_group_name
version = "16"
sku_name = "GP_Standard_D2ds_v5"
storage_mb = 65536
backup_retention_days = 14
geo_redundant_backup_enabled = true
public_network_access_enabled = false
zone = "1"
high_availability {
mode = "ZoneRedundant"
standby_availability_zone = "2"
}
authentication {
active_directory_auth_enabled = true
password_auth_enabled = false
}
}
```

View File

@@ -0,0 +1,23 @@
# Storage account
Zone-redundant, TLS 1.2, no public blob access, no shared keys, with versioning.
```hcl
resource "azurerm_storage_account" "main" {
name = "stworkload001"
location = var.location
resource_group_name = var.resource_group_name
account_tier = "Standard"
account_replication_type = "ZRS"
min_tls_version = "TLS1_2"
allow_nested_items_to_be_public = false
shared_access_key_enabled = false
blob_properties {
versioning_enabled = true
delete_retention_policy {
days = 30
}
}
}
```