Skip to content

Commit 2608f69

Browse files
authored
content for authentication and authorization
1 parent 2c1fd39 commit 2608f69

File tree

1 file changed

+27
-35
lines changed

1 file changed

+27
-35
lines changed

docs/aac/java-mwa-guide.md

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -323,44 +323,36 @@ To configure authentication and authorization on any new Azure services (*worklo
323323
324324
- *Grant least privilege to each new service.* Assign only necessary permissions to each new service identity. For example, if an identity only needs to push to a container registry, don't give it pull permissions. Review these permissions regularly and adjust as necessary. Use different identities for different roles, such as deployment and the application. This limits the potential damage if one identity is compromised.
325325
326-
- *Adopt infrastructure as code (IaC).* Use Azure Bicep or similar IaC tools to define and manage your cloud resources. IaC ensures consistent application of security configurations in your deployments and allows you to version control your infrastructure setup.
326+
- *Adopt infrastructure as code (IaC).* Use Azure Bicep or similar IaC tools like Terraform to define and manage your cloud resources. IaC ensures consistent application of security configurations in your deployments and allows you to version control your infrastructure setup.
327327
328-
The reference implementation uses IaC to assign managed identities to added services and specific roles to each identity. It defines roles and permissions access for deployment (`containerRegistryPushRoleId`), application owner (`containerRegistryPushRoleId`), and Azure Container Apps application (`containerRegistryPullRoleId`) (*see following code*).
328+
The reference implementation uses IaC to assign managed identities to added services and specific roles to each identity. It defines roles and permissions access for deployment by defining roles for ACR push and pull (*see following code*).
329329
330-
```bicep
331-
roleAssignments: \[
332-
{
333-
principalId: deploymentSettings.principalId
334-
principalType: deploymentSettings.principalType
335-
roleDefinitionIdOrName: containerRegistryPushRoleId
336-
}
337-
{
338-
principalId: ownerManagedIdentity.outputs.principal_id
339-
principalType: 'ServicePrincipal'
340-
roleDefinitionIdOrName: containerRegistryPushRoleId
341-
}
342-
{
343-
principalId: appManagedIdentity.outputs.principal_id
344-
principalType: 'ServicePrincipal'
345-
roleDefinitionIdOrName: containerRegistryPullRoleId
346-
}
347-
\]
348-
```
330+
```terraform
331+
resource "azurerm_role_assignment" "container_app_acr_pull" {
332+
principal_id = var.aca_identity_principal_id
333+
role_definition_name = "AcrPull"
334+
scope = azurerm_container_registry.acr.id
335+
}
349336
350-
The reference implementation assigns the managed identity the new Azure Container App identity at deployment (*see following code*).
351-
352-
```bicep
353-
module renderingServiceContainerApp 'br/public:avm/res/app/container-app:0.1.0' = {
354-
name: 'application-rendering-service-container-app'
355-
scope: resourceGroup()
356-
params: {
357-
// Other parameters omitted for brevity
358-
managedIdentities: {
359-
userAssignedResourceIds: [
360-
managedIdentity.id
361-
]
362-
}
363-
}
337+
resource "azurerm_user_assigned_identity" "container_registry_user_assigned_identity" {
338+
name = "ContainerRegistryUserAssignedIdentity"
339+
resource_group_name = var.resource_group
340+
location = var.location
341+
}
342+
343+
resource "azurerm_role_assignment" "container_registry_user_assigned_identity_acr_pull" {
344+
scope = azurerm_container_registry.acr.id
345+
role_definition_name = "AcrPull"
346+
principal_id = azurerm_user_assigned_identity.container_registry_user_assigned_identity.principal_id
347+
}
348+
349+
350+
# For demo purposes, allow current user access to the container registry
351+
# Note: when running as a service principal, this is also needed
352+
resource "azurerm_role_assignment" "acr_contributor_user_role_assignement" {
353+
scope = azurerm_container_registry.acr.id
354+
role_definition_name = "Contributor"
355+
principal_id = data.azuread_client_config.current.object_id
364356
}
365357
```
366358

0 commit comments

Comments
 (0)