saif-api-service¶
This is a module for deploying an API to an App Service Plan and add that API to an API Management Service.
⚠️ Authentication Provider Changes¶
This module now supports dual authentication:
- Corporate Tenant: Uses Entra ID (Microsoft) for internal/corporate authentication
- External Tenant: Uses Okta for external user authentication
The API Management policies are configured to validate JWT tokens from both providers, allowing the API to serve both corporate and external users.
Feature flags¶
Optional capabilities such as Cosmos DB NoSQL, Blob Storage, and Service Bus queues are members of the single feature_flags object input, not top-level module arguments. In a Forge v3 project, the templates generate this module call as module "saif-appservices" in infra/api/app.generated.tf.
A module block accepts only one feature_flags argument, and Terraform rejects a second one as a duplicate. When you enable another feature and the module call already defines feature_flags (for example, a project scaffolded with database_type=cosmosdb already has the Cosmos DB members generated into it), add the new feature's members to that existing object instead of adding a new feature_flags = { ... } block:
module "saif-appservices" {
# ... existing generated module arguments ...
feature_flags = {
# Existing members, e.g. from Cosmos DB
cosmosdb_nosql_serverless = true
# Members added for another feature, e.g. Blob Storage
enable_blob_storage = true
blob_storage_settings = {
containers = ["documents"]
contributor_group_id = "12345678-1234-1234-1234-123456789abc"
}
}
}
The feature_flags row in the Inputs table below lists every member and its default. Each feature's development guide documents the members it needs.
Storage account key in Key Vault¶
Set feature_flags.storage_secret_keyvault_name to the name of an existing Key Vault in the shared services subscription to enable shared key access on the storage account and store its key1 as the secret <project_id>-storage-<environment_short_name>. It is valid only when enable_blob_storage, enable_storage_queue, or enable_storage_file is true. The vault must use Azure RBAC, and the principal running Terraform must already hold Key Vault Secrets Officer on it (granted in cloud-foundations; this module does not create the assignment). Clearing the setting removes the secret and disables shared key access again.
Providers¶
| Name | Version |
|---|---|
| azurerm.shared-services | >= 4.46, < 5.0 |
Inputs¶
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| allowed_tenants | Tenants whose tokens the API accepts: 'corp' and/or 'ext'. Both (default) routes on the x-forward-tenant-origin header. Exactly one stamps x-forward-tenant-origin with that tenant and renders only its validation branch. Applies to api_policy_type = 'standard'. | list(string) |
[ |
no |
| api | n/a | object({ |
n/a | yes |
| api_policy_type | APIM policy type. 'standard' uses Okta/Entra tenant-based routing. 'filevine' validates Filevine Identity Server JWTs for webhook endpoints. 'subscription_key' allows legacy apps to authenticate via APIM subscription keys (Experience APIs only). | string |
"standard" |
no |
| application_secrets | Secrets for your application from Azure Devops Library | map(string) |
{} |
no |
| application_settings | Settings for your application | map(string) |
{} |
no |
| azure_logging_level | The logging level for the Azure Infrastructure | string |
"Error" |
no |
| create_staging_slot | Whether to create a staging slot for the web app | bool |
false |
no |
| deployed_by | Deprecated. Per-run deploy identity is no longer written to tags because it changes on every run. Retained for backward compatibility with callers but ignored by this module. | string |
"Terraform" |
no |
| enable_health_check | Whether to enable the App Service health check. Defaults to true. Set to false to opt out. | bool |
true |
no |
| environment | The environment in which the resources are deployed | string |
n/a | yes |
| environment_short_name | The short name of the environment | string |
"" |
no |
| feature_flags | Feature Flags for this module | object({ |
{ |
no |
| is_experience_api | Is this an Experience API | bool |
false |
no |
| is_external_app | Is this an external app | bool |
false |
no |
| is_production | Is this a production environment | bool |
n/a | yes |
| owner | The name of the team that owns the resources | string |
n/a | yes |
| project_id | The id of the project. This will be used to name the resources. | string |
n/a | yes |
| resource_location | The location the resources will be deployed to. | string |
"westus2" |
no |
| tags | A map of tags to be applied to resources in the module | map(string) |
n/a | yes |
| tenant | Deprecated — the Azure infra tenant is fixed to Corporate (see local.azure_tenant). Retained for backward compatibility with existing workspace variable sets (e.g. the Okta credentials variable set that injects tenant = "ext"), but no longer read by this module. | string |
"Corporate" |
no |
Outputs¶
| Name | Description |
|---|---|
| api_url | Base URL of the API through Front Door (internal host, or external host when is_external_app is true). |
| application_client_id | n/a |
| application_id | n/a |
| application_object_id | n/a |
| application_principal_client_id | n/a |
| application_principal_id | n/a |
| application_principal_object_id | n/a |
| cosmosdb_account_endpoint | n/a |
| cosmosdb_account_id | n/a |
| cosmosdb_account_name | n/a |
| organization_name | n/a |
| resource_group_name | n/a |
| storage_file_share_names | Names of the file shares created from feature_flags.storage_file_settings.file_shares. Null when feature_flags.enable_storage_file is false. |
| storage_queue_names | Names of the storage queues created from feature_flags.storage_queue_settings.queues. Null when feature_flags.enable_storage_queue is false. |
| subscription_primary_key | Primary key of the APIM subscription scoped to this API. Only populated when api_policy_type = "subscription_key". |
| subscription_secondary_key | Secondary key of the APIM subscription scoped to this API. Only populated when api_policy_type = "subscription_key". |
| user_assigned_identity_clientid | n/a |
| user_assigned_identity_id | n/a |
| user_assigned_identity_principalid | n/a |
Resources¶
- resource.azurerm_app_configuration_key.application_secrets (/terraform-docs/main.tf#327)
- resource.azurerm_app_configuration_key.application_settings (/terraform-docs/main.tf#315)
- resource.azurerm_key_vault_secret.Application_Secrets (/terraform-docs/main.tf#219)
- resource.azurerm_role_assignment.Application_Secret_Permissions (/terraform-docs/main.tf#300)