Complete the code to enable network security group on a subnet in Azure.
resource "azurerm_subnet_network_security_group_association" "example" { subnet_id = azurerm_subnet.example.id network_security_group_id = [1] }
The network_security_group_id must reference the ID of the network security group resource to associate it with the subnet.
Complete the code to enable encryption at rest for an Azure Storage Account.
resource "azurerm_storage_account" "example" { name = "examplestorageacct" resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location account_tier = "Standard" account_replication_type = "LRS" [1] { services { blob { enabled = true } } key_source = "Microsoft.Storage" } }
network_rules block which controls network access, not encryption.access_tier which controls performance tier.The encryption block enables encryption at rest for the storage account.
Fix the error in the Azure role assignment code to grant a user Reader access to a resource group.
resource "azurerm_role_assignment" "example" { scope = azurerm_resource_group.example.id role_definition_name = [1] principal_id = var.user_object_id }
Contributor which allows write access.Owner which grants full control.The role_definition_name must be set to "Reader" to grant read-only access.
Fill both blanks to configure an Azure Key Vault access policy granting secret get and list permissions to a user.
resource "azurerm_key_vault_access_policy" "example" { key_vault_id = azurerm_key_vault.example.id tenant_id = var.tenant_id object_id = var.user_object_id [1] = ["get", "list"] [2] = [] }
The secret_permissions block defines permissions for secrets, and key_permissions is set to empty as no key permissions are granted.
Fill all three blanks to define an Azure Policy assignment that enforces HTTPS traffic on a storage account.
resource "azurerm_policy_assignment" "example" { name = "enforce-https" scope = azurerm_storage_account.example.id policy_definition_id = [1] parameters = { effect = { value = [2] } } description = [3] }
The policy_definition_id must point to the built-in policy for HTTPS enforcement. The effect is set to "Deny" to block non-HTTPS traffic. The description explains the policy purpose.