Skip to content

APIM module major: contract simplification - #1923

Draft
krusty93 wants to merge 12 commits into
mainfrom
krusty93-shiny-adventure
Draft

APIM module major: contract simplification#1923
krusty93 wants to merge 12 commits into
mainfrom
krusty93-shiny-adventure

Conversation

@krusty93

@krusty93 krusty93 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Collects APIM module breaking changes behind a major version plan instead of relying on Terraform's unsupported deprecated variable attribute for the current binary constraint.

This PR simplifies the module contract so common APIM infrastructure is owned by the module and driven by use_case.

Breaking changes

  • Removes subnet_id; the module always creates the APIM subnet using dx_available_subnet_cidr with a /24 prefix.
  • Removes subnet_pep_id; the private endpoint subnet ID is computed from the VNet and standard pep subnet naming.
  • Removes virtual_network_type_internal; APIM virtual network type is selected by use_case.
  • Removes enable_public_network_access; public network access is selected by use_case and SKU behavior.
  • Removes public_ip_address_id; the module creates a Standard static public IP when required by the selected use case.
  • Removes private_dns_zone_ids; private DNS zones are looked up by name in private_dns_zone_resource_group_name or the VNet resource group, in the current subscription.
  • Removes notification_sender_email; publisher_email is used for notifications.
  • Removes lock_enable; lock behavior is selected by use_case.
  • Removes key_vault_id and certificate_names; hostname certificates are configured directly with Key Vault certificate IDs and the module strips versions internally.
  • Replaces monitoring with log_analytics_workspace_id; logs and metrics are enabled by default for production use cases.
  • Removes management_logger_application_insight_enabled; Application Insights logger is enabled when application_insights.id is set.
  • Removes application_insights.enabled and application_insights.connection_string; the module resolves the connection string from the Application Insights resource ID.
  • Simplifies hostname_configuration.proxy; users can only choose whether the resource-name proxy host is the default SSL binding via use_resource_name_as_default.

Tests

  • Replaces the legacy combined tests/apim.tftest.hcl with dedicated unit.tftest.hcl, contract.tftest.hcl, and integration.tftest.hcl layers.
  • Unit and contract tests use mocked azurerm and dx providers.
  • Integration tests use real providers plus tests/setup shared infrastructure and random instance numbers for isolation.

Validation

  • terraform fmt -recursive
  • terraform validate
  • pnpm nx run azure_api_management:tf-validate --skipNxCache
  • TF_CLI_ARGS_test='-filter=tests/unit.tftest.hcl' pnpm nx run azure_api_management:tf-test --skipNxCache
  • TF_CLI_ARGS_test='-filter=tests/contract.tftest.hcl' pnpm nx run azure_api_management:tf-test --skipNxCache
  • pre-commit Terraform docs, fmt, validate, and tflint hooks

Resolves CES-1911

@krusty93
krusty93 temporarily deployed to bootstrapper-dev-cd July 1, 2026 13:36 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to infra-prod-ci July 1, 2026 13:36 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to bootstrapper-prod-cd July 1, 2026 13:36 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to infra-prod-ci July 1, 2026 13:45 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to bootstrapper-dev-cd July 1, 2026 13:45 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to bootstrapper-prod-cd July 1, 2026 13:45 — with GitHub Actions Inactive
krusty93 and others added 3 commits July 8, 2026 14:26
…in APIM module

Auto-compute subnet IDs from the virtual_network variable using the
standard naming convention, eliminating the need for users to manually
provide subnet IDs. Mark all three variables as deprecated using the
Terraform 1.9+ deprecated variable feature.

- var.subnet_id: computed from virtual_network + apim_subnet naming convention
- var.subnet_pep_id: computed from virtual_network + pep subnet naming convention
- var.virtual_network_type_internal: type is already determined by use_case

Resolves CES-1911

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace the naming-convention lookup approach with actual subnet
creation inside the module. The DX provider computes an available
/27 CIDR block from the VNet and the module creates the subnet.

var.subnet_id is retained as deprecated for backward compatibility:
when provided the existing subnet is used and none is created.

A new 'subnet' output exposes the ID and name of the managed subnet.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@krusty93
krusty93 force-pushed the krusty93-shiny-adventure branch from a163c4c to 138fce7 Compare July 8, 2026 12:28
@krusty93
krusty93 temporarily deployed to infra-prod-ci July 8, 2026 12:28 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to bootstrapper-prod-ci July 8, 2026 12:28 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to bootstrapper-dev-ci July 8, 2026 12:28 — with GitHub Actions Inactive
Collect the APIM module breaking changes behind a major version plan.
The module now owns subnet creation, public IP creation when required,
private DNS zone lookup, monitoring defaults, locks, notification sender
configuration, Application Insights connection string lookup, and a
simpler hostname certificate input contract.

Resolves CES-1911

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@krusty93 krusty93 changed the title Deprecate explicit subnet variables in Azure API Management module APIM module major: contract simplification Jul 8, 2026
@krusty93
krusty93 temporarily deployed to bootstrapper-prod-ci July 8, 2026 13:16 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to bootstrapper-dev-ci July 8, 2026 13:16 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to infra-prod-ci July 8, 2026 13:16 — with GitHub Actions Inactive
@krusty93 krusty93 changed the title APIM module major: contract simplification Next major version for APIM module: contract simplification Jul 8, 2026
Replace the legacy combined APIM test file with dedicated unit,
contract, and integration test layers. Mocked unit and contract tests
cover the simplified major-version contract, while integration tests use
the setup module and real providers for apply scenarios.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@krusty93 krusty93 changed the title Next major version for APIM module: contract simplification APIM module major: contract simplification Jul 8, 2026
@krusty93
krusty93 temporarily deployed to bootstrapper-prod-ci July 8, 2026 13:28 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to infra-prod-ci July 8, 2026 13:28 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to bootstrapper-dev-ci July 8, 2026 13:28 — with GitHub Actions Inactive
krusty93 and others added 6 commits July 24, 2026 16:03
…in APIM module

Auto-compute subnet IDs from the virtual_network variable using the
standard naming convention, eliminating the need for users to manually
provide subnet IDs. Mark all three variables as deprecated using the
Terraform 1.9+ deprecated variable feature.

- var.subnet_id: computed from virtual_network + apim_subnet naming convention
- var.subnet_pep_id: computed from virtual_network + pep subnet naming convention
- var.virtual_network_type_internal: type is already determined by use_case

Resolves CES-1911

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace the naming-convention lookup approach with actual subnet
creation inside the module. The DX provider computes an available
/27 CIDR block from the VNet and the module creates the subnet.

var.subnet_id is retained as deprecated for backward compatibility:
when provided the existing subnet is used and none is created.

A new 'subnet' output exposes the ID and name of the managed subnet.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Collect the APIM module breaking changes behind a major version plan.
The module now owns subnet creation, public IP creation when required,
private DNS zone lookup, monitoring defaults, locks, notification sender
configuration, Application Insights connection string lookup, and a
simpler hostname certificate input contract.

Resolves CES-1911

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace the legacy combined APIM test file with dedicated unit,
contract, and integration test layers. Mocked unit and contract tests
cover the simplified major-version contract, while integration tests use
the setup module and real providers for apply scenarios.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@krusty93
krusty93 force-pushed the krusty93-shiny-adventure branch from f1b104e to d836923 Compare July 24, 2026 14:03
@krusty93
krusty93 temporarily deployed to bootstrapper-prod-ci July 24, 2026 14:03 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to bootstrapper-dev-ci July 24, 2026 14:03 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to bootstrapper-dev-ci July 24, 2026 14:17 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to bootstrapper-prod-ci July 24, 2026 14:17 — with GitHub Actions Inactive
Restore the intended module-owned subnet and network resource changes after the malformed local commit.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@krusty93
krusty93 temporarily deployed to bootstrapper-prod-ci July 24, 2026 16:12 — with GitHub Actions Inactive
@krusty93
krusty93 temporarily deployed to bootstrapper-dev-ci July 24, 2026 16:12 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor
📋 Pre-commit Output Log
[INFO] Initializing environment for https://github.com/antonbabenko/pre-commit-terraform.
Lock Terraform Registry modules..................................(no files to check)Skipped
Terraform Providers Lock (on staged .terraform.lock.hcl files).......................Passed
- hook id: terraform_providers_lock_staged
- duration: 0.16s

No .terraform.lock.hcl files to process.

Terraform fmt........................................................................Passed
terraform_docs on modules............................................................Passed
Terraform validate with tflint.......................................................Passed
Terraform validate...................................................................Passed
Terraform validate with trivy........................................................Passed

Generated on Fri Jul 24 16:14:00 UTC 2026
Run all checks on modified files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant